Skip to contentSkip to conversation

Add gmc 12.1 support

PATCH New Alex Deucher 1 participant 8 messages Nov 19, 2025

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

cover Add gmc 12.1 support

Add GMC (graphics memory controller) 12.1 support. This depends on the mmhub 4.2 and gfxhub 12.1 patches.

Hawking Zhang (1):
drm/amdgpu: Add gmc v12_1 gmc callbacks

Likun Gao (2):
drm/amdgpu: Add gmc v12_1 support
drm/amdgpu: Add gmc v12_1_0 to discovery list

Mukul Joshi (4):
drm/amdgpu: Add per-ASIC PTE init flag drm/amdgpu: Always set snoop bit in PDE on GFX 12.1 drm/amdgpu: Enable PDE.C usage on GFX 12.1 drm/amdkfd: Fix PTE clearing during SVM unmap on GFX 12.1

 drivers/gpu/drm/amd/amdgpu/Makefile           |   2 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h       |   1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c     |   4 +-
 drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c     |  16 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c        |  45 ++-
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c        | 325 ++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h        |  29 ++
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c          |   2 +-
 9 files changed, 402 insertions(+), 23 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h
Signature · 1 line
2.51.1
author maintainer
#1 lore raw

PATCH 1/7 drm/amdgpu: Add gmc v12_1 support

From: Likun Gao <[email protected]>

Add gmc support for gc version 12_1_0.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 34 +++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +28 -6
index 69d90a26ecf50..d22c762473424 100644
@@ -38,7 +38,9 @@
 #include "soc15_common.h"
 #include "nbif_v6_3_1.h"
 #include "gfxhub_v12_0.h"
+#include "gfxhub_v12_1.h"
 #include "mmhub_v4_1_0.h"
+#include "mmhub_v4_2_0.h"
 #include "athub_v4_1_0.h"
 #include "umc_v8_14.h"
 
@@ -594,6 +596,9 @@ static void gmc_v12_0_set_mmhub_funcs(struct amdgpu_device *adev)
 	case IP_VERSION(4, 1, 0):
 		adev->mmhub.funcs = &mmhub_v4_1_0_funcs;
 		break;
+	case IP_VERSION(4, 2, 0):
+		adev->mmhub.funcs = &mmhub_v4_2_0_funcs;
+		break;
 	default:
 		break;
 	}
@@ -606,6 +611,9 @@ static void gmc_v12_0_set_gfxhub_funcs(struct amdgpu_device *adev)
 	case IP_VERSION(12, 0, 1):
 		adev->gfxhub.funcs = &gfxhub_v12_0_funcs;
 		break;
+	case IP_VERSION(12, 1, 0):
+		adev->gfxhub.funcs = &gfxhub_v12_1_funcs;
+		break;
 	default:
 		break;
 	}
@@ -759,6 +767,7 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
 	switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
 	case IP_VERSION(12, 0, 0):
 	case IP_VERSION(12, 0, 1):
+	case IP_VERSION(12, 1, 0):
 		set_bit(AMDGPU_GFXHUB(0), adev->vmhubs_mask);
 		set_bit(AMDGPU_MMHUB0(0), adev->vmhubs_mask);
 		/*
@@ -780,9 +789,14 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
 	if (r)
 		return r;
 
-	r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX,
-			      UTCL2_1_0__SRCID__FAULT,
-			      &adev->gmc.vm_fault);
+	if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(12, 1, 0))
+		r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_UTCL2,
+				      UTCL2_1_0__SRCID__FAULT,
+				      &adev->gmc.vm_fault);
+	else
+		r = amdgpu_irq_add_id(adev, SOC21_IH_CLIENTID_GFX,
+				      UTCL2_1_0__SRCID__FAULT,
+				      &adev->gmc.vm_fault);
 	if (r)
 		return r;
 
@@ -829,7 +843,11 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
 	 * amdgpu graphics/compute will use VMIDs 1-7
 	 * amdkfd will use VMIDs 8-15
 	 */
-	adev->vm_manager.first_kfd_vmid = adev->gfx.disable_kq ? 1 : 8;
+	adev->vm_manager.first_kfd_vmid =
+		 amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(12, 1, 0) ?
+		3 : 8;
+	adev->vm_manager.first_kfd_vmid =
+		adev->gfx.disable_kq ? 1 : (adev->vm_manager.first_kfd_vmid);
 
 	amdgpu_vm_manager_init(adev);
 
@@ -997,7 +1015,10 @@ static int gmc_v12_0_set_clockgating_state(struct amdgpu_ip_block *ip_block,
 	if (r)
 		return r;
 
-	return athub_v4_1_0_set_clockgating(adev, state);
+	if (amdgpu_ip_version(adev, GC_HWIP, 0) != IP_VERSION(12, 1, 0))
+		return athub_v4_1_0_set_clockgating(adev, state);
+	else
+		return 0;
 }
 
 static void gmc_v12_0_get_clockgating_state(struct amdgpu_ip_block *ip_block, u64 *flags)
