diff mbox series

[ndctl,v4,11/17] libcxl: add a stub interface to determine whether a memdev is active

Message ID 20211007082139.3088615-12-vishal.l.verma@intel.com
State Superseded
Headers show
Series Initial CXL support | expand

Commit Message

Verma, Vishal L Oct. 7, 2021, 8:21 a.m. UTC
Add an interface to determine whether a memdev is bound to a region
driver and therefore is currently active.

For now, this just returns '0' all the time - i.e. devices are always
considered inactive. Flesh this out fully once the region driver is
available.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 cxl/lib/libcxl.c   | 10 ++++++++++
 cxl/libcxl.h       |  1 +
 cxl/lib/libcxl.sym |  1 +
 3 files changed, 12 insertions(+)

Comments

Dan Williams Oct. 14, 2021, 7:59 p.m. UTC | #1
On Thu, Oct 7, 2021 at 1:22 AM Vishal Verma <vishal.l.verma@intel.com> wrote:
>
> Add an interface to determine whether a memdev is bound to a region
> driver and therefore is currently active.
>
> For now, this just returns '0' all the time - i.e. devices are always
> considered inactive. Flesh this out fully once the region driver is
> available.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  cxl/lib/libcxl.c   | 10 ++++++++++
>  cxl/libcxl.h       |  1 +
>  cxl/lib/libcxl.sym |  1 +
>  3 files changed, 12 insertions(+)
>
> diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
> index de3a8f7..59d091c 100644
> --- a/cxl/lib/libcxl.c
> +++ b/cxl/lib/libcxl.c
> @@ -362,6 +362,16 @@ CXL_EXPORT size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev)
>         return memdev->lsa_size;
>  }
>
> +CXL_EXPORT int cxl_memdev_is_active(struct cxl_memdev *memdev)
> +{
> +       /*
> +        * TODO: Currently memdevs are always considered inactive. Once we have
> +        * cxl_bus drivers that are bound/unbound to memdevs, we'd use that to
> +        * determine the active/inactive state.
> +        */

So I jumped ahead to look at the use case for this and it brings up
questions if this is the right check for the label helpers to be
using. Note that the LSA commands may still be disabled even if the
memdev is inactive. This is because the NVDIMM bridge might be up and
have claimed the label operations for exclusive access via /dev/nmemX.

So perhaps this should become a narrower focused
cxl_memdev_label_area_active() or cxl_memdev_nvdimm_bridge_active().

I think Ben and I still need to arm wrestle how to mediate the label
area, but my going-in position is that the CXL subsystem works through
the NVDIMM subsystem to coordinate label updates. So
cxl_memdev_nvdimm_bridge_active() should be a sufficient check for
now. That's determined simply by the existence of a pmemX device as a
child of a memX device.


> +       return 0;
> +}
> +
>  CXL_EXPORT void cxl_cmd_unref(struct cxl_cmd *cmd)
>  {
>         if (!cmd)
> diff --git a/cxl/libcxl.h b/cxl/libcxl.h
> index d3b97a1..2e24371 100644
> --- a/cxl/libcxl.h
> +++ b/cxl/libcxl.h
> @@ -43,6 +43,7 @@ unsigned long long cxl_memdev_get_pmem_size(struct cxl_memdev *memdev);
>  unsigned long long cxl_memdev_get_ram_size(struct cxl_memdev *memdev);
>  const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev);
>  size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev);
> +int cxl_memdev_is_active(struct cxl_memdev *memdev);
>
>  #define cxl_memdev_foreach(ctx, memdev) \
>          for (memdev = cxl_memdev_get_first(ctx); \
> diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
> index b9feb93..0e82030 100644
> --- a/cxl/lib/libcxl.sym
> +++ b/cxl/lib/libcxl.sym
> @@ -79,4 +79,5 @@ global:
>  LIBCXL_4 {
>  global:
>         cxl_memdev_get_label_size;
> +       cxl_memdev_is_active;
>  } LIBCXL_3;
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index de3a8f7..59d091c 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -362,6 +362,16 @@  CXL_EXPORT size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev)
 	return memdev->lsa_size;
 }
 
+CXL_EXPORT int cxl_memdev_is_active(struct cxl_memdev *memdev)
+{
+	/*
+	 * TODO: Currently memdevs are always considered inactive. Once we have
+	 * cxl_bus drivers that are bound/unbound to memdevs, we'd use that to
+	 * determine the active/inactive state.
+	 */
+	return 0;
+}
+
 CXL_EXPORT void cxl_cmd_unref(struct cxl_cmd *cmd)
 {
 	if (!cmd)
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
index d3b97a1..2e24371 100644
--- a/cxl/libcxl.h
+++ b/cxl/libcxl.h
@@ -43,6 +43,7 @@  unsigned long long cxl_memdev_get_pmem_size(struct cxl_memdev *memdev);
 unsigned long long cxl_memdev_get_ram_size(struct cxl_memdev *memdev);
 const char *cxl_memdev_get_firmware_verison(struct cxl_memdev *memdev);
 size_t cxl_memdev_get_label_size(struct cxl_memdev *memdev);
+int cxl_memdev_is_active(struct cxl_memdev *memdev);
 
 #define cxl_memdev_foreach(ctx, memdev) \
         for (memdev = cxl_memdev_get_first(ctx); \
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
index b9feb93..0e82030 100644
--- a/cxl/lib/libcxl.sym
+++ b/cxl/lib/libcxl.sym
@@ -79,4 +79,5 @@  global:
 LIBCXL_4 {
 global:
 	cxl_memdev_get_label_size;
+	cxl_memdev_is_active;
 } LIBCXL_3;