drm/amdgpu: add UAPI for user queue query status
Subsystems (3)
PATCH v2 1/4 drm/amdgpu: add UAPI for user queue query status
From: Alex Deucher <[email protected]>
Add an API to query queue status such as whether the queue is hung or whether vram is lost.
Reviewed-by Christian König <[email protected]>
Reviewed-by Sunil Khatri <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
Reviewed-by Prike Liang <[email protected]>
--- include/uapi/drm/amdgpu_drm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/uapi/drm/amdgpu_drm.h +14 -0
@@ -332,6 +332,7 @@ union drm_amdgpu_ctx {/* user queue IOCTL operations */ #define AMDGPU_USERQ_OP_CREATE 1#define AMDGPU_USERQ_OP_FREE 2 +#define AMDGPU_USERQ_OP_QUERY_STATUS 3/* queue priority levels */ /* low < normal low < normal high < high */
@@ -344,6 +345,12 @@ union drm_amdgpu_ctx {/* for queues that need access to protected content */ #define AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE (1 << 2) + +/* the queue is hung */ +#define AMDGPU_USERQ_QUERY_STATUS_FLAGS_HUNG (1 << 0) +/* indicate vram lost since queue was created */ +#define AMDGPU_USERQ_QUERY_STATUS_FLAGS_VRAMLOST (1 << 1) +/* * This structure is a container to pass input configuration * info for all supported userqueue related operations.
@@ -425,9 +432,16 @@ struct drm_amdgpu_userq_out {__u32 _pad; }; +/* The structure to carry output of userqueue ops */ +struct drm_amdgpu_userq_out_query_state { +__u32 flags; +__u32 _pad; +}; +union drm_amdgpu_userq {struct drm_amdgpu_userq_in in;struct drm_amdgpu_userq_out out; +struct drm_amdgpu_userq_out_query_state out_qs; };/* GFX V11 IP specific MQD parameters */
Signature · 1 line
2.34.1
PATCH v2 2/4 drm/amdgpu/userq: implement support for query status
From: Alex Deucher <[email protected]>
Query the status of the user queue, currently whether the queue is hung and whether or not VRAM is lost.
v2: Misc cleanups
Reviewed-by Prike Liang <[email protected]>
Reviewed-by Sunil Khatri <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
Signed-off-by Prike Liang <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +33 -0
@@ -799,6 +799,33 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)return r; } +static int +amdgpu_userq_query_status (struct drm_file *filp,union drm_amdgpu_userq *args) +{ +struct amdgpu_fpriv *fpriv = filp->driver_priv; +struct amdgpu_userq_mgr *uq_mgr = &fpriv->userq_mgr; +struct amdgpu_device *adev = uq_mgr->adev; +struct amdgpu_usermode_queue *queue; +int queue_id = args->in.queue_id; + +mutex_lock (&uq_mgr->userq_mutex); + + queue =amdgpu_userq_find (uq_mgr, queue_id); +if (!queue) { +dev_dbg (adev->dev,"Invalid queue id to query\n" ); +mutex_unlock (&uq_mgr->userq_mutex); +return -EINVAL ; + } + args->out_qs.flags =0 ; +if (queue->state ==AMDGPU_USERQ_STATE_HUNG ) + args->out_qs.flags |=AMDGPU_USERQ_QUERY_STATUS_FLAGS_HUNG ; +if (queue->generation !=amdgpu_vm_generation (adev, &fpriv->vm)) + args->out_qs.flags |=AMDGPU_USERQ_QUERY_STATUS_FLAGS_VRAMLOST ; +mutex_unlock (&uq_mgr->userq_mutex); + +return 0 ; +} +static int amdgpu_userq_input_args_validate (struct drm_device *dev,union drm_amdgpu_userq *args,struct drm_file *filp)
@@ -914,6 +941,12 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,break ; } +case AMDGPU_USERQ_OP_QUERY_STATUS : + r =amdgpu_userq_query_status (filp, args); +if (r) +drm_dbg_driver (dev,"Failed to query usermode queue status\n" ); +break ; +default :drm_dbg_driver (dev,"Invalid user queue op specified: %d\n" , args->in.op);return -EINVAL ;
Signature · 1 line
2.34.1
PATCH v2 3/4 drm/amdgpu: extend UAPI for reporting userq invalid VA
In reply to Prike LiangAdd UAPI new definition for reporting userq invalid virtual address status to user space.
Signed-off-by Prike Liang <[email protected]>
--- include/uapi/drm/amdgpu_drm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/uapi/drm/amdgpu_drm.h +2 -1
@@ -350,7 +350,8 @@ union drm_amdgpu_ctx {#define AMDGPU_USERQ_QUERY_STATUS_FLAGS_HUNG (1 << 0)/* indicate vram lost since queue was created */ #define AMDGPU_USERQ_QUERY_STATUS_FLAGS_VRAMLOST (1 << 1) - +/* the invalid userq VA unmapped */ +#define AMDGPU_USERQ_QUERY_STATUS_FLAGS_INVALID_VA (1 << 2)/* * This structure is a container to pass input configuration * info for all supported userqueue related operations.
Signature · 1 line
2.34.1
PATCH v2 4/4 drm/amdgpu/userq: Add userq invalid VA status report
In reply to Prike LiangReport the userq invalid VA status to the user space.
Signed-off-by Prike Liang <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -0
@@ -821,6 +821,8 @@ amdgpu_userq_query_status(struct drm_file *filp, union drm_amdgpu_userq *args) args->out_qs.flags |=AMDGPU_USERQ_QUERY_STATUS_FLAGS_HUNG ;if (queue->generation !=amdgpu_vm_generation (adev, &fpriv->vm)) args->out_qs.flags |=AMDGPU_USERQ_QUERY_STATUS_FLAGS_VRAMLOST ; +if (queue->state ==AMDGPU_USERQ_STATE_INVALID_VA ) + args->out_qs.flags |=AMDGPU_USERQ_QUERY_STATUS_FLAGS_INVALID_VA ;mutex_unlock (&uq_mgr->userq_mutex);return 0 ;
Signature · 1 line
2.34.1