@@ -1006,7 +1027,8 @@ static void gmc_v12_0_get_clockgating_state(struct amdgpu_ip_block *ip_block, u6
 
 	adev->mmhub.funcs->get_clockgating(adev, flags);
 
-	athub_v4_1_0_get_clockgating(adev, flags);
+	if (amdgpu_ip_version(adev, GC_HWIP, 0) != IP_VERSION(12, 1, 0))
+		athub_v4_1_0_get_clockgating(adev, flags);
 }
 
 static int gmc_v12_0_set_powergating_state(struct amdgpu_ip_block *ip_block,
Signature · 1 line
2.51.1
author maintainer
#2 lore raw

PATCH 2/7 drm/amdgpu: Add gmc v12_1 gmc callbacks

In reply to Alex Deucher

From: Hawking Zhang <[email protected]>

Implement gmc v12_1 gmc callbacks

v2: revert temporary PDE MTYPE to UC setting

---
 drivers/gpu/drm/amd/amdgpu/Makefile    |   2 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c |  10 +-
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 323 +++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h |  29 +++
 4 files changed, 362 insertions(+), 2 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h
drivers/gpu/drm/amd/amdgpu/Makefile +1 -1
index 0c2779047ace7..a9b89994c6de4 100644
@@ -105,7 +105,7 @@ amdgpu-y += \
 	mmhub_v1_7.o gfxhub_v3_0.o mmhub_v3_0.o mmhub_v3_0_2.o gmc_v11_0.o \
 	mmhub_v3_0_1.o gfxhub_v3_0_3.o gfxhub_v1_2.o mmhub_v1_8.o mmhub_v3_3.o \
 	gfxhub_v11_5_0.o mmhub_v4_1_0.o gfxhub_v12_0.o gmc_v12_0.o \
-	mmhub_v4_2_0.o gfxhub_v12_1.o
+	mmhub_v4_2_0.o gfxhub_v12_1.o gmc_v12_1.o
 
 # add UMC block
 amdgpu-y += \
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +9 -1
index d22c762473424..3cb61d2c58f95 100644
@@ -28,6 +28,7 @@
 #include "amdgpu.h"
 #include "amdgpu_atomfirmware.h"
 #include "gmc_v12_0.h"
+#include "gmc_v12_1.h"
 #include "athub/athub_4_1_0_sh_mask.h"
 #include "athub/athub_4_1_0_offset.h"
 #include "oss/osssys_7_0_0_offset.h"
@@ -623,9 +624,16 @@ static int gmc_v12_0_early_init(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
 
+	switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
+	case IP_VERSION(12, 1, 0):
+		gmc_v12_1_set_gmc_funcs(adev);
+		break;
+	default:
+		gmc_v12_0_set_gmc_funcs(adev);
+		break;
+	}
 	gmc_v12_0_set_gfxhub_funcs(adev);
 	gmc_v12_0_set_mmhub_funcs(adev);
-	gmc_v12_0_set_gmc_funcs(adev);
 	gmc_v12_0_set_irq_funcs(adev);
 	gmc_v12_0_set_umc_funcs(adev);
 
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c new file +323 -0

323 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h new file +29 -0
new file mode 100644
index 0000000000000..cc52db3a9908d
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2025 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef __GMC_V12_1_H__
+#define __GMC_V12_1_H__
+
+void gmc_v12_1_set_gmc_funcs(struct amdgpu_device *adev);
+
+#endif
Signature · 1 line
2.51.1
author maintainer
#3 lore raw

PATCH 3/7 drm/amdgpu: Add per-ASIC PTE init flag

In reply to Alex Deucher

From: Mukul Joshi <[email protected]>

On GFX12.1, default PTE setup needs an additional bit to be set. Add PTE initialization flags to handle setup default PTE on a per-ASIC basis.
While at it, fixup the coding style too.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h   | 1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 4 ++--
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c    | 1 +
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index 130310ae3c59e..98514fe0a5f68 100644
@@ -351,6 +351,7 @@ struct amdgpu_gmc {
 	u64 MC_VM_MX_L1_TLB_CNTL;
 
 	u64 noretry_flags;
+	u64 init_pte_flags;
 
 	bool flush_tlb_needs_extra_type_0;
 	bool flush_tlb_needs_extra_type_2;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +2 -2
index f6ffc207ec2a6..8bd411ba8b218 100644
@@ -366,6 +366,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 	struct amdgpu_bo *ancestor = &vmbo->bo;
 	unsigned int entries;
 	struct amdgpu_bo *bo = &vmbo->bo;
+	uint64_t value = 0, flags = 0;
 	uint64_t addr;
 	int r, idx;
 
@@ -402,7 +403,6 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 
 	addr = 0;
 
-	uint64_t value = 0, flags = 0;
 	if (adev->asic_type >= CHIP_VEGA10) {
 		if (level != AMDGPU_VM_PTB) {
 			/* Handle leaf PDEs as PTEs */
@@ -411,7 +411,7 @@ int amdgpu_vm_pt_clear(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 					      &value, &flags);
 		} else {
 			/* Workaround for fault priority problem on GMC9 */
-			flags = AMDGPU_PTE_EXECUTABLE;
+			flags = AMDGPU_PTE_EXECUTABLE | adev->gmc.init_pte_flags;
 		}
 	}
 
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +1 -0
index 3cb61d2c58f95..ab7d3469c5c50 100644
@@ -627,6 +627,7 @@ static int gmc_v12_0_early_init(struct amdgpu_ip_block *ip_block)
 	switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
 	case IP_VERSION(12, 1, 0):
 		gmc_v12_1_set_gmc_funcs(adev);
+		adev->gmc.init_pte_flags = AMDGPU_PTE_IS_PTE;
 		break;
 	default:
 		gmc_v12_0_set_gmc_funcs(adev);
Signature · 1 line
2.51.1
author maintainer
#4 lore raw

PATCH 4/7 drm/amdgpu: Always set snoop bit in PDE on GFX 12.1

In reply to Alex Deucher

From: Mukul Joshi <[email protected]>

GFX 12.1 has the requirement to always set snoop bit in PDE to maintain coherency.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +2 -0
index 347be0ef07ec8..ae08f8b3bfbc1 100644
@@ -249,6 +249,8 @@ static void gmc_v12_1_get_vm_pde(struct amdgpu_device *adev, int level,
 			adev->gmc.vram_start;
 	BUG_ON(*addr & 0xFFFF00000000003FULL);
 
+	*flags |= AMDGPU_PTE_SNOOPED;
+
 	if (!adev->gmc.translate_further)
 		return;
 
Signature · 1 line
2.51.1
author maintainer
#5 lore raw

PATCH 5/7 drm/amdgpu: Enable PDE.C usage on GFX 12.1

In reply to Alex Deucher

From: Mukul Joshi <[email protected]>

On GFX 12.1, PDE.C is ignored if (PDE|PTE)_REQUEST_PHYSICAL is not setup in the GCVM control register. Always set this field to enable PDE.C usage.

---
 drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfxhub_v12_1.c +4 -12
index 8ec0a14d3203b..4c59da7f2ccb1 100644
@@ -322,18 +322,10 @@ static void gfxhub_v12_1_xcc_init_cache_regs(struct amdgpu_device *adev,
 		WREG32_SOC15_RLC(GC, GET_INST(GC, i), regGCVM_L2_CNTL3, tmp);
 
 		tmp = regGCVM_L2_CNTL4_DEFAULT;
-		/* For AMD APP APUs setup WC memory */
-		if (adev->gmc.xgmi.connected_to_cpu || adev->gmc.is_app_apu) {
-			tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL4,
-					    VMC_TAP_PDE_REQUEST_PHYSICAL, 1);
-			tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL4,
-					    VMC_TAP_PTE_REQUEST_PHYSICAL, 1);
-		} else {
-			tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL4,
-					    VMC_TAP_PDE_REQUEST_PHYSICAL, 0);
-			tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL4,
-					    VMC_TAP_PTE_REQUEST_PHYSICAL, 0);
-		}
+		tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL4,
+				    VMC_TAP_PDE_REQUEST_PHYSICAL, 1);
+		tmp = REG_SET_FIELD(tmp, GCVM_L2_CNTL4,
+				    VMC_TAP_PTE_REQUEST_PHYSICAL, 1);
 		WREG32_SOC15_RLC(GC, GET_INST(GC, i), regGCVM_L2_CNTL4, tmp);
 
 		tmp = regGCVM_L2_CNTL5_DEFAULT;
