Skip to contentSkip to conversation

Fix cpm uart corruption with PREEMPT_RT

PATCH In review Rune Torgersen 2 participants 3 messages May 20, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix cpm uart corruption with PREEMPT_RT

Fix CPM serial port corruption when running with CONFIG_PREEMPT_RT. Userland usage of console, and kernel printf's were stepping on each others toes.

drivers/serial/cpm_uart/cpm_uart_core.c +4 -0
index fb93403..79c109d 100755
@@ -1214,7 +1214,9 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 	unsigned int i;
 	cbd_t __iomem *bdp, *bdbase;
 	unsigned char *cp;
+	unsigned long flags;
 
+	spin_lock_irqsave(&pinfo->port.lock, flags);
 	/* Get the address of the host memory buffer.
 	 */
 	bdp = pinfo->tx_cur;
@@ -1282,6 +1284,8 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 		;
 
 	pinfo->tx_cur = bdp;
+
+	spin_unlock_irqrestore(&pinfo->port.lock, flags);
 }
 
 
#1 lore raw
Quoted 20 lines · Rune Torgersen

Fix CPM serial port corruption when running with CONFIG_PREEMPT_RT. Userland usage of console, and kernel printf's were stepping on each others toes.

drivers/serial/cpm_uart/cpm_uart_core.c +2 -0
index fb93403..79c109d 100755
@@ -1214,7 +1214,9 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 	unsigned int i;
 	cbd_t __iomem *bdp, *bdbase;
 	unsigned char *cp;
+	unsigned long flags;
 
+	spin_lock_irqsave(&pinfo->port.lock, flags);
 	/* Get the address of the host memory buffer.
 	 */
 	bdp = pinfo->tx_cur;

drivers/serial/cpm_uart/cpm_uart_core.c static void cpm_uart_console_write(struct console *co, const char *s, · line 1289

Quoted 6 lines
drivers/serial/cpm_uart/cpm_uart_core.c +2 -0
@@ -1282,6 +1284,8 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 		;
 
 	pinfo->tx_cur = bdp;
+
+	spin_unlock_irqrestore(&pinfo->port.lock, flags);
 }

We should bypass the lock when oops_in_progress is set, something like:

drivers/serial/cpm_uart/cpm_uart_core.c +14 -1
index a19dc7e..bc45f8a 100644
@@ -1178,6 +1178,14 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 	unsigned int i;
 	cbd_t __iomem *bdp, *bdbase;
 	unsigned char *cp;
+	unsigned long flags;
+	int nolock = oops_in_progress;
+
+	if (unlikely(nolock)) {
+		local_irq_save(flags);
+	} else {
+		spin_lock_irqsave(&pinfo->port.lock, flags);
+	}
 
 	/* Get the address of the host memory buffer.
 	 */
@@ -1239,8 +1247,13 @@ static void cpm_uart_console_write(struct console *co, const char *s,
 		;
 
 	pinfo->tx_cur = bdp;
-}
 
+	if (unlikely(nolock)) {
+		local_irq_restore(flags);
+	} else {
+		spin_unlock_irqrestore(&pinfo->port.lock, flags);
+	}
+}
 
 static int __init cpm_uart_console_setup(struct console *co, char *options)
 {

-Scott

#2 lore raw
Quoted 9 lines · Scott Wood
Quoted 4 lines · Rune Torgersen

Fix CPM serial port corruption when running with CONFIG_PREEMPT_RT. Userland usage of console, and kernel printf's were stepping on each others toes.=20
=20

=20
We should bypass the lock when oops_in_progress is set, something like:=20
=20

Ok, will respin.