Skip to contentSkip to conversation

Bunch of patches to do trivial clean up and

PATCH Superseded Sunil Khatri 3 participants 14 messages Mar 26

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Bunch of patches to do trivial clean up and

Sunil Khatri (4):
drm/amdgpu/userq: no need to use local variable ret drm/amdgpu/userq: no need to use local variable here for return drm/amdgpu/userq: no need to use local variable here for return drm/amdgpu/userq: Fix the code alignment for readability

 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 31 +++++++++--------------
 1 file changed, 12 insertions(+), 19 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 drm/amdgpu/userq: no need to use local variable ret

In function amdgpu_userq_evict use the function return value in the if condition instead.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -6
index aa0e6eea9436..2a1832fce6d2 100644
@@ -1308,17 +1308,13 @@ void
 amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr)
 {
 	struct amdgpu_device *adev = uq_mgr->adev;
-	int ret;
 
 	/* Wait for any pending userqueue fence work to finish */
-	ret = amdgpu_userq_wait_for_signal(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_wait_for_signal(uq_mgr))
 		dev_err(adev->dev, "Not evicting userqueue, timeout waiting for work\n");
 
-	ret = amdgpu_userq_evict_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_evict_all(uq_mgr))
 		dev_err(adev->dev, "Failed to evict userqueue\n");
-
 }
 
 int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,
Signature · 1 line
2.34.1
maintainer
#2 lore raw

Re: [Patch v1 1/4] drm/amdgpu/userq: no need to use local variable ret

Quoted 13 lines · Sunil Khatri

In function amdgpu_userq_evict use the function return value in the if condition instead.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
index aa0e6eea9436..2a1832fce6d2 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c void · line 1314

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -3
@@ -1308,17 +1308,13 @@ void
 amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr)
 {
 	struct amdgpu_device *adev = uq_mgr->adev;
-	int ret;
 
 	/* Wait for any pending userqueue fence work to finish */
-	ret = amdgpu_userq_wait_for_signal(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_wait_for_signal(uq_mgr))
 		dev_err(adev->dev, "Not evicting userqueue, timeout waiting for work\n");

That actually looks like a pretty bad idea. Instead we should start printing the error code.

But before we do that I would rather like to know why amdgpu_userq_wait_for_signal() can fail?

That should never happen in the first place.

Regards,
Christian.

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -3
-	ret = amdgpu_userq_evict_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_evict_all(uq_mgr))
 		dev_err(adev->dev, "Failed to evict userqueue\n");
-
 }
 
 int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,
#3 lore raw

Re: [Patch v1 1/4] drm/amdgpu/userq: no need to use local variable ret

Quoted 19 lines · Christian König
Quoted 18 lines · Sunil Khatri

In function amdgpu_userq_evict use the function return value in the if condition instead.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
index aa0e6eea9436..2a1832fce6d2 100644
@@ -1308,17 +1308,13 @@ void
  amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr)
  {
  	struct amdgpu_device *adev = uq_mgr->adev;
-	int ret;
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c void · line 1314

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
  	/* Wait for any pending userqueue fence work to finish */
-	ret = amdgpu_userq_wait_for_signal(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_wait_for_signal(uq_mgr))
  		dev_err(adev->dev, "Not evicting userqueue, timeout waiting for work\n");

That actually looks like a pretty bad idea. Instead we should start printing the error code.

Sure could add an error code in the logging.

Quoted 2 lines

But before we do that I would rather like to know why amdgpu_userq_wait_for_signal() can fail?

dma_fence_wait_timeout is what could fail and we are returning -ETIMEDOUT. We could totally avoid checking for the error here completely as we are already printing the error in the called function below.
ret=dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));
if(ret<=0) {
drm_file_err(uq_mgr->file, "Timed out waiting for fence=%llu:%llu\n",
f->context, f->seqno);
return-ETIMEDOUT;
                }

Quoted 10 lines

That should never happen in the first place.

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c void · line 1317

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
-	ret = amdgpu_userq_evict_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_evict_all(uq_mgr))
  		dev_err(adev->dev, "Failed to evict userqueue\n");

Here also the below function returns error and printing error too. We could avoid the return value here too as we are already printing the error. amdgpu_userq_preempt_helper(queue);
if(r)
ret=r;