Signature · 1 line
2.51.1
author maintainer
#6 lore raw

PATCH 6/7 drm/amdkfd: Fix PTE clearing during SVM unmap on GFX 12.1

In reply to Alex Deucher

From: Mukul Joshi <[email protected]>

During migration from VRAM to RAM, when PTE is cleared, reset the PTE to always ensure that PTE.P=1 is set on GFX 12.1. If PTE.P is not set, it can lead to TF faults.

---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -1
index 97c2270f278fd..24a698702da75 100644
@@ -1313,7 +1313,7 @@ svm_range_unmap_from_gpu(struct amdgpu_device *adev, struct amdgpu_vm *vm,
 			 uint64_t start, uint64_t last,
 			 struct dma_fence **fence)
 {
-	uint64_t init_pte_value = 0;
+	uint64_t init_pte_value = adev->gmc.init_pte_flags;
 
 	pr_debug("[0x%llx 0x%llx]\n", start, last);
 
Signature · 1 line
2.51.1
author maintainer
#7 lore raw

PATCH 7/7 drm/amdgpu: Add gmc v12_1_0 to discovery list

In reply to Alex Deucher

From: Likun Gao <[email protected]>

Include gmc v12_1_0 in the discovery list for
gmc IP blocks.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c +1 -0
index 6311b66259b7f..0e743f6ff90ae 100644
@@ -2044,6 +2044,7 @@ static int amdgpu_discovery_set_gmc_ip_blocks(struct amdgpu_device *adev)
 		break;
 	case IP_VERSION(12, 0, 0):
 	case IP_VERSION(12, 0, 1):
+	case IP_VERSION(12, 1, 0):
 		amdgpu_device_ip_block_add(adev, &gmc_v12_0_ip_block);
 		break;
 	default:
Signature · 1 line
2.51.1