[PATCH 07/13] drm/amdgpu/userq: enable support for queue priorities
Khatri, Sunil
sukhatri at amd.com
Fri Apr 11 17:07:26 UTC 2025
A small comment otherwise it looks great.
Reviewed-by: Sunil Khatri <sunil.khatri at amd.com>
On 4/11/2025 12:23 AM, Alex Deucher wrote:
> Enable users to create queues at different priority levels.
> The highest level is restricted to drm master.
>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c | 26 ++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> index 57a4ef64e0b8b..b8b13b6ab4631 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
> @@ -22,6 +22,7 @@
> *
> */
>
> +#include <drm/drm_auth.h>
> #include <drm/drm_exec.h>
> #include "amdgpu.h"
> #include "amdgpu_vm.h"
> @@ -260,6 +261,21 @@ amdgpu_userqueue_destroy(struct drm_file *filp, int queue_id)
> return r;
> }
>
> +static int amdgpu_userq_priority_permit(struct drm_file *filp,
> + int priority)
> Do we want this value of priority to be unsigned as we only want values >=0.
> +{
> + if (priority < AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_HIGH)
> + return 0;
> +
> + if (capable(CAP_SYS_NICE))
> + return 0;
> +
> + if (drm_is_current_master(filp))
> + return 0;
> +
> + return -EACCES;
> +}
> +
> static int
> amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
> {
> @@ -271,6 +287,9 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
> struct amdgpu_db_info db_info;
> uint64_t index;
> int qid, r = 0;
> + int priority =
> + (args->in.flags & AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK) >>
> + AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_SHIFT;
>
> /* Usermode queues are only supported for GFX IP as of now */
> if (args->in.ip_type != AMDGPU_HW_IP_GFX &&
> @@ -280,6 +299,10 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
> return -EINVAL;
> }
>
> + r = amdgpu_userq_priority_permit(filp, priority);
> + if (r)
> + return r;
> +
> /*
> * There could be a situation that we are creating a new queue while
> * the other queues under this UQ_mgr are suspended. So if there is any
> @@ -305,6 +328,7 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
> queue->doorbell_handle = args->in.doorbell_handle;
> queue->queue_type = args->in.ip_type;
> queue->vm = &fpriv->vm;
> + queue->priority = priority;
>
> db_info.queue_type = queue->queue_type;
> db_info.doorbell_handle = queue->doorbell_handle;
> @@ -377,7 +401,7 @@ int amdgpu_userq_ioctl(struct drm_device *dev, void *data,
>
> switch (args->in.op) {
> case AMDGPU_USERQ_OP_CREATE:
> - if (args->in.flags)
> + if (args->in.flags & ~AMDGPU_USERQ_CREATE_FLAGS_QUEUE_PRIORITY_MASK)
> return -EINVAL;
> r = amdgpu_userqueue_create(filp, args);
> if (r)
More information about the amd-gfx
mailing list