From: David Gibson <david@gibson.dropbear.id.au>
To: Paul Mackerras <paulus@samba.org>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
<linuxppc-dev@ozlabs.org>
Subject: [PATCH 1/2] powerpc: Allow duplicate lmb_reserve() calls
Date: Wed, 28 Feb 2007 14:12:29 +1100 (EST) [thread overview]
Message-ID: <20070228031229.430F3DDDF6@ozlabs.org> (raw)
In-Reply-To: <20070228031120.GF11775@localhost.localdomain>
At present calling lmb_reserve() (and hence lmb_add_region()) twice
for exactly the same memory region will cause strange behaviour.
This makes life difficult when booting from a flat device tree with
memory reserve map. Which regions are automatically reserved by the
kernel has changed over time, so it's quite possible a newer kernel
could attempt to auto-reserve a region which is also explicitly listed
in the device tree's reserve map, leading to trouble.
This patch avoids the problem by making lmb_reserve() ignore a call to
reserve a previously reserved region. It also removes a now redundant
test designed to avoid one specific case of the problem noted above.
At present, this patch deals only with duplicate reservations of an
identical region. Attempting to reserve two different, but
overlapping regions will still cause problems. I might post another
patch later dealing with this case, but I'm avoiding it now since it
is substantially more complicated to deal with, less likely to occur
and more likely to indicate a genuine bug elsewhere if it does occur.
Signed-off-by: David Gibson <dwg@au1.ibm.com>
---
arch/powerpc/kernel/prom.c | 3 ---
arch/powerpc/mm/lmb.c | 4 ++++
2 files changed, 4 insertions(+), 3 deletions(-)
Index: working-2.6/arch/powerpc/mm/lmb.c
===================================================================
--- working-2.6.orig/arch/powerpc/mm/lmb.c 2007-02-06 16:21:02.000000000 +1100
+++ working-2.6/arch/powerpc/mm/lmb.c 2007-02-06 16:22:32.000000000 +1100
@@ -146,6 +146,10 @@ static long __init lmb_add_region(struct
unsigned long rgnbase = rgn->region[i].base;
unsigned long rgnsize = rgn->region[i].size;
+ if ((rgnbase == base) && (rgnsize == size))
+ /* Already have this region, so we're done */
+ return 0;
+
adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize);
if ( adjacent > 0 ) {
rgn->region[i].base -= size;
Index: working-2.6/arch/powerpc/kernel/prom.c
===================================================================
--- working-2.6.orig/arch/powerpc/kernel/prom.c 2007-02-06 16:22:48.000000000 +1100
+++ working-2.6/arch/powerpc/kernel/prom.c 2007-02-06 16:22:57.000000000 +1100
@@ -954,9 +954,6 @@ static void __init early_reserve_mem(voi
size = *(reserve_map++);
if (size == 0)
break;
- /* skip if the reservation is for the blob */
- if (base == self_base && size == self_size)
- continue;
DBG("reserving: %llx -> %llx\n", base, size);
lmb_reserve(base, size);
}
next prev parent reply other threads:[~2007-02-28 3:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-28 3:11 [0/2] Automatically reserve the initrd David Gibson
2007-02-28 3:12 ` David Gibson [this message]
2007-02-28 3:12 ` [PATCH 2/2] Automatically lmb_reserve() initrd David Gibson
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=20070228031229.430F3DDDF6@ozlabs.org \
--to=david@gibson.dropbear.id.au \
--cc=benh@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.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).