Skip to contentSkip to conversation

drm/amdgpu: Fix xgmi v6.4.1 link status reporting

PATCH In review Lijo Lazar 2 participants 2 messages Apr 1, 2025

Subsystems (2)
lore
Share & tools
lore

Lijo Lazar

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix xgmi v6.4.1 link status reporting

Use the right register offsets for getting link status.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +18 -6
index 477424472bbe..95231de26cb1 100644
@@ -296,15 +296,27 @@ static const struct amdgpu_pcs_ras_field xgmi3x16_pcs_ras_fields[] = {
 
 static u32 xgmi_v6_4_get_link_status(struct amdgpu_device *adev, int global_link_num)
 {
-	const u32 smnpcs_xgmi3x16_pcs_state_hist1 = 0x11a00070;
-	const int xgmi_inst = 2;
-	u32 link_inst;
+	const u32 smn_xgmi_6_4_pcs_state_hist1[2] = { 0x11a00070, 0x11b00070 };
+	const u32 smn_xgmi_6_4_1_pcs_state_hist1[2] = { 0x11b00070,
+							0x12100070 };
+	u32 i, n;
 	u64 addr;
 
-	link_inst = global_link_num % xgmi_inst;
+	switch (amdgpu_ip_version(adev, XGMI_HWIP, 0)) {
+	case IP_VERSION(6, 4, 0):
+		n = ARRAY_SIZE(smn_xgmi_6_4_pcs_state_hist1);
+		addr = smn_xgmi_6_4_pcs_state_hist1[global_link_num % n];
+		break;
+	case IP_VERSION(6, 4, 1):
+		n = ARRAY_SIZE(smn_xgmi_6_4_1_pcs_state_hist1);
+		addr = smn_xgmi_6_4_1_pcs_state_hist1[global_link_num % n];
+		break;
+	default:
+		return U32_MAX;
+	}
 
-	addr = (smnpcs_xgmi3x16_pcs_state_hist1 | (link_inst << 20)) +
-		adev->asic_funcs->encode_ext_smn_addressing(global_link_num / xgmi_inst);
+	i = global_link_num / n;
+	addr += adev->asic_funcs->encode_ext_smn_addressing(i);
 
 	return RREG32_PCIE_EXT(addr);
 }
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Thanks & Regards
Asad

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, April 1, 2025 4:55 PM
To: [email protected]; Lazar, Lijo <[email protected]>
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Kamal, Asad <[email protected]>
Subject: [PATCH] drm/amdgpu: Fix xgmi v6.4.1 link status reporting

Use the right register offsets for getting link status.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c +18 -7
index 477424472bbe..95231de26cb1 100644
@@ -296,15 +296,27 @@ static const struct amdgpu_pcs_ras_field xgmi3x16_pcs_ras_fields[] = {
 
 static u32 xgmi_v6_4_get_link_status(struct amdgpu_device *adev, int global_link_num)  {
-       const u32 smnpcs_xgmi3x16_pcs_state_hist1 = 0x11a00070;
-       const int xgmi_inst = 2;
-       u32 link_inst;
+       const u32 smn_xgmi_6_4_pcs_state_hist1[2] = { 0x11a00070, 0x11b00070 };
+       const u32 smn_xgmi_6_4_1_pcs_state_hist1[2] = { 0x11b00070,
+                                                       0x12100070 };
+       u32 i, n;
        u64 addr;
 
-       link_inst = global_link_num % xgmi_inst;
+       switch (amdgpu_ip_version(adev, XGMI_HWIP, 0)) {
+       case IP_VERSION(6, 4, 0):
+               n = ARRAY_SIZE(smn_xgmi_6_4_pcs_state_hist1);
+               addr = smn_xgmi_6_4_pcs_state_hist1[global_link_num % n];
+               break;
+       case IP_VERSION(6, 4, 1):
+               n = ARRAY_SIZE(smn_xgmi_6_4_1_pcs_state_hist1);
+               addr = smn_xgmi_6_4_1_pcs_state_hist1[global_link_num % n];
+               break;
+       default:
+               return U32_MAX;
+       }
 
-       addr = (smnpcs_xgmi3x16_pcs_state_hist1 | (link_inst << 20)) +
-               adev->asic_funcs->encode_ext_smn_addressing(global_link_num / xgmi_inst);
+       i = global_link_num / n;
+       addr += adev->asic_funcs->encode_ext_smn_addressing(i);
 
        return RREG32_PCIE_EXT(addr);
 }
--

2.25.1