drm/amdgpu: use the same naming scheme for kq and uq VMID masks
Subsystems (2)
PATCH v2 1/11 drm/amdgpu: use the same naming scheme for kq and uq VMID masks
Fix the ambiguous names in amdgpu_vmid_mgr_set_vmid_mask()'s parameters so there is no confusion.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 16 ++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +8 -8
@@ -635,13 +635,13 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)* pools for both hubs * * @adev: amdgpu device structure -* @gfx_vmid_mask: kernel-queue VMID pool mask for GFXHUB -* @mmhub_vmid_mask: kernel-queue VMID pool mask for MMHUB +* @vmid_kq_mask_gfxhub: kernel-queue VMID pool mask for GFXHUB +* @vmid_kq_mask_mmhub: kernel-queue VMID pool mask for MMHUB * * Sets both hubs' kernel-queue VMID pools (tracked least-recently-used * via id_mgr[].ids_lru), and both hubs' KFD/MES user-queue masks. * vmid_uq_mask_gfxhub is set to the -* complement of @gfx_vmid_mask, since unlike MMHUB's it is always a +* complement of @vmid_kq_mask_gfxhub, since unlike MMHUB's it is always a * clean partition of the full VMID range; vmid_uq_mask_mmhub is the * fixed pool set here instead, since MMHUB's kq and uq pools are * allowed to overlap. A VMID dedicated to a single fixed purpose on
@@ -649,26 +649,26 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)* caller's responsibility to have already set npa_vmid. */ void amdgpu_vmid_mgr_set_vmid_mask (struct amdgpu_device *adev, -unsigned long gfx_vmid_mask, -unsigned long mmhub_vmid_mask) +unsigned long vmid_kq_mask_gfxhub, +unsigned long vmid_kq_mask_mmhub) {unsigned int i;BUILD_BUG_ON (AMDGPU_NUM_VMID >BITS_PER_LONG );if (adev->vm_manager.npa_vmid) - mmhub_vmid_mask &= ~BIT (adev->vm_manager.npa_vmid); + vmid_kq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid);for (i =0 ; i <AMDGPU_MAX_VMHUBS ; i++) {bool is_mmhub =AMDGPU_IS_MMHUB0 (i) ||AMDGPU_IS_MMHUB1 (i);bitmap_copy (adev->vm_manager.id_mgr[i].vmid_mask, - is_mmhub ? &mmhub_vmid_mask : &gfx_vmid_mask, + is_mmhub ? &vmid_kq_mask_mmhub : &vmid_kq_mask_gfxhub,AMDGPU_NUM_VMID ); } adev->vm_manager.vmid_uq_mask_gfxhub = -GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~gfx_vmid_mask; +GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~vmid_kq_mask_gfxhub; adev->vm_manager.vmid_uq_mask_mmhub =0xFF00 ;if (adev->vm_manager.npa_vmid)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h +2 -2
@@ -135,7 +135,7 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev);void amdgpu_vmid_mgr_init (struct amdgpu_device *adev);void amdgpu_vmid_mgr_fini (struct amdgpu_device *adev);void amdgpu_vmid_mgr_set_vmid_mask (struct amdgpu_device *adev, -unsigned long gfx_vmid_mask, -unsigned long mmhub_vmid_mask); +unsigned long vmid_kq_mask_gfxhub, +unsigned long vmid_kq_mask_mmhub);#endif
Signature · 1 line
2.34.1
PATCH v2 2/11 drm/amdgpu: add spm_vmid and exclude it from the MES, KFD and kq pools
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, exclude it from both the kernel-queue pool and vmid_uq_mask_gfxhub, so neither the round-robin kernel-queue allocator nor MES/Userqueues ever maps another context onto it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 46 ++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 ++ 2 files changed, 31 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +29 -17
@@ -638,26 +638,45 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)* @vmid_kq_mask_gfxhub: kernel-queue VMID pool mask for GFXHUB * @vmid_kq_mask_mmhub: kernel-queue VMID pool mask for MMHUB * -* Sets both hubs' kernel-queue VMID pools (tracked least-recently-used -* via id_mgr[].ids_lru), and both hubs' KFD/MES user-queue masks. -* vmid_uq_mask_gfxhub is set to the -* complement of @vmid_kq_mask_gfxhub, since unlike MMHUB's it is always a -* clean partition of the full VMID range; vmid_uq_mask_mmhub is the -* fixed pool set here instead, since MMHUB's kq and uq pools are -* allowed to overlap. A VMID dedicated to a single fixed purpose on -* MMHUB (npa_vmid) is excluded from both MMHUB pools; it is the -* caller's responsibility to have already set npa_vmid. +* Sets both GFXHUB and MMHUB kernel-queue VMID pools +* via id_mgr[].ids_lru, and KFD/MES user-queue masks too. */ void amdgpu_vmid_mgr_set_vmid_mask (struct amdgpu_device *adev,unsigned long vmid_kq_mask_gfxhub,unsigned long vmid_kq_mask_mmhub) { +unsigned long uq_mask_gfxhub, uq_mask_mmhub;unsigned int i;BUILD_BUG_ON (AMDGPU_NUM_VMID >BITS_PER_LONG ); -if (adev->vm_manager.npa_vmid) +/* +* Derive the uq masks from the kq masks as given, then carve each +* hub's dedicated out-of-pool VMID out of both of that hub's pools. +*/ + uq_mask_gfxhub =GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~vmid_kq_mask_gfxhub; + uq_mask_mmhub =0xFF00 ; + +/* +* SPM uses a dedicated vmid that is reserved from gfxhub. +* Unmask the reserved vmids from both user and kernel queues +*/ +if (adev->vm_manager.spm_vmid) { + vmid_kq_mask_gfxhub &= ~BIT (adev->vm_manager.spm_vmid); + uq_mask_gfxhub &= ~BIT (adev->vm_manager.spm_vmid); + } + +/* +* NPA uses a dedicated vmid that is reserved from mmhub. +* Unmask the reserved VMIDs from both user and kernel queues +*/ +if (adev->vm_manager.npa_vmid) { vmid_kq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid); + uq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid); + } + + adev->vm_manager.vmid_uq_mask_gfxhub = uq_mask_gfxhub; + adev->vm_manager.vmid_uq_mask_mmhub = uq_mask_mmhub;for (i =0 ; i <AMDGPU_MAX_VMHUBS ; i++) {bool is_mmhub =AMDGPU_IS_MMHUB0 (i) ||AMDGPU_IS_MMHUB1 (i);
@@ -666,13 +685,6 @@ void amdgpu_vmid_mgr_set_vmid_mask(struct amdgpu_device *adev, is_mmhub ? &vmid_kq_mask_mmhub : &vmid_kq_mask_gfxhub, AMDGPU_NUM_VMID); } - - adev->vm_manager.vmid_uq_mask_gfxhub = -GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~vmid_kq_mask_gfxhub; - - adev->vm_manager.vmid_uq_mask_mmhub =0xFF00 ; -if (adev->vm_manager.npa_vmid) - adev->vm_manager.vmid_uq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2 -0
@@ -411,7 +411,9 @@ struct amdgpu_vm_manager {/* Global registration of recent page fault information */ struct amdgpu_vm_fault_info fault_info; +/* VMIDs dedicated to a single fixed purpose, 0 if unused */ unsigned int npa_vmid; +unsigned int spm_vmid;/* VMID masks for GFXHUB and MMHUB */ uint32_t vmid_uq_mask_gfxhub;
Signature · 1 line
2.34.1
Christian König
maintainerRe: [PATCH v2 02/11] drm/amdgpu: add spm_vmid and exclude it from the MES, KFD and kq pools
Quoted 41 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_vmidis set, exclude it from both the kernel-queue pool andvmid_uq_mask_gfxhub, so neither the round-robin kernel-queue allocator nor MES/Userqueues ever maps another context onto it.Assisted-by Claude:claude-sonnet-5Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 46 ++++++++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 ++ 2 files changed, 31 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +3
-9@@ -638,26 +638,45 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)* @vmid_kq_mask_gfxhub: kernel-queue VMID pool mask for GFXHUB * @vmid_kq_mask_mmhub: kernel-queue VMID pool mask for MMHUB * -* Sets both hubs' kernel-queue VMID pools (tracked least-recently-used -* via id_mgr[].ids_lru), and both hubs' KFD/MES user-queue masks. -* vmid_uq_mask_gfxhub is set to the -* complement of @vmid_kq_mask_gfxhub, since unlike MMHUB's it is always a -* clean partition of the full VMID range; vmid_uq_mask_mmhub is the -* fixed pool set here instead, since MMHUB's kq and uq pools are -* allowed to overlap. A VMID dedicated to a single fixed purpose on -* MMHUB (npa_vmid) is excluded from both MMHUB pools; it is the -* caller's responsibility to have already set npa_vmid. +* Sets both GFXHUB and MMHUB kernel-queue VMID pools +* via id_mgr[].ids_lru, and KFD/MES user-queue masks too. */ void amdgpu_vmid_mgr_set_vmid_mask (struct amdgpu_device *adev,unsigned long vmid_kq_mask_gfxhub,unsigned long vmid_kq_mask_mmhub) { +unsigned long uq_mask_gfxhub, uq_mask_mmhub;unsigned int i;
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_reset_all(struct amdgpu_device *adev) · line 658
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +6
-1BUILD_BUG_ON (AMDGPU_NUM_VMID >BITS_PER_LONG ); -if (adev->vm_manager.npa_vmid) +/* +* Derive the uq masks from the kq masks as given, then carve each +* hub's dedicated out-of-pool VMID out of both of that hub's pools. +*/ + uq_mask_gfxhub =GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~vmid_kq_mask_gfxhub; + uq_mask_mmhub =0xFF00 ;
That looks like it was derived from the original first_kfd_vmid or some fixed MES value.
For now the patch is Reviewed-by: Christian König <[email protected]>, but I think we need to take a look at that value again.
Regards,
Christian.
Quoted 52 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +20
-7+ +/* +* SPM uses a dedicated vmid that is reserved from gfxhub. +* Unmask the reserved vmids from both user and kernel queues +*/ +if (adev->vm_manager.spm_vmid) { + vmid_kq_mask_gfxhub &= ~BIT (adev->vm_manager.spm_vmid); + uq_mask_gfxhub &= ~BIT (adev->vm_manager.spm_vmid); + } + +/* +* NPA uses a dedicated vmid that is reserved from mmhub. +* Unmask the reserved VMIDs from both user and kernel queues +*/ +if (adev->vm_manager.npa_vmid) { vmid_kq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid); + uq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid); + } + + adev->vm_manager.vmid_uq_mask_gfxhub = uq_mask_gfxhub; + adev->vm_manager.vmid_uq_mask_mmhub = uq_mask_mmhub;for (i =0 ; i <AMDGPU_MAX_VMHUBS ; i++) {bool is_mmhub =AMDGPU_IS_MMHUB0 (i) ||AMDGPU_IS_MMHUB1 (i);@@ -666,13 +685,6 @@ void amdgpu_vmid_mgr_set_vmid_mask(struct amdgpu_device *adev, is_mmhub ? &vmid_kq_mask_mmhub : &vmid_kq_mask_gfxhub, AMDGPU_NUM_VMID); } - - adev->vm_manager.vmid_uq_mask_gfxhub = -GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~vmid_kq_mask_gfxhub; - - adev->vm_manager.vmid_uq_mask_mmhub =0xFF00 ; -if (adev->vm_manager.npa_vmid) - adev->vm_manager.vmid_uq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid); }/** drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +2
-0@@ -411,7 +411,9 @@ struct amdgpu_vm_manager {/* Global registration of recent page fault information */ struct amdgpu_vm_fault_info fault_info; +/* VMIDs dedicated to a single fixed purpose, 0 if unused */ unsigned int npa_vmid; +unsigned int spm_vmid;/* VMID masks for GFXHUB and MMHUB */ uint32_t vmid_uq_mask_gfxhub;
PATCH v2 3/11 drm/amdgpu: use dedicated SPM VMID from the reserved path
In reply to Sunil KhatriUse the spm vmid which is dedicated for the SPM only and update the function paths accordingly.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +14 -5
@@ -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; }
@@ -627,6 +628,10 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev) &adev->vm_manager.id_mgr[i];for_each_set_bit (j, id_mgr->vmid_mask,AMDGPU_NUM_VMID )amdgpu_vmid_reset (adev, i, j); + +/* out-of-pool VMID, not covered by vmid_mask */ +if (adev->vm_manager.spm_vmid &&AMDGPU_IS_GFXHUB (i)) +amdgpu_vmid_reset (adev, i, adev->vm_manager.spm_vmid); } }
@@ -711,6 +716,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); } }
Signature · 1 line
2.34.1
Christian König
maintainerRe: [PATCH v2 03/11] drm/amdgpu: use dedicated SPM VMID from the reserved path
Quoted 38 lines · Sunil Khatri
Use the spm vmid which is dedicated for the SPM only and update the function paths accordingly.
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +6
-5@@ -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; }
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_reset_all(struct amdgpu_device *adev) · line 632
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +2
-0@@ -627,6 +628,10 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev) &adev->vm_manager.id_mgr[i];for_each_set_bit (j, id_mgr->vmid_mask,AMDGPU_NUM_VMID )amdgpu_vmid_reset (adev, i, j); + +/* out-of-pool VMID, not covered by vmid_mask */
Better write "The SPM VMID is not part of the normal kernel pool, reset it anyway in case it is used with kernel queues.".
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_reset_all(struct amdgpu_device *adev) · line 633
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+if (adev->vm_manager.spm_vmid &&AMDGPU_IS_GFXHUB (i))
If would be nice if we could rather come up with a loop over the GFXHUBs only.
E.g. something like this:
for (i = AMDGPU_GFXHUB_START; i < AMDGPU_MMHUB0_START; ++i)
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_mgr_init(struct amdgpu_device *adev) · line 720
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +3
-0+amdgpu_vmid_reset (adev, i, adev->vm_manager.spm_vmid); } }@@ -711,6 +716,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 */
Something similar here.
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_mgr_init(struct amdgpu_device *adev) · line 721
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+if (adev->vm_manager.spm_vmid &&AMDGPU_IS_GFXHUB (i))
Same for loop here as well.
Regards,
Christian.
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+amdgpu_sync_create (&id_mgr->ids[adev->vm_manager.spm_vmid].active); } }
Re: [PATCH v2 03/11] drm/amdgpu: use dedicated SPM VMID from the reserved path
Quoted 32 lines · Christian König
Quoted 30 lines · Sunil Khatri
Use the spm vmid which is dedicated for the SPM only and update the function paths accordingly.
Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +6
-3@@ -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,
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_reset_all(struct amdgpu_device *adev) · line 632
Quoted 13 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +2
-2mutex_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; }@@ -627,6 +628,10 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev) &adev->vm_manager.id_mgr[i];for_each_set_bit (j, id_mgr->vmid_mask,AMDGPU_NUM_VMID )amdgpu_vmid_reset (adev, i, j); + +/* out-of-pool VMID, not covered by vmid_mask */ Better write "The SPM VMID is not part of the normal kernel pool, reset it anyway in case it is used with kernel queues.".
Noted
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_reset_all(struct amdgpu_device *adev) · line 633
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+if (adev->vm_manager.spm_vmid &&AMDGPU_IS_GFXHUB (i))If would be nice if we could rather come up with a loop over the GFXHUBs only.
let me see to that.
Quoted 9 lines
E.g. something like this:
for (i =
AMDGPU_GFXHUB_START; i <AMDGPU_MMHUB0_START; ++i)Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+amdgpu_vmid_reset (adev, i, adev->vm_manager.spm_vmid); } }
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_mgr_init(struct amdgpu_device *adev) · line 720
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +2
-0@@ -711,6 +716,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 */ Something similar here.
Noted
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c void amdgpu_vmid_mgr_init(struct amdgpu_device *adev) · line 721
Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+if (adev->vm_manager.spm_vmid &&AMDGPU_IS_GFXHUB (i))Same for loop here as well.
Noted
Regards
Sunil Khatri
Quoted 8 lines
Regards,
Christian.Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +1
-0+amdgpu_sync_create (&id_mgr->ids[adev->vm_manager.spm_vmid].active); } }
PATCH v2 4/11 drm/amdgpu: reserve SPM VMID on gfx7
In reply to Sunil KhatriSet 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.
--- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4 -0
@@ -1008,6 +1008,10 @@ static int gmc_v7_0_sw_init(struct amdgpu_ip_block *ip_block)* amdkfd/MES user queues will use VMIDs 8-15 */ vmid_mask =GENMASK (7 ,1 ); + +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev, vmid_mask, vmid_mask);amdgpu_vm_manager_init (adev);
Signature · 1 line
2.34.1
Christian König
maintainerRe: [PATCH v2 04/11] drm/amdgpu: reserve SPM VMID on gfx7
Quoted 5 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.
Signed-off-by Sunil Khatri <[email protected]>
Patches #4-#9 are Reviewed-by: Christian König <[email protected]>
Quoted 19 lines
--- drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4
-0@@ -1008,6 +1008,10 @@ static int gmc_v7_0_sw_init(struct amdgpu_ip_block *ip_block)* amdkfd/MES user queues will use VMIDs 8-15 */ vmid_mask =GENMASK (7 ,1 ); + +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev, vmid_mask, vmid_mask);amdgpu_vm_manager_init (adev);
PATCH v2 5/11 drm/amdgpu: reserve SPM VMID on gfx8
In reply to Sunil KhatriSet vm_manager.spm_vmid to the top GFXHUB VMID so the SPM reservation path hands out a fixed, isolated VMID on gfx8 instead of borrowing one from the graphics pool.
--- drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +4 -0
@@ -1123,6 +1123,10 @@ static int gmc_v8_0_sw_init(struct amdgpu_ip_block *ip_block)* amdkfd/MES user queues will use VMIDs 8-15 */ vmid_mask =GENMASK (7 ,1 ); + +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev, vmid_mask, vmid_mask);amdgpu_vm_manager_init (adev);
Signature · 1 line
2.34.1
PATCH v2 6/11 drm/amdgpu: reserve SPM VMID on gfx9
In reply to Sunil KhatriSet vm_manager.spm_vmid to the top GFXHUB VMID so the SPM reservation path hands out a fixed, isolated VMID on gfx9 instead of borrowing one from the graphics pool.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +4 -0
@@ -2042,6 +2042,10 @@ static int gmc_v9_0_sw_init(struct amdgpu_ip_block *ip_block)7 ; vmid_mask =GENMASK (last_kq_vmid,1 ); + +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev, vmid_mask, vmid_mask);amdgpu_vm_manager_init (adev);
Signature · 1 line
2.34.1
PATCH v2 7/11 drm/amdgpu: reserve SPM VMID on gfx10
In reply to Sunil KhatriSet vm_manager.spm_vmid to the top GFXHUB VMID so the SPM reservation path hands out a fixed, isolated VMID on gfx10 instead of borrowing one from the graphics pool.
--- drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +4 -0
@@ -869,6 +869,10 @@ static int gmc_v10_0_sw_init(struct amdgpu_ip_block *ip_block)* amdgpu graphics/compute kernel queues will use VMIDs 1-7 * amdkfd/MES user queues will use VMIDs 8-15 */ + +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev,GENMASK (7 ,1 ),GENMASK (AMDGPU_NUM_VMID -1 ,1 ));
Signature · 1 line
2.34.1
PATCH v2 8/11 drm/amdgpu: reserve SPM VMID on gfx11
In reply to Sunil KhatriSet vm_manager.spm_vmid to the top GFXHUB VMID so the SPM reservation path hands out a fixed, isolated VMID on gfx11 instead of borrowing one from the graphics pool.
--- drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v11_0.c +4 -0
@@ -856,6 +856,10 @@ static int gmc_v11_0_sw_init(struct amdgpu_ip_block *ip_block)* amdkfd/MES user queues will use VMIDs 8-15 */ last_kq_vmid = adev->gfx.disable_kq ?0 :7 ; + +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev,GENMASK (last_kq_vmid,1 ),GENMASK (AMDGPU_NUM_VMID -1 ,1 ));
Signature · 1 line
2.34.1
PATCH v2 9/11 drm/amdgpu: reserve SPM VMID on gfx12
In reply to Sunil KhatriSet vm_manager.spm_vmid to the top GFXHUB VMID so the SPM reservation path hands out a fixed, isolated VMID on gfx12 instead of borrowing one from the graphics pool. This also covers gfx12.1, whose VMID setup is handled in this file.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +3 -0
@@ -1006,6 +1006,9 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)if (adev->gfx.disable_kq) last_kq_vmid =0 ; +/* Reserve the last VMID for SPM */ + adev->vm_manager.spm_vmid =AMDGPU_NUM_VMID -1 ; +amdgpu_vmid_mgr_set_vmid_mask (adev,GENMASK (last_kq_vmid,1 ),GENMASK (AMDGPU_NUM_VMID -1 ,1 ));
Signature · 1 line
2.34.1
PATCH v2 10/11 drm/amdgpu: use spm_vmid for the default RLC SPM VMID
In reply to Sunil KhatriThe 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).
--- 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
@@ -5575,7 +5575,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);
@@ -5607,7 +5607,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
@@ -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
@@ -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
@@ -1861,7 +1861,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
@@ -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
@@ -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
@@ -3233,7 +3233,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
@@ -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 ; }
Signature · 1 line
2.34.1
Re: [PATCH v2 10/11] drm/amdgpu: use spm_vmid for the default RLC SPM VMID
Quoted 9 lines · Sunil Khatri
The RLC bring-up paths programmed the
RLC_SPM_VMIDfield to a hardcoded0xfas 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_vmidis the top VMID (0xf) on all affected generations (gfx7 through gfx12).Signed-off-by Sunil Khatri <[email protected]>
Quoted 124 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@@ -5575,7 +5575,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);@@ -5607,7 +5607,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@@ -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@@ -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@@ -1861,7 +1861,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@@ -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@@ -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);AMDGPU_MMHUB0_START return 0; }drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -3233,7 +3233,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@@ -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 ; }
PATCH v2 11/11 drm/amdgpu: remove the now-redundant runtime SPM VMID update
In reply to Sunil KhatriThe SPM reserved VMID is fixed now, so retargeting RLC_SPM_VMID to job->vmid on every submission is dead code. Remove job->spm_update_needed and the update_spm_vmid() calls in amdgpu_vm_flush() and amdgpu_ib_schedule().
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 7 +------ drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +-- 5 files changed, 3 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1 -6
@@ -126,7 +126,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,struct amdgpu_fence *af;struct amdgpu_fence *vm_af;bool need_ctx_switch; -bool emit_spm_needed = false;bool emit_gds_needed = false;uint64_t fence_ctx;uint32_t status =0 , alloc_size;
@@ -195,8 +194,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,/* VM sequence */ vm_af->ib_wptr = ring->wptr; -amdgpu_vm_flush (ring, job, &need_pipe_sync, &emit_spm_needed, - &emit_gds_needed); +amdgpu_vm_flush (ring, job, &need_pipe_sync, &emit_gds_needed); vm_af->ib_dw_size =amdgpu_ring_get_dw_distance (ring, vm_af->ib_wptr, ring->wptr);
@@ -211,9 +209,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,if (need_pipe_sync)amdgpu_ring_emit_pipeline_sync (ring); -if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); -if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, job->gds_size, job->gws_base,
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0 -1
@@ -372,7 +372,6 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,return r; job->vm_needs_flush = needs_flush; - job->spm_update_needed = true;return 0 ; }
drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +0 -1
@@ -75,7 +75,6 @@ struct amdgpu_job {uint32_t preemption_status;bool vm_needs_flush;bool gds_switch_needed; -bool spm_update_needed;uint64_t vm_pd_addr;unsigned vmid;unsigned pasid;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -14
@@ -766,14 +766,12 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,* @ring: ring to use for flush * @job: related job * @need_pipe_sync: is pipe sync needed -* @emit_spm_needed: does the caller need to emit spm * @emit_gds_needed: does the caller need to emit gds * * Emit a VM flush when it is necessary. */ void amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job, -bool *need_pipe_sync,bool *emit_spm_needed, -bool *emit_gds_needed) +bool *need_pipe_sync,bool *emit_gds_needed) {struct amdgpu_device *adev = ring->adev; struct amdgpu_isolation *isolation =
@@ -782,8 +780,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,unsigned vmhub = ring->vm_hub;struct amdgpu_kq_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];struct amdgpu_vmid *id = &id_mgr->ids[job->vmid]; -bool spm_update_needed = adev->gfx.rlc.funcs->update_spm_vmid && - job->spm_update_needed;bool gds_switch_needed = ring->funcs->emit_gds_switch && job->gds_switch_needed;bool vm_flush_needed = job->vm_needs_flush;
@@ -797,7 +793,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true; - spm_update_needed = true; }mutex_lock (&id_mgr->lock);
@@ -807,7 +802,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,mutex_unlock (&id_mgr->lock); gds_switch_needed &= !!ring->funcs->emit_gds_switch; - spm_update_needed &= !!adev->gfx.rlc.funcs->update_spm_vmid; vm_flush_needed &= !!ring->funcs->emit_vm_flush && job->vm_pd_addr !=AMDGPU_BO_INVALID_OFFSET ; pasid_mapping_needed &= adev->gmc.gmc_funcs->emit_pasid_mapping &&
@@ -821,10 +815,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, emit_fence = vm_flush_needed || pasid_mapping_needed || cleaner_shader_needed; - *emit_spm_needed = spm_update_needed; -if (spm_update_needed && emit_fence) - *emit_spm_needed = false; - *emit_gds_needed = gds_switch_needed;if (gds_switch_needed && emit_fence) *emit_gds_needed = false;
@@ -864,9 +854,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (pasid_mapping_needed)amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid); -if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); -if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, job->gds_size, job->gws_base,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -2
@@ -448,8 +448,7 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,int (*callback)(void *p,struct amdgpu_bo *bo), void *param);void amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job, -bool *need_pipe_sync,bool *emit_spm_needed, -bool *emit_gds_needed); +bool *need_pipe_sync,bool *emit_gds_needed);int amdgpu_vm_update_pdes (struct amdgpu_device *adev,struct amdgpu_vm *vm,bool immediate); int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
Signature · 1 line
2.34.1
Re: [PATCH v2 11/11] drm/amdgpu: remove the now-redundant runtime SPM VMID update
Quoted 7 lines · Sunil Khatri
The SPM reserved VMID is fixed now, so retargeting
RLC_SPM_VMIDtojob->vmidon every submission is dead code. Removejob->spm_update_neededand theupdate_spm_vmid()calls inamdgpu_vm_flush()andamdgpu_ib_schedule().Signed-off-by Sunil Khatri <[email protected]>Suggested-by Christian König <[email protected]>
We should also have another patch which removes the ring parameter from adev->gfx.rlc.funcs->update_spm_vmid().
What's left is comming up with an SPM test case and eventually getting it to work with user queues (shouldn't be to hard).
Regards,
Christian.
Quoted 144 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 7 +------ drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +-- 5 files changed, 3 insertions(+), 24 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-6@@ -126,7 +126,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,struct amdgpu_fence *af;struct amdgpu_fence *vm_af;bool need_ctx_switch; -bool emit_spm_needed = false;bool emit_gds_needed = false;uint64_t fence_ctx;uint32_t status =0 , alloc_size;@@ -195,8 +194,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,/* VM sequence */ vm_af->ib_wptr = ring->wptr; -amdgpu_vm_flush (ring, job, &need_pipe_sync, &emit_spm_needed, - &emit_gds_needed); +amdgpu_vm_flush (ring, job, &need_pipe_sync, &emit_gds_needed); vm_af->ib_dw_size =amdgpu_ring_get_dw_distance (ring, vm_af->ib_wptr, ring->wptr);@@ -211,9 +209,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,if (need_pipe_sync)amdgpu_ring_emit_pipeline_sync (ring); -if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); -if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, job->gds_size, job->gws_base,drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0
-1@@ -372,7 +372,6 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,return r; job->vm_needs_flush = needs_flush; - job->spm_update_needed = true;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +0
-1@@ -75,7 +75,6 @@ struct amdgpu_job {uint32_t preemption_status;bool vm_needs_flush;bool gds_switch_needed; -bool spm_update_needed;uint64_t vm_pd_addr;unsigned vmid;unsigned pasid;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-14@@ -766,14 +766,12 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,* @ring: ring to use for flush * @job: related job * @need_pipe_sync: is pipe sync needed -* @emit_spm_needed: does the caller need to emit spm * @emit_gds_needed: does the caller need to emit gds * * Emit a VM flush when it is necessary. */ void amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job, -bool *need_pipe_sync,bool *emit_spm_needed, -bool *emit_gds_needed) +bool *need_pipe_sync,bool *emit_gds_needed) {struct amdgpu_device *adev = ring->adev; struct amdgpu_isolation *isolation =@@ -782,8 +780,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,unsigned vmhub = ring->vm_hub;struct amdgpu_kq_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];struct amdgpu_vmid *id = &id_mgr->ids[job->vmid]; -bool spm_update_needed = adev->gfx.rlc.funcs->update_spm_vmid && - job->spm_update_needed;bool gds_switch_needed = ring->funcs->emit_gds_switch && job->gds_switch_needed;bool vm_flush_needed = job->vm_needs_flush;@@ -797,7 +793,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true; - spm_update_needed = true; }mutex_lock (&id_mgr->lock);@@ -807,7 +802,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,mutex_unlock (&id_mgr->lock); gds_switch_needed &= !!ring->funcs->emit_gds_switch; - spm_update_needed &= !!adev->gfx.rlc.funcs->update_spm_vmid; vm_flush_needed &= !!ring->funcs->emit_vm_flush && job->vm_pd_addr !=AMDGPU_BO_INVALID_OFFSET ; pasid_mapping_needed &= adev->gmc.gmc_funcs->emit_pasid_mapping &&@@ -821,10 +815,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, emit_fence = vm_flush_needed || pasid_mapping_needed || cleaner_shader_needed; - *emit_spm_needed = spm_update_needed; -if (spm_update_needed && emit_fence) - *emit_spm_needed = false; - *emit_gds_needed = gds_switch_needed;if (gds_switch_needed && emit_fence) *emit_gds_needed = false;@@ -864,9 +854,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (pasid_mapping_needed)amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid); -if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); -if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, job->gds_size, job->gws_base,drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1
-2@@ -448,8 +448,7 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,int (*callback)(void *p,struct amdgpu_bo *bo), void *param);void amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job, -bool *need_pipe_sync,bool *emit_spm_needed, -bool *emit_gds_needed); +bool *need_pipe_sync,bool *emit_gds_needed);int amdgpu_vm_update_pdes (struct amdgpu_device *adev,struct amdgpu_vm *vm,bool immediate); int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
Re: [PATCH v2 11/11] drm/amdgpu: remove the now-redundant runtime SPM VMID update
Quoted 11 lines · Christian König
Quoted 7 lines · Sunil Khatri
The SPM reserved VMID is fixed now, so retargeting
RLC_SPM_VMIDtojob->vmidon every submission is dead code. Removejob->spm_update_neededand theupdate_spm_vmid()calls inamdgpu_vm_flush()andamdgpu_ib_schedule().Signed-off-by Sunil Khatri <[email protected]>Suggested-by Christian König <[email protected]>Reviewed-by Christian König <[email protected]>We should also have another patch which removes the ring parameter from
adev->gfx.rlc.funcs->update_spm_vmid().
Sure... There is another patch that i kept for the end and will send in the updated v3. This is to set the pagetable for vmid15.
Quoted 2 lines
What's left is comming up with an SPM test case and eventually getting it to work with user queues (shouldn't be to hard).
sure, here i might need some more input since i am really clear about the exact usecase or how to validate it..
Regards
Sunil Khatri
Quoted 148 lines
Regards,
Christian.Quoted 144 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 7 +------ drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_job.h | 1 - drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 15 +-------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 3 +-- 5 files changed, 3 insertions(+), 24 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c +1
-6@@ -126,7 +126,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,struct amdgpu_fence *af;struct amdgpu_fence *vm_af;bool need_ctx_switch; -bool emit_spm_needed = false;bool emit_gds_needed = false;uint64_t fence_ctx;uint32_t status =0 , alloc_size;@@ -195,8 +194,7 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,/* VM sequence */ vm_af->ib_wptr = ring->wptr; -amdgpu_vm_flush (ring, job, &need_pipe_sync, &emit_spm_needed, - &emit_gds_needed); +amdgpu_vm_flush (ring, job, &need_pipe_sync, &emit_gds_needed); vm_af->ib_dw_size =amdgpu_ring_get_dw_distance (ring, vm_af->ib_wptr, ring->wptr);@@ -211,9 +209,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, struct amdgpu_job *job,if (need_pipe_sync)amdgpu_ring_emit_pipeline_sync (ring); -if (emit_spm_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); -if (emit_gds_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, job->gds_size, job->gws_base,drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +0
-1@@ -372,7 +372,6 @@ static int amdgpu_vmid_grab_reserved(struct amdgpu_vm *vm,return r; job->vm_needs_flush = needs_flush; - job->spm_update_needed = true;return 0 ; }drivers/gpu/drm/amd/amdgpu/amdgpu_job.h +0
-1@@ -75,7 +75,6 @@ struct amdgpu_job {uint32_t preemption_status;bool vm_needs_flush;bool gds_switch_needed; -bool spm_update_needed;uint64_t vm_pd_addr;unsigned vmid;unsigned pasid;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-14@@ -766,14 +766,12 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,* @ring: ring to use for flush * @job: related job * @need_pipe_sync: is pipe sync needed -* @emit_spm_needed: does the caller need to emit spm * @emit_gds_needed: does the caller need to emit gds * * Emit a VM flush when it is necessary. */ void amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job, -bool *need_pipe_sync,bool *emit_spm_needed, -bool *emit_gds_needed) +bool *need_pipe_sync,bool *emit_gds_needed) {struct amdgpu_device *adev = ring->adev; struct amdgpu_isolation *isolation =@@ -782,8 +780,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,unsigned vmhub = ring->vm_hub;struct amdgpu_kq_vmid_mgr *id_mgr = &adev->vm_manager.id_mgr[vmhub];struct amdgpu_vmid *id = &id_mgr->ids[job->vmid]; -bool spm_update_needed = adev->gfx.rlc.funcs->update_spm_vmid && - job->spm_update_needed;bool gds_switch_needed = ring->funcs->emit_gds_switch && job->gds_switch_needed;bool vm_flush_needed = job->vm_needs_flush;@@ -797,7 +793,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, gds_switch_needed = true; vm_flush_needed = true; pasid_mapping_needed = true; - spm_update_needed = true; }mutex_lock (&id_mgr->lock);@@ -807,7 +802,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,mutex_unlock (&id_mgr->lock); gds_switch_needed &= !!ring->funcs->emit_gds_switch; - spm_update_needed &= !!adev->gfx.rlc.funcs->update_spm_vmid; vm_flush_needed &= !!ring->funcs->emit_vm_flush && job->vm_pd_addr !=AMDGPU_BO_INVALID_OFFSET ; pasid_mapping_needed &= adev->gmc.gmc_funcs->emit_pasid_mapping &&@@ -821,10 +815,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job, emit_fence = vm_flush_needed || pasid_mapping_needed || cleaner_shader_needed; - *emit_spm_needed = spm_update_needed; -if (spm_update_needed && emit_fence) - *emit_spm_needed = false; - *emit_gds_needed = gds_switch_needed;if (gds_switch_needed && emit_fence) *emit_gds_needed = false;@@ -864,9 +854,6 @@ void amdgpu_vm_flush(struct amdgpu_ring *ring, struct amdgpu_job *job,if (pasid_mapping_needed)amdgpu_gmc_emit_pasid_mapping (ring, job->vmid, job->pasid); -if (spm_update_needed) - adev->gfx.rlc.funcs->update_spm_vmid (adev, ring->xcc_id, ring, job->vmid); -if (gds_switch_needed) amdgpu_ring_emit_gds_switch(ring, job->vmid, job->gds_base, job->gds_size, job->gws_base,drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1
-2@@ -448,8 +448,7 @@ int amdgpu_vm_validate(struct amdgpu_device *adev, struct amdgpu_vm *vm,int (*callback)(void *p,struct amdgpu_bo *bo), void *param);void amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job, -bool *need_pipe_sync,bool *emit_spm_needed, -bool *emit_gds_needed); +bool *need_pipe_sync,bool *emit_gds_needed);int amdgpu_vm_update_pdes (struct amdgpu_device *adev,struct amdgpu_vm *vm,bool immediate); int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
Quoted 4 lines · Sunil Khatri
Fix the ambiguous names in amdgpu_vmid_mgr_set_vmid_mask()'s parameters so there is no confusion.
Signed-off-by Sunil Khatri <[email protected]>
Quoted 72 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 16 ++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c +8
-8@@ -635,13 +635,13 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)* pools for both hubs * * @adev: amdgpu device structure -* @gfx_vmid_mask: kernel-queue VMID pool mask for GFXHUB -* @mmhub_vmid_mask: kernel-queue VMID pool mask for MMHUB +* @vmid_kq_mask_gfxhub: kernel-queue VMID pool mask for GFXHUB +* @vmid_kq_mask_mmhub: kernel-queue VMID pool mask for MMHUB * * Sets both hubs' kernel-queue VMID pools (tracked least-recently-used * via id_mgr[].ids_lru), and both hubs' KFD/MES user-queue masks. * vmid_uq_mask_gfxhub is set to the -* complement of @gfx_vmid_mask, since unlike MMHUB's it is always a +* complement of @vmid_kq_mask_gfxhub, since unlike MMHUB's it is always a * clean partition of the full VMID range; vmid_uq_mask_mmhub is the * fixed pool set here instead, since MMHUB's kq and uq pools are * allowed to overlap. A VMID dedicated to a single fixed purpose on @@ -649,26 +649,26 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev)* caller's responsibility to have already set npa_vmid. */ void amdgpu_vmid_mgr_set_vmid_mask (struct amdgpu_device *adev, -unsigned long gfx_vmid_mask, -unsigned long mmhub_vmid_mask) +unsigned long vmid_kq_mask_gfxhub, +unsigned long vmid_kq_mask_mmhub) {unsigned int i;BUILD_BUG_ON (AMDGPU_NUM_VMID >BITS_PER_LONG );if (adev->vm_manager.npa_vmid) - mmhub_vmid_mask &= ~BIT (adev->vm_manager.npa_vmid); + vmid_kq_mask_mmhub &= ~BIT (adev->vm_manager.npa_vmid);for (i =0 ; i <AMDGPU_MAX_VMHUBS ; i++) {bool is_mmhub =AMDGPU_IS_MMHUB0 (i) ||AMDGPU_IS_MMHUB1 (i);bitmap_copy (adev->vm_manager.id_mgr[i].vmid_mask, - is_mmhub ? &mmhub_vmid_mask : &gfx_vmid_mask, + is_mmhub ? &vmid_kq_mask_mmhub : &vmid_kq_mask_gfxhub,AMDGPU_NUM_VMID ); } adev->vm_manager.vmid_uq_mask_gfxhub = -GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~gfx_vmid_mask; +GENMASK (AMDGPU_NUM_VMID -1 ,1 ) & ~vmid_kq_mask_gfxhub; adev->vm_manager.vmid_uq_mask_mmhub =0xFF00 ;if (adev->vm_manager.npa_vmid)drivers/gpu/drm/amd/amdgpu/amdgpu_ids.h +2
-2@@ -135,7 +135,7 @@ void amdgpu_vmid_reset_all(struct amdgpu_device *adev);void amdgpu_vmid_mgr_init (struct amdgpu_device *adev);void amdgpu_vmid_mgr_fini (struct amdgpu_device *adev);void amdgpu_vmid_mgr_set_vmid_mask (struct amdgpu_device *adev, -unsigned long gfx_vmid_mask, -unsigned long mmhub_vmid_mask); +unsigned long vmid_kq_mask_gfxhub, +unsigned long vmid_kq_mask_mmhub);#endif