lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sat, 29 Mar 2008 11:48:52 +0100
From:	Haavard Skinnemoen <haavard.skinnemoen@...el.com>
To:	akpm@...ux-foundation.org
Cc:	Andrew Victor <linux@...im.org.za>, Remy Bohmer <linux@...mer.net>,
	linux-kernel@...r.kernel.org, Marc Pignat <marc.pignat@...s.ch>,
	Haavard Skinnemoen <haavard.skinnemoen@...el.com>
Subject: [PATCH] atmel_serial: fix uart/console concurrent access

From: Marc Pignat <marc.pignat@...s.ch>

Strange chars appear on the serial port when a printk and a printf
happens at the same time. This is caused by the pdc sending chars
while atmel_console_write (called from printk) is executing

Concurent access of uart and console to the same port leads to
corrupted data to be transmitted, so disable tx dma (PDC) while
writing to the console.

Signed-off-by: Marc Pignat <marc.pignat@...s.ch>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@...el.com>
---
Andrew, I think we want this one before 2.6.25 as well.

 drivers/serial/atmel_serial.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c
index e99a283..430997e 100644
--- a/drivers/serial/atmel_serial.c
+++ b/drivers/serial/atmel_serial.c
@@ -107,6 +107,7 @@
 
 #define UART_PUT_TPR(port,v)	__raw_writel(v, (port)->membase + ATMEL_PDC_TPR)
 #define UART_PUT_TCR(port,v)	__raw_writel(v, (port)->membase + ATMEL_PDC_TCR)
+#define UART_GET_TCR(port)	__raw_readl((port)->membase + ATMEL_PDC_TCR)
 
 static int (*atmel_open_hook)(struct uart_port *);
 static void (*atmel_close_hook)(struct uart_port *);
@@ -1275,6 +1276,7 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
 {
 	struct uart_port *port = &atmel_ports[co->index].uart;
 	unsigned int status, imr;
+	unsigned int pdc_tx;
 
 	/*
 	 * First, save IMR and then disable interrupts
@@ -1282,6 +1284,10 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
 	imr = UART_GET_IMR(port);
 	UART_PUT_IDR(port, ATMEL_US_RXRDY | ATMEL_US_TXRDY);
 
+	/* Store PDC transmit status and disable it */
+	pdc_tx = UART_GET_PTSR(port) & ATMEL_PDC_TXTEN;
+	UART_PUT_PTCR(port, ATMEL_PDC_TXTDIS);
+
 	uart_console_write(port, s, count, atmel_console_putchar);
 
 	/*
@@ -1291,6 +1297,11 @@ static void atmel_console_write(struct console *co, const char *s, u_int count)
 	do {
 		status = UART_GET_CSR(port);
 	} while (!(status & ATMEL_US_TXRDY));
+
+	/* Restore PDC transmit status */
+	if (pdc_tx)
+		UART_PUT_PTCR(port, ATMEL_PDC_TXTEN);
+
 	/* set interrupts back the way they were */
 	UART_PUT_IER(port, imr);
 }
-- 
1.5.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