Skip to contentSkip to conversation

drm/amdgpu: init NPS supported modes for GC 12.1.0

PATCH New Alex Deucher 1 participant 7 messages Aug 21

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/7 drm/amdgpu: init NPS supported modes for GC 12.1.0

From: Le Ma <[email protected]>

Add nps supported modes init for gc 12.1.0

---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c |  3 +++
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 33 ++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h |  1 +
 3 files changed, 37 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +3 -0
index e69cae39b5f75..27f9f6a4f3fa4 100644
@@ -945,6 +945,9 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
 	if (r)
 		return r;
 
+	if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(12, 1, 0))
+		gmc_v12_1_init_nps_details(adev);
+
 	/*
 	 * number of VMs
 	 * VMID 0 is reserved for System
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c +33 -0
index f9887cec9a6c3..a8e32ee93735d 100644
@@ -733,3 +733,36 @@ void gmc_v12_1_init_vram_info(struct amdgpu_device *adev)
 	adev->gmc.vram_type = AMDGPU_VRAM_TYPE_HBM4;
 	adev->gmc.vram_width = 384 * 64;
 }
+
+void gmc_v12_1_init_nps_details(struct amdgpu_device *adev)
+{
+	enum amdgpu_memory_partition mode;
+	uint32_t supp_modes;
+	int i;
+
+	adev->gmc.supported_nps_modes = 0;
+
+	if (amdgpu_sriov_vf(adev) || (adev->flags & AMD_IS_APU))
+		return;
+
+	mode = amdgpu_gmc_get_memory_partition(adev, &supp_modes);
+
+	/* Mode detected by hardware and supported modes available */
+	if ((mode != UNKNOWN_MEMORY_PARTITION_MODE) && supp_modes) {
+		while ((i = ffs(supp_modes))) {
+			if (AMDGPU_ALL_NPS_MASK & BIT(i))
+				adev->gmc.supported_nps_modes |= BIT(i);
+			supp_modes &= supp_modes - 1;
+		}
+	} else {
+		switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
+		case IP_VERSION(12, 1, 0):
+			adev->gmc.supported_nps_modes =
+				BIT(AMDGPU_NPS1_PARTITION_MODE) |
+				BIT(AMDGPU_NPS2_PARTITION_MODE);
+			break;
+		default:
+			break;
+		}
+	}
+}
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.h +1 -0
index 2f08f4b8cd99e..22da84a1d5185 100644
@@ -27,4 +27,5 @@
 void gmc_v12_1_set_gmc_funcs(struct amdgpu_device *adev);
 void gmc_v12_1_set_irq_funcs(struct amdgpu_device *adev);
 void gmc_v12_1_init_vram_info(struct amdgpu_device *adev);
+void gmc_v12_1_init_nps_details(struct amdgpu_device *adev);
 #endif
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH 2/7 drm/amdgpu: add memory partition sysfs init/fini for GC 12.1.0

From: Le Ma <[email protected]>

Add the nps sysfs node for GC 12.1.0

---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +6 -0
index 27f9f6a4f3fa4..a30942f35faaa 100644
@@ -966,6 +966,9 @@ static int gmc_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
 	if (r)
 		return r;
 
+	if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(12, 1, 0))
+		amdgpu_gmc_sysfs_init(adev);
+
 	return 0;
 }
 
@@ -985,6 +988,9 @@ static int gmc_v12_0_sw_fini(struct amdgpu_ip_block *ip_block)
 {
 	struct amdgpu_device *adev = ip_block->adev;
 
+	if (amdgpu_ip_version(adev, GC_HWIP, 0) == IP_VERSION(12, 1, 0))
+		amdgpu_gmc_sysfs_fini(adev);
+
 	amdgpu_vm_manager_fini(adev);
 	gmc_v12_0_gart_fini(adev);
 	amdgpu_gem_force_release(adev);
Signature · 1 line
2.55.0
author maintainer
#2 lore raw

PATCH 3/7 drm/amdgpu: free memory partition info on gmc v12 sw_fini

In reply to Alex Deucher

From: Le Ma <[email protected]>

Reset the partition count and free the buffer on gmc v12 sw_fini during driver unload.

---
 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
index a30942f35faaa..3add79c474f3b 100644
@@ -997,6 +997,9 @@ static int gmc_v12_0_sw_fini(struct amdgpu_ip_block *ip_block)
 	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
 	amdgpu_bo_fini(adev);
 
+	adev->gmc.num_mem_partitions = 0;
+	kfree(adev->gmc.mem_partitions);
+
 	return 0;
 }
 
Signature · 1 line
2.55.0
author maintainer
#3 lore raw

PATCH 4/7 drm/amdgpu: add NPS2 memory cap for soc v1.0 DPX mode

In reply to Alex Deucher

