Skip to contentSkip to conversation

drm/amdgpu: hand out the dedicated SPM VMID from the reserved path

PATCH Christian König 3 participants 10 messages Sep 29 – Sep 30 4 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 16 lines · Sunil Khatri

The SPM reservation borrowed a VMID from the GFXHUB round-robin pool shared with normal graphics contexts (VMIDs 1-7). SPM streams its output through the selected VMID's page tables, so sharing that slot with dynamically scheduled contexts is a poor isolation boundary and makes the profiling VMID non-deterministic.

Reservation now uses the VMID a hub dedicates to it. When vm_manager.spm_vmid is set, amdgpu_vmid_alloc_reserved() hands out that fixed VMID directly; when it is unset the reservation is rejected with -ENOENT rather than borrowing a pool VMID, so a reserved submission can never end up on VMID 0 (the kernel VM) or on a slot shared with graphics contexts. The dedicated VMID is not part of the round-robin LRU, so it is given an initialized active-fence sync on every GFXHUB instance in amdgpu_vmid_mgr_init() and amdgpu_vmid_free_reserved() has nothing to return to the LRU.

Quoted 2 lines

The behaviour is gated on spm_vmid, so hubs that do not dedicate a VMID simply do not support reservation.

That won't work like this. The SPM VMID would still be used round robin with that.

You need to take the VMID completely out of the mask. Take a look at when amdgpu_vmid_mgr_set_vmid_mask() is called.

Regards,
Christian.

Quoted 46 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +10 -5
index 5e424e3b6e71f..c8cbd0851d478 100644
@@ -551,9 +551,12 @@ int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 		r = -ENOENT;
 		goto unlock;
 	}
-	/* Remove from normal round robin handling */
-	id = list_first_entry(&id_mgr->ids_lru, struct amdgpu_vmid, list);
-	list_del_init(&id->list);
+	if (!adev->vm_manager.spm_vmid) {
+		r = -ENOENT;
+		goto unlock;
+	}
+
+	id = &id_mgr->ids[adev->vm_manager.spm_vmid];
 	vm->reserved_vmid[vmhub] = id;
 	id_mgr->reserved_vmid = true;
 	mutex_unlock(&id_mgr->lock);
@@ -577,8 +580,6 @@ void amdgpu_vmid_free_reserved(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 	mutex_lock(&id_mgr->lock);
 	if (vm->reserved_vmid[vmhub]) {
-		list_add(&vm->reserved_vmid[vmhub]->list,
-			&id_mgr->ids_lru);
 		vm->reserved_vmid[vmhub] = NULL;
 		id_mgr->reserved_vmid = false;
 	}
@@ -670,6 +671,10 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
 			amdgpu_sync_create(&id_mgr->ids[j].active);
 			list_add_tail(&id_mgr->ids[j].list, &id_mgr->ids_lru);
 		}
+
+		/* out-of-pool VMID; create its sync here */
+		if (adev->vm_manager.spm_vmid && AMDGPU_IS_GFXHUB(i))
+			amdgpu_sync_create(&id_mgr->ids[adev->vm_manager.spm_vmid].active);
 	}
 }
 
#3 lore raw
Quoted 17 lines · Christian König
Quoted 16 lines · Sunil Khatri

The SPM reservation borrowed a VMID from the GFXHUB round-robin pool shared with normal graphics contexts (VMIDs 1-7). SPM streams its output through the selected VMID's page tables, so sharing that slot with dynamically scheduled contexts is a poor isolation boundary and makes the profiling VMID non-deterministic.

Reservation now uses the VMID a hub dedicates to it. When vm_manager.spm_vmid is set, amdgpu_vmid_alloc_reserved() hands out that fixed VMID directly; when it is unset the reservation is rejected with -ENOENT rather than borrowing a pool VMID, so a reserved submission can never end up on VMID 0 (the kernel VM) or on a slot shared with graphics contexts. The dedicated VMID is not part of the round-robin LRU, so it is given an initialized active-fence sync on every GFXHUB instance in amdgpu_vmid_mgr_init() and amdgpu_vmid_free_reserved() has nothing to return to the LRU.

