FAILED: patch "[PATCH] drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950" failed to apply to 6.12-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 232213c9bd7f703836164f23160b76657094a7db
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From 232213c9bd7f703836164f23160b76657094a7db Mon Sep 17 00:00:00 2001
From: Elena Sakhnovitch <[email protected]>
Date: Wed, 14 Oct 2026 14:29:35 -0400
Subject: [PATCH] drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950
Add extra type-2 TLB flush for GC 9.5.0, similar race condition was observed as Vega20+XGMI. Add to GC 9.4.3 and 9.4.4 too, as they share the same multi-XCD TLB topology.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +15 -3
@@ -2179,10 +2179,22 @@ static int gmc_v9_0_hw_init(struct amdgpu_ip_block *ip_block)* (type 2), which flushes both. Due to a race condition with * concurrent memory accesses using the same TLB cache line, we still * need a second TLB flush after this. +* +* GC 9.4.3, 9.4.4 and 9.5.0 hit a similar race. */ - adev->gmc.flush_tlb_needs_extra_type_2 = -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,0 ) && - adev->gmc.xgmi.num_physical_nodes; +switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +case IP_VERSION (9 ,4 ,0 ): + adev->gmc.flush_tlb_needs_extra_type_2 = + adev->gmc.xgmi.num_physical_nodes; +break ; +case IP_VERSION (9 ,4 ,3 ): +case IP_VERSION (9 ,4 ,4 ): +case IP_VERSION (9 ,5 ,0 ): + adev->gmc.flush_tlb_needs_extra_type_2 = true; +break ; +default : +break ; + }/* The sequence of these two function calls matters.*/ gmc_v9_0_init_golden_registers (adev);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/4 drm/amd: define gc ip version local variable
From: Alex Sierra <[email protected]>
[ Upstream commit 9bfe4caa4e57ba343d81e837911242f058688200 ]
For better readability. Also leftover orphaned code.
Stable-dep-of: 232213c9bd7f ("drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950")
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 +++----- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -5
@@ -1139,12 +1139,13 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,bool uncached = bo->flags &AMDGPU_GEM_CREATE_UNCACHED ;struct amdgpu_vm *vm = mapping->bo_va->base.vm;unsigned int mtype_local, mtype; +uint32_t gc_ip_version =amdgpu_ip_version (adev,GC_HWIP ,0 );bool snoop = false;bool is_local;dma_resv_assert_held (bo->tbo.base.resv); -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +switch (gc_ip_version) {case IP_VERSION (9 ,4 ,1 ):case IP_VERSION (9 ,4 ,2 ):if (is_vram) {
@@ -1158,10 +1159,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,/* FIXME: is this still needed? Or does * amdgpu_ttm_tt_pde_flags already handle this? */ -if ((amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,2 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,3 )) && +if (gc_ip_version ==IP_VERSION (9 ,4 ,2 ) && adev->gmc.xgmi.connected_to_cpu) snoop = true; }else {
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -2
@@ -1224,6 +1224,7 @@ svm_range_get_pte_flags(struct kfd_node *node,struct kfd_node *bo_node;uint32_t flags = prange->flags;uint32_t mapping_flags =0 ; +uint32_t gc_ip_version =KFD_GC_VERSION (node);uint64_t pte_flags;bool snoop = (domain !=SVM_RANGE_VRAM_DOMAIN );bool coherent = flags & (KFD_IOCTL_SVM_FLAG_COHERENT |KFD_IOCTL_SVM_FLAG_EXT_COHERENT );
@@ -1233,7 +1234,7 @@ svm_range_get_pte_flags(struct kfd_node *node,if (domain ==SVM_RANGE_VRAM_DOMAIN ) bo_node = prange->svm_bo->node; -switch (amdgpu_ip_version (node->adev,GC_HWIP ,0 )) { +switch (gc_ip_version) {case IP_VERSION (9 ,4 ,1 ):if (domain ==SVM_RANGE_VRAM_DOMAIN ) {if (bo_node == node) {
@@ -1322,7 +1323,7 @@ svm_range_get_pte_flags(struct kfd_node *node, pte_flags =AMDGPU_PTE_VALID ; pte_flags |= (domain ==SVM_RANGE_VRAM_DOMAIN ) ?0 :AMDGPU_PTE_SYSTEM ; pte_flags |= snoop ?AMDGPU_PTE_SNOOPED :0 ; -if (KFD_GC_VERSION (node) >=IP_VERSION (12 ,0 ,0 )) +if (gc_ip_version >=IP_VERSION (12 ,0 ,0 )) pte_flags |=AMDGPU_PTE_IS_PTE ; pte_flags |=amdgpu_gem_va_map_flags (node->adev, mapping_flags);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 drm/amd: update mtype flags for gfx 9.5.0
From: Alex Sierra <[email protected]>
[ Upstream commit dad0c70507a834ac12e9286401d90536a3c4cea2 ]
Update mtype flags to meet gfx 9.5.0 requirements for remote GPU memory and system memory.
Stable-dep-of: 232213c9bd7f ("drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950")
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 ++++---- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +4 -4
@@ -1207,7 +1207,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,if (uncached) { mtype =MTYPE_UC ; }else if (ext_coherent) { -if (adev->rev_id) +if (gc_ip_version ==IP_VERSION (9 ,5 ,0 ) || adev->rev_id) mtype = is_local ?MTYPE_CC :MTYPE_UC ;else mtype =MTYPE_UC ;
@@ -1217,10 +1217,10 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,/* dGPU */ if (is_local) mtype = mtype_local; -else if (is_vram) - mtype =MTYPE_NC ; -else +else if (gc_ip_version <IP_VERSION (9 ,5 ,0 ) && !is_vram) mtype =MTYPE_UC ; +else + mtype =MTYPE_NC ; }break ;
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +12 -4
@@ -1272,7 +1272,8 @@ svm_range_get_pte_flags(struct kfd_node *node,case IP_VERSION (9 ,4 ,3 ):case IP_VERSION (9 ,4 ,4 ):if (ext_coherent) - mtype_local = node->adev->rev_id ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_UC ; + mtype_local = (gc_ip_version <IP_VERSION (9 ,5 ,0 ) && !node->adev->rev_id) ? +AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_CC ;else mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ;
@@ -1287,9 +1288,13 @@ svm_range_get_pte_flags(struct kfd_node *node,*/ else if (svm_nodes_in_same_hive(bo_node, node) && !ext_coherent) mapping_flags |= AMDGPU_VM_MTYPE_NC; -/* PCIe P2P or extended system scope coherence */ - else +/* PCIe P2P on GPUs pre-9.5.0 */ + else if (gc_ip_version < IP_VERSION(9, 5, 0) && + !svm_nodes_in_same_hive(bo_node, node)) mapping_flags |= AMDGPU_VM_MTYPE_UC; +/* Other remote memory */ + else + mapping_flags |= ext_coherent ? AMDGPU_VM_MTYPE_UC : AMDGPU_VM_MTYPE_NC;/* system memory accessed by the APU */ }else if (node->adev->flags &AMD_IS_APU ) {/* On NUMA systems, locality is determined per-page
@@ -1301,7 +1306,10 @@ svm_range_get_pte_flags(struct kfd_node *node, mapping_flags |= ext_coherent ?AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_NC ;/* system memory accessed by the dGPU */ }else { - mapping_flags |=AMDGPU_VM_MTYPE_UC ; +if (gc_ip_version <IP_VERSION (9 ,5 ,0 )) + mapping_flags |=AMDGPU_VM_MTYPE_UC ; +else + mapping_flags |=AMDGPU_VM_MTYPE_NC ; }break ;case IP_VERSION (12 ,0 ,0 ):
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 drm/amdkfd: Drop workaround for GC v9.4.3 revID 0
In reply to Sasha LevinFrom: Apurv Mishra <[email protected]>
[ Upstream commit daafa303d19f5522e4c24fbf5c1c981a16df2c2f ]
Remove workaround code for the early engineering
samples GC v9.4.3 SOCs with revID 0
Stable-dep-of: 232213c9bd7f ("drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++++- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 ++------------ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 5 ----- drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +-- 5 files changed, 12 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -1
@@ -2680,6 +2680,13 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)break ; } +/* Check for IP version 9.4.3 with A0 hardware */ +if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) && + !amdgpu_device_get_rev_id (adev)) { +dev_err (adev->dev,"Unsupported A0 hardware\n" ); +return -ENODEV ;/* device unsupported - no device error */ + } + if (amdgpu_has_atpx() && (amdgpu_is_atpx_hybrid() || amdgpu_has_atpx_dgpu_power_cntl()) &&
@@ -2692,7 +2699,6 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) adev->has_pr3 = parent ?pci_pr3_present (parent) : false; } - adev->pm.pp_feature = amdgpu_pp_feature_mask;if (amdgpu_sriov_vf (adev) || sched_policy ==KFD_SCHED_POLICY_NO_HWS ) adev->pm.pp_feature &= ~PP_GFXOFF_MASK ;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -12
@@ -1207,10 +1207,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,if (uncached) { mtype =MTYPE_UC ; }else if (ext_coherent) { -if (gc_ip_version ==IP_VERSION (9 ,5 ,0 ) || adev->rev_id) - mtype = is_local ?MTYPE_CC :MTYPE_UC ; -else - mtype =MTYPE_UC ; + mtype = is_local ?MTYPE_CC :MTYPE_UC ; }else if (adev->flags &AMD_IS_APU ) { mtype = is_local ? mtype_local :MTYPE_NC ; }else {
@@ -1330,7 +1327,7 @@ static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev, mtype_local =MTYPE_CC ; *flags =AMDGPU_PTE_MTYPE_VG10 (*flags, mtype_local); - }else if (adev->rev_id) { + }else {/* MTYPE_UC case */ *flags =AMDGPU_PTE_MTYPE_VG10 (*flags,MTYPE_CC ); }
@@ -2331,13 +2328,6 @@ static int gmc_v9_0_hw_init(void *handle) adev->gmc.flush_tlb_needs_extra_type_2 =amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,0 ) && adev->gmc.xgmi.num_physical_nodes; -/* -* TODO: This workaround is badly documented and had a buggy -* implementation. We should probably verify what we do here. -*/ - adev->gmc.flush_tlb_needs_extra_type_0 = -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) && - adev->rev_id ==0 ;/* The sequence of these two function calls matters.*/ gmc_v9_0_init_golden_registers (adev);
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -5
@@ -347,11 +347,6 @@ struct kfd_dev *kgd2kfd_probe(struct amdgpu_device *adev, bool vf) f2g = &aldebaran_kfd2kgd;break ;case IP_VERSION (9 ,4 ,3 ): - gfx_target_version = adev->rev_id >=1 ?90402 - : adev->flags &AMD_IS_APU ?90400 - :90401 ; - f2g = &gc_9_4_3_kfd2kgd; -break ;case IP_VERSION (9 ,4 ,4 ): gfx_target_version =90402 ; f2g = &gc_9_4_3_kfd2kgd;
drivers/gpu/drm/amd/amdkfd/kfd_queue.c +2 -2
@@ -424,7 +424,7 @@ static u32 kfd_get_vgpr_size_per_cu(u32 gfxv) {u32 vgpr_size =0x40000 ; -if ((gfxv /100 *100 ) ==90400 ||/* GFX_VERSION_AQUA_VANJARAM */ +if (gfxv ==90402 ||/* GFX_VERSION_AQUA_VANJARAM */ gfxv ==90010 ||/* GFX_VERSION_ALDEBARAN */ gfxv ==90008 )/* GFX_VERSION_ARCTURUS */ vgpr_size =0x80000 ;
@@ -483,7 +483,7 @@ void kfd_queue_ctx_save_restore_size(struct kfd_topology_device *dev)if (gfxv ==80002 )/* GFX_VERSION_TONGA */ props->eop_buffer_size =0x8000 ; -else if ((gfxv /100 *100 ) ==90400 )/* GFX_VERSION_AQUA_VANJARAM */ +else if (gfxv ==90402 )/* GFX_VERSION_AQUA_VANJARAM */ props->eop_buffer_size =4096 ;else if (gfxv >=80000 ) props->eop_buffer_size =4096 ;
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -2
@@ -1272,8 +1272,7 @@ svm_range_get_pte_flags(struct kfd_node *node,case IP_VERSION (9 ,4 ,3 ):case IP_VERSION (9 ,4 ,4 ):if (ext_coherent) - mtype_local = (gc_ip_version <IP_VERSION (9 ,5 ,0 ) && !node->adev->rev_id) ? -AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_CC ; + mtype_local =AMDGPU_VM_MTYPE_CC ;else mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950
In reply to Sasha LevinFrom: Elena Sakhnovitch <[email protected]>
[ Upstream commit 232213c9bd7f703836164f23160b76657094a7db ]
Add extra type-2 TLB flush for GC 9.5.0, similar race condition was observed as Vega20+XGMI. Add to GC 9.4.3 and 9.4.4 too, as they share the same multi-XCD TLB topology.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +15 -3
@@ -2324,10 +2324,22 @@ static int gmc_v9_0_hw_init(void *handle)* (type 2), which flushes both. Due to a race condition with * concurrent memory accesses using the same TLB cache line, we still * need a second TLB flush after this. +* +* GC 9.4.3, 9.4.4 and 9.5.0 hit a similar race. */ - adev->gmc.flush_tlb_needs_extra_type_2 = -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,0 ) && - adev->gmc.xgmi.num_physical_nodes; +switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +case IP_VERSION (9 ,4 ,0 ): + adev->gmc.flush_tlb_needs_extra_type_2 = + adev->gmc.xgmi.num_physical_nodes; +break ; +case IP_VERSION (9 ,4 ,3 ): +case IP_VERSION (9 ,4 ,4 ): +case IP_VERSION (9 ,5 ,0 ): + adev->gmc.flush_tlb_needs_extra_type_2 = true; +break ; +default : +break ; + }/* The sequence of these two function calls matters.*/ gmc_v9_0_init_golden_registers (adev);
Signature · 1 line
2.53.0