diff mbox

of: Print rather than WARN'ing when overlap check fails

Message ID 1447132113-31434-1-git-send-email-mpe@ellerman.id.au (mailing list archive)
State Not Applicable
Headers show

Commit Message

Michael Ellerman Nov. 10, 2015, 5:08 a.m. UTC
__rmem_check_for_overlap() is called very early in boot, and on some
powerpc systems it's not safe to call WARN that early in boot.

If the overlap check fails the system will oops instead of printing a
warning. Furthermore because it's so early in boot the console is not up
and the user doesn't see the oops, they just get a dead system.

Fix it by printing an error instead of calling WARN.

Fixes: ae1add247bf8 ("of: Check for overlap in reserved memory regions")
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 drivers/of/of_reserved_mem.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Comments

Michael Ellerman Nov. 10, 2015, 9:28 a.m. UTC | #1
On Tue, 2015-11-10 at 16:08 +1100, Michael Ellerman wrote:

> __rmem_check_for_overlap() is called very early in boot, and on some
> powerpc systems it's not safe to call WARN that early in boot.
> 
> If the overlap check fails the system will oops instead of printing a
> warning. Furthermore because it's so early in boot the console is not up
> and the user doesn't see the oops, they just get a dead system.
> 
> Fix it by printing an error instead of calling WARN.
> 
> Fixes: ae1add247bf8 ("of: Check for overlap in reserved memory regions")
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  drivers/of/of_reserved_mem.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)

I forgot to say, I assume you're OK to merge this and get it to Linus soonish?
Otherwise I can stuff it in a fix branch and ask Linus to pull that. Let me
know which you'd prefer.

cheers
David Laight Nov. 10, 2015, 9:41 a.m. UTC | #2
From: Michael Ellerman

> Sent: 10 November 2015 05:09

> __rmem_check_for_overlap() is called very early in boot, and on some

> powerpc systems it's not safe to call WARN that early in boot.

> 

> If the overlap check fails the system will oops instead of printing a

> warning. Furthermore because it's so early in boot the console is not up

> and the user doesn't see the oops, they just get a dead system.


Wouldn't it be better to add the required checks to WARN()?
That would stop the same problem happening elsewhere.

	David
Michael Ellerman Nov. 10, 2015, 9:47 p.m. UTC | #3
On Tue, 2015-11-10 at 09:41 +0000, David Laight wrote:

> From: Michael Ellerman

> > Sent: 10 November 2015 05:09
> > __rmem_check_for_overlap() is called very early in boot, and on some
> > powerpc systems it's not safe to call WARN that early in boot.
> > 
> > If the overlap check fails the system will oops instead of printing a
> > warning. Furthermore because it's so early in boot the console is not up
> > and the user doesn't see the oops, they just get a dead system.
> 
> Wouldn't it be better to add the required checks to WARN()?

Yes obviously it would. But that's less simple than it sounds. I'm working on
it.

cheers
diff mbox

Patch

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 62f467b8ccae..49703916a30e 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -226,10 +226,9 @@  static void __init __rmem_check_for_overlap(void)
 
 			this_end = this->base + this->size;
 			next_end = next->base + next->size;
-			WARN(1,
-			     "Reserved memory: OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
-			     this->name, &this->base, &this_end,
-			     next->name, &next->base, &next_end);
+			pr_err("Reserved memory: OVERLAP DETECTED!\n%s (%pa--%pa) overlaps with %s (%pa--%pa)\n",
+			       this->name, &this->base, &this_end,
+			       next->name, &next->base, &next_end);
 		}
 	}
 }