diff options
-rw-r--r-- | drivers/nvdimm/pfn_devs.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index c38566f4da7d..335c8175410b 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c | |||
@@ -538,7 +538,8 @@ static struct vmem_altmap *__nvdimm_setup_pfn(struct nd_pfn *nd_pfn, | |||
538 | nd_pfn->npfns = le64_to_cpu(pfn_sb->npfns); | 538 | nd_pfn->npfns = le64_to_cpu(pfn_sb->npfns); |
539 | altmap = NULL; | 539 | altmap = NULL; |
540 | } else if (nd_pfn->mode == PFN_MODE_PMEM) { | 540 | } else if (nd_pfn->mode == PFN_MODE_PMEM) { |
541 | nd_pfn->npfns = (resource_size(res) - offset) / PAGE_SIZE; | 541 | nd_pfn->npfns = PFN_SECTION_ALIGN_UP((resource_size(res) |
542 | - offset) / PAGE_SIZE); | ||
542 | if (le64_to_cpu(nd_pfn->pfn_sb->npfns) > nd_pfn->npfns) | 543 | if (le64_to_cpu(nd_pfn->pfn_sb->npfns) > nd_pfn->npfns) |
543 | dev_info(&nd_pfn->dev, | 544 | dev_info(&nd_pfn->dev, |
544 | "number of pfns truncated from %lld to %ld\n", | 545 | "number of pfns truncated from %lld to %ld\n", |
@@ -625,7 +626,8 @@ static int nd_pfn_init(struct nd_pfn *nd_pfn) | |||
625 | */ | 626 | */ |
626 | start += start_pad; | 627 | start += start_pad; |
627 | size = resource_size(&nsio->res); | 628 | size = resource_size(&nsio->res); |
628 | npfns = (size - start_pad - end_trunc - SZ_8K) / SZ_4K; | 629 | npfns = PFN_SECTION_ALIGN_UP((size - start_pad - end_trunc - SZ_8K) |
630 | / PAGE_SIZE); | ||
629 | if (nd_pfn->mode == PFN_MODE_PMEM) { | 631 | if (nd_pfn->mode == PFN_MODE_PMEM) { |
630 | /* | 632 | /* |
631 | * vmemmap_populate_hugepages() allocates the memmap array in | 633 | * vmemmap_populate_hugepages() allocates the memmap array in |