linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Geoff Levand <geoff@infradead.org>
To: Andre Heider <a.heider@gmail.com>
Cc: cbe-oss-dev@lists.ozlabs.org,
	Hector Martin <hector@marcansoft.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 02/15] [PS3] Get lv1 high memory region from devtree
Date: Wed, 3 Aug 2011 15:30:20 -0700	[thread overview]
Message-ID: <4E39CBFC.2010501@infradead.org> (raw)
In-Reply-To: <1312228986-32307-3-git-send-email-a.heider@gmail.com>

On 08/01/2011 01:02 PM, Andre Heider wrote:
> 
> This lets the bootloader preallocate the high lv1 region and pass its
> location to the kernel through the devtree. Thus, it can be used to hold
> the initrd. If the property doesn't exist, the kernel retains the old
> behavior and attempts to allocate the region itself.

With this mechanism how is the address of the initrd passed to the
new kernel, in the DT?

How would a kexec based bootloader work?  If it's kernel were to allocate
high mem and the bootloader program uses the high mem, how could it tell
that kernel not to destroy the region on shutdown?

If arch/powerpc/boot/ps3.c allocated the mem and added a DT entry
then other OSes that don't know about the Linux device tree won't
be able to use that allocated memory.  Other OSes could do a
test to see if the allocation was already done.  Another option
that might work is to write info into the LV1 repository then
have boot code look there for allocated hig mem.

> Signed-off-by: Hector Martin <hector@marcansoft.com>
> [a.heider: Various cleanups to make checkpatch.pl happy]
> Signed-off-by: Andre Heider <a.heider@gmail.com>
> ---
>  arch/powerpc/platforms/ps3/mm.c |   61 +++++++++++++++++++++++++++++++++++++-
>  1 files changed, 59 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/platforms/ps3/mm.c b/arch/powerpc/platforms/ps3/mm.c
> index c204588..30bb096 100644
> --- a/arch/powerpc/platforms/ps3/mm.c
> +++ b/arch/powerpc/platforms/ps3/mm.c
> @@ -110,6 +110,7 @@ struct map {
>  	u64 htab_size;
>  	struct mem_region rm;
>  	struct mem_region r1;
> +	int destroy_r1;

In the general case we could have multiple high mem
regions, and each could need to be destroyed, so I
think struct mem_region should have a destroy flag.

>  };
>  
>  #define debug_dump_map(x) _debug_dump_map(x, __func__, __LINE__)
> @@ -287,6 +288,49 @@ static void ps3_mm_region_destroy(struct mem_region *r)
>  	}
>  }
>  
> +static int ps3_mm_scan_memory(unsigned long node, const char *uname,
> +			      int depth, void *data)
> +{

Something like 'ps3_mm_dt_scan_highmem() is more descriptive.

> +	struct mem_region *r = data;
> +	void *p;
> +	u64 prop[2];
> +	unsigned long l;
> +	char *type = of_get_flat_dt_prop(node, "device_type", NULL);
> +
> +	if (type == NULL)
> +		return 0;
> +	if (strcmp(type, "memory") != 0)

Should this be 'if (strcmp(type, "memory"))'?

> +		return 0;
> +
> +	p = of_get_flat_dt_prop(node, "sony,lv1-highmem", &l);
> +	if (p == NULL)
> +		return 0;
> +
> +	BUG_ON(l != sizeof(prop));
> +	memcpy(prop, p, sizeof(prop));
> +
> +	r->base = prop[0];
> +	r->size = prop[1];
> +	r->offset = r->base - map.rm.size;
> +
> +	return -1;
> +}
> +
> +static int ps3_mm_get_devtree_highmem(struct mem_region *r)
> +{
> +	r->size = r->base = r->offset = 0;
> +	of_scan_flat_dt(ps3_mm_scan_memory, r);
> +
> +	if (r->base && r->size) {
> +		DBG("%s:%d got high region from devtree: %llxh %llxh\n",
> +		__func__, __LINE__, r->base, r->size);
> +		return 0;
> +	} else {
> +		DBG("%s:%d no high region in devtree...\n", __func__, __LINE__);
> +		return -1;
> +	}
> +}
> +
>  /**
>   * ps3_mm_add_memory - hot add memory
>   */
> @@ -303,6 +347,12 @@ static int __init ps3_mm_add_memory(void)
>  
>  	BUG_ON(!mem_init_done);
>  
> +	if (!map.r1.size) {
> +		DBG("%s:%d: no region 1, not adding memory\n",
> +		    __func__, __LINE__);
> +		return 0;
> +	}

