drm/amdgpu: move ring from IBs into job
authorChristian König <christian.koenig@amd.com>
Sun, 31 Jan 2016 11:29:04 +0000 (12:29 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 10 Feb 2016 19:17:20 +0000 (14:17 -0500)
We can't submit to multiple rings at the same time anyway.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
14 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/cik_sdma.c
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c

index c23eea308991584f3f969bc4ff228da60f2a1447..dd6dd23fb3c79a9c7d85a1ece23fa6838da565fe 100644 (file)
@@ -771,7 +771,6 @@ struct amdgpu_ib {
        uint32_t                        length_dw;
        uint64_t                        gpu_addr;
        uint32_t                        *ptr;
-       struct amdgpu_ring              *ring;
        struct amdgpu_fence             *fence;
        struct amdgpu_user_fence        *user;
        bool                            grabbed_vmid;
@@ -1178,10 +1177,10 @@ struct amdgpu_gfx {
        unsigned ce_ram_size;
 };
 
-int amdgpu_ib_get(struct amdgpu_ring *ring, struct amdgpu_vm *vm,
+int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                  unsigned size, struct amdgpu_ib *ib);
 void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib);
-int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs,
+int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                       struct amdgpu_ib *ib, void *owner);
 int amdgpu_ib_pool_init(struct amdgpu_device *adev);
 void amdgpu_ib_pool_fini(struct amdgpu_device *adev);
@@ -1239,6 +1238,7 @@ struct amdgpu_cs_parser {
 struct amdgpu_job {
        struct amd_sched_job    base;
        struct amdgpu_device    *adev;
+       struct amdgpu_ring      *ring;
        struct amdgpu_ib        *ibs;
        uint32_t                num_ibs;
        void                    *owner;
index 8f3b72f5c91c92d962814f2649176b2d1b26b03d..d928165bfc33175d7687ddc2c75506b37724ef0e 100644 (file)
@@ -542,26 +542,25 @@ static int amdgpu_bo_vm_update_pte(struct amdgpu_cs_parser *p,
 }
 
 static int amdgpu_cs_ib_vm_chunk(struct amdgpu_device *adev,
-                                struct amdgpu_cs_parser *parser)
+                                struct amdgpu_cs_parser *p)
 {
-       struct amdgpu_fpriv *fpriv = parser->filp->driver_priv;
+       struct amdgpu_fpriv *fpriv = p->filp->driver_priv;
        struct amdgpu_vm *vm = &fpriv->vm;
-       struct amdgpu_ring *ring;
+       struct amdgpu_ring *ring = p->job->ring;
        int i, r;
 
        /* Only for UVD/VCE VM emulation */
-       for (i = 0; i < parser->job->num_ibs; i++) {
-               ring = parser->job->ibs[i].ring;
-               if (ring->funcs->parse_cs) {
-                       r = amdgpu_ring_parse_cs(ring, parser, i);
+       if (ring->funcs->parse_cs) {
+               for (i = 0; i < p->job->num_ibs; i++) {
+                       r = amdgpu_ring_parse_cs(ring, p, i);
                        if (r)
                                return r;
                }
        }
 
-       r = amdgpu_bo_vm_update_pte(parser, vm);
+       r = amdgpu_bo_vm_update_pte(p, vm);
        if (!r)
-               amdgpu_cs_sync_rings(parser);
+               amdgpu_cs_sync_rings(p);
 
        return r;
 }
@@ -603,6 +602,11 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
                if (r)
                        return r;
 
+               if (parser->job->ring && parser->job->ring != ring)
+                       return -EINVAL;
+
+               parser->job->ring = ring;
+
                if (ring->funcs->parse_cs) {
                        struct amdgpu_bo_va_mapping *m;
                        struct amdgpu_bo *aobj = NULL;
@@ -631,7 +635,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
                        offset = ((uint64_t)m->it.start) * AMDGPU_GPU_PAGE_SIZE;
                        kptr += chunk_ib->va_start - offset;
 
-                       r =  amdgpu_ib_get(ring, NULL, chunk_ib->ib_bytes, ib);
+                       r =  amdgpu_ib_get(adev, NULL, chunk_ib->ib_bytes, ib);
                        if (r) {
                                DRM_ERROR("Failed to get ib !\n");
                                return r;
@@ -640,7 +644,7 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
                        memcpy(ib->ptr, kptr, chunk_ib->ib_bytes);
                        amdgpu_bo_kunmap(aobj);
                } else {
-                       r =  amdgpu_ib_get(ring, vm, 0, ib);
+                       r =  amdgpu_ib_get(adev, vm, 0, ib);
                        if (r) {
                                DRM_ERROR("Failed to get ib !\n");
                                return r;
@@ -680,8 +684,8 @@ static int amdgpu_cs_ib_fill(struct amdgpu_device *adev,
                struct amdgpu_ib *ib = &parser->job->ibs[parser->job->num_ibs - 1];
 
                /* UVD & VCE fw doesn't support user fences */
-               if (ib->ring->type == AMDGPU_RING_TYPE_UVD ||
-                   ib->ring->type == AMDGPU_RING_TYPE_VCE)
+               if (parser->job->ring->type == AMDGPU_RING_TYPE_UVD ||
+                   parser->job->ring->type == AMDGPU_RING_TYPE_VCE)
                        return -EINVAL;
 
                ib->user = &parser->job->uf;
@@ -757,7 +761,7 @@ static int amdgpu_cs_free_job(struct amdgpu_job *job)
 static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
                            union drm_amdgpu_cs *cs)
 {
-       struct amdgpu_ring * ring = p->job->ibs->ring;
+       struct amdgpu_ring *ring = p->job->ring;
        struct amd_sched_fence *fence;
        struct amdgpu_job *job;
 
@@ -766,7 +770,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 
        job->base.sched = &ring->sched;
        job->base.s_entity = &p->ctx->rings[ring->idx].entity;
-       job->adev = p->adev;
        job->owner = p->filp;
        job->free_job = amdgpu_cs_free_job;
 
index b6737707eda25e1727d9d3c4e0f31e1e0a7b011d..47196ec593fcb89c8fe41aa446ae79f08582e2bd 100644 (file)
@@ -55,10 +55,9 @@ static int amdgpu_debugfs_sa_init(struct amdgpu_device *adev);
  * suballocator.
  * Returns 0 on success, error on failure.
  */
-int amdgpu_ib_get(struct amdgpu_ring *ring, struct amdgpu_vm *vm,
+int amdgpu_ib_get(struct amdgpu_device *adev, struct amdgpu_vm *vm,
                  unsigned size, struct amdgpu_ib *ib)
 {
-       struct amdgpu_device *adev = ring->adev;
        int r;
 
        if (size) {
@@ -77,7 +76,6 @@ int amdgpu_ib_get(struct amdgpu_ring *ring, struct amdgpu_vm *vm,
 
        amdgpu_sync_create(&ib->sync);
 
-       ib->ring = ring;
        ib->vm = vm;
 
        return 0;
@@ -120,11 +118,11 @@ void amdgpu_ib_free(struct amdgpu_device *adev, struct amdgpu_ib *ib)
  * a CONST_IB), it will be put on the ring prior to the DE IB.  Prior
  * to SI there was just a DE IB.
  */
-int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs,
+int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned num_ibs,
                       struct amdgpu_ib *ibs, void *owner)
 {
+       struct amdgpu_device *adev = ring->adev;
        struct amdgpu_ib *ib = &ibs[0];
-       struct amdgpu_ring *ring;
        struct amdgpu_ctx *ctx, *old_ctx;
        struct amdgpu_vm *vm;
        unsigned i;
@@ -133,7 +131,6 @@ int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs,
        if (num_ibs == 0)
                return -EINVAL;
 
-       ring = ibs->ring;
        ctx = ibs->ctx;
        vm = ibs->vm;
 
@@ -178,7 +175,7 @@ int amdgpu_ib_schedule(struct amdgpu_device *adev, unsigned num_ibs,
        for (i = 0; i < num_ibs; ++i) {
                ib = &ibs[i];
 
-               if (ib->ring != ring || ib->ctx != ctx || ib->vm != vm) {
+               if (ib->ctx != ctx || ib->vm != vm) {
                        ring->current_ctx = old_ctx;
                        amdgpu_ring_undo(ring);
                        return -EINVAL;
index 10d098e33707c23eebe498829191939bef413583..84453c1c4b07336356edd45e32ffb7a8702ab5c5 100644 (file)
@@ -70,7 +70,7 @@ static struct fence *amdgpu_sched_dependency(struct amd_sched_job *sched_job)
        struct fence *fence = amdgpu_sync_get_fence(sync);
 
        if (fence == NULL && vm && !job->ibs->grabbed_vmid) {
-               struct amdgpu_ring *ring = job->ibs->ring;
+               struct amdgpu_ring *ring = job->ring;
                int r;
 
                r = amdgpu_vm_grab_id(vm, ring, sync,
@@ -98,7 +98,7 @@ static struct fence *amdgpu_sched_run_job(struct amd_sched_job *sched_job)
        }
        job = to_amdgpu_job(sched_job);
        trace_amdgpu_sched_run_job(job);
-       r = amdgpu_ib_schedule(job->adev, job->num_ibs, job->ibs, job->owner);
+       r = amdgpu_ib_schedule(job->ring, job->num_ibs, job->ibs, job->owner);
        if (r) {
                DRM_ERROR("Error scheduling IBs (%d)\n", r);
                goto err;
@@ -142,6 +142,7 @@ int amdgpu_sched_ib_submit_kernel_helper(struct amdgpu_device *adev,
        *f = fence_get(&job->base.s_fence->base);
 
        job->adev = adev;
+       job->ring = ring;
        job->ibs = ibs;
        job->num_ibs = num_ibs;
        job->owner = owner;
index f808b5a6e52bdf85395ea8637afe67b82d53a1d7..9ca3735c563c225c11868d7cce9785c7ba3d8dbf 100644 (file)
@@ -38,10 +38,10 @@ TRACE_EVENT(amdgpu_cs,
 
            TP_fast_assign(
                           __entry->bo_list = p->bo_list;
-                          __entry->ring = p->job->ibs[i].ring->idx;
+                          __entry->ring = p->job->ring->idx;
                           __entry->dw = p->job->ibs[i].length_dw;
                           __entry->fences = amdgpu_fence_count_emitted(
-                               p->job->ibs[i].ring);
+                               p->job->ring);
                           ),
            TP_printk("bo_list=%p, ring=%u, dw=%u, fences=%u",
                      __entry->bo_list, __entry->ring, __entry->dw,
@@ -65,7 +65,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,
                           __entry->sched_job = &job->base;
                           __entry->ib = job->ibs;
                           __entry->fence = &job->base.s_fence->base;
-                          __entry->ring_name = job->ibs[0].ring->name;
+                          __entry->ring_name = job->ring->name;
                           __entry->num_ibs = job->num_ibs;
                           ),
            TP_printk("adev=%p, sched_job=%p, first ib=%p, sched fence=%p, ring name:%s, num_ibs:%u",
@@ -90,7 +90,7 @@ TRACE_EVENT(amdgpu_sched_run_job,
                           __entry->sched_job = &job->base;
                           __entry->ib = job->ibs;
                           __entry->fence = &job->base.s_fence->base;
-                          __entry->ring_name = job->ibs[0].ring->name;
+                          __entry->ring_name = job->ring->name;
                           __entry->num_ibs = job->num_ibs;
                           ),
            TP_printk("adev=%p, sched_job=%p, first ib=%p, sched fence=%p, ring name:%s, num_ibs:%u",
index a7354798f08737c8423a769dc18e8e1e2290b18d..6b63dcc3a77391a8c3a57550e04840e41a1c4f93 100644 (file)
@@ -1030,7 +1030,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring,
        if (!ib)
                return -ENOMEM;
 
-       r = amdgpu_ib_get(ring, NULL, num_dw * 4, ib);
+       r = amdgpu_ib_get(adev, NULL, num_dw * 4, ib);
        if (r) {
                kfree(ib);
                return r;
index f2bd2334bbe6e709dd96c8c701d8738744416367..46f2bdb76d20200e2262aa8e44b0430e8076d731 100644 (file)
@@ -867,7 +867,7 @@ static int amdgpu_uvd_send_msg(struct amdgpu_ring *ring,
                r = -ENOMEM;
                goto err;
        }
-       r = amdgpu_ib_get(ring, NULL, 64, ib);
+       r = amdgpu_ib_get(adev, NULL, 64, ib);
        if (r)
                goto err1;
 
index 66b7bfafca24af3a8c5c974ef65ef6e375267ec6..bcbe4167d7b12a598ba606323428a9cf244624bb 100644 (file)
@@ -377,7 +377,7 @@ int amdgpu_vce_get_create_msg(struct amdgpu_ring *ring, uint32_t handle,
        ib = kzalloc(sizeof(struct amdgpu_ib), GFP_KERNEL);
        if (!ib)
                return -ENOMEM;
-       r = amdgpu_ib_get(ring, NULL, ib_size_dw * 4, ib);
+       r = amdgpu_ib_get(adev, NULL, ib_size_dw * 4, ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                kfree(ib);
@@ -463,7 +463,7 @@ int amdgpu_vce_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
        if (!ib)
                return -ENOMEM;
 
-       r = amdgpu_ib_get(ring, NULL, ib_size_dw * 4, ib);
+       r = amdgpu_ib_get(adev, NULL, ib_size_dw * 4, ib);
        if (r) {
                kfree(ib);
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
index d0acc9c0fd7f2f7130a8b7f1d7f5d8ce6ba82075..b68642b47b7b0e41c4cfc55017916dbc225ba398 100644 (file)
@@ -355,7 +355,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,
        if (!ib)
                goto error;
 
-       r = amdgpu_ib_get(ring, NULL, 64, ib);
+       r = amdgpu_ib_get(adev, NULL, 64, ib);
        if (r)
                goto error_free;
 
@@ -448,7 +448,7 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev,
        if (!ib)
                return -ENOMEM;
 
-       r = amdgpu_ib_get(ring, NULL, ndw * 4, ib);
+       r = amdgpu_ib_get(adev, NULL, ndw * 4, ib);
        if (r) {
                kfree(ib);
                return r;
@@ -737,7 +737,7 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
        if (!ib)
                return -ENOMEM;
 
-       r = amdgpu_ib_get(ring, NULL, ndw * 4, ib);
+       r = amdgpu_ib_get(adev, NULL, ndw * 4, ib);
        if (r) {
                kfree(ib);
                return r;
index 1007a98f775b351dd3bfa936f1d620f748e77771..f352d755968681aa03c29031cf8182d544aadde3 100644 (file)
@@ -621,7 +621,7 @@ static int cik_sdma_ring_test_ib(struct amdgpu_ring *ring)
        tmp = 0xCAFEDEAD;
        adev->wb.wb[index] = cpu_to_le32(tmp);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(ring, NULL, 256, &ib);
+       r = amdgpu_ib_get(adev, NULL, 256, &ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                goto err0;
index 40159d529e5b2ceb6b1cb93fa96a1f659c0e732b..5f57a820dacba29288f3e1a91b211f145fdf2dd1 100644 (file)
@@ -2631,7 +2631,7 @@ static int gfx_v7_0_ring_test_ib(struct amdgpu_ring *ring)
        }
        WREG32(scratch, 0xCAFEDEAD);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(ring, NULL, 256, &ib);
+       r = amdgpu_ib_get(adev, NULL, 256, &ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                goto err1;
index 2ca36606c2ef93dbff170eab81f3db64f8224126..dbfa895c2ae5f1d0e9e0964deb0f7aa54901a19c 100644 (file)
@@ -699,7 +699,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring)
        }
        WREG32(scratch, 0xCAFEDEAD);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(ring, NULL, 256, &ib);
+       r = amdgpu_ib_get(adev, NULL, 256, &ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                goto err1;
@@ -1171,7 +1171,7 @@ static int gfx_v8_0_do_edc_gpr_workarounds(struct amdgpu_device *adev)
 
        /* allocate an indirect buffer to put the commands in */
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(ring, NULL, total_size, &ib);
+       r = amdgpu_ib_get(adev, NULL, total_size, &ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                return r;
index 5dfb13c56b90f1a3f92c716b0b0f3a12aba544df..49ec93cc71667fa2dee2f53e52a767befb60a154 100644 (file)
@@ -674,7 +674,7 @@ static int sdma_v2_4_ring_test_ib(struct amdgpu_ring *ring)
        tmp = 0xCAFEDEAD;
        adev->wb.wb[index] = cpu_to_le32(tmp);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(ring, NULL, 256, &ib);
+       r = amdgpu_ib_get(adev, NULL, 256, &ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                goto err0;
index 999a169299f0f2d05ed39812a1fcd2fc2b1d2d77..8fe150f0263499380126c5111518477ae472a87a 100644 (file)
@@ -825,7 +825,7 @@ static int sdma_v3_0_ring_test_ib(struct amdgpu_ring *ring)
        tmp = 0xCAFEDEAD;
        adev->wb.wb[index] = cpu_to_le32(tmp);
        memset(&ib, 0, sizeof(ib));
-       r = amdgpu_ib_get(ring, NULL, 256, &ib);
+       r = amdgpu_ib_get(adev, NULL, 256, &ib);
        if (r) {
                DRM_ERROR("amdgpu: failed to get ib (%d).\n", r);
                goto err0;