The patch titled Subject: mm: enable section-unaligned devm_memremap_pages() has been added to the -mm tree. Its filename is mm-enable-section-unaligned-devm_memremap_pages.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-enable-section-unaligned-devm_memremap_pages.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-enable-section-unaligned-devm_memremap_pages.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/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Dan Williams <dan.j.williams@xxxxxxxxx> Subject: mm: enable section-unaligned devm_memremap_pages() Teach devm_memremap_pages() about the new sub-section capabilities of arch_{add,remove}_memory(). Link: http://lkml.kernel.org/r/148486366055.19694.17199008017867229383.stgit@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Toshi Kani <toshi.kani@xxxxxxx> Cc: Logan Gunthorpe <logang@xxxxxxxxxxxx> Cc: Stephen Bates <stephen.bates@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/memremap.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff -puN kernel/memremap.c~mm-enable-section-unaligned-devm_memremap_pages kernel/memremap.c --- a/kernel/memremap.c~mm-enable-section-unaligned-devm_memremap_pages +++ a/kernel/memremap.c @@ -256,7 +256,6 @@ static void devm_memremap_pages_release( { struct page_map *page_map = data; struct resource *res = &page_map->res; - resource_size_t align_start, align_size; struct dev_pagemap *pgmap = &page_map->pgmap; if (percpu_ref_tryget_live(pgmap->ref)) { @@ -265,12 +264,10 @@ static void devm_memremap_pages_release( } /* pages are dead and unused, undo the arch mapping */ - align_start = res->start & PA_SECTION_MASK; - align_size = ALIGN(resource_size(res), PA_SECTION_SIZE); mem_hotplug_begin(); - arch_remove_memory(align_start, align_size); + arch_remove_memory(res->start, resource_size(res)); mem_hotplug_done(); - untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + untrack_pfn(NULL, PHYS_PFN(res->start), resource_size(res)); pgmap_radix_release(res); dev_WARN_ONCE(dev, pgmap->altmap && pgmap->altmap->alloc, "%s: failed to free all reserved pages\n", __func__); @@ -305,17 +302,13 @@ struct dev_pagemap *find_dev_pagemap(res void *devm_memremap_pages(struct device *dev, struct resource *res, struct percpu_ref *ref, struct vmem_altmap *altmap) { - resource_size_t align_start, align_size, align_end; unsigned long pfn, pgoff, order; pgprot_t pgprot = PAGE_KERNEL; struct dev_pagemap *pgmap; struct page_map *page_map; int error, nid, is_ram; - align_start = res->start & PA_SECTION_MASK; - align_size = ALIGN(res->start + resource_size(res), PA_SECTION_SIZE) - - align_start; - is_ram = region_intersects(align_start, align_size, + is_ram = region_intersects(res->start, resource_size(res), IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE); if (is_ram == REGION_MIXED) { @@ -348,7 +341,6 @@ void *devm_memremap_pages(struct device mutex_lock(&pgmap_lock); error = 0; - align_end = align_start + align_size - 1; foreach_order_pgoff(res, order, pgoff) { struct dev_pagemap *dup; @@ -377,13 +369,13 @@ void *devm_memremap_pages(struct device if (nid < 0) nid = numa_mem_id(); - error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(align_start), 0, - align_size); + error = track_pfn_remap(NULL, &pgprot, PHYS_PFN(res->start), 0, + resource_size(res)); if (error) goto err_pfn_remap; mem_hotplug_begin(); - error = arch_add_memory(nid, align_start, align_size, true); + error = arch_add_memory(nid, res->start, resource_size(res), true); mem_hotplug_done(); if (error) goto err_add_memory; @@ -404,7 +396,7 @@ void *devm_memremap_pages(struct device return __va(res->start); err_add_memory: - untrack_pfn(NULL, PHYS_PFN(align_start), align_size); + untrack_pfn(NULL, PHYS_PFN(res->start), resource_size(res)); err_pfn_remap: err_radix: pgmap_radix_release(res); _ Patches currently in -mm which might be from dan.j.williams@xxxxxxxxx are mm-fix-type-width-of-section-to-from-pfn-conversion-macros.patch mm-devm_memremap_pages-use-multi-order-radix-for-zone_device-lookups.patch mm-introduce-struct-mem_section_usage-to-track-partial-population-of-a-section.patch mm-introduce-common-definitions-for-the-size-and-mask-of-a-section.patch mm-cleanup-sparse_init_one_section-return-value.patch mm-track-active-portions-of-a-section-at-boot.patch mm-fix-register_new_memory-zone-type-detection.patch mm-convert-kmalloc_section_memmap-to-populate_section_memmap.patch mm-prepare-for-hot-add-remove-of-sub-section-ranges.patch mm-support-section-unaligned-zone_device-memory-ranges.patch mm-enable-section-unaligned-devm_memremap_pages.patch libnvdimm-pfn-dax-stop-padding-pmem-namespaces-to-section-alignment.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html