Re: [PATCH V4 09/17] nvdimm/label: Export routine to fetch region information

2026-01-09 Thread Neeraj Kumar

On 17/12/25 03:12PM, Jonathan Cameron wrote:

On Wed, 19 Nov 2025 13:22:47 +0530
Neeraj Kumar  wrote:


CXL region information preserved from the LSA needs to be exported for
use by the CXL driver for CXL region re-creation.

To me it feels like the !nvdimm checks may be excessive in an interface
that makes no sense if NULL is passed in.
Perhaps drop those?



Signed-off-by: Neeraj Kumar 
---
 drivers/nvdimm/dimm_devs.c | 18 ++
 include/linux/libnvdimm.h  |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index 3363a97cc5b5..1474b4e45fcc 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -280,6 +280,24 @@ void *nvdimm_provider_data(struct nvdimm *nvdimm)
 }
 EXPORT_SYMBOL_GPL(nvdimm_provider_data);

+bool nvdimm_has_cxl_region(struct nvdimm *nvdimm)
+{
+   if (!nvdimm)
+   return false;


Seems a bit odd that this would ever get called on !nvdimm.
Is that protection worth adding?


+
+   return nvdimm->is_region_label;
+}
+EXPORT_SYMBOL_GPL(nvdimm_has_cxl_region);
+
+void *nvdimm_get_cxl_region_param(struct nvdimm *nvdimm)
+{
+   if (!nvdimm)


This feels a little more plausible as defense but is this
needed?


Yes we can avoid this check, I have fixed it in V5.


Regards,
Neeraj


Re: [PATCH V4 09/17] nvdimm/label: Export routine to fetch region information

2025-12-17 Thread Jonathan Cameron
On Wed, 19 Nov 2025 13:22:47 +0530
Neeraj Kumar  wrote:

> CXL region information preserved from the LSA needs to be exported for
> use by the CXL driver for CXL region re-creation.
To me it feels like the !nvdimm checks may be excessive in an interface
that makes no sense if NULL is passed in.
Perhaps drop those?

> 
> Signed-off-by: Neeraj Kumar 
> ---
>  drivers/nvdimm/dimm_devs.c | 18 ++
>  include/linux/libnvdimm.h  |  2 ++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 3363a97cc5b5..1474b4e45fcc 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -280,6 +280,24 @@ void *nvdimm_provider_data(struct nvdimm *nvdimm)
>  }
>  EXPORT_SYMBOL_GPL(nvdimm_provider_data);
>  
> +bool nvdimm_has_cxl_region(struct nvdimm *nvdimm)
> +{
> + if (!nvdimm)
> + return false;

Seems a bit odd that this would ever get called on !nvdimm.
Is that protection worth adding?

> +
> + return nvdimm->is_region_label;
> +}
> +EXPORT_SYMBOL_GPL(nvdimm_has_cxl_region);
> +
> +void *nvdimm_get_cxl_region_param(struct nvdimm *nvdimm)
> +{
> + if (!nvdimm)

This feels a little more plausible as defense but is this
needed?

> + return NULL;
> +
> + return &nvdimm->cxl_region_params;
> +}
> +EXPORT_SYMBOL_GPL(nvdimm_get_cxl_region_param);
> +
>  static ssize_t commands_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
>  {
> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
> index 07ea2e3f821a..3ffd50ab6ac4 100644
> --- a/include/linux/libnvdimm.h
> +++ b/include/linux/libnvdimm.h
> @@ -330,6 +330,8 @@ int nvdimm_in_overwrite(struct nvdimm *nvdimm);
>  bool is_nvdimm_sync(struct nd_region *nd_region);
>  int nd_region_label_update(struct nd_region *nd_region);
>  int nd_region_label_delete(struct nd_region *nd_region);
> +bool nvdimm_has_cxl_region(struct nvdimm *nvdimm);
> +void *nvdimm_get_cxl_region_param(struct nvdimm *nvdimm);
>  
>  static inline int nvdimm_ctl(struct nvdimm *nvdimm, unsigned int cmd, void 
> *buf,
>   unsigned int buf_len, int *cmd_rc)




Re: [PATCH V4 09/17] nvdimm/label: Export routine to fetch region information

2025-11-19 Thread Dave Jiang



On 11/19/25 12:52 AM, Neeraj Kumar wrote:
> CXL region information preserved from the LSA needs to be exported for
> use by the CXL driver for CXL region re-creation.
> 
> Signed-off-by: Neeraj Kumar 

Reviewed-by: Dave Jiang 

> ---
>  drivers/nvdimm/dimm_devs.c | 18 ++
>  include/linux/libnvdimm.h  |  2 ++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
> index 3363a97cc5b5..1474b4e45fcc 100644
> --- a/drivers/nvdimm/dimm_devs.c
> +++ b/drivers/nvdimm/dimm_devs.c
> @@ -280,6 +280,24 @@ void *nvdimm_provider_data(struct nvdimm *nvdimm)
>  }
>  EXPORT_SYMBOL_GPL(nvdimm_provider_data);
>  
> +bool nvdimm_has_cxl_region(struct nvdimm *nvdimm)
> +{
> + if (!nvdimm)
> + return false;
> +
> + return nvdimm->is_region_label;
> +}
> +EXPORT_SYMBOL_GPL(nvdimm_has_cxl_region);
> +
> +void *nvdimm_get_cxl_region_param(struct nvdimm *nvdimm)
> +{
> + if (!nvdimm)
> + return NULL;
> +
> + return &nvdimm->cxl_region_params;
> +}
> +EXPORT_SYMBOL_GPL(nvdimm_get_cxl_region_param);
> +
>  static ssize_t commands_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
>  {
> diff --git a/include/linux/libnvdimm.h b/include/linux/libnvdimm.h
> index 07ea2e3f821a..3ffd50ab6ac4 100644
> --- a/include/linux/libnvdimm.h
> +++ b/include/linux/libnvdimm.h
> @@ -330,6 +330,8 @@ int nvdimm_in_overwrite(struct nvdimm *nvdimm);
>  bool is_nvdimm_sync(struct nd_region *nd_region);
>  int nd_region_label_update(struct nd_region *nd_region);
>  int nd_region_label_delete(struct nd_region *nd_region);
> +bool nvdimm_has_cxl_region(struct nvdimm *nvdimm);
> +void *nvdimm_get_cxl_region_param(struct nvdimm *nvdimm);
>  
>  static inline int nvdimm_ctl(struct nvdimm *nvdimm, unsigned int cmd, void 
> *buf,
>   unsigned int buf_len, int *cmd_rc)