Properly Check for return values from calls to debug functions in
runtime_disable().

v2: storing the last non zero returned value from the loop.

Signed-off-by: Sunday Clement <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 0f0719528bcc..22925df6a791 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -2826,7 +2826,7 @@ static int runtime_enable(struct kfd_process *p, uint64_t 
r_debug,
 
 static int runtime_disable(struct kfd_process *p)
 {
-       int i = 0, ret;
+       int i = 0, ret = 0;
        bool was_enabled = p->runtime_info.runtime_state == 
DEBUG_RUNTIME_STATE_ENABLED;
 
        p->runtime_info.runtime_state = DEBUG_RUNTIME_STATE_DISABLED;
@@ -2863,6 +2863,7 @@ static int runtime_disable(struct kfd_process *p)
        /* disable ttmp setup */
        for (i = 0; i < p->n_pdds; i++) {
                struct kfd_process_device *pdd = p->pdds[i];
+               int last_err = 0;
 
                if (kfd_dbg_is_per_vmid_supported(pdd->dev)) {
                        pdd->spi_dbg_override =
@@ -2872,14 +2873,17 @@ static int runtime_disable(struct kfd_process *p)
                                        pdd->dev->vm_info.last_vmid_kfd);
 
                        if (!pdd->dev->kfd->shared_resources.enable_mes)
-                               debug_refresh_runlist(pdd->dev->dqm);
+                               last_err = debug_refresh_runlist(pdd->dev->dqm);
                        else
-                               kfd_dbg_set_mes_debug_mode(pdd,
+                               last_err = kfd_dbg_set_mes_debug_mode(pdd,
                                                           
!kfd_dbg_has_cwsr_workaround(pdd->dev));
+
+                       if (last_err)
+                               ret = last_err;
                }
        }
 
-       return 0;
+       return ret;
 }
 
 static int kfd_ioctl_runtime_enable(struct file *filep, struct kfd_process *p, 
void *data)
-- 
2.43.0

Reply via email to