Regards
Sunil Khatri

Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
-
  }
 
  int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,
maintainer
#4 lore raw

Re: [Patch v1 1/4] drm/amdgpu/userq: no need to use local variable ret

Quoted 27 lines · Sunil
Quoted 19 lines · Christian König
Quoted 18 lines · Sunil Khatri

In function amdgpu_userq_evict use the function return value in the if condition instead.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
index aa0e6eea9436..2a1832fce6d2 100644
@@ -1308,17 +1308,13 @@ void
 amdgpu_userq_evict(struct amdgpu_userq_mgr *uq_mgr)
 {
 	struct amdgpu_device *adev = uq_mgr->adev;
-	int ret;
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c void · line 1314

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
 	/* Wait for any pending userqueue fence work to finish */
-	ret = amdgpu_userq_wait_for_signal(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_wait_for_signal(uq_mgr))
 		dev_err(adev->dev, "Not evicting userqueue, timeout waiting for work\n");

That actually looks like a pretty bad idea. Instead we should start printing the error code.

Quoted 5 lines

Sure could add an error code in the logging.

Quoted 1 line

But before we do that I would rather like to know why amdgpu_userq_wait_for_signal() can fail?

dma_fence_wait_timeout is what could fail and we are returning -ETIMEDOUT. We could totally avoid checking for the error here completely as we are already printing the error in the called function below.
ret=dma_fence_wait_timeout(f, true, msecs_to_jiffies(100));

*sigh* I explicitly NAKed that timeout before. Please change that to the maximum.

Additional to that please drop the extra call to dma_fence_is_signaled() before the wait, such stuff is completely superfluous.

Then the second parameter to dma_fence_wait_timeout should be false, this way we can't be interrupted any more and don't need to check the return value for errors.

Thanks for take a look at that,
Christian.

Quoted 28 lines

                if(ret<=0) {
                        drm_file_err(uq_mgr->file, "Timed out waiting for fence=%llu:%llu\n", f->context, f->seqno);
        return-ETIMEDOUT;
                }

Quoted 10 lines

That should never happen in the first place.

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c void · line 1317

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
-	ret = amdgpu_userq_evict_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_evict_all(uq_mgr))
 		dev_err(adev->dev, "Failed to evict userqueue\n");

Here also the below function returns error and printing error too. We could avoid the return value here too as we are already printing the error. amdgpu_userq_preempt_helper(queue);
                if(r)
                        ret=r;

Regards
Sunil Khatri