Quoted 5 lines
Quoted 2 lines

The behaviour is gated on spm_vmid, so hubs that do not dedicate a VMID simply do not support reservation.

That won't work like this. The SPM VMID would still be used round robin with that.

You need to take the VMID completely out of the mask. Take a look at when amdgpu_vmid_mgr_set_vmid_mask() is called.

Noted
Regards
Sunil Khatri

Quoted 49 lines

Regards,
Christian.

Quoted 45 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 15 ++++++++++-----
  1 file changed, 10 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +10 -5
index 5e424e3b6e71f..c8cbd0851d478 100644
@@ -551,9 +551,12 @@ int amdgpu_vmid_alloc_reserved(struct amdgpu_device *adev, struct amdgpu_vm *vm,
  		r = -ENOENT;
  		goto unlock;
  	}
-	/* Remove from normal round robin handling */
-	id = list_first_entry(&id_mgr->ids_lru, struct amdgpu_vmid, list);
-	list_del_init(&id->list);
+	if (!adev->vm_manager.spm_vmid) {
+		r = -ENOENT;
+		goto unlock;
+	}
+
+	id = &id_mgr->ids[adev->vm_manager.spm_vmid];
  	vm->reserved_vmid[vmhub] = id;
  	id_mgr->reserved_vmid = true;
  	mutex_unlock(&id_mgr->lock);
@@ -577,8 +580,6 @@ void amdgpu_vmid_free_reserved(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
  	mutex_lock(&id_mgr->lock);
  	if (vm->reserved_vmid[vmhub]) {
-		list_add(&vm->reserved_vmid[vmhub]->list,
-			&id_mgr->ids_lru);
  		vm->reserved_vmid[vmhub] = NULL;
  		id_mgr->reserved_vmid = false;
  	}
@@ -670,6 +671,10 @@ void amdgpu_vmid_mgr_init(struct amdgpu_device *adev)
  			amdgpu_sync_create(&id_mgr->ids[j].active);
  			list_add_tail(&id_mgr->ids[j].list, &id_mgr->ids_lru);
  		}
+
+		/* out-of-pool VMID; create its sync here */
+		if (adev->vm_manager.spm_vmid && AMDGPU_IS_GFXHUB(i))
+			amdgpu_sync_create(&id_mgr->ids[adev->vm_manager.spm_vmid].active);
  	}
  }
 
#4 lore raw

Re: [PATCH v1 1/9] drm/amdgpu: add spm_vmid and exclude it from the MES and KFD pools

In reply to a message not in the archive
Quoted 25 lines · Sunil Khatri

The SPM (Streaming Performance Monitor) path needs a VMID that is isolated from other GPU contexts. Introduce vm_manager.spm_vmid to let a GFXHUB dedicate a VMID to SPM.

When spm_vmid is set, remove that VMID from the MES user-queue mask and from the KFD compute pool so that neither MES firmware nor KFD ever maps another context onto it. KFD derives its VMID range from the shared compute_vmid_bitmap via ffs()/fls(), so clearing the bit there is sufficient and needs no change inside the KFD subsystem.

The field defaults to 0 (unused), so this is a no-op until a generation opts in by setting spm_vmid.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c    | 3 +++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     | 2 ++
 3 files changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
index afcfb92fb9f5f..71e47bdf11393 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) · line 213

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +4 -0
@@ -207,6 +207,10 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
 		for (i = last_valid_bit; i < AMDGPU_MAX_QUEUES; ++i)
 			clear_bit(i, gpu_resources.cp_queue_bitmap);
 
+		if (adev->vm_manager.spm_vmid)
+			gpu_resources.compute_vmid_bitmap &=
+				~BIT(adev->vm_manager.spm_vmid);
+

