With this change we now have as many clear and move entities as we
have sdma engines (limited to TTM_NUM_MOVE_FENCES).

To enable load-balancing this patch gives access to all sdma
schedulers to all entities.

Signed-off-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Christian König <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index eec0cab8060c..39cfe2dbdf03 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2233,8 +2233,8 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct 
amdgpu_device *adev, bool enable)
        uint64_t size;
        int r, i, j;
 
-       num_clear_entities = adev->sdma.num_instances;
-       num_move_entities = MIN(adev->sdma.num_instances, TTM_NUM_MOVE_FENCES);
+       num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, 
TTM_NUM_MOVE_FENCES);
+       num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, 
TTM_NUM_MOVE_FENCES);
        reserved_windows = 2 * num_move_entities + num_clear_entities;
 
        if (!adev->mman.initialized || amdgpu_in_reset(adev) ||
@@ -2248,11 +2248,8 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct 
amdgpu_device *adev, bool enable)
        }
 
        if (enable) {
-               struct drm_gpu_scheduler *sched;
-
-               sched = adev->mman.buffer_funcs_scheds[0];
                r = drm_sched_entity_init(&adev->mman.default_entity.base,
-                                         DRM_SCHED_PRIORITY_KERNEL, &sched,
+                                         DRM_SCHED_PRIORITY_KERNEL, 
adev->mman.buffer_funcs_scheds,
                                          1, NULL);
                if (r) {
                        dev_err(adev->dev, "Failed setting up entity (%d)\n",
@@ -2264,8 +2261,9 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct 
amdgpu_device *adev, bool enable)
                atomic_set(&adev->mman.next_move_entity, 0);
                for (i = 0; i < num_move_entities; i++) {
                        r = 
drm_sched_entity_init(&adev->mman.move_entities[i].base,
-                                                 DRM_SCHED_PRIORITY_NORMAL, 
&sched,
-                                                 1, NULL);
+                                                 DRM_SCHED_PRIORITY_NORMAL,
+                                                 
adev->mman.buffer_funcs_scheds,
+                                                 
adev->mman.num_buffer_funcs_scheds, NULL);
                        if (r) {
                                dev_err(adev->dev,
                                        "Failed setting up TTM BO move entities 
(%d)\n",
@@ -2287,8 +2285,9 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct 
amdgpu_device *adev, bool enable)
 
                for (i = 0; i < num_clear_entities; i++) {
                        r = 
drm_sched_entity_init(&adev->mman.clear_entities[i].base,
-                                                 DRM_SCHED_PRIORITY_NORMAL, 
&sched,
-                                                 1, NULL);
+                                                 DRM_SCHED_PRIORITY_NORMAL,
+                                                 
adev->mman.buffer_funcs_scheds,
+                                                 
adev->mman.num_buffer_funcs_scheds, NULL);
                        if (r) {
                                for (j = 0; j < num_move_entities; j++)
                                        drm_sched_entity_destroy(
-- 
2.43.0

Reply via email to