Quoted 4 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
-
 }
 
 int amdgpu_userq_mgr_init(struct amdgpu_userq_mgr *userq_mgr, struct drm_file *file_priv,
#5 lore raw

PATCH 2/4 drm/amdgpu/userq: no need to use local variable here for return

In reply to Sunil Khatri

In function amdgpu_userq_restore_worker use directly the function's return value in the if condition instead of local variable ret.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -5
index 2a1832fce6d2..2b07c3941927 100644
@@ -1222,20 +1222,17 @@ static void amdgpu_userq_restore_worker(struct work_struct *work)
 	struct amdgpu_userq_mgr *uq_mgr = work_to_uq_mgr(work, resume_work.work);
 	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
 	struct dma_fence *ev_fence;
-	int ret;
 
 	ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
 	if (!dma_fence_is_signaled(ev_fence))
 		goto put_fence;
 
-	ret = amdgpu_userq_vm_validate(uq_mgr);
-	if (ret) {
+	if (amdgpu_userq_vm_validate(uq_mgr)) {
 		drm_file_err(uq_mgr->file, "Failed to validate BOs to restore\n");
 		goto put_fence;
 	}
 
-	ret = amdgpu_userq_restore_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_restore_all(uq_mgr))
 		drm_file_err(uq_mgr->file, "Failed to restore all queues\n");
 
 put_fence:
Signature · 1 line
2.34.1
maintainer
#6 lore raw

Re: [Patch v1 2/4] drm/amdgpu/userq: no need to use local variable here for return

Quoted 17 lines · Sunil Khatri

In function amdgpu_userq_restore_worker use directly the function's return value in the if condition instead of local variable ret.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
index 2a1832fce6d2..2b07c3941927 100644
@@ -1222,20 +1222,17 @@ static void amdgpu_userq_restore_worker(struct work_struct *work)
 	struct amdgpu_userq_mgr *uq_mgr = work_to_uq_mgr(work, resume_work.work);
 	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
 	struct dma_fence *ev_fence;

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c static void amdgpu_userq_restore_worker(struct work_struct *work) · line 1231

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -3
-	int ret;
 
 	ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
 	if (!dma_fence_is_signaled(ev_fence))
 		goto put_fence;
 
-	ret = amdgpu_userq_vm_validate(uq_mgr);
-	if (ret) {
+	if (amdgpu_userq_vm_validate(uq_mgr)) {
 		drm_file_err(uq_mgr->file, "Failed to validate BOs to restore\n");

Again, probably a good idea to print the error code here.

Regards,
Christian.

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
 		goto put_fence;
 	}
 
-	ret = amdgpu_userq_restore_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_restore_all(uq_mgr))
 		drm_file_err(uq_mgr->file, "Failed to restore all queues\n");
 
 put_fence:
#7 lore raw

Re: [Patch v1 2/4] drm/amdgpu/userq: no need to use local variable here for return

Quoted 25 lines · Christian König
Quoted 23 lines · Sunil Khatri

In function amdgpu_userq_restore_worker use directly the function's return value in the if condition instead of local variable ret.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
index 2a1832fce6d2..2b07c3941927 100644
@@ -1222,20 +1222,17 @@ static void amdgpu_userq_restore_worker(struct work_struct *work)
  	struct amdgpu_userq_mgr *uq_mgr = work_to_uq_mgr(work, resume_work.work);
  	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
  	struct dma_fence *ev_fence;
-	int ret;
 
  	ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
  	if (!dma_fence_is_signaled(ev_fence))
  		goto put_fence;
 
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c static void amdgpu_userq_restore_worker(struct work_struct *work) · line 1231

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
-	ret = amdgpu_userq_vm_validate(uq_mgr);
-	if (ret) {
+	if (amdgpu_userq_vm_validate(uq_mgr)) {
  		drm_file_err(uq_mgr->file, "Failed to validate BOs to restore\n");

Again, probably a good idea to print the error code here.

since this is a void function and all the functions called here are already printing the failures and we could just remove the if and let the called function print error.

Quoted 11 lines

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c static void amdgpu_userq_restore_worker(struct work_struct *work) · line 1236

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
  		goto put_fence;
  	}
 
-	ret = amdgpu_userq_restore_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_restore_all(uq_mgr))
  		drm_file_err(uq_mgr->file, "Failed to restore all queues\n");

Could avoid printing this error all together as we are printing the error in the function. We could update the error message. if(ret)
drm_file_err(uq_mgr->file, "Failed to map all the queues\n");
returnret;

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
  put_fence:
maintainer
#8 lore raw

Re: [Patch v1 2/4] drm/amdgpu/userq: no need to use local variable here for return

Quoted 35 lines · Sunil
Quoted 24 lines · Christian König
Quoted 23 lines · Sunil Khatri

In function amdgpu_userq_restore_worker use directly the function's return value in the if condition instead of local variable ret.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
index 2a1832fce6d2..2b07c3941927 100644
@@ -1222,20 +1222,17 @@ static void amdgpu_userq_restore_worker(struct work_struct *work)
 	struct amdgpu_userq_mgr *uq_mgr = work_to_uq_mgr(work, resume_work.work);
 	struct amdgpu_fpriv *fpriv = uq_mgr_to_fpriv(uq_mgr);
 	struct dma_fence *ev_fence;
-	int ret;
 
 	ev_fence = amdgpu_evf_mgr_get_fence(&fpriv->evf_mgr);
 	if (!dma_fence_is_signaled(ev_fence))
 		goto put_fence;
 
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c static void amdgpu_userq_restore_worker(struct work_struct *work) · line 1231

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
-	ret = amdgpu_userq_vm_validate(uq_mgr);
-	if (ret) {
+	if (amdgpu_userq_vm_validate(uq_mgr)) {
 		drm_file_err(uq_mgr->file, "Failed to validate BOs to restore\n");

Again, probably a good idea to print the error code here.

since this is a void function and all the functions called here are already printing the failures and we could just remove the if and let the called function print error.

Quoted 3 lines

Regards,
Christian.

Quoted 8 lines
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c static void amdgpu_userq_restore_worker(struct work_struct *work) · line 1236

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1 -2
 		goto put_fence;
 	}
 
-	ret = amdgpu_userq_restore_all(uq_mgr);
-	if (ret)
+	if (amdgpu_userq_restore_all(uq_mgr))
 		drm_file_err(uq_mgr->file, "Failed to restore all queues\n");

Could avoid printing this error all together as we are printing the error in the function. We could update the error message.

Yeah that works for me as well.

Thanks,
Christian.

Quoted 7 lines

if(ret)
                drm_file_err(uq_mgr->file, "Failed to map all the queues\n"); returnret;

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
 put_fence:
#9 lore raw

PATCH 3/4 drm/amdgpu/userq: no need to use local variable here for return

In reply to Sunil Khatri

In function amdgpu_userq_gem_va_unmap_validate use function return value directly in the if condition instead of local variable ret.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -4
index 2b07c3941927..48cb2e21ce56 100644
@@ -1478,7 +1478,6 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,
 	u32 ip_mask = amdgpu_userq_get_supported_ip_mask(adev);
 	struct amdgpu_bo_va *bo_va = mapping->bo_va;
 	struct dma_resv *resv = bo_va->base.bo->tbo.base.resv;
-	int ret = 0;
 
 	if (!ip_mask)
 		return 0;
@@ -1493,9 +1492,8 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,
 	 * the eviction fence is always unsignaled.
 	 */
 	if (!dma_resv_test_signaled(resv, DMA_RESV_USAGE_BOOKKEEP)) {
-		ret = dma_resv_wait_timeout(resv, DMA_RESV_USAGE_BOOKKEEP, true,
-					    MAX_SCHEDULE_TIMEOUT);
-		if (ret <= 0)
+		if (dma_resv_wait_timeout(resv, DMA_RESV_USAGE_BOOKKEEP, true,
+					    MAX_SCHEDULE_TIMEOUT) <= 0)
 			return -EBUSY;
 	}
 
Signature · 1 line
2.34.1
maintainer
#10 lore raw

Re: [Patch v1 3/4] drm/amdgpu/userq: no need to use local variable here for return

Quoted 22 lines · Sunil Khatri

In function amdgpu_userq_gem_va_unmap_validate use function return value directly in the if condition instead of local variable ret.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
index 2b07c3941927..48cb2e21ce56 100644
@@ -1478,7 +1478,6 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,
 	u32 ip_mask = amdgpu_userq_get_supported_ip_mask(adev);
 	struct amdgpu_bo_va *bo_va = mapping->bo_va;
 	struct dma_resv *resv = bo_va->base.bo->tbo.base.resv;
-	int ret = 0;
 
 	if (!ip_mask)
 		return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev, · line 1494

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
@@ -1493,9 +1492,8 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,
 	 * the eviction fence is always unsignaled.
 	 */
 	if (!dma_resv_test_signaled(resv, DMA_RESV_USAGE_BOOKKEEP)) {

That test is just nonsense, call dma_resv_wait_timeout() directly here.

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev, · line 1497

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -3
-		ret = dma_resv_wait_timeout(resv, DMA_RESV_USAGE_BOOKKEEP, true,
-					    MAX_SCHEDULE_TIMEOUT);
-		if (ret <= 0)
+		if (dma_resv_wait_timeout(resv, DMA_RESV_USAGE_BOOKKEEP, true,
+					    MAX_SCHEDULE_TIMEOUT) <= 0)
 			return -EBUSY;

That is wrong as well. We need to return ret here and not -EBUSY!

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
 	}
 
#11 lore raw

Re: [Patch v1 3/4] drm/amdgpu/userq: no need to use local variable here for return

Quoted 21 lines · Christian König
Quoted 19 lines · Sunil Khatri

In function amdgpu_userq_gem_va_unmap_validate use function return value directly in the if condition instead of local variable ret.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -1
index 2b07c3941927..48cb2e21ce56 100644
@@ -1478,7 +1478,6 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,
  	u32 ip_mask = amdgpu_userq_get_supported_ip_mask(adev);
  	struct amdgpu_bo_va *bo_va = mapping->bo_va;
  	struct dma_resv *resv = bo_va->base.bo->tbo.base.resv;
-	int ret = 0;
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev, · line 1494

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
  	if (!ip_mask)
  		return 0;
@@ -1493,9 +1492,8 @@ int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev,
  	 * the eviction fence is always unsignaled.
  	 */
  	if (!dma_resv_test_signaled(resv, DMA_RESV_USAGE_BOOKKEEP)) {

That test is just nonsense, call dma_resv_wait_timeout() directly here.

Make sense.

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_gem_va_unmap_validate(struct amdgpu_device *adev, · line 1497

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -3
-		ret = dma_resv_wait_timeout(resv, DMA_RESV_USAGE_BOOKKEEP, true,
-					    MAX_SCHEDULE_TIMEOUT);
-		if (ret <= 0)
+		if (dma_resv_wait_timeout(resv, DMA_RESV_USAGE_BOOKKEEP, true,
+					    MAX_SCHEDULE_TIMEOUT) <= 0)
  			return -EBUSY;

That is wrong as well. We need to return ret here and not -EBUSY!

sure

Regards
Sunil Khatri

Quoted 6 lines

Regards,
Christian.

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0 -0
  	}
 
#12 lore raw

PATCH 4/4 drm/amdgpu/userq: Fix the code alignment for readability

In reply to Sunil Khatri

Fix the code alignment for if condition and also provide a line space between multiline if condition and next statement.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +6 -4
index 48cb2e21ce56..7cdfe3adcbae 100644
@@ -1454,17 +1454,19 @@ int amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device *adev,
 
 	if (!adev->userq_halt_for_enforce_isolation)
 		dev_warn(adev->dev, "userq scheduling already started!\n");
+
 	adev->userq_halt_for_enforce_isolation = false;
+
 	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
 		uqm = queue->userq_mgr;
 		mutex_lock(&uqm->userq_mutex);
-			if (((queue->queue_type == AMDGPU_HW_IP_GFX) ||
-			     (queue->queue_type == AMDGPU_HW_IP_COMPUTE)) &&
-			    (queue->xcp_id == idx)) {
+		if (((queue->queue_type == AMDGPU_HW_IP_GFX) ||
+		     (queue->queue_type == AMDGPU_HW_IP_COMPUTE)) &&
+		    (queue->xcp_id == idx)) {
 			r = amdgpu_userq_restore_helper(queue);
 			if (r)
 				ret = r;
-			}
+		}
 		mutex_unlock(&uqm->userq_mutex);
 	}
 
Signature · 1 line
2.34.1
maintainer Acked-by on v1 4/4
#13 lore raw

Re: [Patch v1 4/4] drm/amdgpu/userq: Fix the code alignment for readability

Quoted 5 lines · Sunil Khatri

Fix the code alignment for if condition and also provide a line space between multiline if condition and next statement.

Quoted 32 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +6 -4
index 48cb2e21ce56..7cdfe3adcbae 100644
@@ -1454,17 +1454,19 @@ int amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device *adev,
 
 	if (!adev->userq_halt_for_enforce_isolation)
 		dev_warn(adev->dev, "userq scheduling already started!\n");
+
 	adev->userq_halt_for_enforce_isolation = false;
+
 	xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
 		uqm = queue->userq_mgr;
 		mutex_lock(&uqm->userq_mutex);
-			if (((queue->queue_type == AMDGPU_HW_IP_GFX) ||
-			     (queue->queue_type == AMDGPU_HW_IP_COMPUTE)) &&
-			    (queue->xcp_id == idx)) {
+		if (((queue->queue_type == AMDGPU_HW_IP_GFX) ||
+		     (queue->queue_type == AMDGPU_HW_IP_COMPUTE)) &&
+		    (queue->xcp_id == idx)) {
 			r = amdgpu_userq_restore_helper(queue);
 			if (r)
 				ret = r;
-			}
+		}
 		mutex_unlock(&uqm->userq_mutex);
 	}