That is quite a mess.

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 138

Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
 		amdgpu_doorbell_get_kfd_info(adev,
 				&gpu_resources.doorbell_physical_address,
 				&gpu_resources.doorbell_aperture_size,
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +2 -0
index 22ecb70fec2cd..afb56a2f9672b 100644
@@ -134,6 +134,9 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
 	adev->mes.vmid_mask_mmhub = 0xFF00;
 	adev->mes.vmid_mask_gfxhub = total_vmid_mask & ~reserved_vmid_mask;
 
+	if (adev->vm_manager.spm_vmid)
+		adev->mes.vmid_mask_gfxhub &= ~BIT(adev->vm_manager.spm_vmid);

Please remove the vmid_mask_gfxhub field from the MES structure if possible and move all of that into adev->vm_manager or adev->vm_manager.id_mgr instead.

Regards,
Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -0
+
 	num_pipes = adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me;
 	if (num_pipes > AMDGPU_MES_MAX_GFX_PIPES)
 		dev_warn(adev->dev, "more gfx pipes than supported by MES! (%d vs %d)\n",
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -0
index 0f6634b749746..57070da337750 100644
@@ -414,6 +414,8 @@ struct amdgpu_vm_manager {
 	/* Global registration of recent page fault information */
 	struct amdgpu_vm_fault_info	fault_info;
 	unsigned int				npa_vmid;
+	/* VMID reserved for SPM, 0 if unused */
+	unsigned int				spm_vmid;
 };
 
 struct amdgpu_bo_va_mapping;
#5 lore raw

Re: [PATCH v1 1/9] drm/amdgpu: add spm_vmid and exclude it from the MES and KFD pools

Quoted 29 lines · Christian König
Quoted 28 lines · Sunil Khatri

The SPM (Streaming Performance Monitor) path needs a VMID that is isolated from other GPU contexts. Introduce vm_manager.spm_vmid to let a GFXHUB dedicate a VMID to SPM.

When spm_vmid is set, remove that VMID from the MES user-queue mask and from the KFD compute pool so that neither MES firmware nor KFD ever maps another context onto it. KFD derives its VMID range from the shared compute_vmid_bitmap via ffs()/fls(), so clearing the bit there is sufficient and needs no change inside the KFD subsystem.

The field defaults to 0 (unused), so this is a no-op until a generation opts in by setting spm_vmid.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 4 ++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c    | 3 +++
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     | 2 ++
  3 files changed, 9 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
index afcfb92fb9f5f..71e47bdf11393 100644
@@ -207,6 +207,10 @@ void amdgpu_amdkfd_device_init(struct amdgpu_device *adev)
  		for (i = last_valid_bit; i < AMDGPU_MAX_QUEUES; ++i)
  			clear_bit(i, gpu_resources.cp_queue_bitmap);
 
Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c void amdgpu_amdkfd_device_init(struct amdgpu_device *adev) · line 213

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +4 -0
+		if (adev->vm_manager.spm_vmid)
+			gpu_resources.compute_vmid_bitmap &=
+				~BIT(adev->vm_manager.spm_vmid);
+

That is quite a mess.

I dint get that part clearly, i am just taking the bit 15th off the bitmap... Any inputs here ?

Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +0 -0
  		amdgpu_doorbell_get_kfd_info(adev,
  				&gpu_resources.doorbell_physical_address,
  				&gpu_resources.doorbell_aperture_size,
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +0 -0
index 22ecb70fec2cd..afb56a2f9672b 100644
@@ -134,6 +134,9 @@ int amdgpu_mes_init(struct amdgpu_device *adev)
  	adev->mes.vmid_mask_mmhub = 0xFF00;
  	adev->mes.vmid_mask_gfxhub = total_vmid_mask & ~reserved_vmid_mask;
 
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c int amdgpu_mes_init(struct amdgpu_device *adev) · line 138

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +2 -0
+	if (adev->vm_manager.spm_vmid)
+		adev->mes.vmid_mask_gfxhub &= ~BIT(adev->vm_manager.spm_vmid);

Please remove the vmid_mask_gfxhub field from the MES structure if possible and move all of that into adev->vm_manager or adev->vm_manager.id_mgr instead.

you mean both
    uint32_t                        vmid_mask_gfxhub; uint32_t                        vmid_mask_mmhub;

To be out from mes structure and move to adev->vm_manager->id_mgr[i].
The reason I think they are part of the mes as they are only use in the mes related files even if they are vm related fields. Whats your suggestion?

Quoted 21 lines

Regards,
Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c +1 -0
+
  	num_pipes = adev->gfx.me.num_pipe_per_me * adev->gfx.me.num_me;
  	if (num_pipes > AMDGPU_MES_MAX_GFX_PIPES)
  		dev_warn(adev->dev, "more gfx pipes than supported by MES! (%d vs %d)\n",
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -0
index 0f6634b749746..57070da337750 100644
@@ -414,6 +414,8 @@ struct amdgpu_vm_manager {
  	/* Global registration of recent page fault information */
  	struct amdgpu_vm_fault_info	fault_info;
  	unsigned int				npa_vmid;
+	/* VMID reserved for SPM, 0 if unused */
+	unsigned int				spm_vmid;
  };
 
  struct amdgpu_bo_va_mapping;

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Re: [PATCH v1 3/9] drm/amdgpu: reserve SPM VMID on gfx7

Quoted 16 lines · Sunil Khatri

Set vm_manager.spm_vmid to the top GFXHUB VMID so the SPM reservation path hands out a fixed, isolated VMID on gfx7 instead of borrowing one from the graphics pool. The reserved VMID is excluded from the MES user-queue mask and the KFD compute pool by the shared reserved-VMID infrastructure.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
index c95e097241bf8..89e7d19203183 100644

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static int gmc_v7_0_sw_init(struct amdgpu_ip_block *ip_block) · line 1013

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4 -0
@@ -1007,6 +1007,10 @@ static int gmc_v7_0_sw_init(struct amdgpu_ip_block *ip_block)
 	 * amdkfd will use VMIDs 8-15
 	 */
 	adev->vm_manager.first_kfd_vmid = 8;
+
+	/* Reserve the last VMID for SPM */
+	adev->vm_manager.spm_vmid = AMDGPU_NUM_VMID - 1;
+

Instead of this mess we should nuke first_kfd_vmid and let amdgpu_vmid_mgr_set_vmid_mask set masks for both kernel queues and user queues.

Regards,
Christian.

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +0 -0
 	amdgpu_vmid_mgr_set_vmid_mask(adev,
 				      GENMASK(adev->vm_manager.first_kfd_vmid - 1, 1),
 				      false);

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw

Re: [PATCH v1 9/9] drm/amdgpu: use spm_vmid for the default RLC SPM VMID

Quoted 7 lines · Sunil Khatri

The RLC bring-up paths programmed the RLC_SPM_VMID field to a hardcoded 0xf as the idle default. Now that the dedicated SPM VMID is tracked in vm_manager.spm_vmid, use it directly so the idle default matches the VMID the reservation path hands out.

No functional change: spm_vmid is the top VMID (0xf) on all affected generations (gfx7 through gfx12).

You also need to remove all the calls to adev->gfx.rlc.funcs->update_spm_vmid from amdgpu_vm_flush() and amdgpu_ib_schedule().

Regards,
Christian.

Quoted 126 lines
---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 4 ++--
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c  | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +-
 8 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -2
index 33403e16df5ca..88f9f0b0bf524 100644
@@ -5583,7 +5583,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
 		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
 		if (!amdgpu_sriov_vf(adev)) /* enable RLC SRM */
 			gfx_v10_0_rlc_enable_srm(adev);
@@ -5615,7 +5615,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
 		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
 		adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
index 7bfc8cbdcad85..036d1b7ade4e6 100644
@@ -944,7 +944,7 @@ static int gfx_v11_0_rlc_init(struct amdgpu_device *adev)
 
 	/* init spm vmid with 0xf */
 	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
index b75512e7b1db6..4caa43ff50a1b 100644
@@ -773,7 +773,7 @@ static int gfx_v12_0_rlc_init(struct amdgpu_device *adev)
 
 	/* init spm vmid with 0xf */
 	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -1
index 91764f2e5ad01..a3d72cbaa6cf1 100644
@@ -1848,7 +1848,7 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
 	int r;
 
 	/* init spm vmid with 0xf */
-	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, adev->vm_manager.spm_vmid);
 
 	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
 		gfx_v12_1_xcc_init_csb(adev, xcc_id);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 549d1239e326b..04ee7e1725a94 100644
@@ -3252,7 +3252,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
 
 	/* init spm vmid with 0xf */
 	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
index ab4123ddbb942..61ba71b57b8e2 100644
@@ -1274,7 +1274,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
 
 	/* init spm vmid with 0xf */
 	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index 1678015ce5a97..4862d17a58237 100644
@@ -3240,7 +3240,7 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
 		break;
 	}
 
-	gfx_v9_0_update_spm_vmid_internal(adev, 0xf);
+	gfx_v9_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
 	adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
index 01ed1701c781a..add8099cf8e05 100644
@@ -1395,7 +1395,7 @@ static int gfx_v9_4_3_rlc_init(struct amdgpu_device *adev)
 {
 	/* init spm vmid with 0xf */
 	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
 	return 0;
 }
#10 lore raw

Re: [PATCH v1 9/9] drm/amdgpu: use spm_vmid for the default RLC SPM VMID

Quoted 8 lines · Christian König
Quoted 7 lines · Sunil Khatri

The RLC bring-up paths programmed the RLC_SPM_VMID field to a hardcoded 0xf as the idle default. Now that the dedicated SPM VMID is tracked in vm_manager.spm_vmid, use it directly so the idle default matches the VMID the reservation path hands out.

No functional change: spm_vmid is the top VMID (0xf) on all affected generations (gfx7 through gfx12).

I don't see the full series for some reason so pointing it out here.

We are reserving and using VMID 15 for NPA VMs currently on GFX 12.1.

Currently, we are using it only on MMHUB. But this may change in the future.

So maybe refrain from using the same VMID 15.

Also, since I can't see the full series, please look at gmc_v12_0_sw_init() on how we are reserving the VMID.

Regards,

Mukul

Quoted 130 lines

You also need to remove all the calls to adev->gfx.rlc.funcs->update_spm_vmid from amdgpu_vm_flush() and amdgpu_ib_schedule().

Regards,
Christian.

Quoted 125 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +-
  8 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -2
index 33403e16df5ca..88f9f0b0bf524 100644
@@ -5583,7 +5583,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
  		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  		if (!amdgpu_sriov_vf(adev)) /* enable RLC SRM */
  			gfx_v10_0_rlc_enable_srm(adev);
@@ -5615,7 +5615,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
  		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  		adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
index 7bfc8cbdcad85..036d1b7ade4e6 100644
@@ -944,7 +944,7 @@ static int gfx_v11_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
index b75512e7b1db6..4caa43ff50a1b 100644
@@ -773,7 +773,7 @@ static int gfx_v12_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -1
index 91764f2e5ad01..a3d72cbaa6cf1 100644
@@ -1848,7 +1848,7 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
  	int r;
 
  	/* init spm vmid with 0xf */
-	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, adev->vm_manager.spm_vmid);
 
  	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
  		gfx_v12_1_xcc_init_csb(adev, xcc_id);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 549d1239e326b..04ee7e1725a94 100644
@@ -3252,7 +3252,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
index ab4123ddbb942..61ba71b57b8e2 100644
@@ -1274,7 +1274,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index 1678015ce5a97..4862d17a58237 100644
@@ -3240,7 +3240,7 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
  		break;
  	}
 
