mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 15:11:31 +00:00
4eca0ef49a
Large amounts of memory managed by the kmem driver may come in via CXL, and it is often desirable to have the memmap for this memory on the new memory itself. Enroll kmem-managed memory for memmap_on_memory semantics if the dax region originates via CXL. For non-CXL dax regions, retain the existing default behavior of hot adding without memmap_on_memory semantics. Link: https://lkml.kernel.org/r/20231107-vv-kmem_memmap-v10-3-1253ec050ed0@intel.com Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: David Hildenbrand <david@redhat.com> Reviewed-by: "Huang, Ying" <ying.huang@intel.com> Tested-by: Li Zhijian <lizhijian@fujitsu.com> [cxl.kmem and nvdimm.kmem] Cc: Michal Hocko <mhocko@suse.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Dan Williams <dan.j.williams@intel.com> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Cc: Fan Ni <fan.ni@samsung.com> Cc: Jeff Moyer <jmoyer@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
49 lines
1.2 KiB
C
49 lines
1.2 KiB
C
// 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;
|
|
|
|
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),
|
|
.memmap_on_memory = true,
|
|
};
|
|
|
|
return PTR_ERR_OR_ZERO(devm_create_dev_dax(&data));
|
|
}
|
|
|
|
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);
|