[PATCH 5/9] drm/amdgpu/userq: add suspend and resume helpers

Khatri, Sunil sukhatri at amd.com
Fri Apr 11 16:03:37 UTC 2025


Reviewed-by: Sunil Khatri <sunil.khatri at amd.com>

On 4/11/2025 7:42 PM, Alex Deucher wrote:
> Add helpers to unmap and map user queues on suspend and
> resume.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 39 +++++++++++++++++++
>   drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h |  3 ++
>   2 files changed, 42 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> index 41a095c12f956..f5c2489baae43 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> @@ -681,3 +681,42 @@ void amdgpu_userq_mgr_fini(struct amdgpu_userq_mgr *userq_mgr)
>   	mutex_unlock(&userq_mgr->userq_mutex);
>   	mutex_destroy(&userq_mgr->userq_mutex);
>   }
> +
> +int amdgpu_userq_suspend(struct amdgpu_device *adev)
> +{
> +	const struct amdgpu_userq_funcs *userq_funcs;
> +	struct amdgpu_usermode_queue *queue;
> +	struct amdgpu_userq_mgr *uqm, *tmp;
> +	int queue_id;
> +	int ret = 0;
> +
> +	mutex_lock(&adev->userq_mutex);
> +	list_for_each_entry_safe(uqm, tmp, &adev->userq_mgr_list, list) {
> +		cancel_delayed_work_sync(&uqm->resume_work);
> +		idr_for_each_entry(&uqm->userq_idr, queue, queue_id) {
> +			userq_funcs = adev->userq_funcs[queue->queue_type];
> +			ret |= userq_funcs->unmap(uqm, queue);
> +		}
> +	}
> +	mutex_unlock(&adev->userq_mutex);
> +	return ret;
> +}
> +
> +int amdgpu_userq_resume(struct amdgpu_device *adev)
> +{
> +	const struct amdgpu_userq_funcs *userq_funcs;
> +	struct amdgpu_usermode_queue *queue;
> +	struct amdgpu_userq_mgr *uqm, *tmp;
> +	int queue_id;
> +	int ret = 0;
> +
> +	mutex_lock(&adev->userq_mutex);
> +	list_for_each_entry_safe(uqm, tmp, &adev->userq_mgr_list, list) {
> +		idr_for_each_entry(&uqm->userq_idr, queue, queue_id) {
> +			userq_funcs = adev->userq_funcs[queue->queue_type];
> +			ret |= userq_funcs->map(uqm, queue);
> +		}
> +	}
> +	mutex_unlock(&adev->userq_mutex);
> +	return ret;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
> index a0cf6978f2ba8..381b9c6f0573d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.h
> @@ -111,4 +111,7 @@ uint64_t amdgpu_userqueue_get_doorbell_index(struct amdgpu_userq_mgr *uq_mgr,
>   					     struct amdgpu_db_info *db_info,
>   					     struct drm_file *filp);
>   
> +int amdgpu_userq_suspend(struct amdgpu_device *adev);
> +int amdgpu_userq_resume(struct amdgpu_device *adev);
> +
>   #endif


More information about the amd-gfx mailing list