-	gfx_v9_0_update_spm_vmid_internal(adev, 0xf);
+	gfx_v9_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  	adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
index 01ed1701c781a..add8099cf8e05 100644
@@ -1395,7 +1395,7 @@ static int gfx_v9_4_3_rlc_init(struct amdgpu_device *adev)
  {
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
#11 lore raw

Re: [PATCH v1 9/9] drm/amdgpu: use spm_vmid for the default RLC SPM VMID

Quoted 12 lines · Mukul Joshi
Quoted 8 lines · Christian König
Quoted 7 lines · Sunil Khatri

The RLC bring-up paths programmed the RLC_SPM_VMID field to a hardcoded 0xf as the idle default. Now that the dedicated SPM VMID is tracked in vm_manager.spm_vmid, use it directly so the idle default matches the VMID the reservation path hands out.

No functional change: spm_vmid is the top VMID (0xf) on all affected generations (gfx7 through gfx12).

Quoted 8 lines

I don't see the full series for some reason so pointing it out here.

We are reserving and using VMID 15 for NPA VMs currently on GFX 12.1.

Currently, we are using it only on MMHUB. But this may change in the future.

So maybe refrain from using the same VMID 15.

@christian,
Whats you suggestion here on using the vmid15 suggestion that Mukul has shared.

Quoted 3 lines

Also, since I can't see the full series, please look at gmc_v12_0_sw_init() on how we are reserving the VMID.

I am not sure Mukul why you arent seeing the full series... I am aware of the NPA VMID 15 reservation in MMHUB and I will check have a look at  gmc_v12_0_sw_init.

Regards
Sunil Khatri

Quoted 136 lines

Regards,

Mukul

Quoted 130 lines

You also need to remove all the calls to adev->gfx.rlc.funcs->update_spm_vmid from amdgpu_vm_flush() and amdgpu_ib_schedule().

Regards,
Christian.

Quoted 125 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +-
  8 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -2
index 33403e16df5ca..88f9f0b0bf524 100644
@@ -5583,7 +5583,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
  		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  		if (!amdgpu_sriov_vf(adev)) /* enable RLC SRM */
  			gfx_v10_0_rlc_enable_srm(adev);
@@ -5615,7 +5615,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
  		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  		adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
index 7bfc8cbdcad85..036d1b7ade4e6 100644
@@ -944,7 +944,7 @@ static int gfx_v11_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
index b75512e7b1db6..4caa43ff50a1b 100644
@@ -773,7 +773,7 @@ static int gfx_v12_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -1
index 91764f2e5ad01..a3d72cbaa6cf1 100644
@@ -1848,7 +1848,7 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
  	int r;
 
  	/* init spm vmid with 0xf */
-	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, adev->vm_manager.spm_vmid);
 
  	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
  		gfx_v12_1_xcc_init_csb(adev, xcc_id);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 549d1239e326b..04ee7e1725a94 100644
