drm/amdgpu: validate return value of pm_runtime_get_sync
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: validate return value of pm_runtime_get_sync
An invalid return value 'r' of the pm_runtime_get_sync is r < 0, so fix the return value check and add proper failure log and exit cleanly.
Successful refcount in userqueue creation to make sure device remains in active state.
--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +4 -1
@@ -289,8 +289,11 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, queue->userq_prop = userq_props; r =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (r) +if (r <0 ) { +drm_err (&adev->ddev,"Failed to increment ref count of device pm_runtime\n" ); +pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); goto free_mqd; + } r = mqd_hw_default->init_mqd (adev, (void *)queue->mqd.cpu_ptr, userq_props);if (r) {
Signature · 1 line
2.34.1
Quoted 8 lines · Sunil Khatri
An invalid return value 'r' of the
pm_runtime_get_syncis r < 0, so fix the return value check and add proper failure log and exit cleanly.Successful refcount in userqueue creation to make sure device remains in active state.
Quoted 10 lines
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, · line 293
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +2
-1@@ -289,8 +289,11 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, queue->userq_prop = userq_props; r =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (r) +if (r <0 ) { +drm_err (&adev->ddev,"Failed to increment ref count of device pm_runtime\n" );
I would use dev_err() here for consistency since we don't use the drm_* variants that much. Also update the error message so that it's clear where it's coming from. E.g., "pm_runtime_get_sync() failed when creating userq\n"
With those fixed:
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +2
-1+pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); goto free_mqd; + } r = mqd_hw_default->init_mqd (adev, (void *)queue->mqd.cpu_ptr, userq_props);if (r) { --2.34.1
Khatri, Sunil
Reviewed-by Alex Deucher[AMD Official Use Only - AMD Internal Distribution Only]
Sure Alex. Will do those changes and push the change.
Regards
Sunil Khatri
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, March 5, 2025 1:11 AM
To: Khatri, Sunil <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Subject: Re: [PATCH V2] drm/amdgpu: validate return value of pm_runtime_get_sync
Quoted 8 lines · Sunil Khatri
An invalid return value 'r' of the
pm_runtime_get_syncis r < 0, so fix the return value check and add proper failure log and exit cleanly.Successful refcount in userqueue creation to make sure device remains in active state.
Quoted 11 lines
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, · line 294
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +3
-1@@ -289,8 +289,11 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, queue->userq_prop = userq_props; r =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (r) + if (r < 0) { + drm_err(&adev->ddev, "Failed to increment ref count of + device pm_runtime\n");
I would use dev_err() here for consistency since we don't use the
drm_* variants that much. Also update the error message so that it's clear where it's coming from. E.g., "pm_runtime_get_sync() failed when creating userq\n"
With those fixed:
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +2
-1+pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); goto free_mqd; + } r = mqd_hw_default->init_mqd (adev, (void *)queue->mqd.cpu_ptr, userq_props);if (r) { --2.34.1