mm/memblock: export max_pfn for kernel modules
PATCH 1/1 mm/memblock: export max_pfn for kernel modules
max_pfn is uesd to get the highest pfn in the system. Drivers like drivers/iommu/mtk_iommu.c checks max_pfn to see if it should enable its "4GB mode".
This patch exports the max_pfn symbol, so we can build the driver as a kernel module.
--- mm/memblock.c | 1 + 1 file changed, 1 insertion(+)
mm/memblock.c +1 -0
@@ -99,6 +99,7 @@ EXPORT_SYMBOL(contig_page_data);unsigned long max_low_pfn;unsigned long min_low_pfn;unsigned long max_pfn; +EXPORT_SYMBOL (max_pfn);unsigned long long max_possible_pfn; static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
Signature · 1 line
2.18.0
Quoted 6 lines · Miles Chen
max_pfnis uesd to get the highest pfn in the system. Drivers likedrivers/iommu/mtk_iommu.cchecksmax_pfnto see if it should enable its "4GB mode".This patch exports the
max_pfnsymbol, so we can build the driver as a kernel module.
Please add that change to the respective user patch (and cc MM-people for that patch), so we have the actual user right along the change and can figure out if this is the right thing to do.
Quoted 19 lines
Signed-off-by Miles Chen <[email protected]>--- mm/memblock.c | 1 + 1 file changed, 1 insertion(+)mm/memblock.c +1
-0@@ -99,6 +99,7 @@ EXPORT_SYMBOL(contig_page_data);unsigned long max_low_pfn;unsigned long min_low_pfn;unsigned long max_pfn; +EXPORT_SYMBOL (max_pfn);unsigned long long max_possible_pfn; static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
Signature · 3 lines
Thanks, David / dhildenb
Quoted 5 lines · David Hildenbrand
Quoted 4 lines · Miles Chen
max_pfnis uesd to get the highest pfn in the system. Drivers likedrivers/iommu/mtk_iommu.cchecksmax_pfnto see if it should enable its "4GB mode".
Quoted 7 lines
Quoted 2 lines
This patch exports the
max_pfnsymbol, so we can build the driver as a kernel module.Please add that change to the respective user patch (and cc MM-people for that patch), so we have the actual user right along the change and can figure out if this is the right thing to do.
Thanks for the comment.
Mike points out another alternative way to do this by totalram_pages(). I will use that approach so we don't have to export max_pfn here.
https://lkml.org/lkml/2020/6/3/771
Miles
Quoted 21 lines
Quoted 19 lines
Signed-off-by Miles Chen <[email protected]>--- mm/memblock.c | 1 + 1 file changed, 1 insertion(+)mm/memblock.c +1
-0@@ -99,6 +99,7 @@ EXPORT_SYMBOL(contig_page_data);unsigned long max_low_pfn;unsigned long min_low_pfn;unsigned long max_pfn; +EXPORT_SYMBOL (max_pfn);unsigned long long max_possible_pfn; static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;
Quoted 6 lines · Miles Chen
max_pfnis uesd to get the highest pfn in the system. Drivers likedrivers/iommu/mtk_iommu.cchecksmax_pfnto see if it should enable its "4GB mode".This patch exports the
max_pfnsymbol, so we can build the driver as a kernel module.
You can use totalram_pages(), like e.g.drivers/media/platform/mtk-vpu/mtk_vpu.c:
$ git grep -np totalram_pages drivers/media/ drivers/media/platform/mtk-vpu/mtk_vpu.c=779=static int mtk_vpu_probe(struct platform_device *pdev) drivers/media/platform/mtk-vpu/mtk_vpu.c:861: vpu->enable_4GB = !!(totalram_pages() > (SZ_2G >> PAGE_SHIFT));
Quoted 19 lines
Signed-off-by Miles Chen <[email protected]>--- mm/memblock.c | 1 + 1 file changed, 1 insertion(+)mm/memblock.c +1
-0@@ -99,6 +99,7 @@ EXPORT_SYMBOL(contig_page_data);unsigned long max_low_pfn;unsigned long min_low_pfn;unsigned long max_pfn; +EXPORT_SYMBOL (max_pfn);unsigned long long max_possible_pfn; static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;Signature · 1 line
2.18.0
Signature · 2 lines
Sincerely yours, Mike.
Quoted 8 lines · Mike Rapoport
Quoted 6 lines · Miles Chen
max_pfnis uesd to get the highest pfn in the system. Drivers likedrivers/iommu/mtk_iommu.cchecksmax_pfnto see if it should enable its "4GB mode".This patch exports the
max_pfnsymbol, so we can build the driver as a kernel module.
Quoted 7 lines
You can use
totalram_pages(), like e.g.drivers/media/platform/mtk-vpu/mtk_vpu.c:$ git grep -np totalram_pages drivers/medhttps://lkml.org/lkml/2020/5/30/123ia/ drivers/media/platform/mtk-vpu/mtk_vpu.c=779=static int mtk_vpu_probe(struct platform_device *pdev) drivers/media/platform/mtk-vpu/mtk_vpu.c:861: vpu->enable_4GB = !!(totalram_pages() > (SZ_2G >> PAGE_SHIFT));
Thanks for the suggestion.totalram_pages() works and I can follow this example.
Miles
Quoted 21 lines
Quoted 20 lines
Signed-off-by Miles Chen <[email protected]>--- mm/memblock.c | 1 + 1 file changed, 1 insertion(+)mm/memblock.c +1
-0@@ -99,6 +99,7 @@ EXPORT_SYMBOL(contig_page_data);unsigned long max_low_pfn;unsigned long min_low_pfn;unsigned long max_pfn; +EXPORT_SYMBOL (max_pfn);unsigned long long max_possible_pfn; static struct memblock_region memblock_memory_init_regions[INIT_MEMBLOCK_REGIONS] __initdata_memblock;Signature · 1 line
2.18.0