@@ -3252,7 +3252,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
index ab4123ddbb942..61ba71b57b8e2 100644
@@ -1274,7 +1274,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index 1678015ce5a97..4862d17a58237 100644
@@ -3240,7 +3240,7 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
  		break;
  	}
 
-	gfx_v9_0_update_spm_vmid_internal(adev, 0xf);
+	gfx_v9_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  	adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
index 01ed1701c781a..add8099cf8e05 100644
@@ -1395,7 +1395,7 @@ static int gfx_v9_4_3_rlc_init(struct amdgpu_device *adev)
  {
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
#12 lore raw

Re: [PATCH v1 9/9] drm/amdgpu: use spm_vmid for the default RLC SPM VMID

Quoted 16 lines · Sunil
Quoted 14 lines · Mukul Joshi
Quoted 8 lines · Christian König
Quoted 7 lines · Sunil Khatri

The RLC bring-up paths programmed the RLC_SPM_VMID field to a hardcoded 0xf as the idle default. Now that the dedicated SPM VMID is tracked in vm_manager.spm_vmid, use it directly so the idle default matches the VMID the reservation path hands out.

No functional change: spm_vmid is the top VMID (0xf) on all affected generations (gfx7 through gfx12).

I don't see the full series for some reason so pointing it out here.

Quoted 8 lines
Quoted 6 lines

We are reserving and using VMID 15 for NPA VMs currently on GFX 12.1.

Currently, we are using it only on MMHUB. But this may change in the future.

So maybe refrain from using the same VMID 15.

@christian,
Whats you suggestion here on using the vmid15 suggestion that Mukul has shared.

As Mukul wrote as well for now that is rather unproblematic since we only need VMID 15 for NPA on the MMHUB and for SPM on the GFXHUB.

But we should really note all special VMIDs usages in the vm_manager and abstract the reserved usages using proper functions in amdgpu_ids.c.

Something like funktions to return the VMIDs which should be used for kernel queues (CS IOCTL) and user queues (MES, old HWS/KFD).

That should give us enough flexibility to change things for future HW generations.

Regards,
Christian.

Quoted 123 lines
Quoted 3 lines

Also, since I can't see the full series, please look at gmc_v12_0_sw_init() on how we are reserving the VMID.

I am not sure Mukul why you arent seeing the full series... I am aware of the NPA VMID 15 reservation in MMHUB and I will check have a look at  gmc_v12_0_sw_init.

Regards
Sunil Khatri

Quoted 115 lines

Regards,

Mukul

Quoted 109 lines

You also need to remove all the calls to adev->gfx.rlc.funcs->update_spm_vmid from amdgpu_vm_flush() and amdgpu_ib_schedule().

Regards,
Christian.

Quoted 104 lines

---

  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +-
  8 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -0
index 33403e16df5ca..88f9f0b0bf524 100644
@@ -5583,7 +5583,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
             gfx_v10_0_init_csb(adev);
   -        gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+        gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);

            if (!amdgpu_sriov_vf(adev)) /* enable RLC SRM */ gfx_v10_0_rlc_enable_srm(adev);

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +1 -0
@@ -5615,7 +5615,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
             gfx_v10_0_init_csb(adev);
   -        gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+        gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
             adev->gfx.rlc.funcs->start(adev);

  diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c index 7bfc8cbdcad85..036d1b7ade4e6 100644

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
@@ -944,7 +944,7 @@ static int gfx_v11_0_rlc_init(struct amdgpu_device *adev)
         /* init spm vmid with 0xf */
       if (adev->gfx.rlc.funcs->update_spm_vmid)
