Skip to contentSkip to conversation

drm/amdgpu: Drop unused fence argument from amdgpu_vmid_grab_used

PATCH Applied Tvrtko Ursulin 4 participants 10 messages Sep 24, 2024 – Oct 8, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/amdgpu: Drop unused fence argument from amdgpu_vmid_grab_used

From: Tvrtko Ursulin <[email protected]>

Fence argument is unused so lets drop it.

Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +2 -4
index 92d27d32de41..8e712a11aba5 100644
@@ -342,15 +342,13 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,
  * @ring: ring we want to submit job to
  * @job: job who wants to use the VMID
  * @id: resulting VMID
- * @fence: fence to wait for if no id could be grabbed
  *
  * Try to reuse a VMID for this submission.
  */
 static int amdgpu_vmid_grab_used(struct amdgpu_vm *vm,
 				 struct amdgpu_ring *ring,
 				 struct amdgpu_job *job,
-				 struct amdgpu_vmid **id,
-				 struct dma_fence **fence)
+				 struct amdgpu_vmid **id)
 {
 	struct amdgpu_device *adev = ring->adev;
 	unsigned vmhub = ring->vm_hub;
@@ -429,7 +427,7 @@ int amdgpu_vmid_grab(struct amdgpu_vm *vm, struct amdgpu_ring *ring,
 		if (r || !id)
 			goto error;
 	} else {
-		r = amdgpu_vmid_grab_used(vm, ring, job, &id, fence);
+		r = amdgpu_vmid_grab_used(vm, ring, job, &id);
 		if (r)
 			goto error;
 
Signature · 1 line
2.46.0
#1 lore raw

PATCH 2/3 drm/amdgpu: Drop impossible condition from amdgpu_job_prepare_job

From: Tvrtko Ursulin <[email protected]>

Fence has been initialised to NULL so no need to test it.

Cc Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index 570820edcfda..d11cb0ad8c49 100644
@@ -353,7 +353,7 @@ amdgpu_job_prepare_job(struct drm_sched_job *sched_job,
 	if (r)
 		goto error;
 
-	if (!fence && job->gang_submit)
+	if (job->gang_submit)
 		fence = amdgpu_device_switch_gang(ring->adev, job->gang_submit);
 
 	while (!fence && job->vm && !job->vmid) {
Signature · 1 line
2.46.0
#2 lore raw

PATCH 3/3 drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

In reply to Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Cc Christian König <[email protected]>

---
I stared for a good while, going back and forth, and couldn't see that the while loop is needed. But maybe I missed something?

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job *sched_job,
 	if (job->gang_submit)
 		fence = amdgpu_device_switch_gang(ring->adev, job->gang_submit);
 
-	while (!fence && job->vm && !job->vmid) {
+	if (!fence && job->vm && !job->vmid) {
 		r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
 		if (r) {
 			dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
Signature · 1 line
2.46.0
maintainer Reviewed-by on v1 3/3
#3 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 7 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Quoted 5 lines

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

Quoted 20 lines

---
I stared for a good while, going back and forth, and couldn't see that the while loop is needed. But maybe I missed something?

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job *sched_job,
  	if (job->gang_submit)
  		fence = amdgpu_device_switch_gang(ring->adev, job->gang_submit);
 
-	while (!fence && job->vm && !job->vmid) {
+	if (!fence && job->vm && !job->vmid) {
  		r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
  		if (r) {
  			dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
#4 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Quoted 11 lines · Christian König

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Quoted 6 lines
Quoted 2 lines
Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

Thanks - CC Alex if you could merge the trivial series please?

Regards,

Tvrtko

Quoted 21 lines
Quoted 20 lines

---
I stared for a good while, going back and forth, and couldn't see that the while loop is needed. But maybe I missed something?
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job 
 *sched_job,
       if (job->gang_submit)
           fence = amdgpu_device_switch_gang(ring->adev, job->gang_submit);
-    while (!fence && job->vm && !job->vmid) {
+    if (!fence && job->vm && !job->vmid) {
           r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
           if (r) {
               dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
Applied
#5 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Applied. Thanks!

Alex

Quoted 53 lines · Tvrtko Ursulin
Quoted 11 lines · Christian König

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Quoted 8 lines
Quoted 2 lines
Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

series.

Thanks - CC Alex if you could merge the trivial series please?

Regards,

Tvrtko

Quoted 24 lines
Quoted 23 lines

---
I stared for a good while, going back and forth, and couldn't see that the
while loop is needed. But maybe I missed something?

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job
 *sched_job,
      if (job->gang_submit)
          fence = amdgpu_device_switch_gang(ring->adev,
 job->gang_submit);
-    while (!fence && job->vm && !job->vmid) {
+    if (!fence && job->vm && !job->vmid) {
          r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
          if (r) {
              dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
#6 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Quoted 1 line · Alex Deucher

Applied. Thanks!

Thanks Alex!

Could you perhaps also merge https://lore.kernel.org/amd-gfx/[email protected]/ via your tree? If it still applies that is.

Regards,

Tvrtko

Quoted 54 lines · Tvrtko Ursulin
Quoted 53 lines · Christian König
Quoted 11 lines

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Quoted 8 lines
Quoted 2 lines
Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

series.

Thanks - CC Alex if you could merge the trivial series please?

Regards,

Tvrtko

Quoted 24 lines
Quoted 23 lines

---
I stared for a good while, going back and forth, and couldn't see that the
while loop is needed. But maybe I missed something?

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job
 *sched_job,
       if (job->gang_submit)
           fence = amdgpu_device_switch_gang(ring->adev,
 job->gang_submit);
-    while (!fence && job->vm && !job->vmid) {
+    if (!fence && job->vm && !job->vmid) {
           r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
           if (r) {
               dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
#7 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Quoted 10 lines · Tvrtko Ursulin
Quoted 1 line · Alex Deucher

Applied. Thanks!

Thanks Alex!

Could you perhaps also merge
https://lore.kernel.org/amd-gfx/[email protected]/
via your tree? If it still applies that is.

Just picked it up. Thanks!

Alex

Quoted 59 lines

Regards,

Tvrtko

Quoted 54 lines · Tvrtko Ursulin
Quoted 53 lines · Christian König
Quoted 11 lines

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Quoted 8 lines
Quoted 2 lines
Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

series.

Thanks - CC Alex if you could merge the trivial series please?

Regards,

Tvrtko

Quoted 24 lines
Quoted 23 lines

---
I stared for a good while, going back and forth, and couldn't see that the
while loop is needed. But maybe I missed something?

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job
 *sched_job,
       if (job->gang_submit)
           fence = amdgpu_device_switch_gang(ring->adev,
 job->gang_submit);
-    while (!fence && job->vm && !job->vmid) {
+    if (!fence && job->vm && !job->vmid) {
           r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
           if (r) {
               dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
#8 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Quoted 6 lines · Alex Deucher
Quoted 5 lines · Tvrtko Ursulin
Quoted 1 line · Alex Deucher

Applied. Thanks!

Quoted 7 lines
Quoted 5 lines

Thanks Alex!

Could you perhaps also merge
https://lore.kernel.org/amd-gfx/[email protected]/
via your tree? If it still applies that is.

Just picked it up. Thanks!

Did you get only 1/2? 2/2 needs more work/review you think or?

Regards,

Tvrtko

Quoted 61 lines

Alex

Quoted 59 lines

Regards,

Tvrtko

Quoted 54 lines · Tvrtko Ursulin
Quoted 53 lines · Christian König
Quoted 11 lines

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Quoted 8 lines
Quoted 2 lines
Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

series.

Thanks - CC Alex if you could merge the trivial series please?

Regards,

Tvrtko

Quoted 24 lines
Quoted 23 lines

---
I stared for a good while, going back and forth, and couldn't see that the
while loop is needed. But maybe I missed something?

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job
 *sched_job,
        if (job->gang_submit)
            fence = amdgpu_device_switch_gang(ring->adev,
 job->gang_submit);
-    while (!fence && job->vm && !job->vmid) {
+    if (!fence && job->vm && !job->vmid) {
            r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
            if (r) {
                dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);
#9 lore raw

Re: [PATCH 3/3] drm/amdgpu: Remove the while loop from amdgpu_job_prepare_job

Quoted 11 lines · Tvrtko Ursulin
Quoted 8 lines · Alex Deucher
Quoted 7 lines · Tvrtko Ursulin
Quoted 1 line · Alex Deucher

Applied. Thanks!

Thanks Alex!

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Could you perhaps also merge
https://lore.kernel.org/amd-gfx/[email protected]/
via your tree? If it still applies that is.

Just picked it up. Thanks!

Did you get only 1/2? 2/2 needs more work/review you think or?

I picked up both. The second patch was still in the CI pipeline when I pushed out an updated branch yesterday. I'll push an updated tree today.

Alex

Quoted 66 lines

Regards,

Tvrtko

Quoted 61 lines

Alex

Quoted 59 lines

Regards,

Tvrtko

Quoted 54 lines · Tvrtko Ursulin
Quoted 53 lines · Christian König
Quoted 11 lines

Am 24.09.24 um 11:51 schrieb Tvrtko Ursulin:

Quoted 10 lines

From: Tvrtko Ursulin <[email protected]>

While loop makes it sound like amdgpu_vmid_grab() potentially needs to be called multiple times to produce a fence, while in reality all code paths either return an error, assign a valid job->vmid or assign a vmid which will be valid once the returned fence signals.

Therefore we can remove the loop to make it clear the call does not need to be repeated.

Quoted 8 lines
Quoted 2 lines
Cc Christian König <[email protected]>

Oh yeah that's a leftover from when we still had the dependency handling inside all this.

series.

Thanks - CC Alex if you could merge the trivial series please?

Regards,

Tvrtko

Quoted 24 lines
Quoted 23 lines

---
I stared for a good while, going back and forth, and couldn't see that the
while loop is needed. But maybe I missed something?

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_job.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_job.c +1 -1
index d11cb0ad8c49..85f10b59d09c 100644
@@ -356,7 +356,7 @@ amdgpu_job_prepare_job(struct drm_sched_job
 *sched_job,
        if (job->gang_submit)
            fence = amdgpu_device_switch_gang(ring->adev,
 job->gang_submit);
-    while (!fence && job->vm && !job->vmid) {
+    if (!fence && job->vm && !job->vmid) {
            r = amdgpu_vmid_grab(job->vm, ring, job, &fence);
            if (r) {
                dev_err(ring->adev->dev, "Error getting VM ID (%d)\n", r);