diff options
author | Dan Williams <dan.j.williams@intel.com> | 2018-06-08 15:16:40 -0700 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-06-08 15:16:40 -0700 |
commit | b56845794e1e93121acb74ca325db965035d5545 (patch) | |
tree | 3435f4e8de92d5a63fdc15953391cf057ee46642 /drivers/nvdimm/pmem.c | |
parent | 808c340be17dc77131fcdf9ad1eb34452d650da1 (diff) | |
parent | cc4a90ac816e00775fbc2a9c018bf2af606abd06 (diff) | |
download | linux-b56845794e1e93121acb74ca325db965035d5545.tar.gz linux-b56845794e1e93121acb74ca325db965035d5545.tar.bz2 linux-b56845794e1e93121acb74ca325db965035d5545.zip |
Merge branch 'for-4.18/dax' into libnvdimm-for-next
Diffstat (limited to 'drivers/nvdimm/pmem.c')
-rw-r--r-- | drivers/nvdimm/pmem.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 97b4c39a9267..bf2dd2a4a5e6 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -289,6 +289,27 @@ static void pmem_release_disk(void *__pmem) put_disk(pmem->disk); } +static void pmem_release_pgmap_ops(void *__pgmap) +{ + dev_pagemap_put_ops(); +} + +static void fsdax_pagefree(struct page *page, void *data) +{ + wake_up_var(&page->_refcount); +} + +static int setup_pagemap_fsdax(struct device *dev, struct dev_pagemap *pgmap) +{ + dev_pagemap_get_ops(); + if (devm_add_action_or_reset(dev, pmem_release_pgmap_ops, pgmap)) + return -ENOMEM; + pgmap->type = MEMORY_DEVICE_FS_DAX; + pgmap->page_free = fsdax_pagefree; + + return 0; +} + static int pmem_attach_disk(struct device *dev, struct nd_namespace_common *ndns) { @@ -347,6 +368,8 @@ static int pmem_attach_disk(struct device *dev, pmem->pfn_flags = PFN_DEV; pmem->pgmap.ref = &q->q_usage_counter; if (is_nd_pfn(dev)) { + if (setup_pagemap_fsdax(dev, &pmem->pgmap)) + return -ENOMEM; addr = devm_memremap_pages(dev, &pmem->pgmap); pfn_sb = nd_pfn->pfn_sb; pmem->data_offset = le64_to_cpu(pfn_sb->dataoff); @@ -358,6 +381,8 @@ static int pmem_attach_disk(struct device *dev, } else if (pmem_should_map_pages(dev)) { memcpy(&pmem->pgmap.res, &nsio->res, sizeof(pmem->pgmap.res)); pmem->pgmap.altmap_valid = false; + if (setup_pagemap_fsdax(dev, &pmem->pgmap)) + return -ENOMEM; addr = devm_memremap_pages(dev, &pmem->pgmap); pmem->pfn_flags |= PFN_MAP; memcpy(&bb_res, &pmem->pgmap.res, sizeof(bb_res)); |