-        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
         return 0;
   }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
index b75512e7b1db6..4caa43ff50a1b 100644
@@ -773,7 +773,7 @@ static int gfx_v12_0_rlc_init(struct amdgpu_device *adev)
         /* init spm vmid with 0xf */
       if (adev->gfx.rlc.funcs->update_spm_vmid)
-        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
         return 0;
   }
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -1
index 91764f2e5ad01..a3d72cbaa6cf1 100644
@@ -1848,7 +1848,7 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
       int r;
         /* init spm vmid with 0xf */
-    gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+    gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, adev->vm_manager.spm_vmid);
         if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
           gfx_v12_1_xcc_init_csb(adev, xcc_id);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 549d1239e326b..04ee7e1725a94 100644
@@ -3252,7 +3252,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
         /* init spm vmid with 0xf */
       if (adev->gfx.rlc.funcs->update_spm_vmid)
-        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
         return 0;
   }
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
index ab4123ddbb942..61ba71b57b8e2 100644
@@ -1274,7 +1274,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
         /* init spm vmid with 0xf */
       if (adev->gfx.rlc.funcs->update_spm_vmid)
-        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
         return 0;
   }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -0
index 1678015ce5a97..4862d17a58237 100644
@@ -3240,7 +3240,7 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
           break;
       }
   -    gfx_v9_0_update_spm_vmid_internal(adev, 0xf);
