EDAC/amd64: Find Chip Select memory size using Address Mask
authorYazen Ghannam <yazen.ghannam@amd.com>
Wed, 21 Aug 2019 23:59:59 +0000 (23:59 +0000)
committerBorislav Petkov <bp@suse.de>
Fri, 23 Aug 2019 05:23:53 +0000 (07:23 +0200)
commite53a3b267fb0a79db9ca1f1e08b97889b22013e6
tree8850719f48919cd2826f39f92846cfba6a13c9a1
parent353a1fcb8f9e5857c0fb720b9e57a86c1fb7c17e
EDAC/amd64: Find Chip Select memory size using Address Mask

Chip Select memory size reporting on AMD Family 17h was recently fixed
in order to account for interleaving. However, the current method is not
robust.

The Chip Select Address Mask can be used to find the memory size. There
are a couple of cases.

1) For single-rank and dual-rank non-interleaved, use the address mask
plus 1 as the size.

2) For dual-rank interleaved, do #1 but "de-interleave" the address mask
first.

Always "de-interleave" the address mask in order to simplify the code
flow. Bit mask manipulation is necessary to check for interleaving, so
just go ahead and do the de-interleaving. In the non-interleaved case,
the original and de-interleaved address masks will be the same.

To de-interleave the mask, count the number of zero bits in the middle
of the mask and swap them with the most significant bits.

For example,
Original=0xFFFF9FE, De-interleaved=0x3FFFFFE

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: "linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Tony Luck <tony.luck@intel.com>
Link: https://lkml.kernel.org/r/20190821235938.118710-5-Yazen.Ghannam@amd.com
drivers/edac/amd64_edac.c