1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright(c) 2023 Intel Corporation. All rights reserved. */
3 #include <linux/module.h>
6 #include "../cxl/cxl.h"
9 static int cxl_dax_region_probe(struct device *dev)
11 struct cxl_dax_region *cxlr_dax = to_cxl_dax_region(dev);
12 int nid = phys_to_target_node(cxlr_dax->hpa_range.start);
13 struct cxl_region *cxlr = cxlr_dax->cxlr;
14 struct dax_region *dax_region;
15 struct dev_dax_data data;
17 if (nid == NUMA_NO_NODE)
18 nid = memory_add_physaddr_to_nid(cxlr_dax->hpa_range.start);
20 dax_region = alloc_dax_region(dev, cxlr->id, &cxlr_dax->hpa_range, nid,
21 PMD_SIZE, IORESOURCE_DAX_KMEM);
25 data = (struct dev_dax_data) {
26 .dax_region = dax_region,
28 .size = range_len(&cxlr_dax->hpa_range),
31 return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
34 static struct cxl_driver cxl_dax_region_driver = {
35 .name = "cxl_dax_region",
36 .probe = cxl_dax_region_probe,
37 .id = CXL_DEVICE_DAX_REGION,
39 .suppress_bind_attrs = true,
43 module_cxl_driver(cxl_dax_region_driver);
44 MODULE_ALIAS_CXL(CXL_DEVICE_DAX_REGION);
45 MODULE_LICENSE("GPL");
46 MODULE_AUTHOR("Intel Corporation");
47 MODULE_IMPORT_NS(CXL);