mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-20 14:16:02 +00:00
[POWERPC] Allow duplicate lmb_reserve() calls
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> Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
83ddcf5d36
commit
eb6de28637
2 changed files with 4 additions and 3 deletions
|
@ -954,9 +954,6 @@ static void __init early_reserve_mem(void)
|
||||||
size = *(reserve_map++);
|
size = *(reserve_map++);
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
break;
|
break;
|
||||||
/* skip if the reservation is for the blob */
|
|
||||||
if (base == self_base && size == self_size)
|
|
||||||
continue;
|
|
||||||
DBG("reserving: %llx -> %llx\n", base, size);
|
DBG("reserving: %llx -> %llx\n", base, size);
|
||||||
lmb_reserve(base, size);
|
lmb_reserve(base, size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,6 +146,10 @@ static long __init lmb_add_region(struct lmb_region *rgn, unsigned long base,
|
||||||
unsigned long rgnbase = rgn->region[i].base;
|
unsigned long rgnbase = rgn->region[i].base;
|
||||||
unsigned long rgnsize = rgn->region[i].size;
|
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);
|
adjacent = lmb_addrs_adjacent(base,size,rgnbase,rgnsize);
|
||||||
if ( adjacent > 0 ) {
|
if ( adjacent > 0 ) {
|
||||||
rgn->region[i].base -= size;
|
rgn->region[i].base -= size;
|
||||||
|
|
Loading…
Reference in a new issue