drm/amdgpu: correct mca ipid die/socket/addr decode
authorYang Wang <kevinyang.wang@amd.com>
Fri, 10 Nov 2023 05:14:41 +0000 (13:14 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Nov 2023 14:30:49 +0000 (09:30 -0500)
correct mca ipid die/socket/addr decode

v2: squash in fix from Yang

Signed-off-by: Yang Wang <kevinyang.wang@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c

index 0e5a77c3c2e216362b2e5363f1ec25f62940ede3..f723a4190ee52097d69579bdc668b45c8a7b3e17 100644 (file)
@@ -2392,8 +2392,8 @@ static const struct mca_bank_ipid smu_v13_0_6_mca_ipid_table[AMDGPU_MCA_IP_COUNT
 
 static void mca_bank_entry_info_decode(struct mca_bank_entry *entry, struct mca_bank_info *info)
 {
-       uint64_t ipid = entry->regs[MCA_REG_IDX_IPID];
-       uint32_t insthi;
+       u64 ipid = entry->regs[MCA_REG_IDX_IPID];
+       u32 instidhi, instid;
 
        /* NOTE: All MCA IPID register share the same format,
         * so the driver can share the MCMP1 register header file.
@@ -2402,9 +2402,15 @@ static void mca_bank_entry_info_decode(struct mca_bank_entry *entry, struct mca_
        info->hwid = REG_GET_FIELD(ipid, MCMP1_IPIDT0, HardwareID);
        info->mcatype = REG_GET_FIELD(ipid, MCMP1_IPIDT0, McaType);
 
-       insthi = REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi);
-       info->aid = ((insthi >> 2) & 0x03);
-       info->socket_id = insthi & 0x03;
+       /*
+        * Unfied DieID Format: SAASS. A:AID, S:Socket.
+        * Unfied DieID[4] = InstanceId[0]
+        * Unfied DieID[0:3] = InstanceIdHi[0:3]
+        */
+       instidhi = REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdHi);
+       instid = REG_GET_FIELD(ipid, MCMP1_IPIDT0, InstanceIdLo);
+       info->aid = ((instidhi >> 2) & 0x03);
+       info->socket_id = ((instid & 0x1) << 2) | (instidhi & 0x03);
 }
 
 static int mca_bank_read_reg(struct amdgpu_device *adev, enum amdgpu_mca_error_type type,
@@ -2578,6 +2584,7 @@ static bool mca_gfx_smu_bank_is_valid(const struct mca_ras_info *mca_ras, struct
        uint32_t instlo;
 
        instlo = REG_GET_FIELD(entry->regs[MCA_REG_IDX_IPID], MCMP1_IPIDT0, InstanceIdLo);
+       instlo &= GENMASK(31, 1);
        switch (instlo) {
        case 0x36430400: /* SMNAID XCD 0 */
        case 0x38430400: /* SMNAID XCD 1 */
@@ -2596,6 +2603,7 @@ static bool mca_smu_bank_is_valid(const struct mca_ras_info *mca_ras, struct amd
        uint32_t errcode, instlo;
 
        instlo = REG_GET_FIELD(entry->regs[MCA_REG_IDX_IPID], MCMP1_IPIDT0, InstanceIdLo);
+       instlo &= GENMASK(31, 1);
        if (instlo != 0x03b30400)
                return false;