summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/panthor/panthor_drv.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2024-09-11 09:48:49 +0200
committerThomas Zimmermann <tzimmermann@suse.de>2024-09-11 09:48:49 +0200
commit61b86391fb5d7b9cad35169b1660119754a01134 (patch)
tree56a10e25a0b75ff8dbf983f9894ef36eee9dc4c1 /drivers/gpu/drm/panthor/panthor_drv.c
parentf327bfdbf6c6d7d8e5402795c7c97fb97c2dcf79 (diff)
parentb615b9c36cae0468491547206406a909a9a37f26 (diff)
Merge drm/drm-next into drm-misc-next
Backmerging to get fixes from v6.12-rc7. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Diffstat (limited to 'drivers/gpu/drm/panthor/panthor_drv.c')
-rw-r--r--drivers/gpu/drm/panthor/panthor_drv.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index 444e3bb1cfb5..0caf9e9a8c45 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -14,6 +14,7 @@
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
+#include <drm/drm_auth.h>
#include <drm/drm_debugfs.h>
#include <drm/drm_drv.h>
#include <drm/drm_exec.h>
@@ -1036,6 +1037,24 @@ static int panthor_ioctl_group_destroy(struct drm_device *ddev, void *data,
return panthor_group_destroy(pfile, args->group_handle);
}
+static int group_priority_permit(struct drm_file *file,
+ u8 priority)
+{
+ /* Ensure that priority is valid */
+ if (priority > PANTHOR_GROUP_PRIORITY_HIGH)
+ return -EINVAL;
+
+ /* Medium priority and below are always allowed */
+ if (priority <= PANTHOR_GROUP_PRIORITY_MEDIUM)
+ return 0;
+
+ /* Higher priorities require CAP_SYS_NICE or DRM_MASTER */
+ if (capable(CAP_SYS_NICE) || drm_is_current_master(file))
+ return 0;
+
+ return -EACCES;
+}
+
static int panthor_ioctl_group_create(struct drm_device *ddev, void *data,
struct drm_file *file)
{
@@ -1051,6 +1070,10 @@ static int panthor_ioctl_group_create(struct drm_device *ddev, void *data,
if (ret)
return ret;
+ ret = group_priority_permit(file, args->priority);
+ if (ret)
+ return ret;
+
ret = panthor_group_create(pfile, args, queue_args);
if (ret >= 0) {
args->group_handle = ret;