Re: [PATCH v5 2/3] cxl/edac: Skip event records marked NOT_REPAIRABLE

From: Jonathan Cameron

Date: Mon Nov 16 2026 - 20:30:27 EST


On Sun, 08 Nov 2026 11:20:24 +0900
Jongwon Lee <ai@xxxxxxxxx> wrote:

> Bit 1 of the DPA field in General Media and DRAM event records is the
> NOT_REPAIRABLE flag. The device sets it when the memory at that DPA
> cannot be repaired.
>
> cxl_find_rec_gen_media() and cxl_find_rec_dram() do not check this flag.
> A repair request that matches such a record passes the lookup and is
> sent to the device. Since the records are keyed by the raw DPA, this
> happens today when user space writes the DPA with bit 1 set.
>
> Skip these records in both lookups, so the repair request fails with
> -EINVAL. The trace events already show dpa_flags='NOT_REPAIRABLE' for
> them, so user space can tell before it asks for a repair.
>
> cxl_find_rec_gen_media() now reads the record, so take the xarray lock
> there too, as cxl_find_rec_dram() does. Also make it return bool, since
> its only caller just checks the result.
>
> Fixes: 0b5ccb0de1e2 ("cxl/edac: Support for finding memory operation attributes from the current boot")

It's silly but broken? I'd argue no. This feels like a useability improvement
to me rather than something we want to call a fix which suggests backports
make sense.

> Signed-off-by: Jongwon Lee <ai@xxxxxxxxx>
> ---
> drivers/cxl/core/edac.c | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/cxl/core/edac.c b/drivers/cxl/core/edac.c
> index 4624ab4644..42683b7c54 100644
> --- a/drivers/cxl/core/edac.c
> +++ b/drivers/cxl/core/edac.c
> @@ -918,24 +918,27 @@ struct cxl_mem_repair_attrbs {
> enum cxl_mem_repair_type repair_type;
> };
>
> -static struct cxl_event_gen_media *
> -cxl_find_rec_gen_media(struct cxl_memdev *cxlmd,
> - struct cxl_mem_repair_attrbs *attrbs)
> +static inline bool cxl_rec_not_repairable(const struct cxl_event_media_hdr *hdr)
> +{
> + return le64_to_cpu(hdr->phys_addr) & CXL_DPA_NOT_REPAIRABLE;
> +}
> +
> +static bool cxl_find_rec_gen_media(struct cxl_memdev *cxlmd,
> + struct cxl_mem_repair_attrbs *attrbs)

A find routine that doesn't return the thing requested seems misnamed.

cxl_check_for_rec_gen_media() or something like that is probably clearer.

> {
> struct cxl_mem_err_rec *array_rec = cxlmd->err_rec_array;
> struct cxl_event_gen_media *rec;
> + bool found;
>
> - if (!array_rec)
> - return NULL;
> + if (!array_rec || attrbs->repair_type != CXL_PPR)
> + return false;

I'd split those two conditions as they are completely unrelated.


>
> + xa_lock(&array_rec->rec_gen_media);

Hmm. Was assuming there would be guard() available but nope.
Was proposed but nothing happened with it.
https://lore.kernel.org/all/20240228135352.14444-1-mschmidt@xxxxxxxxxx/#r

Maybe worth resurrecting that. +CC Michal.


> rec = xa_load(&array_rec->rec_gen_media, attrbs->dpa);
> - if (!rec)
> - return NULL;
> -
> - if (attrbs->repair_type == CXL_PPR)
> - return rec;
> + found = rec && !cxl_rec_not_repairable(&rec->media_hdr);
> + xa_unlock(&array_rec->rec_gen_media);
>
> - return NULL;
> + return found;
> }