Skip to contentSkip to conversation

serial: apbuart: Let boards without apbuart boot

PATCH In review Anton Vorontsov 4 participants 5 messages May 14, 2010 – May 17, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: apbuart: Let boards without apbuart boot

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.

---
 drivers/serial/apbuart.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/serial/apbuart.c +14 -5
index fe91319..c908734 100644
@@ -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)
Signature · 1 line
1.7.0.5
#1 lore raw
Quoted 2 lines · Anton Vorontsov

This patch fixes the following oops:

I sent a patch that fixes that oops too. It is in mm right now. Please check it.

Quoted 126 lines
 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.

---
 drivers/serial/apbuart.c |   19 ++++++++++++++-----

 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/serial/apbuart.c +14 -6
index fe91319..c908734 100644
@@ -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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

#2 lore raw
Quoted 5 lines · Miguel Ojeda
Quoted 2 lines · Anton Vorontsov

This patch fixes the following oops:

I sent a patch that fixes that oops too. It is in mm right now. Please check it.

Hm, and my patch is in Greg's tree already...

Greg, if it didn't make it anywhere further your tree, please drop it in favour of Miguel's patch, Miguel was the first who sent a fix for this problem.

Thanks,

Quoted 120 lines
Quoted 120 lines
 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.

---
 drivers/serial/apbuart.c |   19 ++++++++++++++-----

 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/serial/apbuart.c +14 -6
index fe91319..c908734 100644
@@ -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

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#3 lore raw
Quoted 8 lines · Anton Vorontsov
Quoted 5 lines · Miguel Ojeda
Quoted 2 lines · Anton Vorontsov

This patch fixes the following oops:

I sent a patch that fixes that oops too. It is in mm right now. Please check it.

Hm, and my patch is in Greg's tree already...

Well, that's weird... Andrew sent an email to Greg 4 days ago with the patch after Kristoffer ack'ed it. Maybe Greg missed it.

Quoted 5 lines

Greg, if it didn't make it anywhere further your tree, please drop it in favour of Miguel's patch, Miguel was the first who sent a fix for this problem.

Thanks, but Kristoffer should review your patch too, as they are not exactly the same: My patch changes does an additional check at grlib_apbuart_init() (which also calls grlib_apbuart_configure()), sets the global variable grlib_apbuart_port_nr to 0 and prints a message to the user; keeping the void return type of grlib_apbuart_configure().

See it here: https://patchwork.kernel.org/patch/98713/

Quoted 128 lines

Thanks,

Quoted 112 lines
Quoted 112 lines
 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.

---
 drivers/serial/apbuart.c |   19 ++++++++++++++-----

 1 files changed, 14 insertions(+), 5 deletions(-)
drivers/serial/apbuart.c +12 -5
index fe91319..c908734 100644
@@ -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;
 
Quoted 8 lines
Quoted 8 lines
drivers/serial/apbuart.c +2 -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

--
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2

#4 lore raw

Hi,

Quoted 17 lines · Miguel Ojeda
Quoted 6 lines · Anton Vorontsov
Quoted 4 lines · Miguel Ojeda
Quoted 2 lines · Anton Vorontsov

This patch fixes the following oops:

I sent a patch that fixes that oops too. It is in mm right now. Please check it.

Hm, and my patch is in Greg's tree already...

Well, that's weird... Andrew sent an email to Greg 4 days ago with the patch after Kristoffer ack'ed it. Maybe Greg missed it.

Quoted 4 lines

Greg, if it didn't make it anywhere further your tree, please drop it in favour of Miguel's patch, Miguel was the first who sent a fix for this problem.

Quoted 6 lines

Thanks, but Kristoffer should review your patch too, as they are not exactly the same: My patch changes does an additional check at grlib_apbuart_init() (which also calls grlib_apbuart_configure()), sets the global variable grlib_apbuart_port_nr to 0 and prints a message to the user; keeping the void return type of grlib_apbuart_configure().

Let's run with Miguels patch as it fixes the calls to grlib_apbuart_configure() from both grlib_apbuart_init() and apbuart_console_init().

So Greg could you please drop Anton patch?

Anton if you want to please send a new patch annotating grlib_apbuart_configure with __init though.

Best regards,
Kristoffer Glembo
Aeroflex Gaisler