diff mbox series

[15/19] cxl/region: Specify host-only vs device memory at region creation time

Message ID 168592158192.1948938.1274727683021213802.stgit@dwillia2-xfh.jf.intel.com
State New, archived
Headers show
Series cxl: Device memory setup | expand

Commit Message

Dan Williams June 4, 2023, 11:33 p.m. UTC
In preparation for supporting device-memory (HDM-D[B]) region creation,
convey the endpoint-decoder target type to devm_cxl_add_region().

Note that none of the existing sysfs ABIs allow for HDM-D[B] region
creation. The expectation is that HDM-D[B] region creation requires a
kernel-internal region creation flow, for example, driven by an
accelerator driver.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 drivers/cxl/core/region.c |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

Comments

Jonathan Cameron June 6, 2023, 2:42 p.m. UTC | #1
On Sun, 04 Jun 2023 16:33:01 -0700
Dan Williams <dan.j.williams@intel.com> wrote:

> In preparation for supporting device-memory (HDM-D[B]) region creation,
> convey the endpoint-decoder target type to devm_cxl_add_region().
> 
> Note that none of the existing sysfs ABIs allow for HDM-D[B] region
> creation. The expectation is that HDM-D[B] region creation requires a
> kernel-internal region creation flow, for example, driven by an
> accelerator driver.

There are potential advantages in using CXL type 3 HDM-DB devices with
a normal flow, userspace driven region creation flow.  If there is
any potential for UIO P2P transactions targeting them later (which
we won't necessarily know at setup time) then we'll need to use HDM-DB.
 The targetting of them for UIO will require some accelerator specific
stuff at the source of the transactions, but we won't want to offline
the memory on a type 3 device to convert it over to HDM-H
(assuming that's required...)

+ cache coherent sharing - though I guess region setup code may
be quite different for that anyway :)  I've not divided into
Navneet's set yet to see how he did it.

Code itself is fine - just the comment potentially being misleading or
overly restrictive.

Jonathan
diff mbox series

Patch

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index defc2f0e43e3..75c5de627868 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -2120,7 +2120,8 @@  static ssize_t create_ram_region_show(struct device *dev,
 }
 
 static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
-					  enum cxl_decoder_mode mode, int id)
+					  int id, enum cxl_decoder_mode mode,
+					  enum cxl_decoder_type type)
 {
 	int rc;
 
@@ -2133,7 +2134,7 @@  static struct cxl_region *__create_region(struct cxl_root_decoder *cxlrd,
 		return ERR_PTR(-EBUSY);
 	}
 
-	return devm_cxl_add_region(cxlrd, id, mode, CXL_DECODER_HOSTMEM);
+	return devm_cxl_add_region(cxlrd, id, mode, type);
 }
 
 static ssize_t create_pmem_region_store(struct device *dev,
@@ -2148,7 +2149,8 @@  static ssize_t create_pmem_region_store(struct device *dev,
 	if (rc != 1)
 		return -EINVAL;
 
-	cxlr = __create_region(cxlrd, CXL_DECODER_PMEM, id);
+	cxlr = __create_region(cxlrd, id, CXL_DECODER_PMEM,
+			       CXL_DECODER_HOSTMEM);
 	if (IS_ERR(cxlr))
 		return PTR_ERR(cxlr);
 
@@ -2168,7 +2170,7 @@  static ssize_t create_ram_region_store(struct device *dev,
 	if (rc != 1)
 		return -EINVAL;
 
-	cxlr = __create_region(cxlrd, CXL_DECODER_RAM, id);
+	cxlr = __create_region(cxlrd, id, CXL_DECODER_RAM, CXL_DECODER_HOSTMEM);
 	if (IS_ERR(cxlr))
 		return PTR_ERR(cxlr);
 
@@ -2703,8 +2705,8 @@  construct_region_begin(struct cxl_root_decoder *cxlrd,
 	int err = 0;
 
 	do {
-		cxlr = __create_region(cxlrd, cxled->mode,
-				       atomic_read(&cxlrd->region_id));
+		cxlr = __create_region(cxlrd, atomic_read(&cxlrd->region_id),
+				       cxled->mode, cxled->cxld.target_type);
 	} while (IS_ERR(cxlr) && PTR_ERR(cxlr) == -EBUSY);
 
 	if (IS_ERR(cxlr)) {