Skip to contentSkip to conversation

drm/amdgpu: remove dummy codes

PATCH In review Flora Cui 2 participants 5 messages Nov 4, 2016 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Flora Cui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: remove dummy codes

Change-Id I3238a2520c9161b1c2f9cf176158bdeb9cb21cbb
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +--------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  4 ----
 2 files changed, 1 insertion(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -14
index 4068504..be2ad79 100644
@@ -917,13 +917,6 @@ 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(adev, vm, 0, ib);
-			if (r) {
-				DRM_ERROR("Failed to get ib !\n");
-				return r;
-			}
-
 		}
 
 		ib->gpu_addr = chunk_ib->va_start;
@@ -1008,21 +1001,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 	job = p->job;
 	p->job = NULL;
 
-	r = amd_sched_job_init(&job->base, &ring->sched, entity, p->filp);
+	r = amdgpu_job_submit(job, ring, entity, p->filp, &p->fence);
 	if (r) {
 		amdgpu_job_free(job);
 		return r;
 	}
 
-	job->owner = p->filp;
-	job->fence_ctx = entity->fence_context;
-	p->fence = fence_get(&job->base.s_fence->finished);
 	cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
 	job->uf_sequence = cs->out.handle;
-	amdgpu_job_free_resources(job);
-
 	trace_amdgpu_cs_ioctl(job);
-	amd_sched_entity_push_job(&job->base);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -4
index d6c2839..c6448e1 100644
@@ -960,10 +960,6 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
 
 	ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
 
-	memset(&params, 0, sizeof(params));
-	params.adev = adev;
-	params.src = src;
-
 	/* sync to everything on unmapping */
 	if (!(flags & AMDGPU_PTE_VALID))
 		owner = AMDGPU_FENCE_OWNER_UNDEFINED;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1478244748-15866-1-git-send-email-Flora.Cui-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Well clearly a NAK on this, why do you think this is just dummy code?

Am 04.11.2016 um 08:32 schrieb Flora Cui:

Quoted 12 lines
Change-Id I3238a2520c9161b1c2f9cf176158bdeb9cb21cbb
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +--------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  4 ----
  2 files changed, 1 insertion(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 4068504..be2ad79 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, · line 926

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -7
@@ -917,13 +917,6 @@ 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(adev, vm, 0, ib);
-			if (r) {
-				DRM_ERROR("Failed to get ib !\n");
-				return r;
-			}
-

This is the IB allocation and initialization for the VM case and vital to command submission.

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
  		}
 
  		ib->gpu_addr = chunk_ib->va_start;
@@ -1008,21 +1001,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
  	job = p->job;
  	p->job = NULL;
 
-	r = amd_sched_job_init(&job->base, &ring->sched, entity, p->filp);
+	r = amdgpu_job_submit(job, ring, entity, p->filp, &p->fence);
  	if (r) {
  		amdgpu_job_free(job);
  		return r;
  	}

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, · line 1025

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -6
 
-	job->owner = p->filp;
-	job->fence_ctx = entity->fence_context;
-	p->fence = fence_get(&job->base.s_fence->finished);
  	cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
  	job->uf_sequence = cs->out.handle;
-	amdgpu_job_free_resources(job);
-
  	trace_amdgpu_cs_ioctl(job);
-	amd_sched_entity_push_job(&job->base);

This results in a race condition because the job might already be freed after amdgpu_job_submit() succeeded.

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index d6c2839..c6448e1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 966

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -4
@@ -960,10 +960,6 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
 
  	ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
 
-	memset(&params, 0, sizeof(params));
-	params.adev = adev;
-	params.src = src;
-

This indeed looks like a duplicate, probably a leftover merge issue.

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 965

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
  	/* sync to everything on unmapping */
  	if (!(flags & AMDGPU_PTE_VALID))
  		owner = AMDGPU_FENCE_OWNER_UNDEFINED;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): d7965a02-31ba-cc14-0a37-a0debb216d49-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

