All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Vorontsov <avorontsov@mvista.com>
To: David Miller <davem@davemloft.net>, Greg Kroah-Hartman <gregkh@suse.de>
Cc: Kristoffer Glembo <kristoffer@gaisler.com>, linux-kernel@vger.kernel.org
Subject: [PATCH] serial: apbuart: Let boards without apbuart boot
Date: Fri, 14 May 2010 18:19:49 +0400	[thread overview]
Message-ID: <20100514141949.GA9244@oksana.dev.rtsoft.ru> (raw)

This patch fixes the following oops:

  Unable to handle kernel paging request for data at address 0x00000000
  Faulting instruction address: 0xc016dea8
  Oops: Kernel access of bad area, sig: 11 [#1]
  P1020 RDB
  last sysfs file:
  NIP: c016dea8 LR: c016dea0 CTR: c0010948
  REGS: c033fea0 TRAP: 0300   Not tainted  (2.6.34-rc7-00108-g83b5177-dirty)
  [...]
  NIP [c016dea8] grlib_apbuart_configure+0xd0/0x3bc
  LR [c016dea0] grlib_apbuart_configure+0xc8/0x3bc
  Call Trace:
  [c033ff50] [c016dea0] grlib_apbuart_configure+0xc8/0x3bc (unreliable)
  [c033ffa0] [c0316144] apbuart_console_init+0x10/0x34
  [c033ffb0] [c0314a10] console_init+0x40/0x5c

There's no apbuart on P1020 boards, and what's worse, there's no
clock-frequency property for it. The driver didn't handle this
case, which resulted in the oops above. Once we fix this, the
next oops pops up:

  Unable to handle kernel paging request for data at address 0x00000030
  Faulting instruction address: 0xc0166ecc
  Oops: Kernel access of bad area, sig: 11 [#1]
  P1020 RDB
  [...]
  NIP [c0166ecc] uart_set_options+0xd0/0x164
  LR [c0166e38] uart_set_options+0x3c/0x164
  Call Trace:
  [c033fef0] [c0330000] 0xc0330000 (unreliable)
  [c033ff50] [c03160dc] apbuart_console_setup+0xa8/0x100
  [c033ff70] [c003d668] register_console+0x338/0x3ec
  [c033ffa0] [c0316154] apbuart_console_init+0x20/0x34
  [c033ffb0] [c0314a10] console_init+0x40/0x5c
  [c033ffc0] [c0300968] start_kernel+0x12c/0x234
  [c033fff0] [c0000398] skpinv+0x2b0/0x2ec

And that one is because the driver tries to register the console
even if there were no matches in grlib_apbuart_configure().

While at it, also annotate grlib_apbuart_configure() with __init,
that fixes several section mismatches:

  Section mismatch in reference from the function
  grlib_apbuart_configure() to the variable .init.data:apbuart_match
  The function grlib_apbuart_configure() references the variable
  __initdata apbuart_match.

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
---
 drivers/serial/apbuart.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/serial/apbuart.c b/drivers/serial/apbuart.c
index fe91319..c908734 100644
--- a/drivers/serial/apbuart.c
+++ b/drivers/serial/apbuart.c
@@ -520,11 +520,16 @@ static struct console grlib_apbuart_console = {
 };
 
 
-static void grlib_apbuart_configure(void);
+static int __init grlib_apbuart_configure(void);
 
 static int __init apbuart_console_init(void)
 {
-	grlib_apbuart_configure();
+	int ret;
+
+	ret = grlib_apbuart_configure();
+	if (ret)
+		return ret;
+
 	register_console(&grlib_apbuart_console);
 	return 0;
 }
@@ -593,7 +598,7 @@ static struct of_platform_driver grlib_apbuart_of_driver = {
 };
 
 
-static void grlib_apbuart_configure(void)
+static int __init grlib_apbuart_configure(void)
 {
 	static int enum_done;
 	struct device_node *np, *rp;
@@ -606,12 +611,14 @@ static void grlib_apbuart_configure(void)
 	struct amba_prom_registers *regs;
 
 	if (enum_done)
-		return;
+		return -ENODEV;
 
 	/* Get bus frequency */
 	rp = of_find_node_by_path("/");
 	rp = of_get_next_child(rp, NULL);
 	prop = of_get_property(rp, "clock-frequency", NULL);
+	if (!prop)
+		return -ENODEV;
 	freq_khz = *prop;
 
 	line = 0;
@@ -629,7 +636,7 @@ static void grlib_apbuart_configure(void)
 			d = *device;
 
 		if (!irqs || !regs)
-			return;
+			return -ENODEV;
 
 		grlib_apbuart_nodes[line] = np;
 
@@ -658,6 +665,8 @@ static void grlib_apbuart_configure(void)
 	enum_done = 1;
 
 	grlib_apbuart_driver.nr = grlib_apbuart_port_nr = line;
+
+	return line ? 0 : -ENODEV;
 }
 
 static int __init grlib_apbuart_init(void)
-- 
1.7.0.5

             reply	other threads:[~2010-05-14 14:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-14 14:19 Anton Vorontsov [this message]
2010-05-16  8:41 ` [PATCH] serial: apbuart: Let boards without apbuart boot Miguel Ojeda
2010-05-16 10:20   ` Anton Vorontsov
2010-05-16 15:09     ` Miguel Ojeda
2010-05-17  6:37       ` Kristoffer Glembo

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=20100514141949.GA9244@oksana.dev.rtsoft.ru \
    --to=avorontsov@mvista.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@suse.de \
    --cc=kristoffer@gaisler.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.