+    gfx_v9_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
         adev->gfx.rlc.funcs->start(adev);

  diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c index 01ed1701c781a..add8099cf8e05 100644

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
@@ -1395,7 +1395,7 @@ static int gfx_v9_4_3_rlc_init(struct amdgpu_device *adev)
   {
       /* init spm vmid with 0xf */
       if (adev->gfx.rlc.funcs->update_spm_vmid)
-        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+        adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
         return 0;
   }
#13 lore raw

Re: [PATCH v1 9/9] drm/amdgpu: use spm_vmid for the default RLC SPM VMID

In reply to Christian König
Quoted 9 lines · Christian König
Quoted 7 lines · Sunil Khatri

The RLC bring-up paths programmed the RLC_SPM_VMID field to a hardcoded 0xf as the idle default. Now that the dedicated SPM VMID is tracked in vm_manager.spm_vmid, use it directly so the idle default matches the VMID the reservation path hands out.

No functional change: spm_vmid is the top VMID (0xf) on all affected generations (gfx7 through gfx12).

You also need to remove all the calls to adev->gfx.rlc.funcs->update_spm_vmid from amdgpu_vm_flush() and amdgpu_ib_schedule().

Sure in the next patch set will remove them...

Regards
Sunil Khatri

Quoted 129 lines