author
#4 lore raw
Quoted 19 lines · Christian König

Well clearly a NAK on this, why do you think this is just dummy code?

Am 04.11.2016 um 08:32 schrieb Flora Cui:

Quoted 16 lines
Change-Id I3238a2520c9161b1c2f9cf176158bdeb9cb21cbb
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +--------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  4 ----
 2 files changed, 1 insertion(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -2
index 4068504..be2ad79 100644
@@ -917,13 +917,6 @@ 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(adev, vm, 0, ib);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, · line 926

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -5
-			if (r) {
-				DRM_ERROR("Failed to get ib !\n");
-				return r;
-			}
-

This is the IB allocation and initialization for the VM case and vital to command submission.

flora: amdgpu_ib_get do nothing with param size=0

Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -4
 		}
 		ib->gpu_addr = chunk_ib->va_start;
@@ -1008,21 +1001,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 	job = p->job;
 	p->job = NULL;
-	r = amd_sched_job_init(&job->base, &ring->sched, entity, p->filp);
+	r = amdgpu_job_submit(job, ring, entity, p->filp, &p->fence);
 	if (r) {
 		amdgpu_job_free(job);
 		return r;
 	}
-	job->owner = p->filp;
-	job->fence_ctx = entity->fence_context;
-	p->fence = fence_get(&job->base.s_fence->finished);
 	cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, · line 1025

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -3
 	job->uf_sequence = cs->out.handle;
-	amdgpu_job_free_resources(job);
-
 	trace_amdgpu_cs_ioctl(job);
-	amd_sched_entity_push_job(&job->base);

This results in a race condition because the job might already be freed after amdgpu_job_submit() succeeded.

flora: OK. I'll drop this.

Quoted 15 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 964

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -4
index d6c2839..c6448e1 100644
@@ -960,10 +960,6 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
 	ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
-	memset(&params, 0, sizeof(params));
-	params.adev = adev;
-	params.src = src;
-

This indeed looks like a duplicate, probably a leftover merge issue.

Quoted 8 lines

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
 	/* sync to everything on unmapping */
 	if (!(flags & AMDGPU_PTE_VALID))
 		owner = AMDGPU_FENCE_OWNER_UNDEFINED;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

Am 04.11.2016 um 10:22 schrieb Flora Cui:

Quoted 27 lines · Christian König
Quoted 10 lines

Well clearly a NAK on this, why do you think this is just dummy code?

Am 04.11.2016 um 08:32 schrieb Flora Cui:

Quoted 7 lines
Change-Id I3238a2520c9161b1c2f9cf176158bdeb9cb21cbb
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +--------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  4 ----
  2 files changed, 1 insertion(+), 18 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 4068504..be2ad79 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_ib_fill(struct amdgpu_device *adev, · line 925

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -7
@@ -917,13 +917,6 @@ 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(adev, vm, 0, ib);
-			if (r) {
-				DRM_ERROR("Failed to get ib !\n");
-				return r;
-			}
-

This is the IB allocation and initialization for the VM case and vital to command submission.

Quoted 1 line

flora: amdgpu_ib_get do nothing with param size=0

That's clearly a bug. The function should at least clear the structure members.

Christian.

Quoted 22 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -4
  		}
  		ib->gpu_addr = chunk_ib->va_start;
@@ -1008,21 +1001,15 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
  	job = p->job;
  	p->job = NULL;
-	r = amd_sched_job_init(&job->base, &ring->sched, entity, p->filp);
+	r = amdgpu_job_submit(job, ring, entity, p->filp, &p->fence);
  	if (r) {
  		amdgpu_job_free(job);
  		return r;
  	}
