NVDIMM Device and Persistent Memory development
 help / color / mirror / Atom feed
* [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli
@ 2024-11-15 18:40 Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 1/9] ndctl/cxl-events: Don't fail test until event counts are reported Ira Weiny
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:40 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny,
	Sushant1 Kumar

Feedback from v2 lead to the realization that cxl-cli required changes
to address the region mode vs decoder mode difference properly.

While v2 separated these modes they were not sufficiently separated in
the user interface of create-region.  This has been corrected in this
version.  Specifically a new option has been added to cxl create-region.
The option requires a decoder mode (DC partition) when the region type
is 'dc'.  The option is ignored, and can be omitted, for ram and pmem
regions.

Other libcxl API changes were made to simplify the interface a bit.

Documentation was added both at the libcxl and cxl-cli levels.

cxl-dcd.sh was cleaned up quite a bit an enhanced.

https://github.com/weiny2/ndctl/tree/dcd-region2-2024-11-15

CXL Dynamic Capacity Device (DCD) support is close to landing in the
upstream kernel.  cxl-cli requires modifications to interact with those
devices.  This includes creating and operating on DCD regions.
cxl-testing allows for quick regression testing as well as helping to
design the cxl-cli interfaces.

Add preliminary patches with some fixes.  Update libcxl, cxl-cli and
cxl-test with DCD support.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Major changes in v3:
- [djiang: rework test script for clarity]
- [Alison: split patches between libcxl changes and cli changes]
- [Alison: fix lib symbol versioning]
- [iweiny: clarify region vs decoder mode with API to specify the
  decoder mode]
- Link to v2: https://patch.msgid.link/20241104-dcd-region2-v2-0-be057b479eeb@intel.com

---
Ira Weiny (7):
      ndctl/cxl-events: Don't fail test until event counts are reported
      ndctl/cxl/region: Report max size for region creation
      libcxl: Separate region mode from decoder mode
      cxl/region: Use new region mode in cxl-cli
      libcxl: Add extent functionality to DC regions
      cxl/region: Add extent output to region query
      cxl/test: Add Dynamic Capacity tests

Navneet Singh (2):
      libcxl: Add Dynamic Capacity region support
      cxl/region: Add cxl-cli support for DCD regions

 Documentation/cxl/cxl-create-region.txt |  11 +-
 Documentation/cxl/cxl-list.txt          |  29 ++
 Documentation/cxl/lib/libcxl.txt        |  62 ++-
 cxl/filter.h                            |   3 +
 cxl/json.c                              |  80 ++-
 cxl/json.h                              |   3 +
 cxl/lib/libcxl.c                        | 261 +++++++++-
 cxl/lib/libcxl.sym                      |  13 +
 cxl/lib/private.h                       |  17 +-
 cxl/libcxl.h                            |  96 +++-
 cxl/list.c                              |   3 +
 cxl/memdev.c                            |   4 +-
 cxl/region.c                            |  93 +++-
 test/cxl-dcd.sh                         | 879 ++++++++++++++++++++++++++++++++
 test/cxl-events.sh                      |   8 +-
 test/meson.build                        |   2 +
 util/json.h                             |   1 +
 17 files changed, 1519 insertions(+), 46 deletions(-)
---
base-commit: 04815e5f8b87e02a4fb5a61aeebaa5cad25a15c3
change-id: 20241030-dcd-region2-2d0149eb8efd

