[PATCH v4 5/6] mm/nvdimm: Use correct alignment when looking at first pfn from a region
Aneesh Kumar K.V
aneesh.kumar at linux.ibm.com
Thu Jun 20 19:16:25 AEST 2019
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 at linux.ibm.com>
---
kernel/memremap.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/kernel/memremap.c b/kernel/memremap.c
index a0e5f6b91b04..63800128844b 100644
--- a/kernel/memremap.c
+++ b/kernel/memremap.c
@@ -58,9 +58,11 @@ static unsigned long pfn_first(struct dev_pagemap *pgmap)
struct vmem_altmap *altmap = &pgmap->altmap;
unsigned long pfn;
- pfn = PHYS_PFN(res->start);
- 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;
}
--
2.21.0
More information about the Linuxppc-dev
mailing list