@@ -55,10 +55,12 @@ static void dax_kmem_percpu_kill(void *d
static int dax_kmem_probe(struct device *dev)
{
void *addr;
+ int numa_node;
struct resource res;
int rc, id, region_id;
struct nd_pfn_sb *pfn_sb;
struct dev_dax *dev_dax;
+ struct resource *new_res;
struct dax_kmem *dax_kmem;
struct nd_namespace_io *nsio;
struct dax_region *dax_region;
@@ -86,13 +88,30 @@ static int dax_kmem_probe(struct device
pfn_sb = nd_pfn->pfn_sb;
- if (!devm_request_mem_region(dev, nsio->res.start,
- resource_size(&nsio->res),
- dev_name(&ndns->dev))) {
+ new_res = devm_request_mem_region(dev, nsio->res.start,
+ resource_size(&nsio->res),
+ "System RAM (pmem)");
+ if (!new_res) {
dev_warn(dev, "could not reserve region %pR\n", &nsio->res);
return -EBUSY;
}
+ /*
+ * Set flags appropriate for System RAM. Leave ..._BUSY clear
+ * so that add_memory() can add a child resource.
+ */
+ new_res->flags = IORESOURCE_SYSTEM_RAM;
+
+ numa_node = dev_to_node(dev);
+ if (numa_node < 0) {
+ pr_warn_once("bad numa_node: %d, forcing to 0\n", numa_node);
+ numa_node = 0;
+ }
+
+ rc = add_memory(numa_node, nsio->res.start, resource_size(&nsio->res));
+ if (rc)
+ return rc;
+
dax_kmem->dev = dev;
init_completion(&dax_kmem->cmp);
rc = percpu_ref_init(&dax_kmem->ref, dax_kmem_percpu_release, 0,
@@ -106,6 +125,9 @@ static int dax_kmem_probe(struct device
return rc;
dax_kmem->pgmap.ref = &dax_kmem->ref;
+
+ dax_kmem->pgmap.res.name = "name_kmem_override2";
+
addr = devm_memremap_pages(dev, &dax_kmem->pgmap);
if (IS_ERR(addr))
return PTR_ERR(addr);