[PATCH v2 16/20] drm/amdgpu: give ttm entities access to all the sdma scheds

Pierre-Eric Pelloux-Prayer
2025-11-13T16:12:12Z

Signed-off-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
---
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 11fec0fa4c11..94d0ff34593f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2191,8 +2191,8 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
u32 num_clear_entities, num_move_entities;
u32 windows, w;

- 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);
windows = adev->gmc.is_app_apu ? 0 : (2 * num_move_entities + num_clear_entities);

if (!adev->mman.initialized || amdgpu_in_reset(adev) ||
@@ -2200,11 +2200,8 @@ u32 amdgpu_ttm_set_buffer_funcs_status(struct amdgpu_device *adev, bool enable)
return windows;

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",
@@ -2216,8 +2213,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",
@@ -2239,8 +2237,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