Skip to content

Commit 9f4873f

Browse files
yghannamsuryasaimadhu
authored andcommitted
EDAC/amd64: Handle three rank interleaving mode
AMD Rome systems and later support interleaving between three identical ranks within a channel. Check for this mode by counting the number of enabled chip selects and comparing their masks. If there are exactly three enabled chip selects and their masks are identical, then three rank interleaving is enabled. The size of a rank is determined from its mask value. However, three rank interleaving doesn't follow the method of swapping an interleave bit with the most significant bit. Rather, the interleave bit is flipped and the most significant bit remains the same. There is only a single interleave bit in this case. Account for this when determining the chip select size by keeping the most significant bit at its original value and ignoring any zero bits. This will return a full bitmask in [MSB:1]. Fixes: e53a3b2 ("EDAC/amd64: Find Chip Select memory size using Address Mask") Signed-off-by: Yazen Ghannam <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 34417f2 commit 9f4873f

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

drivers/edac/amd64_edac.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,12 +1065,14 @@ static void debug_dump_dramcfg_low(struct amd64_pvt *pvt, u32 dclr, int chan)
10651065
#define CS_ODD_PRIMARY BIT(1)
10661066
#define CS_EVEN_SECONDARY BIT(2)
10671067
#define CS_ODD_SECONDARY BIT(3)
1068+
#define CS_3R_INTERLEAVE BIT(4)
10681069

10691070
#define CS_EVEN (CS_EVEN_PRIMARY | CS_EVEN_SECONDARY)
10701071
#define CS_ODD (CS_ODD_PRIMARY | CS_ODD_SECONDARY)
10711072

10721073
static int f17_get_cs_mode(int dimm, u8 ctrl, struct amd64_pvt *pvt)
10731074
{
1075+
u8 base, count = 0;
10741076
int cs_mode = 0;
10751077

10761078
if (csrow_enabled(2 * dimm, ctrl, pvt))
@@ -1083,6 +1085,20 @@ static int f17_get_cs_mode(int dimm, u8 ctrl, struct amd64_pvt *pvt)
10831085
if (csrow_sec_enabled(2 * dimm + 1, ctrl, pvt))
10841086
cs_mode |= CS_ODD_SECONDARY;
10851087

1088+
/*
1089+
* 3 Rank inteleaving support.
1090+
* There should be only three bases enabled and their two masks should
1091+
* be equal.
1092+
*/
1093+
for_each_chip_select(base, ctrl, pvt)
1094+
count += csrow_enabled(base, ctrl, pvt);
1095+
1096+
if (count == 3 &&
1097+
pvt->csels[ctrl].csmasks[0] == pvt->csels[ctrl].csmasks[1]) {
1098+
edac_dbg(1, "3R interleaving in use.\n");
1099+
cs_mode |= CS_3R_INTERLEAVE;
1100+
}
1101+
10861102
return cs_mode;
10871103
}
10881104

@@ -1891,10 +1907,14 @@ static int f17_addr_mask_to_cs_size(struct amd64_pvt *pvt, u8 umc,
18911907
*
18921908
* The MSB is the number of bits in the full mask because BIT[0] is
18931909
* always 0.
1910+
*
1911+
* In the special 3 Rank interleaving case, a single bit is flipped
1912+
* without swapping with the most significant bit. This can be handled
1913+
* by keeping the MSB where it is and ignoring the single zero bit.
18941914
*/
18951915
msb = fls(addr_mask_orig) - 1;
18961916
weight = hweight_long(addr_mask_orig);
1897-
num_zero_bits = msb - weight;
1917+
num_zero_bits = msb - weight - !!(cs_mode & CS_3R_INTERLEAVE);
18981918

18991919
/* Take the number of zero bits off from the top of the mask. */
19001920
addr_mask_deinterleaved = GENMASK_ULL(msb - num_zero_bits, 1);

0 commit comments

Comments
 (0)