Re: [PATCH 08/14] EDAC/amd64: Add determine_edac_cap() into pvt->ops

Yazen Ghannam
2022-03-28T16:22:57Z

On Mon, Feb 28, 2022 at 09:43:48PM +0530, Naveen Krishna Chatradhi wrote:
> From: Muralidhara M K <muralimk@amd.com>
>
> Add function pointer for determine_edac_cap() in pvt->ops and assign
> family specific determine_edac_cap() definitions appropriately.
>

Please include the "why".

> Signed-off-by: Muralidhara M K <muralimk@amd.com>
> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
> ---
> This patch is created by splitting the 5/12th patch in series
> [v7 5/12] https://patchwork.kernel.org/project/linux-edac/patch/20220203174942.31630-6-nchatrad@amd.com/
>
> drivers/edac/amd64_edac.c | 37 ++++++++++++++++++++++++-------------
> drivers/edac/amd64_edac.h | 1 +
> 2 files changed, 25 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 15d775a9ce7e..af6711cf03e9 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -1267,13 +1267,25 @@ static int get_channel_from_ecc_syndrome(struct mem_ctl_info *, u16);
> * Determine if the DIMMs have ECC enabled. ECC is enabled ONLY if all the DIMMs
> * are ECC capable.
> */
> -static unsigned long determine_edac_cap(struct amd64_pvt *pvt)
> +static unsigned long f1x_determine_edac_cap(struct amd64_pvt *pvt)
> {
> unsigned long edac_cap = EDAC_FLAG_NONE;
> u8 bit;
>
> - if (pvt->umc) {
> - u8 i, umc_en_mask = 0, dimm_ecc_en_mask = 0;
> + bit = (pvt->fam > 0xf || pvt->ext_model >= K8_REV_F)
> + ? 19
> + : 17;
> +
> + if (pvt->dclr0 & BIT(bit))
> + edac_cap = EDAC_FLAG_SECDED;
> +
> + return edac_cap;
> +}
> +
> +static unsigned long f17_determine_edac_cap(struct amd64_pvt *pvt)
> +{
> + u8 i, umc_en_mask = 0, dimm_ecc_en_mask = 0;
> + unsigned long edac_cap = EDAC_FLAG_NONE;
>
> for_each_umc(i) {
> if (!(pvt->umc[i].sdp_ctrl & UMC_SDP_INIT))
> @@ -1288,14 +1300,6 @@ static unsigned long determine_edac_cap(struct amd64_pvt *pvt)
>
> if (umc_en_mask == dimm_ecc_en_mask)
> edac_cap = EDAC_FLAG_SECDED;
> - } else {
> - bit = (pvt->fam > 0xf || pvt->ext_model >= K8_REV_F)
> - ? 19
> - : 17;
> -
> - if (pvt->dclr0 & BIT(bit))
> - edac_cap = EDAC_FLAG_SECDED;
> - }
>
> return edac_cap;
> }
> @@ -3759,7 +3763,7 @@ static void setup_mci_misc_attrs(struct mem_ctl_info *mci)
> mci->edac_ctl_cap |= EDAC_FLAG_S4ECD4ED;

This patch is okay overall. But I think we should audit which EDAC_FLAG values
are used to make sure they truly match the system capabilities.

Thanks,
Yazen