Best regards,
-- 
Ira Weiny <ira.weiny@intel.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ndctl PATCH v3 1/9] ndctl/cxl-events: Don't fail test until event counts are reported
  2024-11-15 18:40 [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
@ 2024-11-15 18:40 ` Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 2/9] ndctl/cxl/region: Report max size for region creation Ira Weiny
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:40 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny

In testing DCD event modifications a failed cxl-event test lacked
details on the event counts.  This was because the greps were failing
the test rather than the check against the counts.

Suppress the grep failure and rely on event count checks for pass/fail
of the test.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 test/cxl-events.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/test/cxl-events.sh b/test/cxl-events.sh
index ff4f3fdff1d8f6fd80f093126a27bf14b52d167f..c216d6aa9148c938a649cb22656127b3df440039 100644
--- a/test/cxl-events.sh
+++ b/test/cxl-events.sh
@@ -71,10 +71,10 @@ echo 0 > /sys/kernel/tracing/tracing_on
 echo "TEST: Events seen"
 trace_out=$(cat /sys/kernel/tracing/trace)
 
-num_overflow=$(grep -c "cxl_overflow" <<< "${trace_out}")
-num_fatal=$(grep -c "log=Fatal" <<< "${trace_out}")
-num_failure=$(grep -c "log=Failure" <<< "${trace_out}")
-num_info=$(grep -c "log=Informational" <<< "${trace_out}")
+num_overflow=$(grep -c "cxl_overflow" <<< "${trace_out}" || true)
+num_fatal=$(grep -c "log=Fatal" <<< "${trace_out}" || true)
+num_failure=$(grep -c "log=Failure" <<< "${trace_out}" || true)
+num_info=$(grep -c "log=Informational" <<< "${trace_out}" || true)
 echo "     LOG     (Expected) : (Found)"
 echo "     overflow      ($num_overflow_expected) : $num_overflow"
 echo "     Fatal         ($num_fatal_expected) : $num_fatal"

-- 
2.47.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH v3 2/9] ndctl/cxl/region: Report max size for region creation
  2024-11-15 18:40 [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 1/9] ndctl/cxl-events: Don't fail test until event counts are reported Ira Weiny
@ 2024-11-15 18:40 ` Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 3/9] libcxl: Separate region mode from decoder mode Ira Weiny
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:40 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny

When creating a region if the size exceeds the max an error is printed.
However, the max available space is not reported which makes it harder
to determine what is wrong.

Add the max size available to the output error.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 cxl/region.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cxl/region.c b/cxl/region.c
index 96aa5931d2281c7577679b7f6165218964fa0425..207cf2d003148992255c715f286bc0f38de2ca84 100644
--- a/cxl/region.c
+++ b/cxl/region.c
@@ -677,8 +677,8 @@ static int create_region(struct cxl_ctx *ctx, int *count,
 	}
 	if (!default_size && size > max_extent) {
 		log_err(&rl,
-			"%s: region size %#lx exceeds max available space\n",
-			cxl_decoder_get_devname(p->root_decoder), size);
+			"%s: region size %#lx exceeds max available space (%#lx)\n",
+			cxl_decoder_get_devname(p->root_decoder), size, max_extent);
 		return -ENOSPC;
 	}
 

-- 
2.47.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH v3 3/9] libcxl: Separate region mode from decoder mode
  2024-11-15 18:40 [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 1/9] ndctl/cxl-events: Don't fail test until event counts are reported Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 2/9] ndctl/cxl/region: Report max size for region creation Ira Weiny
