Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Serge Semin <fancer.lancer@gmail.com>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: "Florian Fainelli" <f.fainelli@gmail.com>,
	"Hauke Mehrtens" <hauke@hauke-m.de>,
	"Rafał Miłecki" <zajec5@gmail.com>,
	linux-mips@vger.kernel.org,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	linux-kernel@vger.kernel.org,
	bcm-kernel-feedback-list@broadcom.com,
	"Maciej W. Rozycki" <macro@linux-mips.org>,
	"John Crispin" <john@phrozen.org>,
	"Keguang Zhang" <keguang.zhang@gmail.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] MIPS: replace add_memory_region with memblock
Date: Fri, 9 Oct 2020 17:15:37 +0300	[thread overview]
Message-ID: <20201009141537.ijj4cr45zqtkh4yz@mobilestation> (raw)
In-Reply-To: <20201009120752.GA10588@alpha.franken.de>

On Fri, Oct 09, 2020 at 02:07:52PM +0200, Thomas Bogendoerfer wrote:
> On Thu, Oct 08, 2020 at 06:20:06PM +0300, Serge Semin wrote:
> > > Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> > > ---
> > > Changes in v2:
> > > 	fixed missing memblock include in fw/sni/sniprom.c
> > > 	tested on cobalt, IP22, IP28, IP30, IP32, JAZZ, SNI
> > 
> > ...
> > 
> > > diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c
> > > index 9e50dc8df2f6..fab532cb5a11 100644
> > > --- a/arch/mips/kernel/prom.c
> > > +++ b/arch/mips/kernel/prom.c
> > > @@ -50,14 +50,18 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
> > >  		size = PHYS_ADDR_MAX - base;
> > >  	}
> > >  
> > > -	add_memory_region(base, size, BOOT_MEM_RAM);
> > > +	memblock_add(base, size);
> > >  }
> > >  
> > >  int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
> > >  					phys_addr_t size, bool nomap)
> > >  {
> > > -	add_memory_region(base, size,
> > > -			  nomap ? BOOT_MEM_NOMAP : BOOT_MEM_RESERVED);
> > > +	if (nomap) {
> > > +		memblock_remove(base, size);
> > > +	} else {
> > > +		memblock_add(base, size);
> > > +		memblock_reserve(base, size);
> > > +	}
> > >  
> > >  	return 0;
> > >  }
> > 
> > I guess originally the arch-specific early_init_dt_add_memory_arch() and
> > early_init_dt_reserve_memory_arch() methods have been added since MIPS's got its
> > own memory types declarations (BOOT_MEM_RAM, BOOT_MEM_RESERVED, etc) and had had
> > a specific internal system memory regions mapping (add_memory_region(),
> > boot_mem_map, etc). Since the leftover of that framework is going to be removed,
> > we can freely use the standard early_init_dt_add_memory_arch() and
> > early_init_dt_reserve_memory_arch() implementations from drivers/of/fdt.c:1102
> > drivers/of/fdt.c:1149 .
> 
> perfect, I'll remove it in my next version.
> 
> > > @@ -426,13 +387,14 @@ static int __init early_parse_memmap(char *p)
> > >  
> > >  	if (*p == '@') {
> > >  		start_at = memparse(p+1, &p);
> > > -		add_memory_region(start_at, mem_size, BOOT_MEM_RAM);
> > > +		memblock_add(start_at, mem_size);
> > >  	} else if (*p == '#') {
> > >  		pr_err("\"memmap=nn#ss\" (force ACPI data) invalid on MIPS\n");
> > >  		return -EINVAL;
> > >  	} else if (*p == '$') {
> > >  		start_at = memparse(p+1, &p);
> > 
> > > -		add_memory_region(start_at, mem_size, BOOT_MEM_RESERVED);
> > > +		memblock_add(start_at, mem_size);
> > > +		memblock_reserve(start_at, mem_size);
> > 
> > I suppose we could remove the memory addition from here too. What do you think?
> 

> I'm not sure about that, add_memory_region() did a memblock_add
> and then memblock_reserve for BOOT_MEM_RESERVED, that's why I changed
> it that way.

The main question here whether we need to preserve the MIPS-specific semantics
of the kernel 'memmap' parameter. Currently the memmap parameter passed with
'$' specifier will be perceived as a reserved RAM region, while, for instance, 
the same parameter on x86 will be converted to a region, which won't be
registered in memblock at all, so the system won't be able to reuse it if it's
needed to be (see parse_memmap_one() and e820__memblock_setup() for details).

I don't really know what approach is correct... 
Documentation/admin-guide/kernel-parameters.txt isn't certain about that. It
says that the region must be reserved, but no words whether it is supposed to be
mappable or non-mappable.

-Sergey

> 
> Thomas.
> 
> -- 
> Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
> good idea.                                                [ RFC1925, 2.3 ]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-10-09 14:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08  8:43 [PATCH v2] MIPS: replace add_memory_region with memblock Thomas Bogendoerfer
2020-10-08 15:20 ` Serge Semin
2020-10-08 15:30   ` Maciej W. Rozycki
2020-10-08 15:54     ` Serge Semin
2020-10-08 16:49       ` Florian Fainelli
2020-10-08 21:20         ` Serge Semin
2020-10-08 16:56       ` Maciej W. Rozycki
2020-10-08 22:51         ` Serge Semin
2020-10-09  3:00   ` Jiaxun Yang
2020-10-09 12:09     ` Thomas Bogendoerfer
2020-10-09 12:07   ` Thomas Bogendoerfer
2020-10-09 14:15     ` Serge Semin [this message]
2020-10-12 10:01       ` Thomas Bogendoerfer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201009141537.ijj4cr45zqtkh4yz@mobilestation \
    --to=fancer.lancer@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=f.fainelli@gmail.com \
    --cc=hauke@hauke-m.de \
    --cc=jiaxun.yang@flygoat.com \
    --cc=john@phrozen.org \
    --cc=keguang.zhang@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox