Skip to contentSkip to conversation

drm/amdgpu: properly handle GC vs MM in amdgpu_vmid_mgr_init()

PATCH In review Alex Deucher 3 participants 3 messages Apr 29, 2025 – Apr 30, 2025

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: properly handle GC vs MM in amdgpu_vmid_mgr_init()

When kernel queues are disabled, all GC vmids are available for the scheduler. MM vmids are still managed by the driver so make all 16 available.

Also fix gmc 10 vs 11 mix up in
commit 1f61fc28b939 ("drm/amdgpu/mes: make more vmids available when disable_kq=1")

Fixes 1f61fc28b939 ("drm/amdgpu/mes: make more vmids available when disable_kq=1")
Cc Arvind Yadav <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 8 ++++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  | 2 +-
 3 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +6 -2
index 359c19de9a5b9..c7a6d40ded5c3 100644
@@ -576,8 +576,12 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
 		INIT_LIST_HEAD(&id_mgr->ids_lru);
 		id_mgr->reserved_use_count = 0;
 
-		/* manage only VMIDs not used by KFD */
-		id_mgr->num_ids = adev->vm_manager.first_kfd_vmid;
+		if (AMDGPU_IS_MMHUB0(i) ||
+		    AMDGPU_IS_MMHUB1(i))
+			id_mgr->num_ids = 16;
+		else
+			/* manage only VMIDs not used by KFD */
+			id_mgr->num_ids = adev->vm_manager.first_kfd_vmid;
 
 		/* skip over VMID 0, since it is the system VM */
 		for (j = 1; j < id_mgr->num_ids; ++j) {
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
index 7648e977b44bc..a3e2787501f18 100644
@@ -896,7 +896,7 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block *ip_block)
 	 * amdgpu graphics/compute will use VMIDs 1-7
 	 * amdkfd will use VMIDs 8-15
 	 */
-	adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
+	adev->vm_manager.first_kfd_vmid = 8;
 
 	amdgpu_vm_manager_init(adev);
 
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
index 7f5ca170f141a..917d894a1316a 100644
@@ -828,7 +828,7 @@ static int gmc_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
 	 * amdgpu graphics/compute will use VMIDs 1-7
 	 * amdkfd will use VMIDs 8-15
 	 */
-	adev->vm_manager.first_kfd_vmid = 8;
+	adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
 
 	amdgpu_vm_manager_init(adev);
 
Signature · 1 line
2.49.0
Reviewed-by Arvind Yadav on v1 1/1
#1 lore raw
Quoted 61 lines · Alex Deucher

When kernel queues are disabled, all GC vmids are available for the scheduler. MM vmids are still managed by the driver so make all 16 available.

Also fix gmc 10 vs 11 mix up in
commit 1f61fc28b939 ("drm/amdgpu/mes: make more vmids available when disable_kq=1")

Fixes 1f61fc28b939 ("drm/amdgpu/mes: make more vmids available when disable_kq=1")
Cc Arvind Yadav <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 8 ++++++--
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  | 2 +-
  3 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +6 -2
index 359c19de9a5b9..c7a6d40ded5c3 100644
@@ -576,8 +576,12 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
  		INIT_LIST_HEAD(&id_mgr->ids_lru);
  		id_mgr->reserved_use_count = 0;
 
-		/* manage only VMIDs not used by KFD */
-		id_mgr->num_ids = adev->vm_manager.first_kfd_vmid;
+		if (AMDGPU_IS_MMHUB0(i) ||
+		    AMDGPU_IS_MMHUB1(i))
+			id_mgr->num_ids = 16;
+		else
+			/* manage only VMIDs not used by KFD */
+			id_mgr->num_ids = adev->vm_manager.first_kfd_vmid;
 
  		/* skip over VMID 0, since it is the system VM */
  		for (j = 1; j < id_mgr->num_ids; ++j) {
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
index 7648e977b44bc..a3e2787501f18 100644
@@ -896,7 +896,7 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block *ip_block)
  	 * amdgpu graphics/compute will use VMIDs 1-7
  	 * amdkfd will use VMIDs 8-15
  	 */
-	adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
+	adev->vm_manager.first_kfd_vmid = 8;
 
  	amdgpu_vm_manager_init(adev);
 
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
index 7f5ca170f141a..917d894a1316a 100644
@@ -828,7 +828,7 @@ static int gmc_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
  	 * amdgpu graphics/compute will use VMIDs 1-7
  	 * amdkfd will use VMIDs 8-15
  	 */
-	adev->vm_manager.first_kfd_vmid = 8;
+	adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
 
  	amdgpu_vm_manager_init(adev);
 
#2 lore raw
Quoted 28 lines · Arvind
Quoted 24 lines · Alex Deucher

When kernel queues are disabled, all GC vmids are available for the scheduler. MM vmids are still managed by the driver so make all 16 available.

Also fix gmc 10 vs 11 mix up in
commit 1f61fc28b939 ("drm/amdgpu/mes: make more vmids available when disable_kq=1")

Fixes 1f61fc28b939 ("drm/amdgpu/mes: make more vmids available when disable_kq=1")
Cc Arvind Yadav <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 8 ++++++--
  drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c  | 2 +-
  3 files changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0 -0
index 359c19de9a5b9..c7a6d40ded5c3 100644
@@ -576,8 +576,12 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
              INIT_LIST_HEAD(&id_mgr->ids_lru);
              id_mgr->reserved_use_count = 0;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_mgr_init(struct amdgpu_device *adev) · line 584

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +6 -2
-             /* manage only VMIDs not used by KFD */
-             id_mgr->num_ids = adev->vm_manager.first_kfd_vmid;
+             if (AMDGPU_IS_MMHUB0(i) ||
+                 AMDGPU_IS_MMHUB1(i))
+                     id_mgr->num_ids = 16;
+             else
+                     /* manage only VMIDs not used by KFD */
+                     id_mgr->num_ids = adev->vm_manager.first_kfd_vmid;

We need to handle pre GC 10 here as well. I just sent out an updated patch.

Alex

Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0 -0
              /* skip over VMID 0, since it is the system VM */
              for (j = 1; j < id_mgr->num_ids; ++j) {
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1 -1
index 7648e977b44bc..a3e2787501f18 100644
@@ -896,7 +896,7 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block *ip_block)
       * amdgpu graphics/compute will use VMIDs 1-7
       * amdkfd will use VMIDs 8-15
       */
-     adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
+     adev->vm_manager.first_kfd_vmid = 8;
 
      amdgpu_vm_manager_init(adev);
 
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +1 -1
index 7f5ca170f141a..917d894a1316a 100644
@@ -828,7 +828,7 @@ static int gmc_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
       * amdgpu graphics/compute will use VMIDs 1-7
       * amdkfd will use VMIDs 8-15
       */
-     adev->vm_manager.first_kfd_vmid = 8;
+     adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
 
      amdgpu_vm_manager_init(adev);