diff options
author | Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> | 2019-01-29 20:53:22 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2019-02-15 11:15:43 -0500 |
commit | b5bb37eddb63b16b7ab959598d108b1c444be77d (patch) | |
tree | 9d4147f07b1e4ac4a5bf9d5f3b895e519768a452 /drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | |
parent | 021830d24ba55a578f602979274965344c8e6284 (diff) |
drm/amdgpu: Add command to override the context priority.
Given a master fd we can then override the priority of the context
in another fd.
Using these overrides was recommended by Christian instead of trying
to submit from a master fd, and I am adding a way to override a
single context instead of the entire process so we can only upgrade
a single Vulkan queue and not effectively the entire process.
Reused the flags field as it was checked to be 0 anyways, so nothing
used it. This is source-incompatible (due to the name change), but
ABI compatible.
Signed-off-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c')
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c index 0b70410488b6..0767a93e4d91 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c | |||
@@ -76,6 +76,39 @@ static int amdgpu_sched_process_priority_override(struct amdgpu_device *adev, | |||
76 | return 0; | 76 | return 0; |
77 | } | 77 | } |
78 | 78 | ||
79 | static int amdgpu_sched_context_priority_override(struct amdgpu_device *adev, | ||
80 | int fd, | ||
81 | unsigned ctx_id, | ||
82 | enum drm_sched_priority priority) | ||
83 | { | ||
84 | struct file *filp = fget(fd); | ||
85 | struct amdgpu_fpriv *fpriv; | ||
86 | struct amdgpu_ctx *ctx; | ||
87 | int r; | ||
88 | |||
89 | if (!filp) | ||
90 | return -EINVAL; | ||
91 | |||
92 | r = amdgpu_file_to_fpriv(filp, &fpriv); | ||
93 | if (r) { | ||
94 | fput(filp); | ||
95 | return r; | ||
96 | } | ||
97 | |||
98 | ctx = amdgpu_ctx_get(fpriv, ctx_id); | ||
99 | |||
100 | if (!ctx) { | ||
101 | fput(filp); | ||
102 | return -EINVAL; | ||
103 | } | ||
104 | |||
105 | amdgpu_ctx_priority_override(ctx, priority); | ||
106 | amdgpu_ctx_put(ctx); | ||
107 | fput(filp); | ||
108 | |||
109 | return 0; | ||
110 | } | ||
111 | |||
79 | int amdgpu_sched_ioctl(struct drm_device *dev, void *data, | 112 | int amdgpu_sched_ioctl(struct drm_device *dev, void *data, |
80 | struct drm_file *filp) | 113 | struct drm_file *filp) |
81 | { | 114 | { |
@@ -85,7 +118,7 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data, | |||
85 | int r; | 118 | int r; |
86 | 119 | ||
87 | priority = amdgpu_to_sched_priority(args->in.priority); | 120 | priority = amdgpu_to_sched_priority(args->in.priority); |
88 | if (args->in.flags || priority == DRM_SCHED_PRIORITY_INVALID) | 121 | if (priority == DRM_SCHED_PRIORITY_INVALID) |
89 | return -EINVAL; | 122 | return -EINVAL; |
90 | 123 | ||
91 | switch (args->in.op) { | 124 | switch (args->in.op) { |
@@ -94,6 +127,12 @@ int amdgpu_sched_ioctl(struct drm_device *dev, void *data, | |||
94 | args->in.fd, | 127 | args->in.fd, |
95 | priority); | 128 | priority); |
96 | break; | 129 | break; |
130 | case AMDGPU_SCHED_OP_CONTEXT_PRIORITY_OVERRIDE: | ||
131 | r = amdgpu_sched_context_priority_override(adev, | ||
132 | args->in.fd, | ||
133 | args->in.ctx_id, | ||
134 | priority); | ||
135 | break; | ||
97 | default: | 136 | default: |
98 | DRM_ERROR("Invalid sched op specified: %d\n", args->in.op); | 137 | DRM_ERROR("Invalid sched op specified: %d\n", args->in.op); |
99 | r = -EINVAL; | 138 | r = -EINVAL; |