[RFC PATCH 4/4] drm/amd/amdgpu: Check RLIMIT_GPUPRIO in priority permissions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add support for the new RLIMIT_GPUPRIO when doing the priority
checks creating an amdgpu_ctx.

Signed-off-by: Joshua Ashton <joshua@xxxxxxxxx>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index 8ec255091c4a..4ac645455bc1 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -28,6 +28,8 @@
 #include "amdgpu_sched.h"
 #include "amdgpu_ras.h"
 #include <linux/nospec.h>
+#include <linux/sched/signal.h>
+#include <uapi/asm-generic/resource.h>
 
 #define to_amdgpu_ctx_entity(e)	\
 	container_of((e), struct amdgpu_ctx_entity, entity)
@@ -94,11 +96,16 @@ amdgpu_ctx_to_drm_sched_prio(int32_t ctx_prio)
 static int amdgpu_ctx_priority_permit(struct drm_file *filp,
 				      int32_t priority)
 {
+	enum drm_sched_priority in_drm_priority, rlim_drm_priority;
+
 	if (!amdgpu_ctx_priority_is_valid(priority))
 		return -EINVAL;
 
-	/* NORMAL and below are accessible by everyone */
-	if (priority <= AMDGPU_CTX_PRIORITY_NORMAL)
+	/* Check priority against RLIMIT to see what is allowed. */
+	in_drm_priority = amdgpu_ctx_to_drm_sched_prio(priority);
+	rlim_drm_priority = (enum drm_sched_priority)rlimit(RLIMIT_GPUPRIO);
+
+	if (in_drm_priority <= rlim_drm_priority)
 		return 0;
 
 	if (capable(CAP_SYS_NICE))
-- 
2.40.0




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux