The patch titled Subject: mm/pgmap: use correct alignment when looking at first pfn from a region has been added to the -mm tree. Its filename is mm-pgmap-use-correct-alignment-when-looking-at-first-pfn-from-a-region.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-pgmap-use-correct-alignment-when-looking-at-first-pfn-from-a-region.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-pgmap-use-correct-alignment-when-looking-at-first-pfn-from-a-region.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxx> Subject: mm/pgmap: use correct alignment when looking at first pfn from a region vmem_altmap_offset() adjusts 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); This was found by code inspection. If the pmem region is not correctly section aligned we can skip pfns while iterating device pfn using for_each_device_pfn(pfn, pgmap) Link: http://lkml.kernel.org/r/20190917153129.12905-1-aneesh.kumar@xxxxxxxxxxxxx Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxxxxx> Cc: Ralph Campbell <rcampbell@xxxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memremap.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) --- a/mm/memremap.c~mm-pgmap-use-correct-alignment-when-looking-at-first-pfn-from-a-region +++ a/mm/memremap.c @@ -55,8 +55,16 @@ static void pgmap_array_delete(struct re static unsigned long pfn_first(struct dev_pagemap *pgmap) { - return PHYS_PFN(pgmap->res.start) + - vmem_altmap_offset(pgmap_altmap(pgmap)); + const struct resource *res = &pgmap->res; + struct vmem_altmap *altmap = pgmap_altmap(pgmap); + unsigned long pfn; + + if (altmap) { + pfn = altmap->base_pfn + vmem_altmap_offset(altmap); + } else + pfn = PHYS_PFN(res->start); + + return pfn; } static unsigned long pfn_end(struct dev_pagemap *pgmap) _ Patches currently in -mm which might be from aneesh.kumar@xxxxxxxxxxxxx are mm-pgmap-use-correct-alignment-when-looking-at-first-pfn-from-a-region.patch