Skip to contentSkip to conversation

drm/amdkfd: Ignored various return code

PATCH Superseded Andrew Martin 3 participants 4 messages Nov 13, 2025 – Nov 14, 2025

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 drm/amdkfd: Ignored various return code

The return code of a non void function should not be ignored. In cases where we do not care, the code needs to suppress it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 13 ++++++++-----
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +8 -5
index 644f79f3c9af..e4438fca6283 100644
@@ -313,8 +313,10 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)
 void amdgpu_amdkfd_gpu_reset(struct amdgpu_device *adev)
 {
 	if (amdgpu_device_should_recover_gpu(adev))
-		amdgpu_reset_domain_schedule(adev->reset_domain,
-					     &adev->kfd.reset_work);
+		WARN_ONCE(!amdgpu_reset_domain_schedule(adev->reset_domain,
+							&adev->kfd.reset_work),
+							"Failed to queue work! at %s",
+							 __func__);
 }
 
 int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,
@@ -715,9 +717,10 @@ void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle)
 		if (gfx_block != NULL)
 			gfx_block->version->funcs->set_powergating_state((void *)gfx_block, state);
 	}
-	amdgpu_dpm_switch_power_profile(adev,
-					PP_SMC_POWER_PROFILE_COMPUTE,
-					!idle);
+	WARN_ONCE(!amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_COMPUTE, !idle),
+		  "(%s) failed to disable video power profile mode",
+		  __func__);
+
 }
 
 bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -1
index 22925df6a791..025609a4abcf 100644
@@ -2780,7 +2780,8 @@ static int runtime_enable(struct kfd_process *p, uint64_t r_debug,
 		 * saved in MES.
 		 */
 		if (pdd->dev->kfd->shared_resources.enable_mes)
-			kfd_dbg_set_mes_debug_mode(pdd, !kfd_dbg_has_cwsr_workaround(pdd->dev));
+			(void)kfd_dbg_set_mes_debug_mode(pdd,
+							 !kfd_dbg_has_cwsr_workaround(pdd->dev));
 	}
 
 	p->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_ENABLED;
Signature · 1 line
2.43.0
#1 lore raw
Quoted 14 lines · Andrew Martin

The return code of a non void function should not be ignored. In cases where we do not care, the code needs to suppress it.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 13 ++++++++-----
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |  3 ++-
  2 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
index 644f79f3c9af..e4438fca6283 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev) · line 319

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +4 -2
@@ -313,8 +313,10 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)
  void amdgpu_amdkfd_gpu_reset(struct amdgpu_device *adev)
  {
  	if (amdgpu_device_should_recover_gpu(adev))
-		amdgpu_reset_domain_schedule(adev->reset_domain,
-					     &adev->kfd.reset_work);
+		WARN_ONCE(!amdgpu_reset_domain_schedule(adev->reset_domain,
+							&adev->kfd.reset_work),
+							"Failed to queue work! at %s",
+							 __func__);

amdgpu_reset_domain_schedule only return false if reset_work already exist in the workqueue, it is fine to ignore the return value, don't want WARN_ONCE for this.

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle) · line 722

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -3
  }
 
  int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,
@@ -715,9 +717,10 @@ void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle)
  		if (gfx_block != NULL)
  			gfx_block->version->funcs->set_powergating_state((void *)gfx_block, state);
  	}
-	amdgpu_dpm_switch_power_profile(adev,
-					PP_SMC_POWER_PROFILE_COMPUTE,
-					!idle);
+	WARN_ONCE(!amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_COMPUTE, !idle),
+		  "(%s) failed to disable video power profile mode",
+		  __func__);

amdgpu_dpm_switch_power_profile return false for SRIOV, pp_funcs->switch_power_profile may return false for many cases, like if (!hwmgr || !hwmgr->pm_en), I think we don't need WARN for those cases.

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -0
+
  }
 
  bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
