All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishal Verma <vishal.l.verma@intel.com>
To: linux-cxl@vger.kernel.org
Cc: Gregory Price <gregory.price@memverge.com>,
	 Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
	 Davidlohr Bueso <dave@stgolabs.net>,
	 Dan Williams <dan.j.williams@intel.com>,
	 Vishal Verma <vishal.l.verma@intel.com>,
	nvdimm@lists.linux.dev
Subject: [PATCH ndctl 5/7] cxl/region: determine region type based on root decoder capability
Date: Tue, 07 Feb 2023 12:16:31 -0700	[thread overview]
Message-ID: <20230120-vv-volatile-regions-v1-5-b42b21ee8d0b@intel.com> (raw)
In-Reply-To: <20230120-vv-volatile-regions-v1-0-b42b21ee8d0b@intel.com>

In the common case, root decoders are expected to be either pmem
capable, or volatile capable, but not necessarily both simultaneously.
If a decoder only has one of pmem or volatile capabilities,
cxl-create-region should just infer the type of the region (pmem
or ram) based on this capability.

Maintain the default behavior of cxl-create-region to choose type=pmem,
but only as a fallback if the selected root decoder has multiple
capabilities. If it is only capable of either pmem, or ram, then infer
region type from this without requiring it to be specified explicitly.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 Documentation/cxl/cxl-create-region.txt |  3 ++-
 cxl/region.c                            | 27 +++++++++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/Documentation/cxl/cxl-create-region.txt b/Documentation/cxl/cxl-create-region.txt
index ada0e52..f11a412 100644
--- a/Documentation/cxl/cxl-create-region.txt
+++ b/Documentation/cxl/cxl-create-region.txt
@@ -75,7 +75,8 @@ include::bus-option.txt[]
 
 -t::
 --type=::
-	Specify the region type - 'pmem' or 'ram'. Defaults to 'pmem'.
+	Specify the region type - 'pmem' or 'ram'. Default to root decoder
+	capability, and if that is ambiguous, default to 'pmem'.
 
 -U::
 --uuid=::
diff --git a/cxl/region.c b/cxl/region.c
index 9079b2d..1c8ccc7 100644
--- a/cxl/region.c
+++ b/cxl/region.c
@@ -448,6 +448,31 @@ static int validate_decoder(struct cxl_decoder *decoder,
 	return 0;
 }
 
+static void set_type_from_decoder(struct cxl_ctx *ctx, struct parsed_params *p)
+{
+	int num_cap = 0;
+
+	/* if param.type was explicitly specified, nothing to do here */
+	if (param.type)
+		return;
+
+	/*
+	 * if the root decoder only has one type of capability, default
+	 * to that mode for the region.
+	 */
+	if (cxl_decoder_is_pmem_capable(p->root_decoder))
+		num_cap++;
+	if (cxl_decoder_is_volatile_capable(p->root_decoder))
+		num_cap++;
+
+	if (num_cap == 1) {
+		if (cxl_decoder_is_volatile_capable(p->root_decoder))
+			p->mode = CXL_DECODER_MODE_RAM;
+		else if (cxl_decoder_is_pmem_capable(p->root_decoder))
+			p->mode = CXL_DECODER_MODE_PMEM;
+	}
+}
+
 static int create_region_validate_config(struct cxl_ctx *ctx,
 					 struct parsed_params *p)
 {
@@ -481,6 +506,8 @@ found:
 		return -ENXIO;
 	}
 
+	set_type_from_decoder(ctx, p);
+
 	rc = validate_decoder(p->root_decoder, p);
 	if (rc)
 		return rc;

-- 
2.39.1


  parent reply	other threads:[~2023-02-07 19:16 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 19:16 [PATCH ndctl 0/7] cxl: add support for listing and creating volatile regions Vishal Verma
2023-02-07 19:16 ` [PATCH ndctl 1/7] cxl/region: skip region_actions for region creation Vishal Verma
     [not found]   ` <CGME20230207220732uscas1p28eab99f743962581e50c2657b2e2132e@uscas1p2.samsung.com>
2023-02-07 22:07     ` Fan Ni
2023-02-08  0:19       ` Verma, Vishal L
2023-02-08  3:45   ` Ira Weiny
2023-02-08  5:41   ` Dan Williams
2023-02-07 19:16 ` [PATCH ndctl 2/7] cxl: add a type attribute to region listings Vishal Verma
2023-02-08  3:46   ` Ira Weiny
2023-02-08  5:47   ` Dan Williams
2023-02-08  6:10     ` Verma, Vishal L
     [not found]   ` <CGME20230210004800uscas1p1b66223937b4d5519341a61ef304e1a44@uscas1p1.samsung.com>
2023-02-10  0:47     ` Fan Ni
2023-02-07 19:16 ` [PATCH ndctl 3/7] cxl: add core plumbing for creation of ram regions Vishal Verma
2023-02-08  3:55   ` Ira Weiny
2023-02-08  6:23     ` Verma, Vishal L
2023-02-08 22:07       ` Ira Weiny
2023-02-08  5:49   ` Dan Williams
     [not found]   ` <CGME20230210010415uscas1p1211243c08bc794b314f7b20bdad93267@uscas1p1.samsung.com>
2023-02-10  1:04     ` Fan Ni
2023-02-10  1:10       ` Verma, Vishal L
2023-02-10  1:15         ` Fan Ni
2023-02-07 19:16 ` [PATCH ndctl 4/7] cxl/region: accept user-supplied UUIDs for pmem regions Vishal Verma
2023-02-08  3:56   ` Ira Weiny
2023-02-08  5:51   ` Dan Williams
2023-02-07 19:16 ` Vishal Verma [this message]
2023-02-08  4:07   ` [PATCH ndctl 5/7] cxl/region: determine region type based on root decoder capability Ira Weiny
2023-02-08  6:34     ` Verma, Vishal L
2023-02-08 22:09       ` Ira Weiny
2023-02-08  5:55   ` Dan Williams
2023-02-08  6:36     ` Verma, Vishal L
2023-02-07 19:16 ` [PATCH ndctl 6/7] cxl/list: Include regions in the verbose listing Vishal Verma
2023-02-08  4:08   ` Ira Weiny
2023-02-07 19:16 ` [PATCH ndctl 7/7] cxl/list: Enumerate device-dax properties for regions Vishal Verma
2023-02-08  4:15   ` Ira Weiny
2023-02-08  6:00   ` Dan Williams
2023-02-08  6:48     ` Verma, Vishal L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230120-vv-volatile-regions-v1-5-b42b21ee8d0b@intel.com \
    --to=vishal.l.verma@intel.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=gregory.price@memverge.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.