Skip to content

Commit c1918dd

Browse files
Luben Tuikovgregkh
authored andcommitted
drm/scheduler: Scheduler priority fixes (v2)
[ Upstream commit e2d732f ] Remove DRM_SCHED_PRIORITY_LOW, as it was used in only one place. Rename and separate by a line DRM_SCHED_PRIORITY_MAX to DRM_SCHED_PRIORITY_COUNT as it represents a (total) count of said priorities and it is used as such in loops throughout the code. (0-based indexing is the the count number.) Remove redundant word HIGH in priority names, and rename *KERNEL* to *HIGH*, as it really means that, high. v2: Add back KERNEL and remove SW and HW, in lieu of a single HIGH between NORMAL and KERNEL. Signed-off-by: Luben Tuikov <luben.tuikov@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e2578eb commit c1918dd

8 files changed

Lines changed: 18 additions & 16 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const unsigned int amdgpu_ctx_num_entities[AMDGPU_HW_IP_NUM] = {
4646
static int amdgpu_ctx_priority_permit(struct drm_file *filp,
4747
enum drm_sched_priority priority)
4848
{
49-
if (priority < 0 || priority >= DRM_SCHED_PRIORITY_MAX)
49+
if (priority < 0 || priority >= DRM_SCHED_PRIORITY_COUNT)
5050
return -EINVAL;
5151

5252
/* NORMAL and below are accessible by everyone */
@@ -65,7 +65,7 @@ static int amdgpu_ctx_priority_permit(struct drm_file *filp,
6565
static enum gfx_pipe_priority amdgpu_ctx_sched_prio_to_compute_prio(enum drm_sched_priority prio)
6666
{
6767
switch (prio) {
68-
case DRM_SCHED_PRIORITY_HIGH_HW:
68+
case DRM_SCHED_PRIORITY_HIGH:
6969
case DRM_SCHED_PRIORITY_KERNEL:
7070
return AMDGPU_GFX_PIPE_PRIO_HIGH;
7171
default:

drivers/gpu/drm/amd/amdgpu/amdgpu_job.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void amdgpu_job_stop_all_jobs_on_sched(struct drm_gpu_scheduler *sched)
251251
int i;
252252

253253
/* Signal all jobs not yet scheduled */
254-
for (i = DRM_SCHED_PRIORITY_MAX - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) {
254+
for (i = DRM_SCHED_PRIORITY_COUNT - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) {
255255
struct drm_sched_rq *rq = &sched->sched_rq[i];
256256

257257
if (!rq)

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
267267
&ring->sched;
268268
}
269269

270-
for (i = 0; i < DRM_SCHED_PRIORITY_MAX; ++i)
270+
for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_COUNT; ++i)
271271
atomic_set(&ring->num_jobs[i], 0);
272272

273273
return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct amdgpu_ring {
243243
bool has_compute_vm_bug;
244244
bool no_scheduler;
245245

246-
atomic_t num_jobs[DRM_SCHED_PRIORITY_MAX];
246+
atomic_t num_jobs[DRM_SCHED_PRIORITY_COUNT];
247247
struct mutex priority_mutex;
248248
/* protected by priority_mutex */
249249
int priority;

drivers/gpu/drm/amd/amdgpu/amdgpu_sched.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ enum drm_sched_priority amdgpu_to_sched_priority(int amdgpu_priority)
3636
{
3737
switch (amdgpu_priority) {
3838
case AMDGPU_CTX_PRIORITY_VERY_HIGH:
39-
return DRM_SCHED_PRIORITY_HIGH_HW;
39+
return DRM_SCHED_PRIORITY_HIGH;
4040
case AMDGPU_CTX_PRIORITY_HIGH:
41-
return DRM_SCHED_PRIORITY_HIGH_SW;
41+
return DRM_SCHED_PRIORITY_HIGH;
4242
case AMDGPU_CTX_PRIORITY_NORMAL:
4343
return DRM_SCHED_PRIORITY_NORMAL;
4444
case AMDGPU_CTX_PRIORITY_LOW:
4545
case AMDGPU_CTX_PRIORITY_VERY_LOW:
46-
return DRM_SCHED_PRIORITY_LOW;
46+
return DRM_SCHED_PRIORITY_MIN;
4747
case AMDGPU_CTX_PRIORITY_UNSET:
4848
return DRM_SCHED_PRIORITY_UNSET;
4949
default:

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2101,7 +2101,7 @@ void amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
21012101
ring = adev->mman.buffer_funcs_ring;
21022102
sched = &ring->sched;
21032103
r = drm_sched_entity_init(&adev->mman.entity,
2104-
DRM_SCHED_PRIORITY_KERNEL, &sched,
2104+
DRM_SCHED_PRIORITY_KERNEL, &sched,
21052105
1, NULL);
21062106
if (r) {
21072107
DRM_ERROR("Failed setting up TTM BO move entity (%d)\n",

drivers/gpu/drm/scheduler/sched_main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ drm_sched_select_entity(struct drm_gpu_scheduler *sched)
625625
return NULL;
626626

627627
/* Kernel run queue has higher priority than normal run queue*/
628-
for (i = DRM_SCHED_PRIORITY_MAX - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) {
628+
for (i = DRM_SCHED_PRIORITY_COUNT - 1; i >= DRM_SCHED_PRIORITY_MIN; i--) {
629629
entity = drm_sched_rq_select_entity(&sched->sched_rq[i]);
630630
if (entity)
631631
break;
@@ -852,7 +852,7 @@ int drm_sched_init(struct drm_gpu_scheduler *sched,
852852
sched->name = name;
853853
sched->timeout = timeout;
854854
sched->hang_limit = hang_limit;
855-
for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_MAX; i++)
855+
for (i = DRM_SCHED_PRIORITY_MIN; i < DRM_SCHED_PRIORITY_COUNT; i++)
856856
drm_sched_rq_init(sched, &sched->sched_rq[i]);
857857

858858
init_waitqueue_head(&sched->wake_up_worker);

include/drm/gpu_scheduler.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
struct drm_gpu_scheduler;
3434
struct drm_sched_rq;
3535

36+
/* These are often used as an (initial) index
37+
* to an array, and as such should start at 0.
38+
*/
3639
enum drm_sched_priority {
3740
DRM_SCHED_PRIORITY_MIN,
38-
DRM_SCHED_PRIORITY_LOW = DRM_SCHED_PRIORITY_MIN,
3941
DRM_SCHED_PRIORITY_NORMAL,
40-
DRM_SCHED_PRIORITY_HIGH_SW,
41-
DRM_SCHED_PRIORITY_HIGH_HW,
42+
DRM_SCHED_PRIORITY_HIGH,
4243
DRM_SCHED_PRIORITY_KERNEL,
43-
DRM_SCHED_PRIORITY_MAX,
44+
45+
DRM_SCHED_PRIORITY_COUNT,
4446
DRM_SCHED_PRIORITY_INVALID = -1,
4547
DRM_SCHED_PRIORITY_UNSET = -2
4648
};
@@ -274,7 +276,7 @@ struct drm_gpu_scheduler {
274276
uint32_t hw_submission_limit;
275277
long timeout;
276278
const char *name;
277-
struct drm_sched_rq sched_rq[DRM_SCHED_PRIORITY_MAX];
279+
struct drm_sched_rq sched_rq[DRM_SCHED_PRIORITY_COUNT];
278280
wait_queue_head_t wake_up_worker;
279281
wait_queue_head_t job_scheduled;
280282
atomic_t hw_rq_count;

0 commit comments

Comments
 (0)