@ 2024-11-15 18:40 ` Ira Weiny
  2024-11-15 18:40 ` [ndctl PATCH v3 4/9] cxl/region: Use new region mode in cxl-cli Ira Weiny
  2024-11-15 18:49 ` [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
  4 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:40 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny

With the introduction of DCD, region mode and decoder mode no longer
remain a 1:1 relation.  An interleaved region may be made up of Dynamic
Capacity partitions with different indexes on each of the target
devices.

Introduce a new region mode enumeration and access function to libcxl.

To maintain compatibility with existing software the region mode values
are defined the same as the current decoder mode.  In addition
cxl_region_get_mode() is retained.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes:
[Alison/iweiny: Ensure correct libcxl symbol export version]
[Alison/iweiny: Add new libcxl interfaces to documentation]
[iweiny: Add deprecated cxl_region_get_mode() documentation]
---
 Documentation/cxl/lib/libcxl.txt | 20 ++++++++++++++++++--
 cxl/lib/libcxl.c                 | 25 +++++++++++++++----------
 cxl/lib/libcxl.sym               |  5 +++++
 cxl/lib/private.h                |  2 +-
 cxl/libcxl.h                     | 35 +++++++++++++++++++++++++++++++++++
 5 files changed, 74 insertions(+), 13 deletions(-)

diff --git a/Documentation/cxl/lib/libcxl.txt b/Documentation/cxl/lib/libcxl.txt
index 40598a08b9f4840f79e3ab43f62f412d8b2136ed..d5c3558aacecb08d7f5754fdcc77d6e743560601 100644
--- a/Documentation/cxl/lib/libcxl.txt
+++ b/Documentation/cxl/lib/libcxl.txt
@@ -553,11 +553,20 @@ struct cxl_region *cxl_region_get_next(struct cxl_region *region);
 
 ===== REGION: Attributes
 ----
+enum cxl_region_mode {
+	CXL_REGION_MODE_NONE = CXL_DECODER_MODE_NONE,
+	CXL_REGION_MODE_MIXED = CXL_DECODER_MODE_MIXED,
+	CXL_REGION_MODE_PMEM = CXL_DECODER_MODE_PMEM,
+	CXL_REGION_MODE_RAM = CXL_DECODER_MODE_RAM,
+};
+const char *cxl_region_mode_name(enum cxl_region_mode mode);
+enum cxl_region_mode cxl_region_mode_from_ident(const char *ident);
+enum cxl_region_mode cxl_region_get_region_mode(struct cxl_region *region);
+
 int cxl_region_get_id(struct cxl_region *region);
 const char *cxl_region_get_devname(struct cxl_region *region);
 void cxl_region_get_uuid(struct cxl_region *region, uuid_t uu);
 unsigned long long cxl_region_get_size(struct cxl_region *region);
-enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region);
 unsigned long long cxl_region_get_resource(struct cxl_region *region);
 unsigned int cxl_region_get_interleave_ways(struct cxl_region *region);
 unsigned int cxl_region_get_interleave_granularity(struct cxl_region *region);
@@ -576,8 +585,12 @@ int cxl_region_clear_all_targets(struct cxl_region *region);
 int cxl_region_decode_commit(struct cxl_region *region);
 int cxl_region_decode_reset(struct cxl_region *region);
 struct daxctl_region *cxl_region_get_daxctl_region(struct cxl_region *region);
-----
 
+DEPRECATED:
+
+enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region);
+
+----
 A region's resource attribute is the Host Physical Address at which the region's
 address space starts. The region's address space is a subset of the parent root
 decoder's address space.
@@ -601,6 +614,9 @@ where its properties can be interrogated by daxctl. The helper
 cxl_region_get_daxctl_region() returns an 'struct daxctl_region *' that
 can be used with other libdaxctl APIs.
 
+Regions now have a mode distinct from decoders.  cxl_region_get_mode() is
+deprecated in favor of cxl_region_get_region_mode().
+
 include::../../copyright.txt[]
 
 SEE ALSO
diff --git a/cxl/lib/libcxl.c b/cxl/lib/libcxl.c
index 63aa4ef3acdc2fb3c4ec6c13be5feb802e817d0d..35a40091e8f5813c1b3ef2ffb931c9ec584b02ad 100644
--- a/cxl/lib/libcxl.c
+++ b/cxl/lib/libcxl.c
@@ -431,10 +431,10 @@ CXL_EXPORT bool cxl_region_qos_class_mismatch(struct cxl_region *region)
 		if (!memdev)
 			continue;
 
-		if (region->mode == CXL_DECODER_MODE_RAM) {
+		if (region->mode == CXL_REGION_MODE_RAM) {
 			if (root_decoder->qos_class != memdev->ram_qos_class)
 				return true;
-		} else if (region->mode == CXL_DECODER_MODE_PMEM) {
+		} else if (region->mode == CXL_REGION_MODE_PMEM) {
 			if (root_decoder->qos_class != memdev->pmem_qos_class)
 				return true;
 		}
@@ -619,9 +619,9 @@ static void *add_cxl_region(void *parent, int id, const char *cxlregion_base)
 
 	sprintf(path, "%s/mode", cxlregion_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
-		region->mode = CXL_DECODER_MODE_NONE;
+		region->mode = CXL_REGION_MODE_NONE;
 	else
-		region->mode = cxl_decoder_mode_from_ident(buf);
+		region->mode = cxl_region_mode_from_ident(buf);
 
 	sprintf(path, "%s/modalias", cxlregion_base);
 	if (sysfs_read_attr(ctx, path, buf) == 0)
@@ -748,11 +748,16 @@ CXL_EXPORT unsigned long long cxl_region_get_resource(struct cxl_region *region)
 	return region->start;
 }
 
-CXL_EXPORT enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region)
+CXL_EXPORT enum cxl_region_mode cxl_region_get_region_mode(struct cxl_region *region)
 {
 	return region->mode;
 }
 
+CXL_EXPORT enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region)
+{
+	return (enum cxl_decoder_mode)cxl_region_get_region_mode(region);
+}
+
 CXL_EXPORT unsigned int
 cxl_region_get_interleave_ways(struct cxl_region *region)
 {
@@ -2700,7 +2705,7 @@ cxl_decoder_get_region(struct cxl_decoder *decoder)
 }
 
 static struct cxl_region *cxl_decoder_create_region(struct cxl_decoder *decoder,
-						    enum cxl_decoder_mode mode)
+						    enum cxl_region_mode mode)
 {
 	struct cxl_ctx *ctx = cxl_decoder_get_ctx(decoder);
 	char *path = decoder->dev_buf;
@@ -2708,9 +2713,9 @@ static struct cxl_region *cxl_decoder_create_region(struct cxl_decoder *decoder,
 	struct cxl_region *region;
 	int rc;
 
-	if (mode == CXL_DECODER_MODE_PMEM)
+	if (mode == CXL_REGION_MODE_PMEM)
 		sprintf(path, "%s/create_pmem_region", decoder->dev_path);
-	else if (mode == CXL_DECODER_MODE_RAM)
+	else if (mode == CXL_REGION_MODE_RAM)
 		sprintf(path, "%s/create_ram_region", decoder->dev_path);
 
 	rc = sysfs_read_attr(ctx, path, buf);
@@ -2754,13 +2759,13 @@ static struct cxl_region *cxl_decoder_create_region(struct cxl_decoder *decoder,
 CXL_EXPORT struct cxl_region *
 cxl_decoder_create_pmem_region(struct cxl_decoder *decoder)
 {
-	return cxl_decoder_create_region(decoder, CXL_DECODER_MODE_PMEM);
+	return cxl_decoder_create_region(decoder, CXL_REGION_MODE_PMEM);
 }
 
 CXL_EXPORT struct cxl_region *
 cxl_decoder_create_ram_region(struct cxl_decoder *decoder)
 {
-	return cxl_decoder_create_region(decoder, CXL_DECODER_MODE_RAM);
+	return cxl_decoder_create_region(decoder, CXL_REGION_MODE_RAM);
 }
 
 CXL_EXPORT int cxl_decoder_get_nr_targets(struct cxl_decoder *decoder)
diff --git a/cxl/lib/libcxl.sym b/cxl/lib/libcxl.sym
index 0c155a40ad4765106f0eab1745281d462af782fe..17a660f508ad1e053af2992824535ccf7ce877b2 100644
--- a/cxl/lib/libcxl.sym
+++ b/cxl/lib/libcxl.sym
@@ -288,3 +288,8 @@ global:
 	cxl_memdev_trigger_poison_list;
 	cxl_region_trigger_poison_list;
 } LIBCXL_7;
+
+LIBCXL_9 {
+global:
+	cxl_region_get_region_mode;
+} LIBECXL_8;
diff --git a/cxl/lib/private.h b/cxl/lib/private.h
index b6cd910e93359b53cac34427acfe84c7abcb78b0..0f45be89b6a00477d13fb6d7f1906213a3073c48 100644
--- a/cxl/lib/private.h
+++ b/cxl/lib/private.h
@@ -171,7 +171,7 @@ struct cxl_region {
 	unsigned int interleave_ways;
 	unsigned int interleave_granularity;
 	enum cxl_decode_state decode_state;
-	enum cxl_decoder_mode mode;
+	enum cxl_region_mode mode;
 	struct daxctl_region *dax_region;
 	struct kmod_module *module;
 	struct list_head mappings;
diff --git a/cxl/libcxl.h b/cxl/libcxl.h
index 0a5fd0e13cc24e0032d4a83d780278fbe0038d32..06b87a0924faafec6c80eca83ea7551d4e117256 100644
--- a/cxl/libcxl.h
+++ b/cxl/libcxl.h
@@ -303,6 +303,39 @@ int cxl_memdev_is_enabled(struct cxl_memdev *memdev);
 	for (endpoint = cxl_endpoint_get_first(port); endpoint != NULL;        \
 	     endpoint = cxl_endpoint_get_next(endpoint))
 
+enum cxl_region_mode {
+	CXL_REGION_MODE_NONE = CXL_DECODER_MODE_NONE,
+	CXL_REGION_MODE_MIXED = CXL_DECODER_MODE_MIXED,
+	CXL_REGION_MODE_PMEM = CXL_DECODER_MODE_PMEM,
+	CXL_REGION_MODE_RAM = CXL_DECODER_MODE_RAM,
+};
+
+static inline const char *cxl_region_mode_name(enum cxl_region_mode mode)
+{
+	static const char *names[] = {
+		[CXL_REGION_MODE_NONE] = "none",
+		[CXL_REGION_MODE_MIXED] = "mixed",
+		[CXL_REGION_MODE_PMEM] = "pmem",
+		[CXL_REGION_MODE_RAM] = "ram",
+	};
+
+	if (mode < CXL_REGION_MODE_NONE || mode > CXL_REGION_MODE_RAM)
+		mode = CXL_REGION_MODE_NONE;
+	return names[mode];
+}
+
+static inline enum cxl_region_mode
+cxl_region_mode_from_ident(const char *ident)
+{
+	if (strcmp(ident, "ram") == 0)
+		return CXL_REGION_MODE_RAM;
+	else if (strcmp(ident, "volatile") == 0)
+		return CXL_REGION_MODE_RAM;
+	else if (strcmp(ident, "pmem") == 0)
+		return CXL_REGION_MODE_PMEM;
+	return CXL_REGION_MODE_NONE;
+}
+
 struct cxl_region;
 struct cxl_region *cxl_region_get_first(struct cxl_decoder *decoder);
 struct cxl_region *cxl_region_get_next(struct cxl_region *region);
@@ -318,6 +351,8 @@ const char *cxl_region_get_devname(struct cxl_region *region);
 void cxl_region_get_uuid(struct cxl_region *region, uuid_t uu);
 unsigned long long cxl_region_get_size(struct cxl_region *region);
 unsigned long long cxl_region_get_resource(struct cxl_region *region);
+enum cxl_region_mode cxl_region_get_region_mode(struct cxl_region *region);
+/* Deprecated: use cxl_region_get_region_mode() */
 enum cxl_decoder_mode cxl_region_get_mode(struct cxl_region *region);
 unsigned int cxl_region_get_interleave_ways(struct cxl_region *region);
 unsigned int cxl_region_get_interleave_granularity(struct cxl_region *region);

-- 
2.47.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH v3 4/9] cxl/region: Use new region mode in cxl-cli
  2024-11-15 18:40 [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
                   ` (2 preceding siblings ...)
  2024-11-15 18:40 ` [ndctl PATCH v3 3/9] libcxl: Separate region mode from decoder mode Ira Weiny
@ 2024-11-15 18:40 ` Ira Weiny
  2024-11-15 18:49 ` [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
  4 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:40 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny

With the introduction of DCD, region mode and decoder mode no longer
remain a 1:1 relation.  An interleaved region may be made up of Dynamic
Capacity partitions with different indexes on each of the target
devices.

Modify cxl-cli to use the new region mode interface from libcxl.  Modify
parameter processing and variable name changes for clarity in the
future.

Functionality remains the same.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>

---
Changes:
[Alison: split libcxl and cxl-cli changes]
[iweiny: Process region mode based on --type]
[iweiny: s/mode/decoder_mode for clarity]
---
 cxl/json.c   |  6 +++---
 cxl/region.c | 50 ++++++++++++++++++++++++++++++++------------------
 2 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/cxl/json.c b/cxl/json.c
index 5066d3bed13f8fcc36ab8f0ea127685c246d94d7..dcd3cc28393faf7e8adf299a857531ecdeaac50a 100644
--- a/cxl/json.c
+++ b/cxl/json.c
@@ -1147,7 +1147,7 @@ void util_cxl_mappings_append_json(struct json_object *jregion,
 struct json_object *util_cxl_region_to_json(struct cxl_region *region,
 					     unsigned long flags)
 {
-	enum cxl_decoder_mode mode = cxl_region_get_mode(region);
+	enum cxl_region_mode mode = cxl_region_get_region_mode(region);
 	const char *devname = cxl_region_get_devname(region);
 	struct json_object *jregion, *jobj;
 	u64 val;
@@ -1174,8 +1174,8 @@ struct json_object *util_cxl_region_to_json(struct cxl_region *region,
 			json_object_object_add(jregion, "size", jobj);
 	}
 
-	if (mode != CXL_DECODER_MODE_NONE) {
-		jobj = json_object_new_string(cxl_decoder_mode_name(mode));
+	if (mode != CXL_REGION_MODE_NONE) {
+		jobj = json_object_new_string(cxl_region_mode_name(mode));
 		if (jobj)
 			json_object_object_add(jregion, "type", jobj);
 	}
diff --git a/cxl/region.c b/cxl/region.c
index 207cf2d003148992255c715f286bc0f38de2ca84..527bd6708b162815068a95ddb360fce3914347de 100644
--- a/cxl/region.c
+++ b/cxl/region.c
@@ -49,7 +49,8 @@ struct parsed_params {
 	int argc;
 	const char **argv;
 	struct cxl_decoder *root_decoder;
-	enum cxl_decoder_mode mode;
+	enum cxl_decoder_mode decoder_mode;
+	enum cxl_region_mode region_mode;
 	bool enforce_qos;
 };
 
@@ -301,19 +302,28 @@ static int parse_create_options(struct cxl_ctx *ctx, int count,
 		return -ENXIO;
 	p->num_memdevs = json_object_array_length(p->memdevs);
 
+	p->region_mode = CXL_REGION_MODE_NONE;
 	if (param.type) {
-		p->mode = cxl_decoder_mode_from_ident(param.type);
-		if (p->mode == CXL_DECODER_MODE_RAM && param.uuid) {
+		p->region_mode = cxl_region_mode_from_ident(param.type);
+		if (p->region_mode == CXL_REGION_MODE_RAM && param.uuid) {
 			log_err(&rl,
 				"can't set UUID for ram / volatile regions");
 			goto err;
 		}
-		if (p->mode == CXL_DECODER_MODE_NONE) {
+		if (p->region_mode == CXL_REGION_MODE_NONE) {
 			log_err(&rl, "unsupported type: %s\n", param.type);
 			goto err;
 		}
-	} else {
-		p->mode = CXL_DECODER_MODE_PMEM;
+	}
+
+	switch (p->region_mode) {
+	case CXL_REGION_MODE_RAM:
+		p->decoder_mode = CXL_DECODER_MODE_RAM;
+		break;
+	case CXL_REGION_MODE_PMEM:
+	default:
+		p->decoder_mode = CXL_DECODER_MODE_PMEM;
+		break;
 	}
 
 	if (param.size) {
@@ -410,7 +420,7 @@ static void collect_minsize(struct cxl_ctx *ctx, struct parsed_params *p)
 		struct cxl_memdev *memdev = json_object_get_userdata(jobj);
 		u64 size = 0;
 
-		switch(p->mode) {
+		switch(p->decoder_mode) {
 		case CXL_DECODER_MODE_RAM:
 			size = cxl_memdev_get_ram_size(memdev);
 			break;
@@ -446,7 +456,7 @@ static int create_region_validate_qos_class(struct parsed_params *p)
 			json_object_array_get_idx(p->memdevs, i);
 		struct cxl_memdev *memdev = json_object_get_userdata(jobj);
 
-		if (p->mode == CXL_DECODER_MODE_RAM)
+		if (p->decoder_mode == CXL_DECODER_MODE_RAM)
 			qos_class = cxl_memdev_get_ram_qos_class(memdev);
 		else
 			qos_class = cxl_memdev_get_pmem_qos_class(memdev);
@@ -475,7 +485,7 @@ static int validate_decoder(struct cxl_decoder *decoder,
 	const char *devname = cxl_decoder_get_devname(decoder);
 	int rc;
 
-	switch(p->mode) {
+	switch(p->decoder_mode) {
 	case CXL_DECODER_MODE_RAM:
 		if (!cxl_decoder_is_volatile_capable(decoder)) {
 			log_err(&rl, "%s is not volatile capable\n", devname);
@@ -512,10 +522,14 @@ static void set_type_from_decoder(struct cxl_ctx *ctx, struct parsed_params *p)
 	 * default to pmem if both types are set, otherwise the single
 	 * capability dominates.
 	 */
-	if (cxl_decoder_is_volatile_capable(p->root_decoder))
-		p->mode = CXL_DECODER_MODE_RAM;
-	if (cxl_decoder_is_pmem_capable(p->root_decoder))
-		p->mode = CXL_DECODER_MODE_PMEM;
+	if (cxl_decoder_is_volatile_capable(p->root_decoder)) {
+		p->decoder_mode = CXL_DECODER_MODE_RAM;
+		p->region_mode = CXL_REGION_MODE_RAM;
+	}
+	if (cxl_decoder_is_pmem_capable(p->root_decoder)) {
+		p->decoder_mode = CXL_DECODER_MODE_PMEM;
+		p->region_mode = CXL_REGION_MODE_PMEM;
+	}
 }
 
 static int create_region_validate_config(struct cxl_ctx *ctx,
@@ -685,14 +699,14 @@ static int create_region(struct cxl_ctx *ctx, int *count,
 	if (size > max_extent)
 		size = ALIGN_DOWN(max_extent, SZ_256M * p->ways);
 
-	if (p->mode == CXL_DECODER_MODE_PMEM) {
+	if (p->region_mode == CXL_REGION_MODE_PMEM) {
 		region = cxl_decoder_create_pmem_region(p->root_decoder);
 		if (!region) {
 			log_err(&rl, "failed to create region under %s\n",
 				param.root_decoder);
 			return -ENXIO;
 		}
-	} else if (p->mode == CXL_DECODER_MODE_RAM) {
+	} else if (p->region_mode == CXL_REGION_MODE_RAM) {
 		region = cxl_decoder_create_ram_region(p->root_decoder);
 		if (!region) {
 			log_err(&rl, "failed to create region under %s\n",
@@ -714,7 +728,7 @@ static int create_region(struct cxl_ctx *ctx, int *count,
 
 	try(cxl_region, set_interleave_granularity, region, granularity);
 	try(cxl_region, set_interleave_ways, region, p->ways);
-	if (p->mode == CXL_DECODER_MODE_PMEM) {
+	if (p->region_mode == CXL_REGION_MODE_PMEM) {
 		if (!param.uuid)
 			uuid_generate(p->uuid);
 		try(cxl_region, set_uuid, region, p->uuid);
@@ -732,14 +746,14 @@ static int create_region(struct cxl_ctx *ctx, int *count,
 			rc = -ENXIO;
 			goto out;
 		}
-		if (cxl_decoder_get_mode(ep_decoder) != p->mode) {
+		if (cxl_decoder_get_mode(ep_decoder) != p->decoder_mode) {
 			/*
 			 * The cxl_memdev_find_decoder() helper returns a free
 			 * decoder whose size has been checked for 0.
 			 * Thus it is safe to change the mode here if needed.
 			 */
 			try(cxl_decoder, set_dpa_size, ep_decoder, 0);
-			try(cxl_decoder, set_mode, ep_decoder, p->mode);
+			try(cxl_decoder, set_mode, ep_decoder, p->decoder_mode);
 		}
 		try(cxl_decoder, set_dpa_size, ep_decoder, size/p->ways);
 		rc = cxl_region_set_target(region, i, ep_decoder);

-- 
2.47.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [ndctl PATCH v3 2/9] ndctl/cxl/region: Report max size for region creation
  2024-11-15 18:46 Ira Weiny
@ 2024-11-15 18:46 ` Ira Weiny
  0 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:46 UTC (permalink / raw)
  To: Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny

