@@ -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))
Add support for the new RLIMIT_GPUPRIO when doing the priority checks creating an amdgpu_ctx. Signed-off-by: Joshua Ashton <joshua@froggi.es> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)