-	job->owner = p->filp;
-	job->fence_ctx = entity->fence_context;
-	p->fence = fence_get(&job->base.s_fence->finished);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_submit(struct amdgpu_cs_parser *p, · line 1025

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -3
  	cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
  	job->uf_sequence = cs->out.handle;
-	amdgpu_job_free_resources(job);
-
  	trace_amdgpu_cs_ioctl(job);
-	amd_sched_entity_push_job(&job->base);

This results in a race condition because the job might already be freed after amdgpu_job_submit() succeeded.

Quoted 23 lines

flora: OK. I'll drop this.

Quoted 21 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 964

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -4
index d6c2839..c6448e1 100644
@@ -960,10 +960,6 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
  	ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);
-	memset(&params, 0, sizeof(params));
-	params.adev = adev;
-	params.src = src;
-

This indeed looks like a duplicate, probably a leftover merge issue.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
  	/* sync to everything on unmapping */
  	if (!(flags & AMDGPU_PTE_VALID))
  		owner = AMDGPU_FENCE_OWNER_UNDEFINED;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 7418b59b-4582-10e6-4fca-dae089b2ecc4-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#7 lore raw

Am 04.11.2016 um 11:49 schrieb Christian König:

Quoted 29 lines

Am 04.11.2016 um 10:22 schrieb Flora Cui:

Quoted 28 lines · Christian König
Quoted 27 lines

Well clearly a NAK on this, why do you think this is just dummy code?

Am 04.11.2016 um 08:32 schrieb Flora Cui:

Quoted 12 lines
Change-Id I3238a2520c9161b1c2f9cf176158bdeb9cb21cbb
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 15 +--------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c |  4 ----
  2 files changed, 1 insertion(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 4068504..be2ad79 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_ib_fill(struct · line 926

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -7
@@ -917,13 +917,6 @@ 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(adev, vm, 0, ib);
-            if (r) {
-                DRM_ERROR("Failed to get ib !\n");
-                return r;
-            }
-

This is the IB allocation and initialization for the VM case and vital to command submission.

Quoted 3 lines
Quoted 1 line

flora: amdgpu_ib_get do nothing with param size=0

That's clearly a bug. The function should at least clear the structure members.

On the other hand we zero clear the IB array now anyway.

So what you could do is remove the size check from amdgpu_ib_get() and then drop this code as well.

Regards,
Christian.

Quoted 54 lines

Christian.

Quoted 24 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -4
          }
          ib->gpu_addr = chunk_ib->va_start;
@@ -1008,21 +1001,15 @@ static int amdgpu_cs_submit(struct 
 amdgpu_cs_parser *p,
      job = p->job;
      p->job = NULL;
-    r = amd_sched_job_init(&job->base, &ring->sched, entity, 
 p->filp);
+    r = amdgpu_job_submit(job, ring, entity, p->filp, &p->fence);
      if (r) {
          amdgpu_job_free(job);
          return r;
      }
-    job->owner = p->filp;
-    job->fence_ctx = entity->fence_context;
-    p->fence = fence_get(&job->base.s_fence->finished);
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c static int amdgpu_cs_submit(struct · line 1025

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -3
      cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
      job->uf_sequence = cs->out.handle;
-    amdgpu_job_free_resources(job);
-
      trace_amdgpu_cs_ioctl(job);
-    amd_sched_entity_push_job(&job->base);

This results in a race condition because the job might already be freed after amdgpu_job_submit() succeeded.

Quoted 25 lines

flora: OK. I'll drop this.

Quoted 23 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
      return 0;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index d6c2839..c6448e1 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct · line 966

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -4
@@ -960,10 +960,6 @@ static int amdgpu_vm_bo_update_mapping(struct 
 amdgpu_device *adev,
      ring = container_of(vm->entity.sched, struct amdgpu_ring, 
 sched);
-    memset(&params, 0, sizeof(params));
-    params.adev = adev;
-    params.src = src;
-

This indeed looks like a duplicate, probably a leftover merge issue.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
      /* sync to everything on unmapping */
      if (!(flags & AMDGPU_PTE_VALID))
          owner = AMDGPU_FENCE_OWNER_UNDEFINED;
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx