Skip to contentSkip to conversation

drm/amdkfd: Failed to check various return code

PATCH In review Andrew Martin 2 participants 3 messages Dec 6, 2024 – Dec 9, 2024

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

PATCH 1/1 drm/amdkfd: Failed to check various return code

Clean up code to quiet the compiler on us failing to check the return code.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c   | 14 +++++++-------
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  3 +++
 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
index 503051352922..de30143ea51b 100644
@@ -368,7 +368,7 @@ void amdgpu_amdkfd_free_gtt_mem(struct amdgpu_device *adev, void **mem_obj)
 {
 	struct amdgpu_bo **bo = (struct amdgpu_bo **) mem_obj;
 
-	amdgpu_bo_reserve(*bo, true);
+	(void)amdgpu_bo_reserve(*bo, true);
 	amdgpu_bo_kunmap(*bo);
 	amdgpu_bo_unpin(*bo);
 	amdgpu_bo_unreserve(*bo);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +7 -7
index f30548f4c3b3..1e998f972c30 100644
@@ -730,7 +730,7 @@ kfd_mem_dmaunmap_userptr(struct kgd_mem *mem,
 		return;
 
 	amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
-	ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+	(void)ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 
 	dma_unmap_sgtable(adev->dev, ttm->sg, direction, 0);
 	sg_free_table(ttm->sg);
@@ -779,7 +779,7 @@ kfd_mem_dmaunmap_sg_bo(struct kgd_mem *mem,
 	}
 
 	amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
-	ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+	(void)ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 
 	dir = mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
 				DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
@@ -989,7 +989,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
 		if (!attachment[i])
 			continue;
 		if (attachment[i]->bo_va) {
-			amdgpu_bo_reserve(bo[i], true);
+			(void)amdgpu_bo_reserve(bo[i], true);
 			if (--attachment[i]->bo_va->ref_count == 0)
 				amdgpu_vm_bo_del(adev, attachment[i]->bo_va);
 			amdgpu_bo_unreserve(bo[i]);
@@ -1259,11 +1259,11 @@ static int unmap_bo_from_gpuvm(struct kgd_mem *mem,
 		return -EBUSY;
 	}
 
-	amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
+	(void)amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
 
-	amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
+	(void)amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
 
-	amdgpu_sync_fence(sync, bo_va->last_pt_update);
+	(void)amdgpu_sync_fence(sync, bo_va->last_pt_update);
 
 	return 0;
 }
@@ -2352,7 +2352,7 @@ void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_mem *mem)
 {
 	struct amdgpu_bo *bo = mem->bo;
 
-	amdgpu_bo_reserve(bo, true);
+	(void)amdgpu_bo_reserve(bo, true);
 	amdgpu_bo_kunmap(bo);
 	amdgpu_bo_unpin(bo);
 	amdgpu_bo_unreserve(bo);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -0
index c79fe9069e22..2f955c76fc56 100644
@@ -2373,6 +2373,9 @@ static int wait_on_destroy_queue(struct device_queue_manager *dqm,
 								q->process);
 	int ret = 0;
 
+	if (WARN_ON(!pdd))
+		return ret;
+
 	if (pdd->qpd.is_debug)
 		return ret;
 
Signature · 1 line
2.43.0
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Minor comment below.

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Andrew Martin
Sent: Friday, December 6, 2024 5:11 PM
To: [email protected]
Cc: Kuehling, Felix <[email protected]>; Tudor, Alexandru <[email protected]>; Martin, Andrew <[email protected]>; Martin, Andrew <[email protected]>
Subject: [PATCH] drm/amdkfd: Failed to check various return code

Clean up code to quiet the compiler on us failing to check the return code.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c   | 14 +++++++-------
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  3 +++
 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
index 503051352922..de30143ea51b 100644
@@ -368,7 +368,7 @@ void amdgpu_amdkfd_free_gtt_mem(struct amdgpu_device *adev, void **mem_obj)
 {
        struct amdgpu_bo **bo = (struct amdgpu_bo **) mem_obj;
 
-       amdgpu_bo_reserve(*bo, true);
+       (void)amdgpu_bo_reserve(*bo, true);
        amdgpu_bo_kunmap(*bo);
        amdgpu_bo_unpin(*bo);
        amdgpu_bo_unreserve(*bo);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +7 -7
index f30548f4c3b3..1e998f972c30 100644
@@ -730,7 +730,7 @@ kfd_mem_dmaunmap_userptr(struct kgd_mem *mem,
                return;
 
        amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
-       ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+       (void)ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 
        dma_unmap_sgtable(adev->dev, ttm->sg, direction, 0);
        sg_free_table(ttm->sg);
@@ -779,7 +779,7 @@ kfd_mem_dmaunmap_sg_bo(struct kgd_mem *mem,
        }
 
        amdgpu_bo_placement_from_domain(bo, AMDGPU_GEM_DOMAIN_CPU);
-       ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+       (void)ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 
        dir = mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
                                DMA_BIDIRECTIONAL : DMA_TO_DEVICE;
@@ -989,7 +989,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct kgd_mem *mem,
                if (!attachment[i])
                        continue;
                if (attachment[i]->bo_va) {
-                       amdgpu_bo_reserve(bo[i], true);
+                       (void)amdgpu_bo_reserve(bo[i], true);
                        if (--attachment[i]->bo_va->ref_count == 0)
                                amdgpu_vm_bo_del(adev, attachment[i]->bo_va);
                        amdgpu_bo_unreserve(bo[i]);
@@ -1259,11 +1259,11 @@ static int unmap_bo_from_gpuvm(struct kgd_mem *mem,
                return -EBUSY;
        }
 
-       amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
+       (void)amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
 
-       amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
+       (void)amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
 
-       amdgpu_sync_fence(sync, bo_va->last_pt_update);
+       (void)amdgpu_sync_fence(sync, bo_va->last_pt_update);
 
        return 0;
 }
@@ -2352,7 +2352,7 @@ void amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_mem *mem)
 {
        struct amdgpu_bo *bo = mem->bo;
 
-       amdgpu_bo_reserve(bo, true);
+       (void)amdgpu_bo_reserve(bo, true);
        amdgpu_bo_kunmap(bo);
        amdgpu_bo_unpin(bo);
        amdgpu_bo_unreserve(bo);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0 -0
index c79fe9069e22..2f955c76fc56 100644
@@ -2373,6 +2373,9 @@ static int wait_on_destroy_queue(struct device_queue_manager *dqm,
                                                                q->process);
        int ret = 0;
 

This should be a separate commit. This doesn't match the above description and falls under drm/amdkfd. The above changes looks fine, just use drm/amdgpu for the commit header.

+ if (WARN_ON(!pdd))
+ return ret;
+

        if (pdd->qpd.is_debug)
                return ret;

--
2.43.0

#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Greetings Harish, sending peace

Thank you for the tutor ledge, acknowledge below!

Quoted 124 lines

-----Original Message-----
From: Kasiviswanathan, Harish <[email protected]>
Sent: Monday, December 9, 2024 1:51 PM
To: Martin, Andrew <[email protected]>; amd- [email protected]
Cc: Kuehling, Felix <[email protected]>; Tudor, Alexandru <[email protected]>; Martin, Andrew <[email protected]>; Martin, Andrew <[email protected]>
Subject: RE: [PATCH] drm/amdkfd: Failed to check various return code

[AMD Official Use Only - AMD Internal Distribution Only]

Minor comment below.

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Andrew Martin
Sent: Friday, December 6, 2024 5:11 PM
To: [email protected]
Cc: Kuehling, Felix <[email protected]>; Tudor, Alexandru <[email protected]>; Martin, Andrew <[email protected]>; Martin, Andrew <[email protected]>
Subject: [PATCH] drm/amdkfd: Failed to check various return code

Clean up code to quiet the compiler on us failing to check the return code.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c         |  2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c   | 14 +++++++----
---
 .../gpu/drm/amd/amdkfd/kfd_device_queue_manager.c  |  3 +++
 3 files changed, 11 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -1
index 503051352922..de30143ea51b 100644
@@ -368,7 +368,7 @@ void amdgpu_amdkfd_free_gtt_mem(struct
 amdgpu_device *adev, void **mem_obj)  {
        struct amdgpu_bo **bo = (struct amdgpu_bo **) mem_obj;
 
-       amdgpu_bo_reserve(*bo, true);
+       (void)amdgpu_bo_reserve(*bo, true);
        amdgpu_bo_kunmap(*bo);
        amdgpu_bo_unpin(*bo);
        amdgpu_bo_unreserve(*bo);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
index f30548f4c3b3..1e998f972c30 100644
@@ -730,7 +730,7 @@ kfd_mem_dmaunmap_userptr(struct kgd_mem
 *mem,
                return;
 
        amdgpu_bo_placement_from_domain(bo,
 AMDGPU_GEM_DOMAIN_CPU);
-       ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+       (void)ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 
        dma_unmap_sgtable(adev->dev, ttm->sg, direction, 0);
        sg_free_table(ttm->sg);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
@@ -779,7 +779,7 @@ kfd_mem_dmaunmap_sg_bo(struct kgd_mem *mem,
        }
 
        amdgpu_bo_placement_from_domain(bo,
 AMDGPU_GEM_DOMAIN_CPU);
-       ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
+       (void)ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
 
        dir = mem->alloc_flags & KFD_IOC_ALLOC_MEM_FLAGS_WRITABLE ?
                                DMA_BIDIRECTIONAL : DMA_TO_DEVICE; @@ -989,7
+989,7 @@ static int kfd_mem_attach(struct amdgpu_device *adev, struct
kgd_mem *mem,
                if (!attachment[i])
                        continue;
                if (attachment[i]->bo_va) {
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
-                       amdgpu_bo_reserve(bo[i], true);
+                       (void)amdgpu_bo_reserve(bo[i], true);
                        if (--attachment[i]->bo_va->ref_count == 0)
                                amdgpu_vm_bo_del(adev, attachment[i]->bo_va);
                        amdgpu_bo_unreserve(bo[i]); @@ -1259,11 +1259,11 @@

static int unmap_bo_from_gpuvm(struct kgd_mem *mem,

                return -EBUSY;
        }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +3 -3
-       amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
+       (void)amdgpu_vm_bo_unmap(adev, bo_va, entry->va);
 
-       amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
+       (void)amdgpu_vm_clear_freed(adev, vm, &bo_va->last_pt_update);
 
-       amdgpu_sync_fence(sync, bo_va->last_pt_update);
+       (void)amdgpu_sync_fence(sync, bo_va->last_pt_update);
 
        return 0;
 }
@@ -2352,7 +2352,7 @@ void

amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel(struct kgd_mem

*mem)  {
        struct amdgpu_bo *bo = mem->bo;
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c +1 -1
-       amdgpu_bo_reserve(bo, true);
+       (void)amdgpu_bo_reserve(bo, true);
        amdgpu_bo_kunmap(bo);
        amdgpu_bo_unpin(bo);
        amdgpu_bo_unreserve(bo);
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0 -0
index c79fe9069e22..2f955c76fc56 100644
@@ -2373,6 +2373,9 @@ static int wait_on_destroy_queue(struct
 device_queue_manager *dqm,
                                                                q->process);
        int ret = 0;
 

This should be a separate commit. This doesn't match the above description and falls under drm/amdkfd.
The above changes looks fine, just use drm/amdgpu for the commit header.

drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +3 -0
+       if (WARN_ON(!pdd))
+               return ret;
+
        if (pdd->qpd.is_debug)
                return ret;

Got it, now it all makes sense.

Quoted 3 lines

--
2.43.0