From: Gregory Price <gourry@gourry.net>
To: linux-mm@kvack.org
Cc: linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, kernel-team@meta.com,
dave@stgolabs.net, jonathan.cameron@huawei.com,
dave.jiang@intel.com, alison.schofield@intel.com,
vishal.l.verma@intel.com, ira.weiny@intel.com,
dan.j.williams@intel.com, willy@infradead.org, jack@suse.cz,
terry.bowman@amd.com, john@jagalactic.com
Subject: [PATCH 7/9] cxl/core: add cxl_devdax_region driver for explicit userland region binding
Date: Thu, 29 Jan 2026 16:04:40 -0500 [thread overview]
Message-ID: <20260129210442.3951412-8-gourry@gourry.net> (raw)
In-Reply-To: <20260129210442.3951412-1-gourry@gourry.net>
Add a new cxl_devdax_region driver that probes CXL regions in device
dax mode and creates dax_region devices. This allows explicit binding to
the device_dax dax driver instead of the kmem driver.
Exports to_cxl_region() to core.h so it can be used by the driver.
Signed-off-by: Gregory Price <gourry@gourry.net>
---
drivers/cxl/core/core.h | 2 ++
drivers/cxl/core/dax_region.c | 16 ++++++++++++++++
drivers/cxl/core/region.c | 21 +++++++++++++++++----
drivers/cxl/cxl.h | 1 +
4 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/drivers/cxl/core/core.h b/drivers/cxl/core/core.h
index 217dd708a2a6..ea4df8abc2ad 100644
--- a/drivers/cxl/core/core.h
+++ b/drivers/cxl/core/core.h
@@ -46,6 +46,8 @@ u64 cxl_dpa_to_hpa(struct cxl_region *cxlr, const struct cxl_memdev *cxlmd,
int devm_cxl_add_dax_region(struct cxl_region *cxlr, enum dax_driver_type);
int devm_cxl_add_pmem_region(struct cxl_region *cxlr);
+extern struct cxl_driver cxl_devdax_region_driver;
+
#else
static inline u64 cxl_dpa_to_hpa(struct cxl_region *cxlr,
const struct cxl_memdev *cxlmd, u64 dpa)
diff --git a/drivers/cxl/core/dax_region.c b/drivers/cxl/core/dax_region.c
index 0602db5f7248..391d51e5ec37 100644
--- a/drivers/cxl/core/dax_region.c
+++ b/drivers/cxl/core/dax_region.c
@@ -111,3 +111,19 @@ int devm_cxl_add_dax_region(struct cxl_region *cxlr,
put_device(dev);
return rc;
}
+
+static int cxl_devdax_region_driver_probe(struct device *dev)
+{
+ struct cxl_region *cxlr = to_cxl_region(dev);
+
+ if (cxlr->mode != CXL_PARTMODE_RAM)
+ return -ENODEV;
+
+ return devm_cxl_add_dax_region(cxlr, DAXDRV_DEVICE_TYPE);
+}
+
+struct cxl_driver cxl_devdax_region_driver = {
+ .name = "cxl_devdax_region",
+ .probe = cxl_devdax_region_driver_probe,
+ .id = CXL_DEVICE_REGION,
+};
diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 61ec939c1462..6200ca1cc2dd 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -39,8 +39,6 @@
*/
static nodemask_t nodemask_region_seen = NODE_MASK_NONE;
-static struct cxl_region *to_cxl_region(struct device *dev);
-
#define __ACCESS_ATTR_RO(_level, _name) { \
.attr = { .name = __stringify(_name), .mode = 0444 }, \
.show = _name##_access##_level##_show, \
@@ -2430,7 +2428,7 @@ bool is_cxl_region(struct device *dev)
}
EXPORT_SYMBOL_NS_GPL(is_cxl_region, "CXL");
-static struct cxl_region *to_cxl_region(struct device *dev)
+struct cxl_region *to_cxl_region(struct device *dev)
{
if (dev_WARN_ONCE(dev, dev->type != &cxl_region_type,
"not a cxl_region device\n"))
@@ -3726,11 +3724,26 @@ static struct cxl_driver cxl_region_driver = {
int cxl_region_init(void)
{
- return cxl_driver_register(&cxl_region_driver);
+ int rc;
+
+ rc = cxl_driver_register(&cxl_region_driver);
+ if (rc)
+ return rc;
+
+ rc = cxl_driver_register(&cxl_devdax_region_driver);
+ if (rc)
+ goto err_dax;
+
+ return 0;
+
+err_dax:
+ cxl_driver_unregister(&cxl_region_driver);
+ return rc;
}
void cxl_region_exit(void)
{
+ cxl_driver_unregister(&cxl_devdax_region_driver);
cxl_driver_unregister(&cxl_region_driver);
}
diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
index c06a239c0008..674d5f870c70 100644
--- a/drivers/cxl/cxl.h
+++ b/drivers/cxl/cxl.h
@@ -859,6 +859,7 @@ int cxl_dvsec_rr_decode(struct cxl_dev_state *cxlds,
struct cxl_endpoint_dvsec_info *info);
bool is_cxl_region(struct device *dev);
+struct cxl_region *to_cxl_region(struct device *dev);
extern const struct bus_type cxl_bus_type;
--
2.52.0
next prev parent reply other threads:[~2026-01-29 21:05 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-29 21:04 [PATCH 0/9] cxl: explicit DAX driver selection and hotplug Gregory Price
2026-01-29 21:04 ` [PATCH 1/9] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-02-02 17:10 ` Jonathan Cameron
2026-02-02 17:46 ` Gregory Price
2026-01-29 21:04 ` [PATCH 2/9] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg Gregory Price
2026-02-02 17:25 ` Jonathan Cameron
2026-02-02 18:02 ` Gregory Price
2026-02-02 18:46 ` Jonathan Cameron
2026-02-02 21:37 ` Gregory Price
2026-02-04 21:08 ` David Hildenbrand (arm)
2026-02-05 4:23 ` Gregory Price
2026-01-29 21:04 ` [PATCH 3/9] dax: plumb online_type from dax_kmem creators to hotplug Gregory Price
2026-01-29 21:04 ` [PATCH 4/9] drivers/cxl,dax: add dax driver mode selection for dax regions Gregory Price
2026-02-02 17:54 ` Jonathan Cameron
2026-01-29 21:04 ` [PATCH 5/9] cxl/core/region: move pmem region driver logic into pmem_region Gregory Price
2026-02-02 17:56 ` Jonathan Cameron
2026-01-29 21:04 ` [PATCH 6/9] cxl/core/region: move dax region device logic into dax_region.c Gregory Price
2026-02-02 17:57 ` Jonathan Cameron
2026-01-29 21:04 ` Gregory Price [this message]
2026-01-29 21:04 ` [PATCH 8/9] cxl/core: Add dax_kmem_region and sysram_region drivers Gregory Price
2026-01-30 21:27 ` Cheatham, Benjamin
2026-01-30 22:12 ` Gregory Price
2026-02-02 17:02 ` Cheatham, Benjamin
2026-02-02 17:41 ` Gregory Price
2026-02-02 19:19 ` Gregory Price
2026-02-02 18:20 ` Jonathan Cameron
2026-02-02 18:23 ` Gregory Price
2026-01-29 21:04 ` [PATCH 9/9] Documentation/driver-api/cxl: add dax and sysram driver documentation Gregory Price
2026-01-29 21:17 ` [PATCH 0/9] cxl: explicit DAX driver selection and hotplug Gregory Price
2026-01-30 17:34 ` Gregory Price
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=20260129210442.3951412-8-gourry@gourry.net \
--to=gourry@gourry.net \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=john@jagalactic.com \
--cc=jonathan.cameron@huawei.com \
--cc=kernel-team@meta.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nvdimm@lists.linux.dev \
--cc=terry.bowman@amd.com \
--cc=vishal.l.verma@intel.com \
--cc=willy@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox