diff mbox series

drivers: of: increase MAX_RESERVED_REGIONS to 32

Message ID 20170926084000.29105-1-stewart@linux.vnet.ibm.com (mailing list archive)
State Accepted
Headers show
Series drivers: of: increase MAX_RESERVED_REGIONS to 32 | expand

Commit Message

Stewart Smith Sept. 26, 2017, 8:40 a.m. UTC
There are two types of memory reservations firmware can ask the kernel
to make in the device tree: static and dynamic.
See Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt

If you have greater than 16 entries in /reserved-memory (as we do on
POWER9 systems) you would get this scary looking error message:
 [    0.000000] OF: reserved mem: not enough space all defined regions.

This is harmless if all your reservations are static (which with OPAL on
POWER9, they are).

It is not harmless if you have any dynamic reservations after the 16th.

In the first pass over the fdt to find reservations, the child nodes of
/reserved-memory are added to a static array in of_reserved_mem.c so that
memory can be reserved in a 2nd pass. The array has 16 entries. This is why,
on my dual socket POWER9 system, I get that error 4 times with 20 static
reservations.

We don't have a problem on ppc though, as in arch/powerpc/kernel/prom.c
we look at the new style /reserved-ranges property to do reservations,
and this logic was introduced in 0962e8004e974 (well before any powernv
system shipped).

A Google search shows up no occurances of that exact error message, so we're
probably safe in that no machine that people use has memory not being reserved
when it should be.

The simple fix is to bump the length of the array to 32 which "should be
enough for everyone(TM)". The simple fix of not recording static allocations
in the array would cause problems for devices with "memory-region" properties.
A more future-proof fix is likely possible, although more invasive and this
simple fix is perfectly suitable in the meantime while a more future-proof
fix is developed.

Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 drivers/of/of_reserved_mem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Mauricio Faria de Oliveira Oct. 2, 2017, 10:58 p.m. UTC | #1
On 09/26/2017 05:40 AM, Stewart Smith wrote:
> The simple fix is to bump the length of the array to 32 which "should be
> enough for everyone(TM)".

Tested-by: Mauricio Faria de Oliveira <mauricfo@linux.vnet.ibm.com>

# uname -r
4.14.0-rc3

# dmesg
[    0.000000] opal: OPAL detected !
[    0.000000] crashkernel: memory value expected
[    0.000000] OF: reserved mem: not enough space all defined regions.
[    0.000000] OF: reserved mem: not enough space all defined regions.
[    0.000000] OF: reserved mem: not enough space all defined regions.
[    0.000000] OF: reserved mem: not enough space all defined regions.
[    0.000000] Allocated 2883584 bytes for 2048 pacas at c00000000fd40000
<...>

# uname -r
4.14.0-rc3.of32maxrsvdmemregions

# dmesg | head
[    0.000000] opal: OPAL detected !
[    0.000000] crashkernel: memory value expected
[    0.000000] Allocated 2883584 bytes for 2048 pacas at c00000000fd40000
<...>
Rob Herring (Arm) Oct. 12, 2017, 5:25 p.m. UTC | #2
On Tue, Sep 26, 2017 at 3:40 AM, Stewart Smith
<stewart@linux.vnet.ibm.com> wrote:
> There are two types of memory reservations firmware can ask the kernel
> to make in the device tree: static and dynamic.
> See Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
>
> If you have greater than 16 entries in /reserved-memory (as we do on
> POWER9 systems) you would get this scary looking error message:
>  [    0.000000] OF: reserved mem: not enough space all defined regions.
>
> This is harmless if all your reservations are static (which with OPAL on
> POWER9, they are).
>
> It is not harmless if you have any dynamic reservations after the 16th.
>
> In the first pass over the fdt to find reservations, the child nodes of
> /reserved-memory are added to a static array in of_reserved_mem.c so that
> memory can be reserved in a 2nd pass. The array has 16 entries. This is why,
> on my dual socket POWER9 system, I get that error 4 times with 20 static
> reservations.
>
> We don't have a problem on ppc though, as in arch/powerpc/kernel/prom.c
> we look at the new style /reserved-ranges property to do reservations,
> and this logic was introduced in 0962e8004e974 (well before any powernv
> system shipped).
>
> A Google search shows up no occurances of that exact error message, so we're
> probably safe in that no machine that people use has memory not being reserved
> when it should be.
>
> The simple fix is to bump the length of the array to 32 which "should be
> enough for everyone(TM)". The simple fix of not recording static allocations
> in the array would cause problems for devices with "memory-region" properties.
> A more future-proof fix is likely possible, although more invasive and this
> simple fix is perfectly suitable in the meantime while a more future-proof
> fix is developed.
>
> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
> ---
>  drivers/of/of_reserved_mem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied.

Rob
diff mbox series

Patch

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index d507c3569a88..32771c2ced7b 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -25,7 +25,7 @@ 
 #include <linux/sort.h>
 #include <linux/slab.h>
 
-#define MAX_RESERVED_REGIONS	16
+#define MAX_RESERVED_REGIONS	32
 static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS];
 static int reserved_mem_count;