index 22925df6a791..025609a4abcf 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int runtime_enable(struct kfd_process *p, uint64_t r_debug, · line 2784

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -1
@@ -2780,7 +2780,8 @@ static int runtime_enable(struct kfd_process *p, uint64_t r_debug,
  		 * saved in MES.
  		 */
  		if (pdd->dev->kfd->shared_resources.enable_mes)
-			kfd_dbg_set_mes_debug_mode(pdd, !kfd_dbg_has_cwsr_workaround(pdd->dev));
+			(void)kfd_dbg_set_mes_debug_mode(pdd,
+							 !kfd_dbg_has_cwsr_workaround(pdd->dev));

This looks good. It is easier to review if one patch only fix one ignored return code issue.

Regards,

Philip

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
  	}
 
  	p->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_ENABLED;
#2 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Greetings @Yang, Philip

Quoted 1 line

This looks good. It is easier to review if one patch only fix one ignored return code issue.

Thanks for the useful comments. The next patch(es) will remove the WARN_ONCE and the user "(void)" to suppress the unneeded return code. I will also break up the next update into 3 patches (1 for each ignore ).

Quoted 91 lines

-----Original Message-----
From: Yang, Philip <[email protected]>
Sent: Friday, November 14, 2025 1:53 PM
To: Martin, Andrew <[email protected]>; amd- [email protected]
Subject: Re: [PATCH v3] drm/amdkfd: Ignored various return code

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c int amdgpu_amdkfd_post_reset(struct

Quoted 15 lines · Andrew Martin

The return code of a non void function should not be ignored. In cases where we do not care, the code needs to suppress it.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 13 ++++++++-----
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |  3 ++-
  2 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
index 644f79f3c9af..e4438fca6283 100644
@@ -313,8 +313,10 @@ int amdgpu_amdkfd_post_reset(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -2
  void amdgpu_amdkfd_gpu_reset(struct amdgpu_device *adev)
  {
    if (amdgpu_device_should_recover_gpu(adev))
-           amdgpu_reset_domain_schedule(adev->reset_domain,
-                                        &adev->kfd.reset_work);
+           WARN_ONCE(!amdgpu_reset_domain_schedule(adev-
 reset_domain,
+                                                   &adev-
 kfd.reset_work),
+                                                   "Failed to queue work!

at %s",

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c int amdgpu_amdkfd_post_reset(struct · line 321

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -0
+                                                    __func__);

amdgpu_reset_domain_schedule only return false if reset_work already exist in the workqueue, it is fine to ignore the return value, don't want WARN_ONCE for this.

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
  }

int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t
size, @@ -715,9 +717,10 @@ void amdgpu_amdkfd_set_compute_idle(struct

amdgpu_device *adev, bool idle)

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle)

Quoted 8 lines
            if (gfx_block != NULL)
                    gfx_block->version->funcs-
set_powergating_state((void *)gfx_block, state);
    }
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -3
-   amdgpu_dpm_switch_power_profile(adev,
-                                   PP_SMC_POWER_PROFILE_COMPUTE,
-                                   !idle);
+   WARN_ONCE(!amdgpu_dpm_switch_power_profile(adev,

PP_SMC_POWER_PROFILE_COMPUTE, !idle),

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle) · line 722

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -0
+             "(%s) failed to disable video power profile mode",
+             __func__);

amdgpu_dpm_switch_power_profile return false for SRIOV, pp_funcs-

Quoted 1 line

switch_power_profile may return false for many cases, like if (!hwmgr ||

!hwmgr->pm_en), I think we don't need WARN for those cases.

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int runtime_enable(struct kfd_process *p,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -0
+
  }
 
  bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
index 22925df6a791..025609a4abcf 100644
@@ -2780,7 +2780,8 @@ static int runtime_enable(struct kfd_process *p,

uint64_t r_debug,

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int runtime_enable(struct kfd_process *p, uint64_t r_debug,

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -1
             * saved in MES.
             */
            if (pdd->dev->kfd->shared_resources.enable_mes)
-                   kfd_dbg_set_mes_debug_mode(pdd,

!kfd_dbg_has_cwsr_workaround(pdd->dev));

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int runtime_enable(struct kfd_process *p, · line 2784

Quoted 2 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -0
+                   (void)kfd_dbg_set_mes_debug_mode(pdd,
+

!kfd_dbg_has_cwsr_workaround(pdd->dev));

This looks good. It is easier to review if one patch only fix one ignored return code issue.

Regards,

Philip

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
    }
 
    p->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_ENABLED;
maintainer
#3 lore raw
In reply to Andrew Martin
Quoted 14 lines · Andrew Martin

The return code of a non void function should not be ignored. In cases where we do not care, the code needs to suppress it.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 13 ++++++++-----
  drivers/gpu/drm/amd/amdkfd/kfd_chardev.c   |  3 ++-
  2 files changed, 10 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
index 644f79f3c9af..e4438fca6283 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev) · line 319

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +4 -2
@@ -313,8 +313,10 @@ int amdgpu_amdkfd_post_reset(struct amdgpu_device *adev)
  void amdgpu_amdkfd_gpu_reset(struct amdgpu_device *adev)
  {
  	if (amdgpu_device_should_recover_gpu(adev))
-		amdgpu_reset_domain_schedule(adev->reset_domain,
-					     &adev->kfd.reset_work);
+		WARN_ONCE(!amdgpu_reset_domain_schedule(adev->reset_domain,
+							&adev->kfd.reset_work),
+							"Failed to queue work! at %s",
+							 __func__);

The return value is not an error. It only indicates that reset work was already queued.

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle) · line 722

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +3 -3
  }
 
  int amdgpu_amdkfd_alloc_gtt_mem(struct amdgpu_device *adev, size_t size,
@@ -715,9 +717,10 @@ void amdgpu_amdkfd_set_compute_idle(struct amdgpu_device *adev, bool idle)
  		if (gfx_block != NULL)
  			gfx_block->version->funcs->set_powergating_state((void *)gfx_block, state);
  	}
-	amdgpu_dpm_switch_power_profile(adev,
-					PP_SMC_POWER_PROFILE_COMPUTE,
-					!idle);
+	WARN_ONCE(!amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_COMPUTE, !idle),
+		  "(%s) failed to disable video power profile mode",
+		  __func__);

I think 0 means success here. But I agree with Philip that we can probably ignore errors here. I believe some chips just don't support power profiles and return an error here.

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +1 -0
+
  }
 
  bool amdgpu_amdkfd_is_kfd_vmid(struct amdgpu_device *adev, u32 vmid)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
index 22925df6a791..025609a4abcf 100644

drivers/gpu/drm/amd/amdkfd/kfd_chardev.c static int runtime_enable(struct kfd_process *p, uint64_t r_debug, · line 2784

Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -1
@@ -2780,7 +2780,8 @@ static int runtime_enable(struct kfd_process *p, uint64_t r_debug,
  		 * saved in MES.
  		 */
  		if (pdd->dev->kfd->shared_resources.enable_mes)
-			kfd_dbg_set_mes_debug_mode(pdd, !kfd_dbg_has_cwsr_workaround(pdd->dev));
+			(void)kfd_dbg_set_mes_debug_mode(pdd,
+							 !kfd_dbg_has_cwsr_workaround(pdd->dev));

In this case we could actually handle the error and return an error up to the caller.

Regards,
  Felix

Quoted 3 lines
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +0 -0
  	}
 
  	p->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_ENABLED;