]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/amdgpu: move UVD and VCE sched entity init after sched init
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 8 Nov 2023 14:40:44 +0000 (09:40 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 10 Nov 2023 16:33:08 +0000 (11:33 -0500)
We need kernel scheduling entities to deal with handle clean up
if apps are not cleaned up properly.  With commit 56e449603f0ac5
("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: 56e449603f0a ("drm/sched: Convert the GPU scheduler to variable number of run-queues")
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Luben Tuikov <ltuikov89@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: ltuikov89@gmail.com
13 files changed:
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.h
drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
drivers/gpu/drm/amd/amdgpu/uvd_v4_2.c
drivers/gpu/drm/amd/amdgpu/uvd_v5_0.c
drivers/gpu/drm/amd/amdgpu/uvd_v6_0.c
drivers/gpu/drm/amd/amdgpu/uvd_v7_0.c
drivers/gpu/drm/amd/amdgpu/vce_v2_0.c
drivers/gpu/drm/amd/amdgpu/vce_v3_0.c
drivers/gpu/drm/amd/amdgpu/vce_v4_0.c

index e8a26852eb32c84cea2fdedd7ad2cb9a4863d654..7eeaf0aa7f8121fc59dcd30e48a00dc9750d5e5f 100644 (file)
@@ -2584,6 +2584,18 @@ static int amdgpu_device_init_schedulers(struct amdgpu_device *adev)
                                  ring->name);
                        return r;
                }
+               r = amdgpu_uvd_entity_init(adev, ring);
+               if (r) {
+                       DRM_ERROR("Failed to create UVD scheduling entity on ring %s.\n",
+                                 ring->name);
+                       return r;
+               }
+               r = amdgpu_vce_entity_init(adev, ring);
+               if (r) {
+                       DRM_ERROR("Failed to create VCE scheduling entity on ring %s.\n",
+                                 ring->name);
+                       return r;
+               }
        }
 
        amdgpu_xcp_update_partition_sched_list(adev);
index 815b7c34ed33c0e6c4d52ffdace24641b5da083d..65949cc7abb93243aea94860cf87eef2327e849a 100644 (file)
@@ -399,20 +399,20 @@ int amdgpu_uvd_sw_fini(struct amdgpu_device *adev)
  *
  * @adev: amdgpu_device pointer
  *
+ * Initialize the entity used for handle management in the kernel driver.
  */