When creating a region if the size exceeds the max an error is printed.
However, the max available space is not reported which makes it harder
to determine what is wrong.

Add the max size available to the output error.

Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Fan Ni <fan.ni@samsung.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
 cxl/region.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cxl/region.c b/cxl/region.c
index 96aa5931d2281c7577679b7f6165218964fa0425..207cf2d003148992255c715f286bc0f38de2ca84 100644
--- a/cxl/region.c
+++ b/cxl/region.c
@@ -677,8 +677,8 @@ static int create_region(struct cxl_ctx *ctx, int *count,
 	}
 	if (!default_size && size > max_extent) {
 		log_err(&rl,
-			"%s: region size %#lx exceeds max available space\n",
-			cxl_decoder_get_devname(p->root_decoder), size);
+			"%s: region size %#lx exceeds max available space (%#lx)\n",
+			cxl_decoder_get_devname(p->root_decoder), size, max_extent);
 		return -ENOSPC;
 	}
 

-- 
2.47.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli
  2024-11-15 18:40 [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
                   ` (3 preceding siblings ...)
  2024-11-15 18:40 ` [ndctl PATCH v3 4/9] cxl/region: Use new region mode in cxl-cli Ira Weiny
@ 2024-11-15 18:49 ` Ira Weiny
  4 siblings, 0 replies; 7+ messages in thread
From: Ira Weiny @ 2024-11-15 18:49 UTC (permalink / raw)
  To: Ira Weiny, Alison Schofield
  Cc: Vishal Verma, Jonathan Cameron, Fan Ni, Navneet Singh,
	Dan Williams, Dave Jiang, linux-cxl, nvdimm, Ira Weiny,
	Sushant1 Kumar

Please ignore.  smtp failed after only sending patch 5/9.  This series was
resent correctly it's entirety here:

https://lore.kernel.org/all/20241115-dcd-region2-v3-0-585d480ccdab@intel.com/

Apologies,
Ira



Ira Weiny wrote:
> Feedback from v2 lead to the realization that cxl-cli required changes
> to address the region mode vs decoder mode difference properly.
> 
> While v2 separated these modes they were not sufficiently separated in
> the user interface of create-region.  This has been corrected in this
> version.  Specifically a new option has been added to cxl create-region.
> The option requires a decoder mode (DC partition) when the region type
> is 'dc'.  The option is ignored, and can be omitted, for ram and pmem
> regions.
> 
> Other libcxl API changes were made to simplify the interface a bit.
> 
> Documentation was added both at the libcxl and cxl-cli levels.
> 
> cxl-dcd.sh was cleaned up quite a bit an enhanced.
> 
> https://github.com/weiny2/ndctl/tree/dcd-region2-2024-11-15
> 
> CXL Dynamic Capacity Device (DCD) support is close to landing in the
> upstream kernel.  cxl-cli requires modifications to interact with those
> devices.  This includes creating and operating on DCD regions.
> cxl-testing allows for quick regression testing as well as helping to
> design the cxl-cli interfaces.
> 
> Add preliminary patches with some fixes.  Update libcxl, cxl-cli and
> cxl-test with DCD support.
> 
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
> ---
> Major changes in v3:
> - [djiang: rework test script for clarity]
> - [Alison: split patches between libcxl changes and cli changes]
> - [Alison: fix lib symbol versioning]
> - [iweiny: clarify region vs decoder mode with API to specify the
>   decoder mode]
> - Link to v2: https://patch.msgid.link/20241104-dcd-region2-v2-0-be057b479eeb@intel.com
> 
> ---
> Ira Weiny (7):
>       ndctl/cxl-events: Don't fail test until event counts are reported
>       ndctl/cxl/region: Report max size for region creation
>       libcxl: Separate region mode from decoder mode
>       cxl/region: Use new region mode in cxl-cli
>       libcxl: Add extent functionality to DC regions
>       cxl/region: Add extent output to region query
>       cxl/test: Add Dynamic Capacity tests
> 
> Navneet Singh (2):
>       libcxl: Add Dynamic Capacity region support
>       cxl/region: Add cxl-cli support for DCD regions
> 
>  Documentation/cxl/cxl-create-region.txt |  11 +-
>  Documentation/cxl/cxl-list.txt          |  29 ++
>  Documentation/cxl/lib/libcxl.txt        |  62 ++-
>  cxl/filter.h                            |   3 +
>  cxl/json.c                              |  80 ++-
>  cxl/json.h                              |   3 +
>  cxl/lib/libcxl.c                        | 261 +++++++++-
>  cxl/lib/libcxl.sym                      |  13 +
>  cxl/lib/private.h                       |  17 +-
>  cxl/libcxl.h                            |  96 +++-
>  cxl/list.c                              |   3 +
>  cxl/memdev.c                            |   4 +-
>  cxl/region.c                            |  93 +++-
>  test/cxl-dcd.sh                         | 879 ++++++++++++++++++++++++++++++++
>  test/cxl-events.sh                      |   8 +-
>  test/meson.build                        |   2 +
>  util/json.h                             |   1 +
>  17 files changed, 1519 insertions(+), 46 deletions(-)
> ---
> base-commit: 04815e5f8b87e02a4fb5a61aeebaa5cad25a15c3
> change-id: 20241030-dcd-region2-2d0149eb8efd
> 
> Best regards,
> -- 
> Ira Weiny <ira.weiny@intel.com>
> 



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-11-15 18:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-15 18:40 [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
2024-11-15 18:40 ` [ndctl PATCH v3 1/9] ndctl/cxl-events: Don't fail test until event counts are reported Ira Weiny
2024-11-15 18:40 ` [ndctl PATCH v3 2/9] ndctl/cxl/region: Report max size for region creation Ira Weiny
2024-11-15 18:40 ` [ndctl PATCH v3 3/9] libcxl: Separate region mode from decoder mode Ira Weiny
2024-11-15 18:40 ` [ndctl PATCH v3 4/9] cxl/region: Use new region mode in cxl-cli Ira Weiny
2024-11-15 18:49 ` [ndctl PATCH v3 0/9] ndctl: Dynamic Capacity additions for cxl-cli Ira Weiny
  -- strict thread matches above, loose matches on Subject: below --
2024-11-15 18:46 Ira Weiny
2024-11-15 18:46 ` [ndctl PATCH v3 2/9] ndctl/cxl/region: Report max size for region creation Ira Weiny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox