* [PATCH] MIPS: kernel: Fix for_each_memblock conversion
@ 2020-11-16 17:45 Thomas Bogendoerfer
2020-11-16 18:49 ` Mike Rapoport
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-11-16 17:45 UTC (permalink / raw)
To: Mike Rapoport, Andrew Morton, linux-mips, linux-kernel
The loop over all memblocks works with PFN numbers and not physical
addresses, so we need for_each_mem_pfn_range().
Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
---
arch/mips/kernel/setup.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 0d4253208bde..ca579deef939 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -262,8 +262,8 @@ static void __init bootmem_init(void)
static void __init bootmem_init(void)
{
phys_addr_t ramstart, ramend;
- phys_addr_t start, end;
- u64 i;
+ unsigned long start, end;
+ int i;
ramstart = memblock_start_of_DRAM();
ramend = memblock_end_of_DRAM();
@@ -300,7 +300,7 @@ static void __init bootmem_init(void)
min_low_pfn = ARCH_PFN_OFFSET;
max_pfn = PFN_DOWN(ramend);
- for_each_mem_range(i, &start, &end) {
+ for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) {
/*
* Skip highmem here so we get an accurate max_low_pfn if low
* memory stops short of high memory.
--
2.16.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: kernel: Fix for_each_memblock conversion
2020-11-16 17:45 [PATCH] MIPS: kernel: Fix for_each_memblock conversion Thomas Bogendoerfer
@ 2020-11-16 18:49 ` Mike Rapoport
2020-11-16 20:05 ` Serge Semin
2020-11-17 11:47 ` Thomas Bogendoerfer
2 siblings, 0 replies; 7+ messages in thread
From: Mike Rapoport @ 2020-11-16 18:49 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: Andrew Morton, linux-mips, linux-kernel
On Mon, Nov 16, 2020 at 06:45:15PM +0100, Thomas Bogendoerfer wrote:
> The loop over all memblocks works with PFN numbers and not physical
> addresses, so we need for_each_mem_pfn_range().
>
> Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Thanks, Thomas!
> ---
> arch/mips/kernel/setup.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index 0d4253208bde..ca579deef939 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -262,8 +262,8 @@ static void __init bootmem_init(void)
> static void __init bootmem_init(void)
> {
> phys_addr_t ramstart, ramend;
> - phys_addr_t start, end;
> - u64 i;
> + unsigned long start, end;
> + int i;
>
> ramstart = memblock_start_of_DRAM();
> ramend = memblock_end_of_DRAM();
> @@ -300,7 +300,7 @@ static void __init bootmem_init(void)
>
> min_low_pfn = ARCH_PFN_OFFSET;
> max_pfn = PFN_DOWN(ramend);
> - for_each_mem_range(i, &start, &end) {
> + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) {
> /*
> * Skip highmem here so we get an accurate max_low_pfn if low
> * memory stops short of high memory.
> --
> 2.16.4
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: kernel: Fix for_each_memblock conversion
2020-11-16 17:45 [PATCH] MIPS: kernel: Fix for_each_memblock conversion Thomas Bogendoerfer
2020-11-16 18:49 ` Mike Rapoport
@ 2020-11-16 20:05 ` Serge Semin
2020-11-17 8:05 ` Mike Rapoport
2020-11-17 11:47 ` Thomas Bogendoerfer
2 siblings, 1 reply; 7+ messages in thread
From: Serge Semin @ 2020-11-16 20:05 UTC (permalink / raw)
To: Thomas Bogendoerfer
Cc: Mike Rapoport, Andrew Morton, linux-mips, linux-kernel
On Mon, Nov 16, 2020 at 06:45:15PM +0100, Thomas Bogendoerfer wrote:
> The loop over all memblocks works with PFN numbers and not physical
> addresses, so we need for_each_mem_pfn_range().
Great catch! Don't know how that has been working so far. Anyway
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
-Sergey
>
> Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---
> arch/mips/kernel/setup.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> index 0d4253208bde..ca579deef939 100644
> --- a/arch/mips/kernel/setup.c
> +++ b/arch/mips/kernel/setup.c
> @@ -262,8 +262,8 @@ static void __init bootmem_init(void)
> static void __init bootmem_init(void)
> {
> phys_addr_t ramstart, ramend;
> - phys_addr_t start, end;
> - u64 i;
> + unsigned long start, end;
> + int i;
>
> ramstart = memblock_start_of_DRAM();
> ramend = memblock_end_of_DRAM();
> @@ -300,7 +300,7 @@ static void __init bootmem_init(void)
>
> min_low_pfn = ARCH_PFN_OFFSET;
> max_pfn = PFN_DOWN(ramend);
> - for_each_mem_range(i, &start, &end) {
> + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) {
> /*
> * Skip highmem here so we get an accurate max_low_pfn if low
> * memory stops short of high memory.
> --
> 2.16.4
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: kernel: Fix for_each_memblock conversion
2020-11-16 20:05 ` Serge Semin
@ 2020-11-17 8:05 ` Mike Rapoport
2020-11-17 9:12 ` Serge Semin
2020-11-17 9:13 ` Thomas Bogendoerfer
0 siblings, 2 replies; 7+ messages in thread
From: Mike Rapoport @ 2020-11-17 8:05 UTC (permalink / raw)
To: Serge Semin; +Cc: Thomas Bogendoerfer, Andrew Morton, linux-mips, linux-kernel
On Mon, Nov 16, 2020 at 11:05:54PM +0300, Serge Semin wrote:
> On Mon, Nov 16, 2020 at 06:45:15PM +0100, Thomas Bogendoerfer wrote:
> > The loop over all memblocks works with PFN numbers and not physical
> > addresses, so we need for_each_mem_pfn_range().
>
> Great catch! Don't know how that has been working so far. Anyway
The loop is relevant only for systems with highmem, apparently there are
not many highmem users out there.
> Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
>
> -Sergey
>
> >
> > Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
> > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > ---
> > arch/mips/kernel/setup.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> > index 0d4253208bde..ca579deef939 100644
> > --- a/arch/mips/kernel/setup.c
> > +++ b/arch/mips/kernel/setup.c
> > @@ -262,8 +262,8 @@ static void __init bootmem_init(void)
> > static void __init bootmem_init(void)
> > {
> > phys_addr_t ramstart, ramend;
> > - phys_addr_t start, end;
> > - u64 i;
> > + unsigned long start, end;
> > + int i;
> >
> > ramstart = memblock_start_of_DRAM();
> > ramend = memblock_end_of_DRAM();
> > @@ -300,7 +300,7 @@ static void __init bootmem_init(void)
> >
> > min_low_pfn = ARCH_PFN_OFFSET;
> > max_pfn = PFN_DOWN(ramend);
> > - for_each_mem_range(i, &start, &end) {
> > + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) {
> > /*
> > * Skip highmem here so we get an accurate max_low_pfn if low
> > * memory stops short of high memory.
> > --
> > 2.16.4
> >
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: kernel: Fix for_each_memblock conversion
2020-11-17 8:05 ` Mike Rapoport
@ 2020-11-17 9:12 ` Serge Semin
2020-11-17 9:13 ` Thomas Bogendoerfer
1 sibling, 0 replies; 7+ messages in thread
From: Serge Semin @ 2020-11-17 9:12 UTC (permalink / raw)
To: Mike Rapoport
Cc: Thomas Bogendoerfer, Andrew Morton, linux-mips, linux-kernel
On Tue, Nov 17, 2020 at 10:05:18AM +0200, Mike Rapoport wrote:
> On Mon, Nov 16, 2020 at 11:05:54PM +0300, Serge Semin wrote:
> > On Mon, Nov 16, 2020 at 06:45:15PM +0100, Thomas Bogendoerfer wrote:
> > > The loop over all memblocks works with PFN numbers and not physical
> > > addresses, so we need for_each_mem_pfn_range().
> >
> > Great catch! Don't know how that has been working so far. Anyway
>
> The loop is relevant only for systems with highmem, apparently there are
> not many highmem users out there.
That has been mostly a rhetorical question. The thing is that our
platform is 32bit and it is active user of highmem.) So I am very
puzzled how I haven't noticed a effect caused by that bug before.
Most likely that happened due to our platform having a first memory
chunk starting with physical address 0x0. That's why we always have a
low memory defined.
-Sergey
>
> > Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
> >
> > -Sergey
> >
> > >
> > > Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
> > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > ---
> > > arch/mips/kernel/setup.c | 6 +++---
> > > 1 file changed, 3 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
> > > index 0d4253208bde..ca579deef939 100644
> > > --- a/arch/mips/kernel/setup.c
> > > +++ b/arch/mips/kernel/setup.c
> > > @@ -262,8 +262,8 @@ static void __init bootmem_init(void)
> > > static void __init bootmem_init(void)
> > > {
> > > phys_addr_t ramstart, ramend;
> > > - phys_addr_t start, end;
> > > - u64 i;
> > > + unsigned long start, end;
> > > + int i;
> > >
> > > ramstart = memblock_start_of_DRAM();
> > > ramend = memblock_end_of_DRAM();
> > > @@ -300,7 +300,7 @@ static void __init bootmem_init(void)
> > >
> > > min_low_pfn = ARCH_PFN_OFFSET;
> > > max_pfn = PFN_DOWN(ramend);
> > > - for_each_mem_range(i, &start, &end) {
> > > + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) {
> > > /*
> > > * Skip highmem here so we get an accurate max_low_pfn if low
> > > * memory stops short of high memory.
> > > --
> > > 2.16.4
> > >
>
> --
> Sincerely yours,
> Mike.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: kernel: Fix for_each_memblock conversion
2020-11-17 8:05 ` Mike Rapoport
2020-11-17 9:12 ` Serge Semin
@ 2020-11-17 9:13 ` Thomas Bogendoerfer
1 sibling, 0 replies; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-11-17 9:13 UTC (permalink / raw)
To: Mike Rapoport; +Cc: Serge Semin, Andrew Morton, linux-mips, linux-kernel
On Tue, Nov 17, 2020 at 10:05:18AM +0200, Mike Rapoport wrote:
> On Mon, Nov 16, 2020 at 11:05:54PM +0300, Serge Semin wrote:
> > On Mon, Nov 16, 2020 at 06:45:15PM +0100, Thomas Bogendoerfer wrote:
> > > The loop over all memblocks works with PFN numbers and not physical
> > > addresses, so we need for_each_mem_pfn_range().
> >
> > Great catch! Don't know how that has been working so far. Anyway
>
> The loop is relevant only for systems with highmem, apparently there are
> not many highmem users out there.
I found the bug on a SGI IP22 probably because PHYS_OFFSET is != 0.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] MIPS: kernel: Fix for_each_memblock conversion
2020-11-16 17:45 [PATCH] MIPS: kernel: Fix for_each_memblock conversion Thomas Bogendoerfer
2020-11-16 18:49 ` Mike Rapoport
2020-11-16 20:05 ` Serge Semin
@ 2020-11-17 11:47 ` Thomas Bogendoerfer
2 siblings, 0 replies; 7+ messages in thread
From: Thomas Bogendoerfer @ 2020-11-17 11:47 UTC (permalink / raw)
To: Mike Rapoport, Andrew Morton, linux-mips, linux-kernel
On Mon, Nov 16, 2020 at 06:45:15PM +0100, Thomas Bogendoerfer wrote:
> The loop over all memblocks works with PFN numbers and not physical
> addresses, so we need for_each_mem_pfn_range().
>
> Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()")
> Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> ---
> arch/mips/kernel/setup.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
applied to mips-fixes.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-11-17 11:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-16 17:45 [PATCH] MIPS: kernel: Fix for_each_memblock conversion Thomas Bogendoerfer
2020-11-16 18:49 ` Mike Rapoport
2020-11-16 20:05 ` Serge Semin
2020-11-17 8:05 ` Mike Rapoport
2020-11-17 9:12 ` Serge Semin
2020-11-17 9:13 ` Thomas Bogendoerfer
2020-11-17 11:47 ` Thomas Bogendoerfer
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).