Regards,
Christian.

Quoted 125 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c  | 4 ++--
  drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c  | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c   | 2 +-
  drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +-
  8 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -2
index 33403e16df5ca..88f9f0b0bf524 100644
@@ -5583,7 +5583,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
  		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  		if (!amdgpu_sriov_vf(adev)) /* enable RLC SRM */
  			gfx_v10_0_rlc_enable_srm(adev);
@@ -5615,7 +5615,7 @@ static int gfx_v10_0_rlc_resume(struct amdgpu_device *adev)
 
  		gfx_v10_0_init_csb(adev);
 
-		gfx_v10_0_update_spm_vmid_internal(adev, 0xf);
+		gfx_v10_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  		adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
index 7bfc8cbdcad85..036d1b7ade4e6 100644
@@ -944,7 +944,7 @@ static int gfx_v11_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +1 -1
index b75512e7b1db6..4caa43ff50a1b 100644
@@ -773,7 +773,7 @@ static int gfx_v12_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -1
index 91764f2e5ad01..a3d72cbaa6cf1 100644
@@ -1848,7 +1848,7 @@ static int gfx_v12_1_xcc_rlc_resume(struct amdgpu_device *adev,
  	int r;
 
  	/* init spm vmid with 0xf */
-	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, 0xf);
+	gfx_v12_1_update_spm_vmid(adev, xcc_id, NULL, adev->vm_manager.spm_vmid);
 
  	if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
  		gfx_v12_1_xcc_init_csb(adev, xcc_id);
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 549d1239e326b..04ee7e1725a94 100644
@@ -3252,7 +3252,7 @@ static int gfx_v7_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
index ab4123ddbb942..61ba71b57b8e2 100644
@@ -1274,7 +1274,7 @@ static int gfx_v8_0_rlc_init(struct amdgpu_device *adev)
 
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
index 1678015ce5a97..4862d17a58237 100644
@@ -3240,7 +3240,7 @@ static int gfx_v9_0_rlc_resume(struct amdgpu_device *adev)
  		break;
  	}
 
-	gfx_v9_0_update_spm_vmid_internal(adev, 0xf);
+	gfx_v9_0_update_spm_vmid_internal(adev, adev->vm_manager.spm_vmid);
 
  	adev->gfx.rlc.funcs->start(adev);
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
index 01ed1701c781a..add8099cf8e05 100644
@@ -1395,7 +1395,7 @@ static int gfx_v9_4_3_rlc_init(struct amdgpu_device *adev)
  {
  	/* init spm vmid with 0xf */
  	if (adev->gfx.rlc.funcs->update_spm_vmid)
-		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, 0xf);
+		adev->gfx.rlc.funcs->update_spm_vmid(adev, 0, NULL, adev->vm_manager.spm_vmid);
 
  	return 0;
  }