On Fri,  9 Jan 2026 18:14:28 +0530
Neeraj Kumar <[email protected]> wrote:

> Preserve region information from region label during nvdimm_probe. This
> preserved region information is used for creating cxl region to achieve
> region persistency across reboot.
> This patch supports interleave way == 1, it is therefore it preserves
> only one region into LSA
> 
> Reviewed-by: Dave Jiang <[email protected]>
> Signed-off-by: Neeraj Kumar <[email protected]>

With change to import for getting the region uuid,
Reviewed-by: Jonathan Cameron <[email protected]>

> diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
> index 2ad148bfe40b..7adb415f0926 100644
> --- a/drivers/nvdimm/label.c
> +++ b/drivers/nvdimm/label.c
> @@ -494,6 +494,42 @@ int nd_label_reserve_dpa(struct nvdimm_drvdata *ndd)
>       return 0;
>  }
>  
> +int nvdimm_cxl_region_preserve(struct nvdimm_drvdata *ndd)
> +{
> +     struct nvdimm *nvdimm = to_nvdimm(ndd->dev);
> +     struct cxl_pmem_region_params *p = &nvdimm->cxl_region_params;
> +     struct nd_namespace_index *nsindex;
> +     unsigned long *free;
> +     u32 nslot, slot;
> +
> +     if (!preamble_current(ndd, &nsindex, &free, &nslot))
> +             return 0; /* no label, nothing to preserve */
> +
> +     for_each_clear_bit_le(slot, free, nslot) {
> +             union nd_lsa_label *lsa_label = to_lsa_label(ndd, slot);
> +             struct cxl_region_label *region_label = 
> &lsa_label->region_label;
> +             uuid_t *region_uuid = (uuid_t *)&region_label->type;

Another case where I think we should be importing.
I'm not entirely sure why that's the convention for these but we
should probably stick to it anyway.

> +
> +             /* TODO: Currently preserving only one region */
> +             if (uuid_equal(&cxl_region_uuid, region_uuid)) {
> +                     nvdimm->is_region_label = true;
> +                     import_uuid(&p->uuid, region_label->uuid);
> +                     p->flags = __le32_to_cpu(region_label->flags);
> +                     p->nlabel = __le16_to_cpu(region_label->nlabel);
> +                     p->position = __le16_to_cpu(region_label->position);
> +                     p->dpa = __le64_to_cpu(region_label->dpa);
> +                     p->rawsize = __le64_to_cpu(region_label->rawsize);
> +                     p->hpa = __le64_to_cpu(region_label->hpa);
> +                     p->slot = __le32_to_cpu(region_label->slot);
> +                     p->ig = __le32_to_cpu(region_label->ig);
> +                     p->align = __le32_to_cpu(region_label->align);
> +                     break;
> +             }
> +     }
> +
> +     return 0;
> +}


Reply via email to