drm/amdgpu: Flush TLB after mapping for VG20+XGMI
Subsystems (2)
PATCH 1/1 drm/amdgpu: Flush TLB after mapping for VG20+XGMI
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always flush_tlb after updating mapping.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -0
@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_unlock; } +/* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/ + flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,0 )); +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;
Signature · 1 line
2.35.1
Am 01.04.22 um 21:57 schrieb Philip Yang:
Quoted 5 lines
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
flush_tlbafter updating mapping.Signed-off-by Philip Yang <[email protected]>
You could drop the extra (), but either way Reviewed-by: Christian König <[email protected]>.
Quoted 21 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6
-0@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_unlock; } +/* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/ + flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,0 )); +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;
Dear Philip,
Thank you for your patch.
Am 01.04.22 um 21:57 schrieb Philip Yang:
Quoted 2 lines
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
Can you please rephrase. “may have stall …” is really hard to understand.
Quoted 1 line
flush_tlbafter updating mapping.
Maybe:
So, always flush_tlb after updating the mapping.
Quoted 12 lines
Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_unlock; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 848
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6
-0+/* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/ + flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,0 )); +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;
Did you do any performance measurement, if that flushing affects anything?
Kind regards,
Paul
On 2022-04-04 12:19, Paul Menzel wrote:
Dear Philip,
Thank you for your patch.
Am 01.04.22 um 21:57 schrieb Philip Yang:
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
Can you please rephrase. “may have stall …” is really hard to understand. The patch already pushed and merged.
flush_tlb after updating mapping.
Maybe:
So, always flush_tlb after updating the mapping.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++
1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm,
goto error_unlock;
}
+ /* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, + * heavy-weight flush TLB unconditionally.
+ */
+ flush_tlb |= (adev->gmc.xgmi.num_physical_nodes &&
+ adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 0)); +
memset(¶ms, 0, sizeof(params));
params.adev = adev;
params.vm = vm;
Did you do any performance measurement, if that flushing affects anything?
There was another patch to optimize TLB flush to improve map to GPU performance, for this config, always flush TLB after updating mapping is the original performance before the optimization.
Regards,
Philip
Kind regards,
Paul
Am 2022-04-04 um 12:19 schrieb Paul Menzel:
Quoted 33 lines
Dear Philip,
Thank you for your patch.
Am 01.04.22 um 21:57 schrieb Philip Yang:
Quoted 2 lines
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
Can you please rephrase. “may have stall …” is really hard to understand.
Quoted 1 line
flush_tlbafter updating mapping.Maybe:
So, always
flush_tlbafter updating the mapping.Quoted 16 lines
Signed-off-by Philip Yang <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 6 ++++++1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-0@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_unlock; } + /* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3
-0+ flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP][0] == IP_VERSION(9, 4, 0)); + memset(¶ms, 0, sizeof(params)); params.adev = adev;params.vm = vm;
Did you do any performance measurement, if that flushing affects anything?
There probably is a performance impact. However, this fix is needed for correctness. And it is very specific to this GPU configuration (at least two Vega20 GPUs with an XGMI bridge between them). This fixes a regression that was introduced by recent changes to the TLB flushing code. The workaround was originally introduced maybe 4 years ago.
Regards,
Felix
Quoted 5 lines
Kind regards,
Paul
Dear Philip,
Thank you for your response.
Am 04.04.22 um 18:52 schrieb philip yang:
Quoted 8 lines · Paul Menzel
Quoted 6 lines
Am 01.04.22 um 21:57 schrieb Philip Yang:
Quoted 2 lines
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
Can you please rephrase. “may have stall …” is really hard to understand.
The patch already pushed and merged.
Sorry, but that really sucks, that commits with such a hard to understand commit message are merged.
Quoted 31 lines
Quoted 22 lines
Quoted 1 line
flush_tlbafter updating mapping.Maybe:
So, always
flush_tlbafter updating the mapping.Quoted 16 lines
Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-0@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev,struct amdgpu_vm *vm, goto error_unlock; } + /* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/ Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_update_range(struct amdgpu_device *adev,
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3
-0+ flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,0 )); +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;Did you do any performance measurement, if that flushing affects anything?
Quoted 3 lines
There was another patch to optimize TLB flush to improve map to GPU performance, for this config, always flush TLB after updating mapping is the original performance before the optimization.
So, why didn’t you reference this commit in the commit message, and also did not give that information in the commit message?
Kind regards,
Paul
Quoted 16 lines · Philip Yang
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
flush_tlbafter updating mapping.Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_unlock; }
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 848
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6
-0+/* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/ + flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,0 )); +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;
On top of what commit does this work?
It does not apply at top of v5.18-rc1.
It does apply, but fails to compile, on top of "drm/amdkfd: Create file descriptor after client is added to smi_clients list" that is commit:
* cbe879c87245ce6272afe6456dbc8ce2c8f38d64 in amd-staging-drm-next
* e45422695c196dbc665a95526c85ff4b8752aff2 in drm-next
fetched from https://gitlab.freedesktop.org/agd5f/linux.git
The compile error is due to flush_tlb being undeclared.
Best Regards,
Tomasz Mon
Quoted 31 lines · Tomasz Moń
Quoted 16 lines · Philip Yang
For VG20 + XGMI bridge, all mappings PTEs cache in TC, this may have stall invalid PTEs in TC because one cache line has 8 pages. Need always
flush_tlbafter updating mapping.Signed-off-by Philip Yang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++++ 1 file changed, 6 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -837,6 +837,12 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, goto error_unlock; }drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm, · line 848
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6
-0+/* Vega20+XGMI where PTEs get inadvertently cached in L2 texture cache, +* heavy-weight flush TLB unconditionally. +*/ + flush_tlb |= (adev->gmc.xgmi.num_physical_nodes && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,0 )); +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;On top of what commit does this work?
Quoted 1 line
It does not apply at top of v5.18-rc1.
This is stuff for drm-next
(https://gitlab.freedesktop.org/agd5f/linux/-/commits/drm-next).
E.g., 5.19.
Alex
Quoted 11 lines
It does apply, but fails to compile, on top of "drm/amdkfd: Create file descriptor after client is added to
smi_clientslist" that is commit:
*cbe879c87245ce6272afe6456dbc8ce2c8f38d64in amd-staging-drm-next
*e45422695c196dbc665a95526c85ff4b8752aff2in drm-next
fetched from https://gitlab.freedesktop.org/agd5f/linux.gitThe compile error is due to
flush_tlbbeing undeclared.Best Regards,
Tomasz Mon
Quoted 8 lines · Alex Deucher
Quoted 3 lines · Tomasz Moń
On top of what commit does this work?
It does not apply at top of v5.18-rc1.
This is stuff for drm-next
(https://gitlab.freedesktop.org/agd5f/linux/-/commits/drm-next).
E.g., 5.19.
This does not compile on current drm-next, just like I noted in the next paragraph of my email.
Quoted 10 lines
Quoted 10 lines
It does apply, but fails to compile, on top of "drm/amdkfd: Create file
descriptor after client is added tosmi_clientslist" that is commit:
*cbe879c87245ce6272afe6456dbc8ce2c8f38d64in amd-staging-drm- next
*e45422695c196dbc665a95526c85ff4b8752aff2in drm-next fetched from https://gitlab.freedesktop.org/agd5f/linux.gitThe compile error is due to
flush_tlbbeing undeclared.
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c: In function ‘amdgpu_vm_bo_update_mapping’:drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:845:9: error: ‘flush_tlb’ undeclared (first use in this function); did you mean ‘kfd_flush_tlb’?
845 | flush_tlb |= (adev->gmc.xgmi.num_physical_nodes &&
| ^~~~~~~~~
| kfd_flush_tlbdrivers/gpu/drm/amd/amdgpu/amdgpu_vm.c:845:9: note: each undeclared identifier is reported only once for each function it appears in
Best Regards,
Tomasz Mon