From: Le Ma <[email protected]>

DPX currently advertises only NPS1 as a compatible memory partition mode in soc_v1_0_get_xcp_res_info(). As a result, supported_nps_configs and amd-smi partition --accelerator report NPS1 for the DPX profile even when the device supports both NPS1 and NPS2.

Include NPS2 in the DPX compatible NPS mask so the reported profile capabilities match the supported memory partition modes.

---
 drivers/gpu/drm/amd/amdgpu/soc_v1_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/soc_v1_0.c +2 -1
index fb3c7cb350995..ada99210479f3 100644
@@ -963,7 +963,8 @@ static int soc_v1_0_get_xcp_res_info(struct amdgpu_xcp_mgr *xcp_mgr,
 		break;
 	case AMDGPU_DPX_PARTITION_MODE:
 		num_xcp = 2;
-		nps_modes = BIT(AMDGPU_NPS1_PARTITION_MODE);
+		nps_modes = BIT(AMDGPU_NPS1_PARTITION_MODE) |
+			    BIT(AMDGPU_NPS2_PARTITION_MODE);
 		break;
 	case AMDGPU_TPX_PARTITION_MODE:
 		num_xcp = 3;
Signature · 1 line
2.55.0
author maintainer
#4 lore raw

PATCH 5/7 drm/amdgpu: add DPX mode for 6-XCC configuration

In reply to Alex Deucher

From: Mangesh Gadre <[email protected]>

Add DPX to the 6-XCC supported mode mask This allows DPX to be advertised and selected

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +1 -0
index 35faea0ff17ff..14293d52cf104 100644
@@ -665,6 +665,7 @@ void amdgpu_xcp_update_supported_modes(struct amdgpu_xcp_mgr *xcp_mgr)
 		break;
 	case 6:
 		xcp_mgr->supp_xcp_modes = BIT(AMDGPU_SPX_PARTITION_MODE) |
+					  BIT(AMDGPU_DPX_PARTITION_MODE) |
 					  BIT(AMDGPU_TPX_PARTITION_MODE) |
 					  BIT(AMDGPU_CPX_PARTITION_MODE);
 		break;
Signature · 1 line
2.55.0
author maintainer
#5 lore raw

PATCH 6/7 drm/amdgpu: skip DPX mode for unsupported GC parts

In reply to Alex Deucher

From: Mangesh Gadre <[email protected]>

DPX is unsupported on GC 9.4.3/9.4.4/9.5.0 skip these 6-XCC parts,so do not advertise it.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c +5 -1
index 14293d52cf104..18f4455ef0a8f 100644
@@ -665,9 +665,13 @@ void amdgpu_xcp_update_supported_modes(struct amdgpu_xcp_mgr *xcp_mgr)
 		break;
 	case 6:
 		xcp_mgr->supp_xcp_modes = BIT(AMDGPU_SPX_PARTITION_MODE) |
-					  BIT(AMDGPU_DPX_PARTITION_MODE) |
 					  BIT(AMDGPU_TPX_PARTITION_MODE) |
 					  BIT(AMDGPU_CPX_PARTITION_MODE);
+
+		if (amdgpu_ip_version(adev, GC_HWIP, 0) != IP_VERSION(9, 4, 3) &&
+			amdgpu_ip_version(adev, GC_HWIP, 0) != IP_VERSION(9, 4, 4) &&
+			amdgpu_ip_version(adev, GC_HWIP, 0) != IP_VERSION(9, 5, 0))
+			xcp_mgr->supp_xcp_modes |= BIT(AMDGPU_DPX_PARTITION_MODE);
 		break;
 	case 4:
 		xcp_mgr->supp_xcp_modes = BIT(AMDGPU_SPX_PARTITION_MODE) |
Signature · 1 line
2.55.0
author maintainer
#6 lore raw

PATCH 7/7 drm/amdgpu: Skip showing available NPS modes

In reply to Alex Deucher

From: Lijo Lazar <[email protected]>

Dynamic memory partition switch is not supported on CPU-GPU xgmi connected configurations.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +2 -1
index ea0228129d5a1..7c05545063346 100644
@@ -1364,7 +1364,8 @@ int amdgpu_gmc_sysfs_init(struct amdgpu_device *adev)
 	if (!adev->gmc.gmc_funcs->query_mem_partition_mode)
 		return 0;
 
-	nps_switch_support = (hweight32(adev->gmc.supported_nps_modes &
+	nps_switch_support = !adev->gmc.xgmi.connected_to_cpu &&
+			     (hweight32(adev->gmc.supported_nps_modes &
 					AMDGPU_ALL_NPS_MASK) > 1);
 	if (!nps_switch_support)
 		dev_attr_current_memory_partition.attr.mode &=
Signature · 1 line
2.55.0