* [PATCH] mm/memblock: export max_pfn for kernel modules
@ 2020-06-03 16:11 Miles Chen
2020-06-03 16:16 ` David Hildenbrand
2020-06-03 17:06 ` Mike Rapoport
0 siblings, 2 replies; 5+ messages in thread
From: Miles Chen @ 2020-06-03 16:11 UTC (permalink / raw)
To: Mike Rapoport, Andrew Morton, Matthias Brugger
Cc: linux-mm, linux-kernel, linux-arm-kernel, linux-mediatek,
wsd_upstream, Miles Chen
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.
Signed-off-by: Miles Chen <miles.chen@mediatek.com>
---
mm/memblock.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/memblock.c b/mm/memblock.c
index c79ba6f9920c..3b2b21ecebb6 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -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;
--
2.18.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/memblock: export max_pfn for kernel modules
2020-06-03 16:11 [PATCH] mm/memblock: export max_pfn for kernel modules Miles Chen
@ 2020-06-03 16:16 ` David Hildenbrand
2020-06-04 3:39 ` Miles Chen
2020-06-03 17:06 ` Mike Rapoport
1 sibling, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2020-06-03 16:16 UTC (permalink / raw)
To: Miles Chen, Mike Rapoport, Andrew Morton, Matthias Brugger
Cc: linux-mm, linux-kernel, linux-arm-kernel, linux-mediatek, wsd_upstream
On 03.06.20 18:11, Miles Chen wrote:
> 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.
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.
>
> Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> ---
> mm/memblock.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index c79ba6f9920c..3b2b21ecebb6 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -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;
>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/memblock: export max_pfn for kernel modules
2020-06-03 16:16 ` David Hildenbrand
@ 2020-06-04 3:39 ` Miles Chen
0 siblings, 0 replies; 5+ messages in thread
From: Miles Chen @ 2020-06-04 3:39 UTC (permalink / raw)
To: David Hildenbrand
Cc: Mike Rapoport, Andrew Morton, Matthias Brugger, linux-mm,
linux-kernel, linux-arm-kernel, linux-mediatek, wsd_upstream
On Wed, 2020-06-03 at 18:16 +0200, David Hildenbrand wrote:
> On 03.06.20 18:11, Miles Chen wrote:
> > 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.
>
> 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
> >
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > mm/memblock.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/mm/memblock.c b/mm/memblock.c
> > index c79ba6f9920c..3b2b21ecebb6 100644
> > --- a/mm/memblock.c
> > +++ b/mm/memblock.c
> > @@ -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;
> >
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/memblock: export max_pfn for kernel modules
2020-06-03 16:11 [PATCH] mm/memblock: export max_pfn for kernel modules Miles Chen
2020-06-03 16:16 ` David Hildenbrand
@ 2020-06-03 17:06 ` Mike Rapoport
2020-06-04 3:39 ` Miles Chen
1 sibling, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2020-06-03 17:06 UTC (permalink / raw)
To: Miles Chen
Cc: Andrew Morton, Matthias Brugger, linux-mm, linux-kernel,
linux-arm-kernel, linux-mediatek, wsd_upstream
On Thu, Jun 04, 2020 at 12:11:32AM +0800, Miles Chen wrote:
> 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.
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));
> Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> ---
> mm/memblock.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index c79ba6f9920c..3b2b21ecebb6 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -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;
> --
> 2.18.0
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm/memblock: export max_pfn for kernel modules
2020-06-03 17:06 ` Mike Rapoport
@ 2020-06-04 3:39 ` Miles Chen
0 siblings, 0 replies; 5+ messages in thread
From: Miles Chen @ 2020-06-04 3:39 UTC (permalink / raw)
To: Mike Rapoport
Cc: Andrew Morton, Matthias Brugger, linux-mm, linux-kernel,
linux-arm-kernel, linux-mediatek, wsd_upstream
On Wed, 2020-06-03 at 20:06 +0300, Mike Rapoport wrote:
> On Thu, Jun 04, 2020 at 12:11:32AM +0800, Miles Chen wrote:
> > 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.
>
> 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
>
> > Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> > ---
> > mm/memblock.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/mm/memblock.c b/mm/memblock.c
> > index c79ba6f9920c..3b2b21ecebb6 100644
> > --- a/mm/memblock.c
> > +++ b/mm/memblock.c
> > @@ -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;
> > --
> > 2.18.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-06-04 3:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 16:11 [PATCH] mm/memblock: export max_pfn for kernel modules Miles Chen
2020-06-03 16:16 ` David Hildenbrand
2020-06-04 3:39 ` Miles Chen
2020-06-03 17:06 ` Mike Rapoport
2020-06-04 3:39 ` Miles Chen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).