drm/amdgpu/bu: Use legacy TLB flush for gfx943
Subsystems (3)
Alex Deucher
maintainerPATCH 1/6 drm/amdgpu/bu: Use legacy TLB flush for gfx943
From: Graham Sider <[email protected]>
Invalidate TLBs via a legacy flush request (flush_type=0) prior to the heavyweight flush requests (flush_type=2) in gmc_v9_0.c. This is temporarily required to mitigate a bug causing CPC UTCL1 to return stale translations after invalidation requests in address range mode.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +17 -0
@@ -833,6 +833,14 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ inv_req =gmc_v9_0_get_invalidate_req (vmid,2 ); inv_req2 =gmc_v9_0_get_invalidate_req (vmid, flush_type); + }else if (flush_type ==2 && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,3 )) { +/* FIXME: Temporarily add a legacy flush (type 0) before heavyweight +* flush for gfx943 to mitigate a bug which causes CPC UTCL1 to return +* stale translations even after TLB heavyweight flush. +*/ + inv_req =gmc_v9_0_get_invalidate_req (vmid,0 ); + inv_req2 =gmc_v9_0_get_invalidate_req (vmid, flush_type); }else { inv_req =gmc_v9_0_get_invalidate_req (vmid, flush_type); inv_req2 =0 ;
@@ -976,6 +984,15 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (vega20_xgmi_wa) kiq->pmf->kiq_invalidate_tlbs (ring, pasid,2 , all_hub); + +/* FIXME: Temporarily add a legacy flush (type 0) before heavyweight +* flush for gfx943 to mitigate a bug which causes CPC UTCL1 to return +* stale translations even after TLB heavyweight flush. +*/ +if (flush_type ==2 && adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,3 )) + kiq->pmf->kiq_invalidate_tlbs (ring, + pasid,0 , all_hub); + kiq->pmf->kiq_invalidate_tlbs (ring, pasid, flush_type, all_hub); r =amdgpu_fence_emit_polling (ring, &seq,MAX_KIQ_REG_WAIT );
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 2/6 drm/amdgpu/bu: Add use_mtype_cc_wa module param
From: Graham Sider <[email protected]>
By default, set use_mtype_cc_wa to 1 to set PTE coherence flag MTYPE_CC instead of MTYPE_RW by default. This is required for the time being to mitigate a bug causing XCCs to hit stale data due to TCC marking fully dirty lines as exclusive.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 7 +++++++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 10 +++++++--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 7 +++++-- 4 files changed, 20 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -213,6 +213,7 @@ extern int amdgpu_noretry;extern int amdgpu_force_asic_type;extern int amdgpu_smartshift_bias;extern int amdgpu_use_xgmi_p2p; +extern bool amdgpu_use_mtype_cc_wa;#ifdef CONFIG_HSA_AMD extern int sched_policy;extern bool debug_evictions;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +7 -0
@@ -831,6 +831,13 @@ MODULE_PARM_DESC(no_queue_eviction_on_vm_fault, "No queue eviction on VM fault (module_param_named (no_queue_eviction_on_vm_fault, amdgpu_no_queue_eviction_on_vm_fault, int,0444 );#endif +/** +* DOC: use_mtype_cc_wa (bool) +*/ +bool amdgpu_use_mtype_cc_wa = true; +MODULE_PARM_DESC (use_mtype_cc_wa,"Use MTYPE_CC workaround (0 = use MTYPE_RW where applicable, 1 = use MTYPE_CC where applicable (default))" ); +module_param_named (use_mtype_cc_wa, amdgpu_use_mtype_cc_wa, bool,0444 ); +/** * DOC: pcie_p2p (bool) * Enable PCIe P2P (requires large-BAR). Default value: true (on)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +7 -3
@@ -1192,6 +1192,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,bool coherent = bo->flags &AMDGPU_GEM_CREATE_COHERENT ;bool uncached = bo->flags &AMDGPU_GEM_CREATE_UNCACHED ;unsigned int mtype; +unsigned int mtype_default;bool snoop = false;switch (adev->ip_versions[GC_HWIP ][0 ]) {
@@ -1235,7 +1236,10 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,/* FIXME: Needs more work for handling multiple memory * partitions (> NPS1 mode) e.g. NPS4 for both APU and dGPU * modes. +* FIXME: Temporarily using MTYPE_CC instead of MTYPE_RW where applicable. +* To force use of MTYPE_RW, set use_mtype_cc_wa=0 */ + mtype_default = amdgpu_use_mtype_cc_wa ?MTYPE_CC :MTYPE_RW ; snoop = true;if (uncached) { mtype =MTYPE_UC ;
@@ -1250,14 +1254,14 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,* socket should be treated as remote access so MTYPE_RW * cannot be used always. */ - mtype =MTYPE_RW ; + mtype = mtype_default; }else if (adev->flags &AMD_IS_APU ) {/* APU on carve out mode */ - mtype =MTYPE_RW ; + mtype = mtype_default; }else {/* dGPU */ if (is_vram && bo_adev == adev) - mtype =MTYPE_RW ; + mtype = mtype_default;else if (is_vram) mtype =MTYPE_NC ;else
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +5 -2
@@ -1197,9 +1197,12 @@ svm_range_get_pte_flags(struct kfd_node *node,if (uncached) { mapping_flags |=AMDGPU_VM_MTYPE_UC ; }else if (domain ==SVM_RANGE_VRAM_DOMAIN ) { -/* local HBM region close to partition */ +/* local HBM region close to partition +* FIXME: Temporarily using MTYPE_CC instead of MTYPE_RW where applicable. +* To force use of MTYPE_RW, set use_mtype_cc_wa=0 +*/ if (bo_node == node) - mapping_flags |=AMDGPU_VM_MTYPE_RW ; + mapping_flags |= amdgpu_use_mtype_cc_wa ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ;/* local HBM region far from partition or remote XGMI GPU */ else if (svm_nodes_in_same_hive (bo_node, node)) mapping_flags |=AMDGPU_VM_MTYPE_NC ;
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 3/6 drm/amdgpu: Fix per-BO MTYPE selection for GFXv9.4.3
In reply to Alex DeucherFrom: Felix Kuehling <[email protected]>
Treat system memory on NUMA systems as remote by default. Overriding with a more efficient MTYPE per page will be implemented in the next patch.
No need for a special case for APP APUs. System memory is handled the same for carve-out and native mode. And VRAM doesn't exist in native mode.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 40 +++++++++++---------------- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 24 +++++++++------- 2 files changed, 30 insertions(+), 34 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +16 -24
@@ -1191,9 +1191,10 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,bool is_vram = bo->tbo.resource->mem_type ==TTM_PL_VRAM ;bool coherent = bo->flags &AMDGPU_GEM_CREATE_COHERENT ;bool uncached = bo->flags &AMDGPU_GEM_CREATE_UNCACHED ; -unsigned int mtype; -unsigned int mtype_default; +/* TODO: memory partitions struct amdgpu_vm *vm = mapping->bo_va->base.vm;*/ +unsigned int mtype_local, mtype;bool snoop = false; +bool is_local;switch (adev->ip_versions[GC_HWIP ][0 ]) {case IP_VERSION (9 ,4 ,1 ):
@@ -1233,35 +1234,26 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev, }break ;case IP_VERSION (9 ,4 ,3 ): -/* FIXME: Needs more work for handling multiple memory -* partitions (> NPS1 mode) e.g. NPS4 for both APU and dGPU -* modes. -* FIXME: Temporarily using MTYPE_CC instead of MTYPE_RW where applicable. -* To force use of MTYPE_RW, set use_mtype_cc_wa=0 +/* Only local VRAM BOs or system memory on non-NUMA APUs +* can be assumed to be local in their entirety. Choose +* MTYPE_NC as safe fallback for all system memory BOs on +* NUMA systems. Their MTYPE can be overridden per-page in +* gmc_v9_0_override_vm_pte_flags. */ - mtype_default = amdgpu_use_mtype_cc_wa ?MTYPE_CC :MTYPE_RW ; + mtype_local = amdgpu_use_mtype_cc_wa ?MTYPE_CC :MTYPE_RW ; + is_local = (!is_vram && (adev->flags &AMD_IS_APU ) && +num_possible_nodes () <=1 ) || + (is_vram && adev == bo_adev/* TODO: memory partitions && +bo->mem_id == vm->mem_id*/ ); snoop = true;if (uncached) { mtype =MTYPE_UC ; - }else if (adev->gmc.is_app_apu) { -/* FIXME: APU in native mode, NPS1 single socket only -* -* For suporting NUMA partitioned APU e.g. in NPS4 mode, -* this need to look at the NUMA node on which the -* system memory allocation was done. -* -* Memory access by a different partition within same -* socket should be treated as remote access so MTYPE_RW -* cannot be used always. -*/ - mtype = mtype_default; }else if (adev->flags &AMD_IS_APU ) { -/* APU on carve out mode */ - mtype = mtype_default; + mtype = is_local ? mtype_local :MTYPE_NC ; }else {/* dGPU */ -if (is_vram && bo_adev == adev) - mtype = mtype_default; +if (is_local) + mtype = mtype_local;else if (is_vram) mtype =MTYPE_NC ;else
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +14 -10
@@ -1150,6 +1150,7 @@ svm_range_get_pte_flags(struct kfd_node *node,bool snoop = (domain !=SVM_RANGE_VRAM_DOMAIN );bool coherent = flags &KFD_IOCTL_SVM_FLAG_COHERENT ;bool uncached = flags &KFD_IOCTL_SVM_FLAG_UNCACHED ; +unsigned int mtype_local;if (domain ==SVM_RANGE_VRAM_DOMAIN ) bo_node = prange->svm_bo->node;
@@ -1190,19 +1191,16 @@ svm_range_get_pte_flags(struct kfd_node *node, }break ;case IP_VERSION (9 ,4 ,3 ): -//TODO: Need more work for handling multiple memory partitions -//e.g. NPS4. Current approch is only applicable without memory -//partitions. + mtype_local = amdgpu_use_mtype_cc_wa ?AMDGPU_VM_MTYPE_CC : +AMDGPU_VM_MTYPE_RW ; snoop = true;if (uncached) { mapping_flags |=AMDGPU_VM_MTYPE_UC ; }else if (domain ==SVM_RANGE_VRAM_DOMAIN ) { -/* local HBM region close to partition -* FIXME: Temporarily using MTYPE_CC instead of MTYPE_RW where applicable. -* To force use of MTYPE_RW, set use_mtype_cc_wa=0 -*/ -if (bo_node == node) - mapping_flags |= amdgpu_use_mtype_cc_wa ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ; +/* local HBM region close to partition */ +if (bo_node->adev == node->adev/* TODO: memory partitions && +bo_node->mem_id == node->mem_id*/ ) + mapping_flags |= mtype_local;/* local HBM region far from partition or remote XGMI GPU */ else if (svm_nodes_in_same_hive (bo_node, node)) mapping_flags |=AMDGPU_VM_MTYPE_NC ;
@@ -1211,7 +1209,13 @@ svm_range_get_pte_flags(struct kfd_node *node, mapping_flags |=AMDGPU_VM_MTYPE_UC ;/* system memory accessed by the APU */ }else if (node->adev->flags &AMD_IS_APU ) { - mapping_flags |=AMDGPU_VM_MTYPE_NC ; +/* On NUMA systems, locality is determined per-page +* in amdgpu_gmc_override_vm_pte_flags +*/ +if (num_possible_nodes () <=1 ) + mapping_flags |= mtype_local; +else + mapping_flags |=AMDGPU_VM_MTYPE_NC ;/* system memory accessed by the dGPU */ }else { mapping_flags |=AMDGPU_VM_MTYPE_UC ;
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 4/6 drm/amdgpu: Override MTYPE per page on GFXv9.4.3 APUs
In reply to Alex DeucherFrom: Felix Kuehling <[email protected]>
On GFXv9.4.3 NUMA APUs, system memory locality must be determined per page to choose the correct MTYPE. This patch adds a GMC callback that can provide this per-page override and implements it for native mode.
Carve-out mode is not yet supported and will use the safe default (remote) MTYPE for system memory.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 7 +++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 22 ++++++-- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 64 +++++++++++++++++++++++ 3 files changed, 90 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +7 -0
@@ -148,6 +148,10 @@ struct amdgpu_gmc_funcs {void (*get_vm_pte)(struct amdgpu_device *adev,struct amdgpu_bo_va_mapping *mapping,uint64_t *flags); +/* override per-page pte flags */ +void (*override_vm_pte_flags)(struct amdgpu_device *dev, +struct amdgpu_vm *vm, +uint64_t addr,uint64_t *flags);/* get the amount of memory used by the vbios for pre-OS console */ unsigned int (*get_vbios_fb_size)(struct amdgpu_device *adev);
@@ -336,6 +340,9 @@ struct amdgpu_gmc {#define amdgpu_gmc_map_mtype (adev, flags) (adev)->gmc.gmc_funcs->map_mtype((adev),(flags))#define amdgpu_gmc_get_vm_pde (adev, level, dst, flags) (adev)->gmc.gmc_funcs->get_vm_pde((adev), (level), (dst), (flags))#define amdgpu_gmc_get_vm_pte (adev, mapping, flags) (adev)->gmc.gmc_funcs->get_vm_pte((adev), (mapping), (flags)) +#define amdgpu_gmc_override_vm_pte_flags (adev, vm, addr, pte_flags) \ + (adev)->gmc.gmc_funcs->override_vm_pte_flags \ + ((adev), (vm), (addr), (pte_flags))#define amdgpu_gmc_get_vbios_fb_size (adev) (adev)->gmc.gmc_funcs->get_vbios_fb_size((adev))/**
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +19 -3
@@ -786,13 +786,14 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params, uint64_t pe, uint64_t addr, unsigned int count, uint32_t incr, uint64_t flags) - { + struct amdgpu_device *adev = params->adev; +if (level !=AMDGPU_VM_PTB ) { flags |=AMDGPU_PDE_PTE ; -amdgpu_gmc_get_vm_pde (params->adev, level, &addr, &flags); +amdgpu_gmc_get_vm_pde (adev, level, &addr, &flags); - } else if (params->adev->asic_type >= CHIP_VEGA10 && + }else if (adev->asic_type >=CHIP_VEGA10 && !(flags &AMDGPU_PTE_VALID ) && !(flags &AMDGPU_PTE_PRT )) {
@@ -800,6 +801,21 @@ static void amdgpu_vm_pte_update_flags(struct amdgpu_vm_update_params *params, flags |=AMDGPU_PTE_EXECUTABLE ; } +/* APUs mapping system memory may need different MTYPEs on different +* NUMA nodes. Only do this for contiguous ranges that can be assumed +* to be on the same NUMA node. +*/ +if ((flags &AMDGPU_PTE_SYSTEM ) && (adev->flags &AMD_IS_APU ) && + adev->gmc.gmc_funcs->override_vm_pte_flags && +num_possible_nodes () >1 ) { +if (!params->pages_addr) +amdgpu_gmc_override_vm_pte_flags (adev, params->vm, + addr, &flags); +else +dev_dbg (adev->dev, +"override_vm_pte_flags skipped: non-contiguous\n" ); + } + params->vm->update_funcs->update (params, pt, pe, addr, count, incr, flags); }
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +64 -0
76 lines not on this page · raw message
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 5/6 drm/amdgpu/bu: add mtype_local as a module parameter
In reply to Alex DeucherFrom: David Francis <[email protected]>
Selects the MTYPE to be used for local memory, (0 = MTYPE_CC (default), 1 = MTYPE_NC, 2 = MTYPE_RW)
This change is for internal testing only - do not upstream.
v2: squash in build fix (Alex)
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 19 ++++++++++++++++--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +-- 4 files changed, 22 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -1
@@ -213,7 +213,7 @@ extern int amdgpu_noretry;extern int amdgpu_force_asic_type;extern int amdgpu_smartshift_bias;extern int amdgpu_use_xgmi_p2p; -extern bool amdgpu_use_mtype_cc_wa; +extern int amdgpu_mtype_local;#ifdef CONFIG_HSA_AMD extern int sched_policy;extern bool debug_evictions;
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -4
@@ -832,11 +832,11 @@ module_param_named(no_queue_eviction_on_vm_fault, amdgpu_no_queue_eviction_on_vm#endif /** -* DOC: use_mtype_cc_wa (bool) +* DOC: mtype_local (int) */ -bool amdgpu_use_mtype_cc_wa = true; -MODULE_PARM_DESC (use_mtype_cc_wa,"Use MTYPE_CC workaround (0 = use MTYPE_RW where applicable, 1 = use MTYPE_CC where applicable (default))" ); -module_param_named (use_mtype_cc_wa, amdgpu_use_mtype_cc_wa, bool,0444 ); +int amdgpu_mtype_local; +MODULE_PARM_DESC (mtype_local,"MTYPE for local memory (0 = MTYPE_CC (default), 1 = MTYPE_NC, 2 = MTYPE_RW)" ); +module_param_named (mtype_local, amdgpu_mtype_local, int,0444 );/** * DOC: pcie_p2p (bool)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +16 -3
@@ -1240,7 +1240,16 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,* NUMA systems. Their MTYPE can be overridden per-page in * gmc_v9_0_override_vm_pte_flags. */ - mtype_local = amdgpu_use_mtype_cc_wa ?MTYPE_CC :MTYPE_RW ; + mtype_local =MTYPE_CC ; +if (amdgpu_mtype_local ==1 ) { +DRM_INFO_ONCE ("Using MTYPE_NC for local memory\n" ); + mtype_local =MTYPE_NC ; + }else if (amdgpu_mtype_local ==2 ) { +DRM_INFO_ONCE ("Using MTYPE_RW for local memory\n" ); + mtype_local =MTYPE_RW ; + }else { +DRM_INFO_ONCE ("Using MTYPE_CC for local memory\n" ); + } is_local = (!is_vram && (adev->flags &AMD_IS_APU ) &&num_possible_nodes () <=1 ) || (is_vram && adev == bo_adev/* TODO: memory partitions &&
@@ -1354,9 +1363,13 @@ static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev,dev_dbg (adev->dev,"vm->mem_id=%d, local_node=%d, nid=%d\n" ,/*vm->mem_id*/ 0 , local_node, nid);if (nid == local_node) { -unsigned int mtype_local = - amdgpu_use_mtype_cc_wa ?MTYPE_CC :MTYPE_RW ;uint64_t old_flags = *flags; +unsigned int mtype_local =MTYPE_CC ; + +if (amdgpu_mtype_local ==1 ) + mtype_local =MTYPE_NC ; +else if (amdgpu_mtype_local ==2 ) + mtype_local =MTYPE_RW ; *flags = (*flags & ~AMDGPU_PTE_MTYPE_VG10_MASK ) |AMDGPU_PTE_MTYPE_VG10 (mtype_local);
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -2
@@ -1191,8 +1191,7 @@ svm_range_get_pte_flags(struct kfd_node *node, }break ;case IP_VERSION (9 ,4 ,3 ): - mtype_local = amdgpu_use_mtype_cc_wa ?AMDGPU_VM_MTYPE_CC : -AMDGPU_VM_MTYPE_RW ; + mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : (amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_RW :AMDGPU_VM_MTYPE_CC ); snoop = true;if (uncached) { mapping_flags |=AMDGPU_VM_MTYPE_UC ;
Signature · 1 line
2.40.1
Alex Deucher
maintainerPATCH 6/6 drm/amdgpu/bu: update mtype_local parameter settings
In reply to Alex DeucherFrom: Graham Sider <[email protected]>
Update mtype_local module parameter to use MTYPE_RW by default.
0: MTYPE_RW (default)
1: MTYPE_NC
2: MTYPE_CC
--- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 2 +- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 12 ++++++------ drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -1
@@ -835,7 +835,7 @@ module_param_named(no_queue_eviction_on_vm_fault, amdgpu_no_queue_eviction_on_vm* DOC: mtype_local (int) */ int amdgpu_mtype_local; -MODULE_PARM_DESC (mtype_local,"MTYPE for local memory (0 = MTYPE_CC (default), 1 = MTYPE_NC, 2 = MTYPE_RW)" ); +MODULE_PARM_DESC (mtype_local,"MTYPE for local memory (0 = MTYPE_RW (default), 1 = MTYPE_NC, 2 = MTYPE_CC)" );module_param_named (mtype_local, amdgpu_mtype_local, int,0444 );/**
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +6 -6
@@ -1240,15 +1240,15 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,* NUMA systems. Their MTYPE can be overridden per-page in * gmc_v9_0_override_vm_pte_flags. */ - mtype_local =MTYPE_CC ; + mtype_local =MTYPE_RW ;if (amdgpu_mtype_local ==1 ) {DRM_INFO_ONCE ("Using MTYPE_NC for local memory\n" ); mtype_local =MTYPE_NC ; }else if (amdgpu_mtype_local ==2 ) { -DRM_INFO_ONCE ("Using MTYPE_RW for local memory\n" ); - mtype_local =MTYPE_RW ; - }else {DRM_INFO_ONCE ("Using MTYPE_CC for local memory\n" ); + mtype_local =MTYPE_CC ; + }else { +DRM_INFO_ONCE ("Using MTYPE_RW for local memory\n" ); } is_local = (!is_vram && (adev->flags &AMD_IS_APU ) && num_possible_nodes() <= 1) ||
@@ -1364,12 +1364,12 @@ static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev, /*vm->mem_id*/0, local_node, nid);if (nid == local_node) {uint64_t old_flags = *flags; -unsigned int mtype_local =MTYPE_CC ; +unsigned int mtype_local =MTYPE_RW ;if (amdgpu_mtype_local ==1 ) mtype_local =MTYPE_NC ;else if (amdgpu_mtype_local ==2 ) - mtype_local =MTYPE_RW ; + mtype_local =MTYPE_CC ; *flags = (*flags & ~AMDGPU_PTE_MTYPE_VG10_MASK ) |AMDGPU_PTE_MTYPE_VG10 (mtype_local);
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -1
@@ -1191,7 +1191,8 @@ svm_range_get_pte_flags(struct kfd_node *node, }break ;case IP_VERSION (9 ,4 ,3 ): - mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : (amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_RW :AMDGPU_VM_MTYPE_CC ); + mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : + (amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ); snoop = true;if (uncached) { mapping_flags |=AMDGPU_VM_MTYPE_UC ;
Signature · 1 line
2.40.1
All those workaround were only to be used during bringup and are not supposed for upstreaming.
Especially we probably don't want the module parameter to override the MTYPE used in the VM mappings in a release.
Christian.
Am 10.05.23 um 19:56 schrieb Alex Deucher:
Quoted 49 lines
From: Graham Sider <[email protected]>
Invalidate TLBs via a legacy flush request (flush_type=0) prior to the heavyweight flush requests (flush_type=2) in
gmc_v9_0.c. This is temporarily required to mitigate a bug causing CPC UTCL1 to return stale translations after invalidation requests in address range mode.Signed-off-by Graham Sider <[email protected]>Reviewed-by Philip Yang <[email protected]>Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +17
-0@@ -833,6 +833,14 @@ static void gmc_v9_0_flush_gpu_tlb(struct amdgpu_device *adev, uint32_t vmid,*/ inv_req =gmc_v9_0_get_invalidate_req (vmid,2 ); inv_req2 =gmc_v9_0_get_invalidate_req (vmid, flush_type); + }else if (flush_type ==2 && + adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,3 )) { +/* FIXME: Temporarily add a legacy flush (type 0) before heavyweight +* flush for gfx943 to mitigate a bug which causes CPC UTCL1 to return +* stale translations even after TLB heavyweight flush. +*/ + inv_req =gmc_v9_0_get_invalidate_req (vmid,0 ); + inv_req2 =gmc_v9_0_get_invalidate_req (vmid, flush_type); }else { inv_req =gmc_v9_0_get_invalidate_req (vmid, flush_type); inv_req2 =0 ;@@ -976,6 +984,15 @@ static int gmc_v9_0_flush_gpu_tlb_pasid(struct amdgpu_device *adev,if (vega20_xgmi_wa) kiq->pmf->kiq_invalidate_tlbs (ring, pasid,2 , all_hub); + +/* FIXME: Temporarily add a legacy flush (type 0) before heavyweight +* flush for gfx943 to mitigate a bug which causes CPC UTCL1 to return +* stale translations even after TLB heavyweight flush. +*/ +if (flush_type ==2 && adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (9 ,4 ,3 )) + kiq->pmf->kiq_invalidate_tlbs (ring, + pasid,0 , all_hub); + kiq->pmf->kiq_invalidate_tlbs (ring, pasid, flush_type, all_hub); r =amdgpu_fence_emit_polling (ring, &seq,MAX_KIQ_REG_WAIT );