Re: [PATCH 2/2] RAS: Introduce the FRU Memory Poison Manager

From: Borislav Petkov
Date: Wed Feb 14 2024 - 06:06:11 EST


On Tue, Feb 13, 2024 at 09:35:16PM -0600, Yazen Ghannam wrote:
> +static inline struct cper_fru_poison_desc *get_fpd(struct fru_rec *rec, u32 entry)
> +{
> + return &rec->entries[entry];
> +}

This one needs to go too.

> +static inline u32 get_fmp_len(struct fru_rec *rec)
> +{
> + return rec->sec_desc.section_length - sizeof(struct cper_section_descriptor);
> +}

Oh well, I guess we can keep that one.

> +/* Calculate a new checksum. */
> +static u32 get_fmp_checksum(struct fru_rec *rec)
> +{
> + struct cper_sec_fru_mem_poison *fmp = get_fmp(rec);
> + u32 len, checksum;
> +
> + len = get_fmp_len(rec);
> +
> + /* Get the current total. */
> + checksum = do_fmp_checksum(fmp, len);
> +
> + /* Subtract the current checksum from total. */
> + checksum -= fmp->checksum;
> +
> + /* Return the compliment value. */
> + return 0 - checksum;
> +}

Let's get rid of that one.

Also, I think it is called *complement* value and you simply do

/* Use the complement value. */
rec->fmp.checksum = -checksum;

I'd say.

---

diff --git a/drivers/ras/amd/fmpm.c b/drivers/ras/amd/fmpm.c
index 9eaf892e35b9..f8799beddcc4 100644
--- a/drivers/ras/amd/fmpm.c
+++ b/drivers/ras/amd/fmpm.c
@@ -195,11 +195,12 @@ static u32 do_fmp_checksum(struct cper_sec_fru_mem_poison *fmp, u32 len)
return checksum;
}

-/* Calculate a new checksum. */
-static u32 get_fmp_checksum(struct fru_rec *rec)
+static int update_record_on_storage(struct fru_rec *rec)
{
u32 len, checksum;
+ int ret;

+ /* Calculate a new checksum. */
len = get_fmp_len(rec);

/* Get the current total. */
@@ -208,15 +209,8 @@ static u32 get_fmp_checksum(struct fru_rec *rec)
/* Subtract the current checksum from total. */
checksum -= rec->fmp.checksum;

- /* Return the compliment value. */
- return 0 - checksum;
-}
-
-static int update_record_on_storage(struct fru_rec *rec)
-{
- int ret;
-
- rec->fmp.checksum = get_fmp_checksum(rec);
+ /* Use the complement value. */
+ rec->fmp.checksum = -checksum;

pr_debug("Writing to storage");


--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette