CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5
Modified __pmem_label_update function using setter functions to update
namespace label as per CXL LSA 2.1
Signed-off-by: Neeraj Kumar <s.neeraj@samsung.com>
---
drivers/nvdimm/label.c | 3 +++
drivers/nvdimm/nd.h | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 3235562d0e1c..182f8c9a01bf 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -924,6 +924,7 @@ static int __pmem_label_update(struct nd_region *nd_region,
nd_label = to_label(ndd, slot);
memset(nd_label, 0, sizeof_namespace_label(ndd));
+ nsl_set_type(ndd, nd_label);
nsl_set_uuid(ndd, nd_label, nspm->uuid);
nsl_set_name(ndd, nd_label, nspm->alt_name);
nsl_set_flags(ndd, nd_label, flags);
@@ -935,7 +936,9 @@ static int __pmem_label_update(struct nd_region *nd_region,
nsl_set_lbasize(ndd, nd_label, nspm->lbasize);
nsl_set_dpa(ndd, nd_label, res->start);
nsl_set_slot(ndd, nd_label, slot);
+ nsl_set_alignment(ndd, nd_label, 0);
nsl_set_type_guid(ndd, nd_label, &nd_set->type_guid);
+ nsl_set_region_uuid(ndd, nd_label, NULL);
nsl_set_claim_class(ndd, nd_label, ndns->claim_class);
nsl_calculate_checksum(ndd, nd_label);
nd_dbg_dpa(nd_region, ndd, res, "\n");
diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h
index 158809c2be9e..e362611d82cc 100644
--- a/drivers/nvdimm/nd.h
+++ b/drivers/nvdimm/nd.h
@@ -295,6 +295,29 @@ static inline const u8 *nsl_uuid_raw(struct nvdimm_drvdata *ndd,
return nd_label->efi.uuid;
}
+static inline void nsl_set_type(struct nvdimm_drvdata *ndd,
+ struct nd_namespace_label *ns_label)
+{
+ if (ndd->cxl && ns_label)
+ uuid_parse(CXL_NAMESPACE_UUID, (uuid_t *) ns_label->cxl.type);
+}
+
+static inline void nsl_set_alignment(struct nvdimm_drvdata *ndd,
+ struct nd_namespace_label *ns_label,
+ u32 align)
+{
+ if (ndd->cxl)
+ ns_label->cxl.align = __cpu_to_le32(align);
+}
+
+static inline void nsl_set_region_uuid(struct nvdimm_drvdata *ndd,
+ struct nd_namespace_label *ns_label,
+ const uuid_t *uuid)
+{
+ if (ndd->cxl && uuid)
+ export_uuid(ns_label->cxl.region_uuid, uuid);
+}
+
bool nsl_validate_type_guid(struct nvdimm_drvdata *ndd,
struct nd_namespace_label *nd_label, guid_t *guid);
enum nvdimm_claim_class nsl_get_claim_class(struct nvdimm_drvdata *ndd,
--
2.34.1
On 9/17/25 6:41 AM, Neeraj Kumar wrote: > CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5 > Modified __pmem_label_update function using setter functions to update > namespace label as per CXL LSA 2.1 > > Signed-off-by: Neeraj Kumar <s.neeraj@samsung.com> > --- > drivers/nvdimm/label.c | 3 +++ > drivers/nvdimm/nd.h | 23 +++++++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c > index 3235562d0e1c..182f8c9a01bf 100644 > --- a/drivers/nvdimm/label.c > +++ b/drivers/nvdimm/label.c > @@ -924,6 +924,7 @@ static int __pmem_label_update(struct nd_region *nd_region, > > nd_label = to_label(ndd, slot); > memset(nd_label, 0, sizeof_namespace_label(ndd)); > + nsl_set_type(ndd, nd_label); > nsl_set_uuid(ndd, nd_label, nspm->uuid); > nsl_set_name(ndd, nd_label, nspm->alt_name); > nsl_set_flags(ndd, nd_label, flags); > @@ -935,7 +936,9 @@ static int __pmem_label_update(struct nd_region *nd_region, > nsl_set_lbasize(ndd, nd_label, nspm->lbasize); > nsl_set_dpa(ndd, nd_label, res->start); > nsl_set_slot(ndd, nd_label, slot); > + nsl_set_alignment(ndd, nd_label, 0); > nsl_set_type_guid(ndd, nd_label, &nd_set->type_guid); > + nsl_set_region_uuid(ndd, nd_label, NULL); > nsl_set_claim_class(ndd, nd_label, ndns->claim_class); > nsl_calculate_checksum(ndd, nd_label); > nd_dbg_dpa(nd_region, ndd, res, "\n"); > diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h > index 158809c2be9e..e362611d82cc 100644 > --- a/drivers/nvdimm/nd.h > +++ b/drivers/nvdimm/nd.h > @@ -295,6 +295,29 @@ static inline const u8 *nsl_uuid_raw(struct nvdimm_drvdata *ndd, > return nd_label->efi.uuid; > } > > +static inline void nsl_set_type(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label) > +{ > + if (ndd->cxl && ns_label) > + uuid_parse(CXL_NAMESPACE_UUID, (uuid_t *) ns_label->cxl.type); You can do: uuid_copy(ns_label->cxl.type, cxl_namespace_uuid); All the constant UUIDs are preparsed by nd_label_init(). For the entire series you can use those pre-parsed uuid_t and just use uuid_copy() instead of having to do string to uuid_t conversions. DJ > +} > + > +static inline void nsl_set_alignment(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label, > + u32 align) > +{ > + if (ndd->cxl) > + ns_label->cxl.align = __cpu_to_le32(align); > +} > + > +static inline void nsl_set_region_uuid(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label, > + const uuid_t *uuid) > +{ > + if (ndd->cxl && uuid) > + export_uuid(ns_label->cxl.region_uuid, uuid); > +} > + > bool nsl_validate_type_guid(struct nvdimm_drvdata *ndd, > struct nd_namespace_label *nd_label, guid_t *guid); > enum nvdimm_claim_class nsl_get_claim_class(struct nvdimm_drvdata *ndd,
On 9/17/25 6:41 AM, Neeraj Kumar wrote: > CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5 > Modified __pmem_label_update function using setter functions to update > namespace label as per CXL LSA 2.1 > > Signed-off-by: Neeraj Kumar <s.neeraj@samsung.com> > --- > drivers/nvdimm/label.c | 3 +++ > drivers/nvdimm/nd.h | 23 +++++++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c > index 3235562d0e1c..182f8c9a01bf 100644 > --- a/drivers/nvdimm/label.c > +++ b/drivers/nvdimm/label.c > @@ -924,6 +924,7 @@ static int __pmem_label_update(struct nd_region *nd_region, > > nd_label = to_label(ndd, slot); > memset(nd_label, 0, sizeof_namespace_label(ndd)); > + nsl_set_type(ndd, nd_label); > nsl_set_uuid(ndd, nd_label, nspm->uuid); > nsl_set_name(ndd, nd_label, nspm->alt_name); > nsl_set_flags(ndd, nd_label, flags); > @@ -935,7 +936,9 @@ static int __pmem_label_update(struct nd_region *nd_region, > nsl_set_lbasize(ndd, nd_label, nspm->lbasize); > nsl_set_dpa(ndd, nd_label, res->start); > nsl_set_slot(ndd, nd_label, slot); > + nsl_set_alignment(ndd, nd_label, 0); > nsl_set_type_guid(ndd, nd_label, &nd_set->type_guid); > + nsl_set_region_uuid(ndd, nd_label, NULL); > nsl_set_claim_class(ndd, nd_label, ndns->claim_class); > nsl_calculate_checksum(ndd, nd_label); > nd_dbg_dpa(nd_region, ndd, res, "\n"); > diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h > index 158809c2be9e..e362611d82cc 100644 > --- a/drivers/nvdimm/nd.h > +++ b/drivers/nvdimm/nd.h > @@ -295,6 +295,29 @@ static inline const u8 *nsl_uuid_raw(struct nvdimm_drvdata *ndd, > return nd_label->efi.uuid; > } > > +static inline void nsl_set_type(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label) > +{ > + if (ndd->cxl && ns_label) > + uuid_parse(CXL_NAMESPACE_UUID, (uuid_t *) ns_label->cxl.type); Personally would prefer something like: if (!(ndd->cxl && ns_label)) return; uuid_parse(....); Also, no space needed after casting. > +} > + > +static inline void nsl_set_alignment(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label, > + u32 align) > +{ > + if (ndd->cxl) > + ns_label->cxl.align = __cpu_to_le32(align); same comment as above > +} > + > +static inline void nsl_set_region_uuid(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label, > + const uuid_t *uuid) > +{ > + if (ndd->cxl && uuid) > + export_uuid(ns_label->cxl.region_uuid, uuid); same comment as above > +} > + > bool nsl_validate_type_guid(struct nvdimm_drvdata *ndd, > struct nd_namespace_label *nd_label, guid_t *guid); > enum nvdimm_claim_class nsl_get_claim_class(struct nvdimm_drvdata *ndd,
On 19/09/25 04:59PM, Dave Jiang wrote: > > >On 9/17/25 6:41 AM, Neeraj Kumar wrote: >> CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5 >> Modified __pmem_label_update function using setter functions to update >> namespace label as per CXL LSA 2.1 >> >> Signed-off-by: Neeraj Kumar <s.neeraj@samsung.com> >> --- >> drivers/nvdimm/label.c | 3 +++ >> drivers/nvdimm/nd.h | 23 +++++++++++++++++++++++ >> 2 files changed, 26 insertions(+) >> >> diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c >> index 3235562d0e1c..182f8c9a01bf 100644 >> --- a/drivers/nvdimm/label.c >> +++ b/drivers/nvdimm/label.c >> +static inline void nsl_set_type(struct nvdimm_drvdata *ndd, >> + struct nd_namespace_label *ns_label) >> +{ >> + if (ndd->cxl && ns_label) >> + uuid_parse(CXL_NAMESPACE_UUID, (uuid_t *) ns_label->cxl.type); > >Personally would prefer something like: > >if (!(ndd->cxl && ns_label)) > return; >uuid_parse(....); > >Also, no space needed after casting. > >> +} >> + >> +static inline void nsl_set_alignment(struct nvdimm_drvdata *ndd, >> + struct nd_namespace_label *ns_label, >> + u32 align) >> +{ >> + if (ndd->cxl) >> + ns_label->cxl.align = __cpu_to_le32(align); > >same comment as above >> +} >> + >> +static inline void nsl_set_region_uuid(struct nvdimm_drvdata *ndd, >> + struct nd_namespace_label *ns_label, >> + const uuid_t *uuid) >> +{ >> + if (ndd->cxl && uuid) >> + export_uuid(ns_label->cxl.region_uuid, uuid); > >same comment as above Sure Dave, I will fix it in next patch-set Regards, Neeraj
Neeraj Kumar wrote: > CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5 > Modified __pmem_label_update function using setter functions to update > namespace label as per CXL LSA 2.1 Again I'm curious as to why? Is it to be able to use the setter's later? I see a call to nsl_set_type() added later in the series but then deleted in an even later patch. (??) I don't have time ATM to really follow this through but giving a why in the commit message may have made this a simple patch to review. Now I'm not clear if it is ok or not. Ira > > Signed-off-by: Neeraj Kumar <s.neeraj@samsung.com> > --- > drivers/nvdimm/label.c | 3 +++ > drivers/nvdimm/nd.h | 23 +++++++++++++++++++++++ > 2 files changed, 26 insertions(+) > > diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c > index 3235562d0e1c..182f8c9a01bf 100644 > --- a/drivers/nvdimm/label.c > +++ b/drivers/nvdimm/label.c > @@ -924,6 +924,7 @@ static int __pmem_label_update(struct nd_region *nd_region, > > nd_label = to_label(ndd, slot); > memset(nd_label, 0, sizeof_namespace_label(ndd)); > + nsl_set_type(ndd, nd_label); > nsl_set_uuid(ndd, nd_label, nspm->uuid); > nsl_set_name(ndd, nd_label, nspm->alt_name); > nsl_set_flags(ndd, nd_label, flags); > @@ -935,7 +936,9 @@ static int __pmem_label_update(struct nd_region *nd_region, > nsl_set_lbasize(ndd, nd_label, nspm->lbasize); > nsl_set_dpa(ndd, nd_label, res->start); > nsl_set_slot(ndd, nd_label, slot); > + nsl_set_alignment(ndd, nd_label, 0); > nsl_set_type_guid(ndd, nd_label, &nd_set->type_guid); > + nsl_set_region_uuid(ndd, nd_label, NULL); > nsl_set_claim_class(ndd, nd_label, ndns->claim_class); > nsl_calculate_checksum(ndd, nd_label); > nd_dbg_dpa(nd_region, ndd, res, "\n"); > diff --git a/drivers/nvdimm/nd.h b/drivers/nvdimm/nd.h > index 158809c2be9e..e362611d82cc 100644 > --- a/drivers/nvdimm/nd.h > +++ b/drivers/nvdimm/nd.h > @@ -295,6 +295,29 @@ static inline const u8 *nsl_uuid_raw(struct nvdimm_drvdata *ndd, > return nd_label->efi.uuid; > } > > +static inline void nsl_set_type(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label) > +{ > + if (ndd->cxl && ns_label) > + uuid_parse(CXL_NAMESPACE_UUID, (uuid_t *) ns_label->cxl.type); > +} > + > +static inline void nsl_set_alignment(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label, > + u32 align) > +{ > + if (ndd->cxl) > + ns_label->cxl.align = __cpu_to_le32(align); > +} > + > +static inline void nsl_set_region_uuid(struct nvdimm_drvdata *ndd, > + struct nd_namespace_label *ns_label, > + const uuid_t *uuid) > +{ > + if (ndd->cxl && uuid) > + export_uuid(ns_label->cxl.region_uuid, uuid); > +} > + > bool nsl_validate_type_guid(struct nvdimm_drvdata *ndd, > struct nd_namespace_label *nd_label, guid_t *guid); > enum nvdimm_claim_class nsl_get_claim_class(struct nvdimm_drvdata *ndd, > -- > 2.34.1 > >
On 19/09/25 05:00PM, Ira Weiny wrote: >Neeraj Kumar wrote: >> CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5 >> Modified __pmem_label_update function using setter functions to update >> namespace label as per CXL LSA 2.1 > >Again I'm curious as to why? > >Is it to be able to use the setter's later? I see a call to >nsl_set_type() added later in the series but then deleted in an even later >patch. (??) > >I don't have time ATM to really follow this through but giving a why in >the commit message may have made this a simple patch to review. Now I'm >not clear if it is ok or not. Hi Ira, Yes these setter functions are required because of namespace modifications as per LSA 2.1. Actually it looks deleted due to refactoring of __pmem_label_update() in later patch. I got your point, I will re-arrange it after __pmem_label_update() refactoring. Regards, Neeraj
On Wed, 17 Sep 2025 19:11:01 +0530 Neeraj Kumar <s.neeraj@samsung.com> wrote: > CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5 > Modified __pmem_label_update function using setter functions to update > namespace label as per CXL LSA 2.1 > > Signed-off-by: Neeraj Kumar <s.neeraj@samsung.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Note I'm not particularly familiar with the nvdimm code so this will ideally want review from someone who is! Jonathan
© 2016 - 2025 Red Hat, Inc.