-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cxl/dax: Create dax devices for CXL RAM regions
While platform firmware takes some responsibility for mapping the RAM capacity of CXL devices present at boot, the OS is responsible for mapping the remainder and hot-added devices. Platform firmware is also responsible for identifying the platform general purpose memory pool, typically DDR attached DRAM, and arranging for the remainder to be 'Soft Reserved'. That reservation allows the CXL subsystem to route the memory to core-mm via memory-hotplug (dax_kmem), or leave it for dedicated access (device-dax). The new 'struct cxl_dax_region' object allows for a CXL memory resource (region) to be published, but also allow for udev and module policy to act on that event. It also prevents cxl_core.ko from having a module loading dependency on any drivers/dax/ modules. Tested-by: Fan Ni <fan.ni@samsung.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Link: https://lore.kernel.org/r/167602003896.1924368.10335442077318970468.stgit@dwillia2-xfh.jf.intel.com Signed-off-by: Dan Williams <dan.j.williams@intel.com>
- Loading branch information
Dan Williams
committed
Feb 11, 2023
1 parent
e9ee9fe
commit 09d09e0
Showing
10 changed files
with
209 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* Copyright(c) 2023 Intel Corporation. All rights reserved. */ | ||
#include <linux/module.h> | ||
#include <linux/dax.h> | ||
|
||
#include "../cxl/cxl.h" | ||
#include "bus.h" | ||
|
||
static int cxl_dax_region_probe(struct device *dev) | ||
{ | ||
struct cxl_dax_region *cxlr_dax = to_cxl_dax_region(dev); | ||
int nid = phys_to_target_node(cxlr_dax->hpa_range.start); | ||
struct cxl_region *cxlr = cxlr_dax->cxlr; | ||
struct dax_region *dax_region; | ||
struct dev_dax_data data; | ||
struct dev_dax *dev_dax; | ||
|
||
if (nid == NUMA_NO_NODE) | ||
nid = memory_add_physaddr_to_nid(cxlr_dax->hpa_range.start); | ||
|
||
dax_region = alloc_dax_region(dev, cxlr->id, &cxlr_dax->hpa_range, nid, | ||
PMD_SIZE, IORESOURCE_DAX_KMEM); | ||
if (!dax_region) | ||
return -ENOMEM; | ||
|
||
data = (struct dev_dax_data) { | ||
.dax_region = dax_region, | ||
.id = -1, | ||
.size = range_len(&cxlr_dax->hpa_range), | ||
}; | ||
dev_dax = devm_create_dev_dax(&data); | ||
if (IS_ERR(dev_dax)) | ||
return PTR_ERR(dev_dax); | ||
|
||
/* child dev_dax instances now own the lifetime of the dax_region */ | ||
dax_region_put(dax_region); | ||
return 0; | ||
} | ||
|
||
static struct cxl_driver cxl_dax_region_driver = { | ||
.name = "cxl_dax_region", | ||
.probe = cxl_dax_region_probe, | ||
.id = CXL_DEVICE_DAX_REGION, | ||
.drv = { | ||
.suppress_bind_attrs = true, | ||
}, | ||
}; | ||
|
||
module_cxl_driver(cxl_dax_region_driver); | ||
MODULE_ALIAS_CXL(CXL_DEVICE_DAX_REGION); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_AUTHOR("Intel Corporation"); | ||
MODULE_IMPORT_NS(CXL); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters