On 19/11/25 08:51AM, Dave Jiang wrote:


On 11/19/25 12:52 AM, Neeraj Kumar wrote:
Modify __pmem_label_update() to update region labels into LSA

CXL 3.2 Spec mentions CXL LSA 2.1 Namespace Labels at section 9.13.2.5
Modified __pmem_label_update() using setter functions to update
namespace label as per CXL LSA 2.1

Create export routine nd_region_label_update() used for creating
region label into LSA. It will be used later from CXL subsystem

Signed-off-by: Neeraj Kumar <[email protected]>

A few nits below, otherwise
Reviewed-by: Dave Jiang <[email protected]>


---
 drivers/nvdimm/label.c          | 360 ++++++++++++++++++++++++++------
 drivers/nvdimm/label.h          |  17 +-
 drivers/nvdimm/namespace_devs.c |  25 ++-
 drivers/nvdimm/nd.h             |  66 ++++++
 include/linux/libnvdimm.h       |   8 +
 5 files changed, 406 insertions(+), 70 deletions(-)

+static unsigned long find_slot(struct nvdimm_drvdata *ndd,
+                              unsigned long label)
+{
+       unsigned long base;
+
+       base = (unsigned long) nd_label_base(ndd);

No need for space after casting

Fixed it in V5


+       return (label - base) / sizeof_namespace_label(ndd);
+}

<snip>

+static int __pmem_label_update(struct nd_region *nd_region,
+                              struct nd_mapping *nd_mapping,
+                              struct nd_namespace_pmem *nspm,
+                              int pos, unsigned long flags,
+                              enum label_type ltype)
+{
+       struct nd_interleave_set *nd_set = nd_region->nd_set;
+       struct nvdimm_drvdata *ndd = to_ndd(nd_mapping);
+       struct nd_namespace_index *nsindex;
+       struct nd_label_ent *label_ent;
+       union nd_lsa_label *lsa_label;
+       unsigned long *free;
+       struct device *dev;
+       u32 nslot, slot;
+       size_t offset;
+       int rc;
+
-       nd_dbg_dpa(nd_region, ndd, res, "\n");
+       lsa_label = to_lsa_label(ndd, slot);
+       memset(lsa_label, 0, sizeof_namespace_label(ndd));
+
+       switch (ltype) {
+       case NS_LABEL_TYPE:
+               dev = &nspm->nsio.common.dev;
+               rc = namespace_label_update(nd_region, nd_mapping,
+                               nspm, pos, flags, &lsa_label->ns_label,
+                               nsindex, slot);
+               if (rc)
+                       return rc;
+
+               break;
+       case RG_LABEL_TYPE:
+               dev = &nd_region->dev;
+               region_label_update(nd_region, &lsa_label->region_label,
+                                   nd_mapping, pos, flags, slot);

inconsistent tabbing this one vs the case above. Should pick the one that 
conforms to the rest of this file. And yeah I get it. The tab formatting under 
nvdimm is different than CXL and it's a pain going between the two.

DJ

Thanks Dave, I have fixed it in V5, Will be sending it soon


Regards,
Neeraj


Reply via email to