drm/amdgpu: add UAPI for user queue query status
Subsystems (3)
PATCH 1/9 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.
--- include/uapi/drm/amdgpu_drm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/uapi/drm/amdgpu_drm.h +14 -0
@@ -334,6 +334,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 */
@@ -346,6 +347,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.
@@ -427,9 +434,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 2/9 drm/amdgpu/userq: implement support for query status
Query the status of the user queue, currently whether the queue is hung and whether or not VRAM is lost.
v2: Misc cleanups
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 35 ++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 1 + 2 files changed, 35 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +34 -1
@@ -472,6 +472,7 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) queue->queue_type = args->in.ip_type; queue->vm = &fpriv->vm; queue->priority = priority; + queue->generation =amdgpu_vm_generation (adev, &fpriv->vm); db_info.queue_type = queue->queue_type; db_info.doorbell_handle = queue->doorbell_handle;
@@ -553,6 +554,34 @@ 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)
@@ -633,7 +662,11 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,if (r)drm_file_err (filp,"Failed to destroy usermode queue\n" );break ; - +case AMDGPU_USERQ_OP_QUERY_STATUS : + r =amdgpu_userq_query_status (filp, args); +if (r) +drm_file_err (filp,"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 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +1 -0
@@ -66,6 +66,7 @@ struct amdgpu_usermode_queue {u32 xcp_id;int priority;struct dentry *debugfs_queue; +uint64_t generation; };struct amdgpu_userq_funcs {
Signature · 1 line
2.34.1
RE: [PATCH 2/9] drm/amdgpu/userq: implement support for query status
[Public]
Maybe we need a PTE schedule check in the amdgpu_vm_generation() for the userq only case. This could be a sperate patch for handling that, for this patch is
Regards,
Prike
Quoted 102 lines
-----Original Message-----
From: Liang, Prike <[email protected]>
Sent: Wednesday, September 10, 2025 7:37 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Liang, Prike <[email protected]>; Khatri, Sunil <[email protected]>; Deucher, Alexander <[email protected]>
Subject: [PATCH 2/9] drm/amdgpu/userq: implement support for query statusQuery the status of the user queue, currently whether the queue is hung and whether or not VRAM is lost.
v2: Misc cleanups
Reviewed-by Sunil Khatri <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 35 ++++++++++++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 1 + 2 files changed, 35 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-0@@ -472,6 +472,7 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) queue->queue_type = args->in.ip_type; queue->vm = &fpriv->vm; queue->priority = priority; + queue->generation =amdgpu_vm_generation (adev, &fpriv->vm); db_info.queue_type = queue->queue_type;db_info.doorbell_handle = queue->doorbell_handle; @@ -553,6 +554,34 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) return r;}
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +20
-0+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;drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-0+if (queue->generation !=amdgpu_vm_generation (adev, &fpriv->vm)) + args->out_qs.flags |=
AMDGPU_USERQ_QUERY_STATUS_FLAGS_VRAMLOST;drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +11
-1+ +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)@@ -633,7 +662,11 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data, if (r)drm_file_err (filp,"Failed to destroy usermode queue\n" );break ; - +case AMDGPU_USERQ_OP_QUERY_STATUS : + r =amdgpu_userq_query_status (filp, args); +if (r) +drm_file_err (filp,"Failed to query usermode queue status\n" ); +break ;default : drm_dbg_driver(dev, "Invalid user queue op specified: %d\n", args-Quoted 1 line
in.op);
return -EINVAL;drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +1
-1@@ -66,6 +66,7 @@ struct amdgpu_usermode_queue {u32 xcp_id;int priority;struct dentry *debugfs_queue; +uint64_t generation; };struct amdgpu_userq_funcs { --2.34.1
PATCH 3/9 drm/amdgpu/userq: extend queue flags for user queue query status
In reply to Prike LiangAdd the userq flag to identify the invalid userq cases.
--- include/uapi/drm/amdgpu_drm.h | 2 ++ 1 file changed, 2 insertions(+)
include/uapi/drm/amdgpu_drm.h +2 -0
@@ -352,6 +352,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
Signature · 1 line
2.34.1
PATCH 4/9 drm/amdgpu/userq: extend userq state
In reply to Prike LiangExtend the userq state for identifying the
userq invalid cases.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 1 + 2 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2 -0
@@ -576,6 +576,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);
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +1 -0
@@ -37,6 +37,7 @@ enum amdgpu_userq_state {AMDGPU_USERQ_STATE_MAPPED ,AMDGPU_USERQ_STATE_PREEMPTED ,AMDGPU_USERQ_STATE_HUNG , + AMDGPU_USERQ_STATE_INVALID_VA, };struct amdgpu_mqd_prop ;
Signature · 1 line
2.34.1
PATCH 5/9 drm/amdgpu: add userq object va track helpers
In reply to Prike LiangAdd the userq object virtual address get(),mapped() and put() helpers for tracking the userq obj va address usage.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 66 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 9 ++- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 13 ++--- 4 files changed, 75 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1 -0
@@ -96,6 +96,7 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it */ unsigned int queue_refcount; +atomic_t userq_va_mapped; };struct amdgpu_bo {
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +61 -5
96 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +7 -2
@@ -53,6 +53,7 @@ struct amdgpu_usermode_queue {enum amdgpu_userq_state state;uint64_t doorbell_handle;uint64_t doorbell_index; +uint64_t flags;struct amdgpu_mqd_prop *userq_prop;struct amdgpu_userq_mgr *userq_mgr;
@@ -138,7 +139,11 @@ int amdgpu_userq_stop_sched_for_enforce_isolation(struct amdgpu_device *adev, u32 idx);int amdgpu_userq_start_sched_for_enforce_isolation (struct amdgpu_device *adev,u32 idx); - -int amdgpu_userq_input_va_validate (struct amdgpu_vm *vm,u64 addr, +int amdgpu_userq_input_va_validate (struct amdgpu_usermode_queue *queue, +struct amdgpu_vm *vm,u64 addr,u64 expected_size); +int amdgpu_userq_buffer_va_get (struct amdgpu_usermode_queue *queue, +struct amdgpu_bo_va_mapping *va_map,u64 addr); +bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr); +int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue,u64 addr);#endif
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +6 -7
@@ -298,8 +298,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, goto free_mqd; } -if (amdgpu_userq_input_va_validate (queue->vm, compute_mqd->eop_va, -max_t (u32,PAGE_SIZE ,AMDGPU_GPU_PAGE_SIZE ))) +if (amdgpu_userq_input_va_validate (queue, queue->vm, compute_mqd->eop_va, +max_t (u32,PAGE_SIZE ,AMDGPU_GPU_PAGE_SIZE ))) goto free_mqd; userq_props->eop_gpu_addr = compute_mqd->eop_va;
@@ -330,8 +330,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, userq_props->tmz_queue = mqd_user->flags &AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE ; -if (amdgpu_userq_input_va_validate (queue->vm, mqd_gfx_v11->shadow_va, - shadow_info.shadow_size)) +if (amdgpu_userq_input_va_validate (queue, queue->vm, mqd_gfx_v11->shadow_va, + shadow_info.shadow_size)) goto free_mqd;kfree (mqd_gfx_v11);
@@ -350,9 +350,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, r = -ENOMEM ; goto free_mqd; } - -if (amdgpu_userq_input_va_validate (queue->vm, mqd_sdma_v11->csa_va, - shadow_info.csa_size)) +if (amdgpu_userq_input_va_validate (queue, queue->vm, mqd_sdma_v11->csa_va, + shadow_info.csa_size)) goto free_mqd; userq_props->csa_addr = mqd_sdma_v11->csa_va;
Signature · 1 line
2.34.1
Re: [PATCH 5/9] drm/amdgpu: add userq object va track helpers
Quoted 29 lines · Prike Liang
Add the userq object virtual address get(),mapped() and
put()helpers for tracking the userq obj va address usage.Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 66 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 9 ++- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 13 ++--- 4 files changed, 75 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-0@@ -96,6 +96,7 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it */ unsigned int queue_refcount; +atomic_t userq_va_mapped; };struct amdgpu_bo {drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev) · line 47
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -44,7 +44,8 @@ u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev)return userq_ip_mask; } -int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr, +int amdgpu_userq_input_va_validate(struct amdgpu_usermode_queue *queue,
I don't think we need the queue here as a parameter.
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-0+ struct amdgpu_vm *vm, u64 addr, u64 expected_size) { struct amdgpu_bo_va_mapping *va_map;@@ -67,6 +68,7 @@ int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr,/* Only validate the userq whether resident in the VM mapping range */ if (user_addr >= va_map->start && va_map->last - user_addr +1 >= size) { +amdgpu_userq_buffer_va_get (queue, va_map, user_addr);amdgpu_bo_unreserve (vm->root.bo);return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr, · line 81
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-0@@ -76,6 +78,61 @@ int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr,return r; } +int amdgpu_userq_buffer_va_get(struct amdgpu_usermode_queue *queue,
struct amdgpu_vm *vm makes more sense then queue here.
Quoted 20 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +20
-0+ struct amdgpu_bo_va_mapping *va_map, u64 addr) +{ +atomic_set (&va_map->bo_va->userq_va_mapped,1 ); +return 0 ; + +} + +bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr) +{ +struct amdgpu_bo_va_mapping *mapping; +u64 user_addr; +bool r; + + user_addr = (addr &AMDGPU_GMC_HOLE_MASK ) >>AMDGPU_GPU_PAGE_SHIFT ; + +if (amdgpu_bo_reserve (vm->root.bo, false)) +return false; + + mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); +if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va->userq_va_mapped))
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr, · line 111
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +10
-0+ r = true; + else + r = false; +amdgpu_bo_unreserve (vm->root.bo); + +return r; +} + +int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue, +u64 addr)
struct amdgpu_vm *vm makes more sense then queue here.
Alex
Quoted 115 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +27
-4+{ +struct amdgpu_bo_va_mapping *mapping; +struct amdgpu_vm *vm = queue->vm; +u64 user_addr; +int r; + + user_addr = (addr &AMDGPU_GMC_HOLE_MASK ) >>AMDGPU_GPU_PAGE_SHIFT ; + r =amdgpu_bo_reserve (vm->root.bo, false); +if (r) +return r; + + mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); +if (!mapping) + goto out_err; + +atomic_set (&mapping->bo_va->userq_va_mapped,0 ); +amdgpu_bo_unreserve (vm->root.bo); +return 0 ; + +out_err: +amdgpu_bo_unreserve (vm->root.bo); +return -EINVAL ; +} +static int amdgpu_userq_unmap_helper (struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_usermode_queue *queue)@@ -462,9 +519,9 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) }/* Validate the userq virtual address.*/ -if (amdgpu_userq_input_va_validate (&fpriv->vm, args->in.queue_va, args->in.queue_size) || -amdgpu_userq_input_va_validate (&fpriv->vm, args->in.rptr_va,AMDGPU_GPU_PAGE_SIZE ) || -amdgpu_userq_input_va_validate (&fpriv->vm, args->in.wptr_va,AMDGPU_GPU_PAGE_SIZE )) { +if (amdgpu_userq_input_va_validate (queue, &fpriv->vm, args->in.queue_va, args->in.queue_size) || +amdgpu_userq_input_va_validate (queue, &fpriv->vm, args->in.rptr_va,AMDGPU_GPU_PAGE_SIZE ) || +amdgpu_userq_input_va_validate (queue, &fpriv->vm, args->in.wptr_va,AMDGPU_GPU_PAGE_SIZE )) {kfree (queue); goto unlock; }@@ -504,7 +561,6 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) goto unlock; } - qid =idr_alloc (&uq_mgr->userq_idr, queue,1 ,AMDGPU_MAX_USERQ_COUNT ,GFP_KERNEL );if (qid <0 ) {drm_file_err (uq_mgr->file,"Failed to allocate a queue id\n" );drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +7
-2@@ -53,6 +53,7 @@ struct amdgpu_usermode_queue {enum amdgpu_userq_state state;uint64_t doorbell_handle;uint64_t doorbell_index; +uint64_t flags;struct amdgpu_mqd_prop *userq_prop;struct amdgpu_userq_mgr *userq_mgr;@@ -138,7 +139,11 @@ int amdgpu_userq_stop_sched_for_enforce_isolation(struct amdgpu_device *adev, u32 idx);int amdgpu_userq_start_sched_for_enforce_isolation (struct amdgpu_device *adev,u32 idx); - -int amdgpu_userq_input_va_validate (struct amdgpu_vm *vm,u64 addr, +int amdgpu_userq_input_va_validate (struct amdgpu_usermode_queue *queue, +struct amdgpu_vm *vm,u64 addr,u64 expected_size); +int amdgpu_userq_buffer_va_get (struct amdgpu_usermode_queue *queue, +struct amdgpu_bo_va_mapping *va_map,u64 addr); +bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr); +int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue,u64 addr);#endif drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +6
-8@@ -298,8 +298,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, goto free_mqd; } -if (amdgpu_userq_input_va_validate (queue->vm, compute_mqd->eop_va, -max_t (u32,PAGE_SIZE ,AMDGPU_GPU_PAGE_SIZE ))) +if (amdgpu_userq_input_va_validate (queue, queue->vm, compute_mqd->eop_va, +max_t (u32,PAGE_SIZE ,AMDGPU_GPU_PAGE_SIZE ))) goto free_mqd; userq_props->eop_gpu_addr = compute_mqd->eop_va;@@ -330,8 +330,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, userq_props->tmz_queue = mqd_user->flags &AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE ; -if (amdgpu_userq_input_va_validate (queue->vm, mqd_gfx_v11->shadow_va, - shadow_info.shadow_size)) +if (amdgpu_userq_input_va_validate (queue, queue->vm, mqd_gfx_v11->shadow_va, + shadow_info.shadow_size)) goto free_mqd;kfree (mqd_gfx_v11);@@ -350,9 +350,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr, r = -ENOMEM ; goto free_mqd; } - -if (amdgpu_userq_input_va_validate (queue->vm, mqd_sdma_v11->csa_va, - shadow_info.csa_size)) +if (amdgpu_userq_input_va_validate (queue, queue->vm, mqd_sdma_v11->csa_va, + shadow_info.csa_size)) goto free_mqd; userq_props->csa_addr = mqd_sdma_v11->csa_va; --2.34.1
RE: [PATCH 5/9] drm/amdgpu: add userq object va track helpers
[Public]
Regards,
Prike
Quoted 43 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: Friday, September 12, 2025 3:02 AM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>
Subject: Re: [PATCH 5/9] drm/amdgpu: add userq object va track helpersQuoted 18 lines · Prike Liang
Add the userq object virtual address get(),mapped() and
put()helpers for tracking the userq obj va address usage.Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_object.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 66 ++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 9 ++- drivers/gpu/drm/amd/amdgpu/mes_userqueue.c | 13 ++--- 4 files changed, 75 insertions(+), 14 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +0
-0drivers/gpu/drm/amd/amdgpu/amdgpu_object.h struct amdgpu_bo_va { · line 96
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +0
-0@@ -96,6 +96,7 @@ struct amdgpu_bo_va {* if non-zero, cannot unmap from GPU because user queues may still access it
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c u32 amdgpu_userq_get_supported_ip_mask(struct
Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h +1
-0*/ unsigned int queue_refcount; +atomic_t userq_va_mapped; };struct amdgpu_bo {drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0@@ -44,7 +44,8 @@ u32 amdgpu_userq_get_supported_ip_mask(struct
amdgpu_device*adev)
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c u32 amdgpu_userq_get_supported_ip_mask(struct amdgpu_device *adev)
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-1return userq_ip_mask; } -int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr, +int amdgpu_userq_input_va_validate(struct amdgpu_usermode_queue +*queue,I don't think we need the queue here as a parameter.
Yeah, at here the queue is not used but that will be passed to the *_va_get() for update the userq VA list. Maybe here needs to put the later userq VA list update implementation here.
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_input_va_validate(struct amdgpu_vm
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-0+ struct amdgpu_vm *vm, u64 addr, u64 expected_size) { struct amdgpu_bo_va_mapping *va_map; @@ -67,6 +68,7 @@ intamdgpu_userq_input_va_validate(struct
amdgpu_vm*vm, u64 addr,/* Only validate the userq whether resident in the VM mapping range */ if (user_addr >= va_map->start && va_map->last - user_addr + 1 >= size) {drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-0+amdgpu_userq_buffer_va_get (queue, va_map, user_addr);amdgpu_bo_unreserve (vm->root.bo);return 0 ; }@@ -76,6 +78,61 @@ int amdgpu_userq_input_va_validate(struct amdgpu_vm*vm, u64 addr,
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr, · line 81
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-0return r; } +int amdgpu_userq_buffer_va_get(struct amdgpu_usermode_queue *queue,struct
amdgpu_vm*vm makes more sense then queue here.
[Prike] We need the userq input for updating the userq VA list later.
Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +24
-0+struct amdgpu_bo_va_mapping *va_map, +u64 addr) { + atomic_set(&va_map->bo_va->userq_va_mapped, 1); +return 0 ; + +} + +bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr) { +struct amdgpu_bo_va_mapping *mapping; +u64 user_addr; +bool r; + + user_addr = (addr &AMDGPU_GMC_HOLE_MASK ) >> +AMDGPU_GPU_PAGE_SHIFT ; + +if (amdgpu_bo_reserve (vm->root.bo, false)) +return false; + + mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); +if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va- userq_va_mapped)) + r = true; +else + r = false; +amdgpu_bo_unreserve (vm->root.bo);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr, · line 111
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +6
-0+ +return r; +} + +int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue, +u64 addr)struct
amdgpu_vm*vm makes more sense then queue here.
Yes, I will update the input parameter accordingly.
Thanks,
Prike
Quoted 141 lines
Alex
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c int amdgpu_userq_input_va_validate(struct amdgpu_vm *vm, u64 addr,
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +7
-0+{ +struct amdgpu_bo_va_mapping *mapping; +struct amdgpu_vm *vm = queue->vm; +u64 user_addr; +int r; + + user_addr = (addr & AMDGPU_GMC_HOLE_MASK) >>
AMDGPU_GPU_PAGE_SHIFT;Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +17
-0+ r =amdgpu_bo_reserve (vm->root.bo, false); +if (r) +return r; + + mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); +if (!mapping) + goto out_err; + +atomic_set (&mapping->bo_va->userq_va_mapped,0 ); +amdgpu_bo_unreserve (vm->root.bo); +return 0 ; + +out_err: +amdgpu_bo_unreserve (vm->root.bo); +return -EINVAL ; +} + static int amdgpu_userq_unmap_helper(struct amdgpu_userq_mgr *uq_mgr,Quoted 2 lines
struct
amdgpu_usermode_queue*queue) @@
-462,9 +519,9 @@ amdgpu_userq_create(structdrm_file*filp, union
drm_amdgpu_userq*args)Quoted 6 lines
} /* Validate the userq virtual address.*/- if (amdgpu_userq_input_va_validate(&fpriv->vm,
args->in.queue_va, args-
in.queue_size) ||
- amdgpu_userq_input_va_validate(&fpriv->vm,args->in.rptr_va,
AMDGPU_GPU_PAGE_SIZE) ||Quoted 1 line
- amdgpu_userq_input_va_validate(&fpriv->vm,
args->in.wptr_va,
AMDGPU_GPU_PAGE_SIZE)) {Quoted 1 line
+ if (amdgpu_userq_input_va_validate(queue,
&fpriv->vm,args->in.queue_va,
args->in.queue_size) ||Quoted 1 line
+ amdgpu_userq_input_va_validate(queue,
&fpriv->vm,args->in.rptr_va,
AMDGPU_GPU_PAGE_SIZE) ||drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-0+ amdgpu_userq_input_va_validate(queue, &fpriv->vm, + args->in.wptr_va, AMDGPU_GPU_PAGE_SIZE)) {kfree (queue); goto unlock; }@@ -504,7 +561,6 @@ amdgpu_userq_create(struct drm_file *filp, union
drm_amdgpu_userq*args)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args)
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-1goto unlock; } - qid = idr_alloc(&uq_mgr->userq_idr, queue, 1,
AMDGPU_MAX_USERQ_COUNT,GFP_KERNEL);drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct
Quoted 36 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +0
-0if (qid <0 ) { drm_file_err(uq_mgr->file, "Failed to allocate a queueid\n"); diff --git
a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.hb/drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h
index33a582200dda..6044afeeb741100644drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +1
-0@@ -53,6 +53,7 @@ struct amdgpu_usermode_queue {enum amdgpu_userq_state state;uint64_t doorbell_handle;uint64_t doorbell_index; +uint64_t flags;struct amdgpu_mqd_prop *userq_prop; struct amdgpu_userq_mgr *userq_mgr; @@ -138,7 +139,11 @@ intamdgpu_userq_stop_sched_for_enforce_isolation(struct
amdgpu_device*adev,u32 idx); int amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device *adev, u32 idx);drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +7
-2- -int amdgpu_userq_input_va_validate (struct amdgpu_vm *vm,u64 addr, +int amdgpu_userq_input_va_validate (struct amdgpu_usermode_queue *queue, +struct amdgpu_vm *vm,u64 addr,u64 expected_size); +int amdgpu_userq_buffer_va_get (struct amdgpu_usermode_queue *queue, +struct amdgpu_bo_va_mapping *va_map, +u64 addr);bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm, +u64 addr);int amdgpu_userq_buffer_va_put (struct +amdgpu_usermode_queue *queue,u64 addr);#endif drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +0
-0@@ -298,8 +298,8 @@ static int mes_userq_mqd_create(struct
amdgpu_userq_mgr*uq_mgr,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-2goto free_mqd; } -if (amdgpu_userq_input_va_validate (queue->vm, compute_mqd- eop_va, -max_t (u32,PAGE_SIZE ,AMDGPU_GPU_PAGE_SIZE ))) + if (amdgpu_userq_input_va_validate(queue, queue->vm,
compute_mqd->eop_va,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +2
-1+ max_t(u32, PAGE_SIZE, + AMDGPU_GPU_PAGE_SIZE))) goto free_mqd; userq_props->eop_gpu_addr = compute_mqd->eop_va; @@ -330,8 +330,8 @@ static int mes_userq_mqd_create(struct amdgpu_userq_mgr
*uq_mgr,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct
Quoted 14 lines
userq_props->tmz_queue = mqd_user->flags &
AMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE;- if (amdgpu_userq_input_va_validate(queue->vm, mqd_gfx_v11-
shadow_va,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-1- shadow_info.shadow_size)) + if (amdgpu_userq_input_va_validate(queue, queue->vm, mqd_gfx_v11-
shadow_va,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-0+ shadow_info.shadow_size)) goto free_mqd;kfree (mqd_gfx_v11);@@ -350,9 +350,8 @@ static int mes_userq_mqd_create(struct
amdgpu_userq_mgr*uq_mgr,drivers/gpu/drm/amd/amdgpu/mes_userqueue.c static int mes_userq_mqd_create(struct amdgpu_userq_mgr *uq_mgr,
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-3r = -ENOMEM ; goto free_mqd; } - -if (amdgpu_userq_input_va_validate (queue->vm, mqd_sdma_v11- csa_va, - shadow_info.csa_size)) + if (amdgpu_userq_input_va_validate(queue, queue->vm,
mqd_sdma_v11->csa_va,Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_userqueue.c +1
-0+ shadow_info.csa_size)) goto free_mqd;userq_props->csa_addr = mqd_sdma_v11->csa_va;--
2.34.1
PATCH 6/9 drm/amdgpu: track the userq bo va for its obj management
In reply to Prike LiangTrack the userq obj for its life time, and reference and dereference the buffer counter at its creating and destroying period.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 38 +++++++++++++++++++++-- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 11 +++++++ 2 files changed, 46 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +35 -3
@@ -81,7 +81,19 @@ int amdgpu_userq_input_va_validate(struct amdgpu_usermode_queue *queue,int amdgpu_userq_buffer_va_get (struct amdgpu_usermode_queue *queue,struct amdgpu_bo_va_mapping *va_map,u64 addr) { +struct amdgpu_userq_va_cursor *va_cursor; +struct userq_va_list ; + + va_cursor =kzalloc (sizeof (*va_cursor),GFP_KERNEL ); +if (!va_cursor) +return -ENOMEM ; + +INIT_LIST_HEAD (&va_cursor->list); + va_cursor->gpu_addr = addr; +atomic_set (&va_map->bo_va->userq_va_mapped,1 ); +list_add (&va_cursor->list, &queue->userq_va_list); +return 0 ; }
@@ -112,15 +124,13 @@ int amdgpu_userq_buffer_va_put(struct amdgpu_usermode_queue *queue, {struct amdgpu_bo_va_mapping *mapping;struct amdgpu_vm *vm = queue->vm; -u64 user_addr;int r; - user_addr = (addr &AMDGPU_GMC_HOLE_MASK ) >>AMDGPU_GPU_PAGE_SHIFT ; r =amdgpu_bo_reserve (vm->root.bo, false);if (r)return r; - mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); + mapping =amdgpu_vm_bo_lookup_mapping (vm, addr);if (!mapping) goto out_err;
@@ -133,6 +143,23 @@ int amdgpu_userq_buffer_va_put(struct amdgpu_usermode_queue *queue,return -EINVAL ; } +int amdgpu_userq_buffer_vas_put (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +struct amdgpu_usermode_queue *queue) +{ +struct amdgpu_userq_va_cursor *va_cursor, *tmp; +int r; + +list_for_each_entry_safe (va_cursor, tmp, &queue->userq_va_list, list) { + r +=amdgpu_userq_buffer_va_put (queue, va_cursor->gpu_addr); +dev_dbg (adev->dev,"put the userq:%p va:%llx r:%d\n" , + queue, va_cursor->gpu_addr, r); +list_del (&va_cursor->list); +kfree (va_cursor); + } +return r; +} +static int amdgpu_userq_unmap_helper (struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_usermode_queue *queue)
@@ -195,9 +222,12 @@ amdgpu_userq_cleanup(struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_device *adev = uq_mgr->adev;const struct amdgpu_userq_funcs *uq_funcs = adev->userq_funcs[queue->queue_type]; +/* Drop the userq reference. */ +amdgpu_userq_buffer_vas_put (adev, queue->vm, queue); uq_funcs->mqd_destroy (uq_mgr, queue);amdgpu_userq_fence_driver_free (queue);idr_remove (&uq_mgr->userq_idr, queue_id); +list_del (&queue->userq_va_list);kfree (queue); }
@@ -518,6 +548,8 @@ amdgpu_userq_create(struct drm_file *filp, union drm_amdgpu_userq *args) goto unlock; } +INIT_LIST_HEAD (&queue->userq_va_list); +/* Validate the userq virtual address.*/ if (amdgpu_userq_input_va_validate(queue, &fpriv->vm, args->in.queue_va, args->in.queue_size) || amdgpu_userq_input_va_validate(queue, &fpriv->vm, args->in.rptr_va, AMDGPU_GPU_PAGE_SIZE ) ||
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +11 -0
@@ -48,6 +48,12 @@ struct amdgpu_userq_obj {struct amdgpu_bo *obj; }; +struct amdgpu_userq_va_cursor { +uint64_t gpu_addr; +struct list_head list; + +}; +struct amdgpu_usermode_queue {int queue_type;enum amdgpu_userq_state state;
@@ -69,6 +75,8 @@ struct amdgpu_usermode_queue {int priority;struct dentry *debugfs_queue;uint64_t generation; + +struct list_head userq_va_list; };struct amdgpu_userq_funcs {
@@ -146,4 +154,7 @@ int amdgpu_userq_buffer_va_get(struct amdgpu_usermode_queue *queue, struct amdgpu_bo_va_mapping *va_map, u64 addr);bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr);int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue,u64 addr); +int amdgpu_userq_buffer_vas_put (struct amdgpu_device *adev, +struct amdgpu_vm *vm, +struct amdgpu_usermode_queue *queue);#endif
Signature · 1 line
2.34.1
PATCH 7/9 drm/amdgpu: keeping waiting userq fence infinitely
In reply to Prike LiangKeeping waiting the userq fence infinitely untill hang detection, and then suspend the hang queue and set the fence error.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +8 -3
@@ -199,7 +199,7 @@ amdgpu_userq_map_helper(struct amdgpu_userq_mgr *uq_mgr,return r; } -static void +static int amdgpu_userq_wait_for_last_fence (struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_usermode_queue *queue) {
@@ -207,11 +207,16 @@ amdgpu_userq_wait_for_last_fence(struct amdgpu_userq_mgr *uq_mgr,int ret;if (f && !dma_fence_is_signaled (f)) { - ret =dma_fence_wait_timeout (f, true,msecs_to_jiffies (100 )); -if (ret <=0 ) + ret =dma_fence_wait_timeout (f, true,MAX_SCHEDULE_TIMEOUT ); +if (ret <=0 ) {drm_file_err (uq_mgr->file,"Timed out waiting for fence=%llu:%llu\n" , f->context, f->seqno); + queue->state =AMDGPU_USERQ_STATE_HUNG ; +return -ETIME ; + } } + +return ret; } static void
Signature · 1 line
2.34.1
Re: [PATCH 7/9] drm/amdgpu: keeping waiting userq fence infinitely
Quoted 24 lines · Prike Liang
Keeping waiting the userq fence infinitely untill hang detection, and then suspend the hang queue and set the fence error.
Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-1@@ -199,7 +199,7 @@ amdgpu_userq_map_helper(struct amdgpu_userq_mgr *uq_mgr,return r; } -static void +static int amdgpu_userq_wait_for_last_fence (struct amdgpu_userq_mgr *uq_mgr,struct amdgpu_usermode_queue *queue) {
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c amdgpu_userq_wait_for_last_fence(struct amdgpu_userq_mgr *uq_mgr, · line 214
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +3
-2@@ -207,11 +207,16 @@ amdgpu_userq_wait_for_last_fence(struct amdgpu_userq_mgr *uq_mgr,int ret;if (f && !dma_fence_is_signaled (f)) { - ret =dma_fence_wait_timeout (f, true,msecs_to_jiffies (100 )); -if (ret <=0 ) + ret =dma_fence_wait_timeout (f, true,MAX_SCHEDULE_TIMEOUT ); +if (ret <=0 ) {drm_file_err (uq_mgr->file,"Timed out waiting for fence=%llu:%llu\n" , f->context, f->seqno); + queue->state =AMDGPU_USERQ_STATE_HUNG ;
I don't think we want to set the queue state to hung here. Just return an error. We'll detect the hang when we attempt to preempt the queues and run detect_and_reset().
Alex
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +4
-1+return -ETIME ; + } } + +return ret; } static void --2.34.1
PATCH 8/9 drm/amdgpu: validate the queue va for resuming the queue
In reply to Prike LiangIt requires validating the userq VA whether is mapped before trying to resume the queue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 31 ++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +27 -4
@@ -101,15 +101,12 @@ int amdgpu_userq_buffer_va_get(struct amdgpu_usermode_queue *queue,bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr) {struct amdgpu_bo_va_mapping *mapping; -u64 user_addr;bool r; - user_addr = (addr &AMDGPU_GMC_HOLE_MASK ) >>AMDGPU_GPU_PAGE_SHIFT ; -if (amdgpu_bo_reserve (vm->root.bo, false))return false; - mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); + mapping =amdgpu_vm_bo_lookup_mapping (vm, addr);if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va->userq_va_mapped)) r = true;else
@@ -119,6 +116,24 @@ bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)return r; } +bool amdgpu_userq_buffer_vas_mapped (struct amdgpu_vm *vm, +struct amdgpu_usermode_queue *queue) +{ +struct amdgpu_userq_va_cursor *va_cursor, *tmp; +int r; + +list_for_each_entry_safe (va_cursor, tmp, &queue->userq_va_list, list) { + r +=amdgpu_userq_buffer_va_mapped (vm, va_cursor->gpu_addr); +dev_dbg (queue->userq_mgr->adev->dev,"validate the userq mapping: %p va:%llx r:%d\n" , + queue, va_cursor->gpu_addr, r); + } + +if (r !=0 ) +return true; + +return false; +} +int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue,u64 addr) {
@@ -774,11 +789,19 @@ static int amdgpu_userq_restore_all(struct amdgpu_userq_mgr *uq_mgr) {struct amdgpu_usermode_queue *queue; +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (uq_mgr);int queue_id;int ret =0 , r;/* Resume all the queues for this process */ idr_for_each_entry (&uq_mgr->userq_idr, queue, queue_id) { + +if (!amdgpu_userq_buffer_vas_mapped (&fpriv->vm, queue)) { +drm_file_err (uq_mgr->file,"trying restore queue without va mappping\n" ); + queue->state =AMDGPU_USERQ_STATE_INVALID_VA ; +continue ; + } + r =amdgpu_userq_map_helper (uq_mgr, queue);if (r) ret = r;
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +2 -0
@@ -157,4 +157,6 @@ int amdgpu_userq_buffer_va_put(struct amdgpu_usermode_queue *queue, u64 addr);int amdgpu_userq_buffer_vas_put (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_usermode_queue *queue); +bool amdgpu_userq_buffer_vas_mapped (struct amdgpu_vm *vm, +struct amdgpu_usermode_queue *queue);#endif
Signature · 1 line
2.34.1
Re: [PATCH 8/9] drm/amdgpu: validate the queue va for resuming the queue
Quoted 33 lines · Prike Liang
It requires validating the userq VA whether is mapped before trying to resume the queue.
Signed-off-by Prike Liang <[email protected]>Reviewed-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 31 ++++++++++++++++++++--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +1
-4@@ -101,15 +101,12 @@ int amdgpu_userq_buffer_va_get(struct amdgpu_usermode_queue *queue,bool amdgpu_userq_buffer_va_mapped (struct amdgpu_vm *vm,u64 addr) {struct amdgpu_bo_va_mapping *mapping; -u64 user_addr;bool r; - user_addr = (addr &AMDGPU_GMC_HOLE_MASK ) >>AMDGPU_GPU_PAGE_SHIFT ; -if (amdgpu_bo_reserve (vm->root.bo, false))return false; - mapping =amdgpu_vm_bo_lookup_mapping (vm, user_addr); + mapping =amdgpu_vm_bo_lookup_mapping (vm, addr);if (!IS_ERR_OR_NULL (mapping) &&atomic_read (&mapping->bo_va->userq_va_mapped)) r = true;else
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr) · line 120
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +2
-0@@ -119,6 +116,24 @@ bool amdgpu_userq_buffer_va_mapped(struct amdgpu_vm *vm, u64 addr)return r; } +bool amdgpu_userq_buffer_vas_mapped (struct amdgpu_vm *vm, +struct amdgpu_usermode_queue *queue)
All you need is the queue here. you can get to the vm from queue->vm. Other than that, it looks reasonable to me.
Alex
Alex
Quoted 53 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +24
-0+{ +struct amdgpu_userq_va_cursor *va_cursor, *tmp; +int r; + +list_for_each_entry_safe (va_cursor, tmp, &queue->userq_va_list, list) { + r +=amdgpu_userq_buffer_va_mapped (vm, va_cursor->gpu_addr); +dev_dbg (queue->userq_mgr->adev->dev,"validate the userq mapping: %p va:%llx r:%d\n" , + queue, va_cursor->gpu_addr, r); + } + +if (r !=0 ) +return true; + +return false; +} +int amdgpu_userq_buffer_va_put (struct amdgpu_usermode_queue *queue,u64 addr) {@@ -774,11 +789,19 @@ static int amdgpu_userq_restore_all(struct amdgpu_userq_mgr *uq_mgr) {struct amdgpu_usermode_queue *queue; +struct amdgpu_fpriv *fpriv =uq_mgr_to_fpriv (uq_mgr);int queue_id;int ret =0 , r;/* Resume all the queues for this process */ idr_for_each_entry (&uq_mgr->userq_idr, queue, queue_id) { + +if (!amdgpu_userq_buffer_vas_mapped (&fpriv->vm, queue)) { +drm_file_err (uq_mgr->file,"trying restore queue without va mappping\n" ); + queue->state =AMDGPU_USERQ_STATE_INVALID_VA ; +continue ; + } + r =amdgpu_userq_map_helper (uq_mgr, queue);if (r) ret = r;drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +2
-1@@ -157,4 +157,6 @@ int amdgpu_userq_buffer_va_put(struct amdgpu_usermode_queue *queue, u64 addr);int amdgpu_userq_buffer_vas_put (struct amdgpu_device *adev,struct amdgpu_vm *vm,struct amdgpu_usermode_queue *queue); +bool amdgpu_userq_buffer_vas_mapped (struct amdgpu_vm *vm, +struct amdgpu_usermode_queue *queue);#endif --2.34.1
PATCH 9/9 drm/amdgpu: validate userq va for GEM unmap
In reply to Prike LiangWhen a user unmaps a userq VA, the driver must ensure the queue has no in-flight jobs. If there is pending work, the kernel should wait for the attached eviction (bookkeeping) fence to signal before deleting the mapping.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 29 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 +++++++++ 3 files changed, 43 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +29 -0
@@ -1188,3 +1188,32 @@ int amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device *adev,mutex_unlock (&adev->userq_mutex);return ret; } + +int amdgpu_userq_gem_va_unmap_validate (struct amdgpu_device *adev, +struct amdgpu_bo_va_mapping *mapping, +uint64_t saddr) +{ +u32 ip_mask =amdgpu_userq_get_supported_ip_mask (adev); +struct amdgpu_bo_va *bo_va = mapping->bo_va; +struct dma_resv *resv = bo_va->base.bo->tbo.base.resv; +int ret; + +if (!ip_mask) +return 0 ; + +dev_warn (adev->dev,"now unmapping a vital queue va:%llx\n" , saddr); +/** +* The userq VA mapping reservation should include the eviction fence, if the eviction fence +* can't signal successfully during unmapping, then driver will warn to flag this improper unmap +* of the userq VA. +* Note: The eviction fence may be attached to different BOs, and this unmap is only for one kind +* of userq VAs, so at this point suppose the eviction fence is always unsignaled. +*/ +if (!dma_resv_test_signaled (resv,DMA_RESV_USAGE_BOOKKEEP )) { + ret =dma_resv_wait_timeout (resv,DMA_RESV_USAGE_BOOKKEEP , true,MAX_SCHEDULE_TIMEOUT ); +if (ret <=0 ) +return -EBUSY ; + } + +return 0 ; +}
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +3 -0
@@ -159,4 +159,7 @@ int amdgpu_userq_buffer_vas_put(struct amdgpu_device *adev, struct amdgpu_usermode_queue *queue);bool amdgpu_userq_buffer_vas_mapped (struct amdgpu_vm *vm,struct amdgpu_usermode_queue *queue); +int amdgpu_userq_gem_va_unmap_validate (struct amdgpu_device *adev, +struct amdgpu_bo_va_mapping *mapping, +uint64_t saddr);#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +11 -0
@@ -1941,6 +1941,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,struct amdgpu_bo_va_mapping *mapping;struct amdgpu_vm *vm = bo_va->base.vm;bool valid = true; +int r; saddr /=AMDGPU_GPU_PAGE_SIZE ;
@@ -1961,6 +1962,16 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,return -ENOENT ; } +/* It's unlikely to happen that the mapping userq hasn't been idled +* during user requests GEM unmap IOCTL except for forcing the unmap +* from user space. +*/ +if (unlikely (atomic_read (&bo_va->userq_va_mapped) >0 )) { + r =amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr); +if (unlikely (r == -EBUSY )) +dev_warn (adev->dev,"Here should be an improper unmap request from user space\n" ); + } +list_del (&mapping->list);amdgpu_vm_it_remove (mapping, &vm->va); mapping->bo_va =NULL ;
Signature · 1 line
2.34.1
Re: [PATCH 9/9] drm/amdgpu: validate userq va for GEM unmap
Quoted 6 lines · Prike Liang
When a user unmaps a userq VA, the driver must ensure the queue has no in-flight jobs. If there is pending work, the kernel should wait for the attached eviction (bookkeeping) fence to signal before deleting the mapping.
Seems reasonable to me, but it would be good to get Christian's input here as well.
Alex
Quoted 89 lines
Suggested-by Christian König <[email protected]>Signed-off-by Prike Liang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c | 29 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h | 3 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 +++++++++ 3 files changed, 43 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c +29
-0@@ -1188,3 +1188,32 @@ int amdgpu_userq_start_sched_for_enforce_isolation(struct amdgpu_device *adev,mutex_unlock (&adev->userq_mutex);return ret; } + +int amdgpu_userq_gem_va_unmap_validate (struct amdgpu_device *adev, +struct amdgpu_bo_va_mapping *mapping, +uint64_t saddr) +{ +u32 ip_mask =amdgpu_userq_get_supported_ip_mask (adev); +struct amdgpu_bo_va *bo_va = mapping->bo_va; +struct dma_resv *resv = bo_va->base.bo->tbo.base.resv; +int ret; + +if (!ip_mask) +return 0 ; + +dev_warn (adev->dev,"now unmapping a vital queue va:%llx\n" , saddr); +/** +* The userq VA mapping reservation should include the eviction fence, if the eviction fence +* can't signal successfully during unmapping, then driver will warn to flag this improper unmap +* of the userq VA. +* Note: The eviction fence may be attached to different BOs, and this unmap is only for one kind +* of userq VAs, so at this point suppose the eviction fence is always unsignaled. +*/ +if (!dma_resv_test_signaled (resv,DMA_RESV_USAGE_BOOKKEEP )) { + ret =dma_resv_wait_timeout (resv,DMA_RESV_USAGE_BOOKKEEP , true,MAX_SCHEDULE_TIMEOUT ); +if (ret <=0 ) +return -EBUSY ; + } + +return 0 ; +}drivers/gpu/drm/amd/amdgpu/amdgpu_userq.h +3
-0@@ -159,4 +159,7 @@ int amdgpu_userq_buffer_vas_put(struct amdgpu_device *adev, struct amdgpu_usermode_queue *queue);bool amdgpu_userq_buffer_vas_mapped (struct amdgpu_vm *vm,struct amdgpu_usermode_queue *queue); +int amdgpu_userq_gem_va_unmap_validate (struct amdgpu_device *adev, +struct amdgpu_bo_va_mapping *mapping, +uint64_t saddr);#endif drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +11
-1@@ -1941,6 +1941,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,struct amdgpu_bo_va_mapping *mapping;struct amdgpu_vm *vm = bo_va->base.vm;bool valid = true; +int r; saddr /=AMDGPU_GPU_PAGE_SIZE ;@@ -1961,6 +1962,16 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device *adev,return -ENOENT ; } +/* It's unlikely to happen that the mapping userq hasn't been idled +* during user requests GEM unmap IOCTL except for forcing the unmap +* from user space. +*/ +if (unlikely (atomic_read (&bo_va->userq_va_mapped) >0 )) { + r =amdgpu_userq_gem_va_unmap_validate (adev, mapping, saddr); +if (unlikely (r == -EBUSY )) +dev_warn (adev->dev,"Here should be an improper unmap request from user space\n" ); + } +list_del (&mapping->list);amdgpu_vm_it_remove (mapping, &vm->va); mapping->bo_va =NULL ; --2.34.1
[Public]
Regards,
Prike
Quoted 66 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Prike Liang
Sent: Wednesday, September 10, 2025 7:37 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>
Subject: [PATCH 1/9] drm/amdgpu: add UAPI for user queue query statusFrom: 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]>--- include/uapi/drm/amdgpu_drm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)include/uapi/drm/amdgpu_drm.h index renamed from include/uapi/drm/amdgpu_drm.h +0
-0
85b3ca14f81e..7292f7bfcd13100644include/uapi/drm/amdgpu_drm.h +1
-0@@ -334,6 +334,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 */ @@ -346,6 +347,12 @@ union
drm_amdgpu_ctx{
/* for queues that need access to protected content */ #defineAMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE(1 << 2)include/uapi/drm/amdgpu_drm.h +13
-1+ +/* 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. @@ -427,9 +434,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 */ --2.34.1
Quoted 6 lines · Prike Liang
From: Alex Deucher <[email protected]>
Add an API to query queue status such as whether the queue is hung or whether vram is lost.
We need mesa code before we can land this new interface.
Alex
Quoted 52 lines
Reviewed-by Christian König <[email protected]>Reviewed-by Sunil Khatri <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- include/uapi/drm/amdgpu_drm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)include/uapi/drm/amdgpu_drm.h +14
-1@@ -334,6 +334,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 */ @@ -346,6 +347,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. @@ -427,9 +434,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 */ --2.34.1
[Public]
Regards,
Prike
Quoted 11 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, September 12, 2025 2:55 AM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>
Subject: Re: [PATCH 1/9] drm/amdgpu: add UAPI for user queue query statusQuoted 1 line · Prike Liang
Quoted 7 lines
Quoted 5 lines
From: Alex Deucher <[email protected]>
Add an API to query queue status such as whether the queue is hung or whether vram is lost.
We need mesa code before we can land this new interface.
Do we have a plan for upstreaming the mesa counterpart code?
Or can we update the userq structure in the drm header first if we need to upstream the following metadata solution?
Quoted 55 lines
Alex
Quoted 53 lines
Reviewed-by Christian König <[email protected]>Reviewed-by Sunil Khatri <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- include/uapi/drm/amdgpu_drm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex85b3ca14f81e..7292f7bfcd13100644include/uapi/drm/amdgpu_drm.h +1
-0@@ -334,6 +334,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 */ @@ -346,6 +347,12 @@union
drm_amdgpu_ctx{
/* for queues that need access to protected content */ #defineAMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE(1 << 2)include/uapi/drm/amdgpu_drm.h +13
-1+ +/* 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. @@ -427,9 +434,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 */ --2.34.1
Quoted 19 lines · Prike
[Public]
Regards,
PrikeQuoted 13 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, September 12, 2025 2:55 AM
To: Liang, Prike <[email protected]>
Cc: [email protected]; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Khatri, Sunil <[email protected]>
Subject: Re: [PATCH 1/9] drm/amdgpu: add UAPI for user queue query statusQuoted 3 lines · Prike Liang
From: Alex Deucher <[email protected]>
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Add an API to query queue status such as whether the queue is hung or whether vram is lost.
We need mesa code before we can land this new interface.
Do we have a plan for upstreaming the mesa counterpart code?
Or can we update the userq structure in the drm header first if we need to upstream the following metadata solution?
We need to write the mesa code first so we can test the whole thing end to end.
Alex
Quoted 56 lines
Quoted 56 lines
Alex
Quoted 53 lines
Reviewed-by Christian König <[email protected]>Reviewed-by Sunil Khatri <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- include/uapi/drm/amdgpu_drm.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)(quoted diff) +0
-0
b/include/uapi/drm/amdgpu_drm.hindex85b3ca14f81e..7292f7bfcd13100644include/uapi/drm/amdgpu_drm.h +1
-0@@ -334,6 +334,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 */ @@ -346,6 +347,12 @@union
drm_amdgpu_ctx{
/* for queues that need access to protected content */ #defineAMDGPU_USERQ_CREATE_FLAGS_QUEUE_SECURE(1 << 2)include/uapi/drm/amdgpu_drm.h +13
-1+ +/* 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. @@ -427,9 +434,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 */ --2.34.1