Did you find this to be hit?  Also, in the general case,
there could be more than one high mem region, but I don't
know of any current systems that do.

> +
>  	start_addr = map.rm.size;
>  	start_pfn = start_addr >> PAGE_SHIFT;
>  	nr_pages = (map.r1.size + PAGE_SIZE - 1) >> PAGE_SHIFT;
> @@ -1219,7 +1269,13 @@ void __init ps3_mm_init(void)
>  
>  
>  	/* arrange to do this in ps3_mm_add_memory */
> -	ps3_mm_region_create(&map.r1, map.total - map.rm.size);
> +
> +	if (ps3_mm_get_devtree_highmem(&map.r1) == 0) {
> +		map.destroy_r1 = 0;
> +	} else {

This should be

	if (!ps3_mm_get_devtree_highmem(&map.r1))
		map.destroy_r1 = 0;
	else {

> +		ps3_mm_region_create(&map.r1, map.total - map.rm.size);
> +		map.destroy_r1 = 1;
> +	}
>  
>  	/* correct map.total for the real total amount of memory we use */
>  	map.total = map.rm.size + map.r1.size;
> @@ -1233,5 +1289,6 @@ void __init ps3_mm_init(void)
>  
>  void ps3_mm_shutdown(void)
>  {
> -	ps3_mm_region_destroy(&map.r1);
> +	if (map.destroy_r1)
> +		ps3_mm_region_destroy(&map.r1);
>  }

-Geoff

  reply	other threads:[~2011-08-03 22:30 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 20:02 [PATCH 00/15] ps3: Support more than the OtherOS lpar Andre Heider
2011-08-01 20:02 ` [PATCH 01/15] [PS3] Add udbg driver using the PS3 gelic Ethernet device Andre Heider
2011-08-03 22:32   ` Geoff Levand
2011-08-04 16:35     ` Andre Heider
2011-08-11 12:13     ` [Cbe-oss-dev] " Arnd Bergmann
2011-08-11 17:32       ` Andre Heider
2011-08-31  4:26         ` Benjamin Herrenschmidt
2011-08-01 20:02 ` [PATCH 02/15] [PS3] Get lv1 high memory region from devtree Andre Heider
2011-08-03 22:30   ` Geoff Levand [this message]
2011-08-04  1:19     ` Hector Martin
2011-08-04 19:24       ` Geoff Levand
2011-08-06 11:50         ` Andre Heider
2011-08-01 20:02 ` [PATCH 03/15] [PS3] Add region 1 memory early Andre Heider
2011-08-03 22:32   ` Geoff Levand
2011-08-04  0:08     ` Hector Martin
2011-08-04  7:05       ` Geert Uytterhoeven
2011-08-04 11:13         ` Hector Martin
2011-08-04 15:57       ` Geoff Levand
2011-08-01 20:02 ` [PATCH 04/15] ps3: MEMORY_HOTPLUG is not a requirement anymore Andre Heider
2011-08-01 20:02 ` [PATCH 05/15] ps3: Detect the current lpar environment Andre Heider
2011-08-03 22:31   ` Geoff Levand
2011-08-04 16:34     ` Andre Heider
2011-08-01 20:02 ` [PATCH 06/15] ps3flash: Fix region align checks Andre Heider
2011-08-01 20:29   ` [Cbe-oss-dev] " Geert Uytterhoeven
2011-08-01 20:56     ` Andre Heider
2011-08-01 21:00       ` Geert Uytterhoeven
2011-08-01 20:02 ` [PATCH 07/15] ps3flash: Refuse to work in lpars other than OtherOS Andre Heider
2011-08-03 22:34   ` Geoff Levand
2011-08-04 16:40     ` Andre Heider
2011-08-04 19:27       ` [Cbe-oss-dev] " Geert Uytterhoeven
2011-08-06 12:40         ` Andre Heider
2011-08-01 20:02 ` [PATCH 08/15] ps3: Only prealloc the flash bounce buffer for the OtherOS lpar Andre Heider
2011-08-01 20:03 ` [PATCH 09/15] ps3: Limit the number of regions per storage device Andre Heider
2011-08-01 20:30   ` [Cbe-oss-dev] " Geert Uytterhoeven
2011-08-01 20:58     ` Andre Heider
2011-08-06 12:28       ` Andre Heider
2011-08-06 12:47         ` Andre Heider
2011-08-01 20:03 ` [PATCH 10/15] ps3stor_lib: Add support for multiple regions Andre Heider
2011-08-01 20:35   ` Geert Uytterhoeven
2011-08-01 21:01     ` Andre Heider
2011-08-01 20:03 ` [PATCH 11/15] ps3disk: Provide a gendisk per accessible region Andre Heider
2011-08-01 20:03 ` [PATCH 12/15] ps3stor_lib: Add support for storage access flags Andre Heider
2011-08-01 20:03 ` [PATCH 13/15] ps3disk: Use region flags Andre Heider
2011-08-01 20:03 ` [PATCH 14/15] ps3: Add a vflash driver for lpars other than OtherOS Andre Heider
2011-08-01 20:03 ` [PATCH 15/15] ps3: Add a NOR FLASH driver for PS3s without NAND Andre Heider
2011-08-03 22:23 ` [PATCH 00/15] ps3: Support more than the OtherOS lpar Geoff Levand
2011-08-04 16:31   ` Andre Heider
2011-08-11 12:17 ` [Cbe-oss-dev] " Arnd Bergmann
2011-08-11 17:34   ` Andre Heider
2011-08-11 19:31 ` [PATCH part1 v2 0/9] ps3: General improvements and preparation for support " Andre Heider
2011-08-11 19:31   ` [PATCH part1 v2 1/9] Add udbg driver using the PS3 gelic Ethernet device Andre Heider
2011-08-23 20:53     ` Geoff Levand
2011-08-31 16:32       ` [PATCH] [ps3] Add gelic udbg driver Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 2/9] ps3: Add helper functions to read highmem info from the repository Andre Heider
2011-08-23 20:53     ` Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 3/9] ps3: Get lv1 high memory region " Andre Heider
2011-08-23 20:53     ` Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 4/9] Add region 1 memory early Andre Heider
2011-08-23 20:53     ` Geoff Levand
2011-08-23 22:37       ` [Cbe-oss-dev] " Antonio Ospite
2011-08-24  2:15         ` Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 5/9] ps3: MEMORY_HOTPLUG is not a requirement anymore Andre Heider
2011-08-23 20:53     ` Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 6/9] ps3: Detect the current lpar Andre Heider
2011-08-23 22:08     ` Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 7/9] ps3: Log the detected lpar on startup Andre Heider
2011-08-11 19:31   ` [PATCH part1 v2 8/9] ps3flash: Refuse to work in lpars other than OtherOS Andre Heider
2011-08-23 22:12     ` Geoff Levand
2011-08-11 19:31   ` [PATCH part1 v2 9/9] ps3: Only prealloc the flash bounce buffer for the OtherOS lpar Andre Heider
2011-08-31  4:29   ` [PATCH part1 v2 0/9] ps3: General improvements and preparation for support more than " Benjamin Herrenschmidt

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=4E39CBFC.2010501@infradead.org \
    --to=geoff@infradead.org \
    --cc=a.heider@gmail.com \
    --cc=cbe-oss-dev@lists.ozlabs.org \
    --cc=hector@marcansoft.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).