aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
diff options
context:
space:
mode:
authorAlex Deucher <[email protected]>2025-02-27 03:56:26 +0000
committerAlex Deucher <[email protected]>2025-04-21 14:56:46 +0000
commita5c34299d866f099c85567117717c18842e67da8 (patch)
treefd48f2b03ed6212020bc171aecf00a4c7bfea362 /drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
parentdrm/amdgpu/userq/mes: handle user queue priority (diff)
downloadkernel-a5c34299d866f099c85567117717c18842e67da8.tar.gz
kernel-a5c34299d866f099c85567117717c18842e67da8.zip
drm/amdgpu/userq: enable support for queue priorities
Enable users to create queues at different priority levels. The highest level is restricted to drm master. Reviewed-by: Sunil Khatri <[email protected]> Reviewed-by: Jesse.Zhang <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userqueue.c
index 9a7ac85ff01c..149993ec537b 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 <linux/pm_runtime.h>
@@ -266,6 +267,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)
+{
+ 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)
{
@@ -278,6 +294,9 @@ amdgpu_userqueue_create(struct drm_file *filp, union drm_amdgpu_userq *args)
bool skip_map_queue;
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 &&
@@ -287,6 +306,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;
+
r = pm_runtime_get_sync(adev_to_drm(adev)->dev);
if (r < 0) {
dev_err(adev->dev, "pm_runtime_get_sync() failed for userqueue create\n");
@@ -319,6 +342,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;
@@ -399,7 +423,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)