[PATCH 4/16] powerpc: Allow duplicate lmb_reserve() calls
Michael Neuling
mikey at neuling.org
Tue Feb 13 18:05:20 EST 2007
> 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 at 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;
This might indicate that two things actually want to use the same memory
region. How about we print a warning?
Mikey
More information about the Linuxppc-dev
mailing list