-int amdgpu_uvd_entity_init(struct amdgpu_device *adev)
+int amdgpu_uvd_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring)
 {
-       struct amdgpu_ring *ring;
-       struct drm_gpu_scheduler *sched;
-       int r;
+       if (ring == &adev->uvd.inst[0].ring) {
+               struct drm_gpu_scheduler *sched = &ring->sched;
+               int r;
 
-       ring = &adev->uvd.inst[0].ring;
-       sched = &ring->sched;
-       r = drm_sched_entity_init(&adev->uvd.entity, DRM_SCHED_PRIORITY_NORMAL,
-                                 &sched, 1, NULL);
-       if (r) {
-               DRM_ERROR("Failed setting up UVD kernel entity.\n");
-               return r;
+               r = drm_sched_entity_init(&adev->uvd.entity, DRM_SCHED_PRIORITY_NORMAL,
+                                         &sched, 1, NULL);
+               if (r) {
+                       DRM_ERROR("Failed setting up UVD kernel entity.\n");
+                       return r;
+               }
        }
 
        return 0;
index a9f342537c6834e8dea2af8566073690b2ab7bb6..9dfad2f48ef40cac6be41a35698a28dbf1e96875 100644 (file)
@@ -73,7 +73,7 @@ struct amdgpu_uvd {
 
 int amdgpu_uvd_sw_init(struct amdgpu_device *adev);
 int amdgpu_uvd_sw_fini(struct amdgpu_device *adev);
-int amdgpu_uvd_entity_init(struct amdgpu_device *adev);
+int amdgpu_uvd_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring);
 int amdgpu_uvd_prepare_suspend(struct amdgpu_device *adev);
 int amdgpu_uvd_suspend(struct amdgpu_device *adev);
 int amdgpu_uvd_resume(struct amdgpu_device *adev);
index 1904edf684071675cf5f10e6c354ba69d20f7afe..0954447f689d9e5477c67a1bf71fb9f53cde063b 100644 (file)
@@ -231,20 +231,20 @@ int amdgpu_vce_sw_fini(struct amdgpu_device *adev)
  *
  * @adev: amdgpu_device pointer
  *
+ * Initialize the entity used for handle management in the kernel driver.
  */
-int amdgpu_vce_entity_init(struct amdgpu_device *adev)
+int amdgpu_vce_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring)
 {
-       struct amdgpu_ring *ring;
-       struct drm_gpu_scheduler *sched;
-       int r;
-
-       ring = &adev->vce.ring[0];
-       sched = &ring->sched;
-       r = drm_sched_entity_init(&adev->vce.entity, DRM_SCHED_PRIORITY_NORMAL,
-                                 &sched, 1, NULL);
-       if (r != 0) {
-               DRM_ERROR("Failed setting up VCE run queue.\n");
-               return r;
+       if (ring == &adev->vce.ring[0]) {
+               struct drm_gpu_scheduler *sched = &ring->sched;
+               int r;
+
+               r = drm_sched_entity_init(&adev->vce.entity, DRM_SCHED_PRIORITY_NORMAL,
+                                         &sched, 1, NULL);
+               if (r != 0) {
+                       DRM_ERROR("Failed setting up VCE run queue.\n");
+                       return r;
+               }
        }
 
        return 0;
index ea680fc9a6c356aea9e5f7123cbd4bcba452c369..6e53f872d084add51b675a85f72beacf9ba34294 100644 (file)
@@ -55,7 +55,7 @@ struct amdgpu_vce {
 
 int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size);
 int amdgpu_vce_sw_fini(struct amdgpu_device *adev);
-int amdgpu_vce_entity_init(struct amdgpu_device *adev);
+int amdgpu_vce_entity_init(struct amdgpu_device *adev, struct amdgpu_ring *ring);
 int amdgpu_vce_suspend(struct amdgpu_device *adev);
 int amdgpu_vce_resume(struct amdgpu_device *adev);
 void amdgpu_vce_free_handles(struct amdgpu_device *adev, struct drm_file *filp);
index 58a8f78c003c7a0634a3a5f1d2d6bcf6858fad20..a6006f231c655903b626750726495bdcd6a508e2 100644 (file)
@@ -577,8 +577,6 @@ static int uvd_v3_1_sw_init(void *handle)
        ptr += ucode_len;
        memcpy(&adev->uvd.keyselect, ptr, 4);
 
-       r = amdgpu_uvd_entity_init(adev);
-
        return r;
 }
 
index d3b1e31f545032f97b96d2b836bab5bda8b989d8..1aa09ad7bbe3e05f2b5854982e78e149ebefde5e 100644 (file)
@@ -127,8 +127,6 @@ static int uvd_v4_2_sw_init(void *handle)
        if (r)
                return r;
 
-       r = amdgpu_uvd_entity_init(adev);
-
        return r;
 }
 
index 5a8116437abf6f95c69e3393887b8b3acc9cb733..f8b229b75435844054d6d4f2e4b38ba82923f80e 100644 (file)
@@ -125,8 +125,6 @@ static int uvd_v5_0_sw_init(void *handle)
        if (r)
                return r;
 
-       r = amdgpu_uvd_entity_init(adev);
-
        return r;
 }
 
index 74c09230aeb32bd38b00551cfbd3c711f85d9294..a9a6880f44e3302bada40d798168219386a505d7 100644 (file)
@@ -432,8 +432,6 @@ static int uvd_v6_0_sw_init(void *handle)
                }
        }
 
-       r = amdgpu_uvd_entity_init(adev);
-
        return r;
 }
 
index 1c42cf10cc2937546d1e003e1b72bd25c1d563ab..6068b784dc6938d0acff333d715108811164a13d 100644 (file)
@@ -480,10 +480,6 @@ static int uvd_v7_0_sw_init(void *handle)
        if (r)
                return r;
 
-       r = amdgpu_uvd_entity_init(adev);
-       if (r)
-               return r;
-
        r = amdgpu_virt_alloc_mm_table(adev);
        if (r)
                return r;
index 67eb01fef789b9ab78eae3d774561e10458733a8..a08e7abca423bd3db15c8d9f30ce213550c93349 100644 (file)
@@ -441,8 +441,6 @@ static int vce_v2_0_sw_init(void *handle)
                        return r;
        }
 
-       r = amdgpu_vce_entity_init(adev);
-
        return r;
 }
 
index 18f6e62af33984b18e42b1f9f7e22a69de9a80ee..f4760748d34998abb9d8a0b0856419dbbd003ef0 100644 (file)
@@ -450,8 +450,6 @@ static int vce_v3_0_sw_init(void *handle)
                        return r;
        }
 
-       r = amdgpu_vce_entity_init(adev);
-
        return r;
 }
 
index e0b70cd3b697c53de7128f5bc28f5924e8848ba7..06d787385ad460f9e78ff15b527d1b3a102d8eff 100644 (file)
@@ -486,11 +486,6 @@ static int vce_v4_0_sw_init(void *handle)
                        return r;
        }
 
-
-       r = amdgpu_vce_entity_init(adev);
-       if (r)
-               return r;
-
        r = amdgpu_virt_alloc_mm_table(adev);
        if (r)
                return r;