Skip to content

Commit 037b98a

Browse files
committed
drm/amdgpu: move UVD and VCE sched entity init after sched init
We need kernel scheduling entities to deal with handle clean up if apps are not cleaned up properly. With commit 56e4496 ("drm/sched: Convert the GPU scheduler to variable number of run-queues") the scheduler entities have to be created after scheduler init, so change the ordering to fix this. v2: Leave logic in UVD and VCE code Fixes: 56e4496 ("drm/sched: Convert the GPU scheduler to variable number of run-queues") Reviewed-by: Christian König <[email protected]> Reviewed-by: Luben Tuikov <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent 8ed79c4 commit 037b98a

File tree

13 files changed

+37
-46
lines changed

13 files changed

+37
-46
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2584,6 +2584,18 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev)
25842584
ring->name);
25852585
return r;
25862586
}
2587+
r = amdgpu_uvd_entity_init(adev, ring);
2588+
if (r) {
2589+
DRM_ERROR("Failed to create UVD scheduling entity on ring %s.\n",
2590+
ring->name);
2591+
return r;
2592+
}
2593+
r = amdgpu_vce_entity_init(adev, ring);
2594+
if (r) {
2595+
DRM_ERROR("Failed to create VCE scheduling entity on ring %s.\n",
2596+
ring->name);
2597+
return r;
2598+
}
25872599
}
25882600

25892601
amdgpu_xcp_update_partition_sched_list(adev);

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -399,20 +399,20 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)
399399
*
400400
* @adev: amdgpu_device pointer
401401
*
402+
* Initialize the entity used for handle management in the kernel driver.
402403
*/
403-
int amdgpu_uvd_entity_init(struct amdgpu_device *adev)
404+
int amdgpu_uvd_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring)
404405
{
405-
struct amdgpu_ring *ring;
406-
struct drm_gpu_scheduler *sched;
407-
int r;
406+
if (ring == &adev->uvd.inst[0].ring) {
407+
struct drm_gpu_scheduler *sched = &ring->sched;
408+
int r;
408409

409-
ring = &adev->uvd.inst[0].ring;
410-
sched = &ring->sched;
411-
r = drm_sched_entity_init(&adev->uvd.entity, DRM_SCHED_PRIORITY_NORMAL,
412-
&sched, 1, NULL);
413-
if (r) {
414-
DRM_ERROR("Failed setting up UVD kernel entity.\n");
415-
return r;
410+
r = drm_sched_entity_init(&adev->uvd.entity, DRM_SCHED_PRIORITY_NORMAL,
411+
&sched, 1, NULL);
412+
if (r) {
413+
DRM_ERROR("Failed setting up UVD kernel entity.\n");
414+
return r;
415+
}
416416
}
417417

418418
return 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct amdgpu_uvd {
7373

7474
int amdgpu_uvd_sw_init(struct amdgpu_device *adev);
7575
int amdgpu_uvd_sw_fini(struct amdgpu_device *adev);
76-
int amdgpu_uvd_entity_init(struct amdgpu_device *adev);
76+
int amdgpu_uvd_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring);
7777
int amdgpu_uvd_prepare_suspend(struct amdgpu_device *adev);
7878
int amdgpu_uvd_suspend(struct amdgpu_device *adev);
7979
int amdgpu_uvd_resume(struct amdgpu_device *adev);

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,20 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev)
231231
*
232232
* @adev: amdgpu_device pointer
233233
*
234+
* Initialize the entity used for handle management in the kernel driver.
234235
*/
235-
int amdgpu_vce_entity_init(struct amdgpu_device *adev)
236+
int amdgpu_vce_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring)
236237
{
237-
struct amdgpu_ring *ring;
238-
struct drm_gpu_scheduler *sched;
239-
int r;
240-
241-
ring = &adev->vce.ring[0];
242-
sched = &ring->sched;
243-
r = drm_sched_entity_init(&adev->vce.entity, DRM_SCHED_PRIORITY_NORMAL,
244-
&sched, 1, NULL);
245-
if (r != 0) {
246-
DRM_ERROR("Failed setting up VCE run queue.\n");
247-
return r;
238+
if (ring == &adev->vce.ring[0]) {
239+
struct drm_gpu_scheduler *sched = &ring->sched;
240+
int r;
241+
242+
r = drm_sched_entity_init(&adev->vce.entity, DRM_SCHED_PRIORITY_NORMAL,
243+
&sched, 1, NULL);
244+
if (r != 0) {
245+
DRM_ERROR("Failed setting up VCE run queue.\n");
246+
return r;
247+
}
248248
}
249249

250250
return 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ struct amdgpu_vce {
5555

5656
int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size);
5757
int amdgpu_vce_sw_fini(struct amdgpu_device *adev);
58-
int amdgpu_vce_entity_init(struct amdgpu_device *adev);
58+
int amdgpu_vce_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring);
5959
int amdgpu_vce_suspend(struct amdgpu_device *adev);
6060
int amdgpu_vce_resume(struct amdgpu_device *adev);
6161
void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ static int uvd_v3_1_sw_init(void *handle)
577577
ptr += ucode_len;
578578
memcpy(&adev->uvd.keyselect, ptr, 4);
579579

580-
r = amdgpu_uvd_entity_init(adev);
581-
582580
return r;
583581
}
584582

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ static int uvd_v4_2_sw_init(void *handle)
127127
if (r)
128128
return r;
129129

130-
r = amdgpu_uvd_entity_init(adev);
131-
132130
return r;
133131
}
134132

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ static int uvd_v5_0_sw_init(void *handle)
125125
if (r)
126126
return r;
127127

128-
r = amdgpu_uvd_entity_init(adev);
129-
130128
return r;
131129
}
132130

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ static int uvd_v6_0_sw_init(void *handle)
432432
}
433433
}
434434

435-
r = amdgpu_uvd_entity_init(adev);
436-
437435
return r;
438436
}
439437

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,6 @@ static int uvd_v7_0_sw_init(void *handle)
480480
if (r)
481481
return r;
482482

483-
r = amdgpu_uvd_entity_init(adev);
484-
if (r)
485-
return r;
486-
487483
r = amdgpu_virt_alloc_mm_table(adev);
488484
if (r)
489485
return r;

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,6 @@ static int vce_v2_0_sw_init(void *handle)
441441
return r;
442442
}
443443

444-
r = amdgpu_vce_entity_init(adev);
445-
446444
return r;
447445
}
448446

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,6 @@ static int vce_v3_0_sw_init(void *handle)
450450
return r;
451451
}
452452

453-
r = amdgpu_vce_entity_init(adev);
454-
455453
return r;
456454
}
457455

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,11 +486,6 @@ static int vce_v4_0_sw_init(void *handle)
486486
return r;
487487
}
488488

489-
490-
r = amdgpu_vce_entity_init(adev);
491-
if (r)
492-
return r;
493-
494489
r = amdgpu_virt_alloc_mm_table(adev);
495490
if (r)
496491
return r;

0 commit comments

Comments
 (0)