All of lore.kernel.org
 help / color / mirror / Atom feed
From: dgilbert@interlog.com (Douglas Gilbert)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] atmel_serial oops when peripheral clock misconfigured
Date: Fri, 09 Nov 2012 11:58:21 -0500	[thread overview]
Message-ID: <509D362D.3040605@interlog.com> (raw)

In lk 3.7.0-rc4 when a peripheral clock is not found for
a serial port the atmel_serial driver brings down the
kernel with an oops during boot-up. This impacts the
Atmel AT91 family of MCUs.

For example, arch/arm/mach-at91/at91sam9x5.c does not
specify properly the peripheral clocks for the UTXD0/URXD0
and UTXD1/URXD1 serial ports. Selecting either of those
ports in a dts file will crash the kernel. at91sam9x5.c needs
to be fixed but stopping atmel_serial crashing the kernel is
more urgent.

Patch attached for your consideration.

Signed-of-by: Douglas Gilbert <dgilbert@interlog.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atmel_serial_clk_oops.patch
Type: text/x-patch
Size: 2246 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121109/d24da5e3/attachment.bin>

WARNING: multiple messages have this Message-ID (diff)
From: Douglas Gilbert <dgilbert@interlog.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
	Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>,
	Robert Nelson <Robert.Nelson@digikey.com>
Subject: [PATCH] atmel_serial oops when peripheral clock misconfigured
Date: Fri, 09 Nov 2012 11:58:21 -0500	[thread overview]
Message-ID: <509D362D.3040605@interlog.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

In lk 3.7.0-rc4 when a peripheral clock is not found for
a serial port the atmel_serial driver brings down the
kernel with an oops during boot-up. This impacts the
Atmel AT91 family of MCUs.

For example, arch/arm/mach-at91/at91sam9x5.c does not
specify properly the peripheral clocks for the UTXD0/URXD0
and UTXD1/URXD1 serial ports. Selecting either of those
ports in a dts file will crash the kernel. at91sam9x5.c needs
to be fixed but stopping atmel_serial crashing the kernel is
more urgent.

Patch attached for your consideration.

Signed-of-by: Douglas Gilbert <dgilbert@interlog.com>

[-- Attachment #2: atmel_serial_clk_oops.patch --]
[-- Type: text/x-patch, Size: 2246 bytes --]

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 3d7e1ee..cc385e0 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -1457,8 +1457,9 @@ static void __devinit atmel_of_init_port(struct atmel_uart_port *atmel_port,
 
 /*
  * Configure the port from the platform device resource info.
+ * Returns 0 for success or 1 in case of error.
  */
-static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
+static int __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
 				      struct platform_device *pdev)
 {
 	struct uart_port *port = &atmel_port->uart;
@@ -1496,6 +1497,8 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
 	/* for console, the clock could already be configured */
 	if (!atmel_port->clk) {
 		atmel_port->clk = clk_get(&pdev->dev, "usart");
+		if (IS_ERR(atmel_port->clk))
+			return 1;	/* peripheral clock not found */
 		clk_enable(atmel_port->clk);
 		port->uartclk = clk_get_rate(atmel_port->clk);
 		clk_disable(atmel_port->clk);
@@ -1511,6 +1514,7 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port,
 	} else {
 		atmel_port->tx_done_mask = ATMEL_US_TXRDY;
 	}
+	return 0;
 }
 
 /*
@@ -1666,13 +1670,18 @@ static int __init atmel_console_init(void)
 		struct atmel_uart_data *pdata =
 			atmel_default_console_device->dev.platform_data;
 		int id = pdata->num;
+		int ret;
 		struct atmel_uart_port *port = &atmel_ports[id];
 
 		port->backup_imr = 0;
 		port->uart.line = id;
 
 		add_preferred_console(ATMEL_DEVICENAME, id, NULL);
-		atmel_init_port(port, atmel_default_console_device);
+		ret = atmel_init_port(port, atmel_default_console_device);
+		if (ret) {
+			pr_err("No peripheral clock for Atmel console ??\n");
+			return -EINVAL;
+		}
 		register_console(&atmel_console);
 	}
 
@@ -1803,7 +1812,12 @@ static int __devinit atmel_serial_probe(struct platform_device *pdev)
 	port->backup_imr = 0;
 	port->uart.line = ret;
 
-	atmel_init_port(port, pdev);
+	ret = atmel_init_port(port, pdev);
+	if (ret) {
+		ret = -EINVAL;
+		pr_err("peripheral clock not found for serial port\n");
+		goto err;
+	}
 
 	if (!atmel_use_dma_rx(&port->uart)) {
 		ret = -ENOMEM;

             reply	other threads:[~2012-11-09 16:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-09 16:58 Douglas Gilbert [this message]
2012-11-09 16:58 ` [PATCH] atmel_serial oops when peripheral clock misconfigured Douglas Gilbert

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=509D362D.3040605@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=linux-arm-kernel@lists.infradead.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.