diff mbox series

[v3,6/6] mm/nvdimm: Use correct alignment when looking at first pfn from a region

Message ID 20190604091357.32213-6-aneesh.kumar@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series [v3,1/6] nvdimm: Consider probe return -EOPNOTSUPP as success | expand

Commit Message

Aneesh Kumar K.V June 4, 2019, 9:13 a.m. UTC
We already add the start_pad to the resource->start but fails to section
align the start. This make sure with altmap we compute the right first
pfn when start_pad is zero and we are doing an align down of start address.

vmem_altmap_offset() adjust the section aligned base_pfn offset.
So we need to make sure we account for the same when computing base_pfn.

ie, for altmap_valid case, our pfn_first should be:

pfn_first = altmap->base_pfn + vmem_altmap_offset(altmap);

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 kernel/memremap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/kernel/memremap.c b/kernel/memremap.c
index 1490e63f69a9..bf488b8658e7 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -60,9 +60,11 @@  static unsigned long pfn_first(struct dev_pagemap *pgmap)
 	struct vmem_altmap *altmap = &pgmap->altmap;
 	unsigned long pfn;
 
-	pfn = res->start >> PAGE_SHIFT;
-	if (pgmap->altmap_valid)
-		pfn += vmem_altmap_offset(altmap);
+	if (pgmap->altmap_valid) {
+		pfn = altmap->base_pfn + vmem_altmap_offset(altmap);
+	} else
+		pfn = PHYS_PFN(res->start);
+
 	return pfn;
 }