[PATCH] Fix cpm uart corruption with PREEMPT_RT

2008-05-20 Thread 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.

Signed-off-by: Rune Torgersen <[EMAIL PROTECTED]>

diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c 
b/drivers/serial/cpm_uart/cpm_uart_core.c
index fb93403..79c109d 100755
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -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);
 }
 
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH] Fix cpm uart corruption with PREEMPT_RT

2008-05-20 Thread 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.
Also only take lock if not in an oops.

Signed-off-by: Rune Torgersen <[EMAIL PROTECTED]>

diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c 
b/drivers/serial/cpm_uart/cpm_uart_core.c
index fb93403..11bee62 100755
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -1214,6 +1214,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.
 */
@@ -1282,6 +1290,12 @@ 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);
+   }
 }
 
 
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Fix cpm uart corruption with PREEMPT_RT

2008-05-20 Thread Scott Wood
On Tue, May 20, 2008 at 02:28:16PM -0500, Rune Torgersen wrote:
> 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.
> 
> Signed-off-by: Rune Torgersen <[EMAIL PROTECTED]>
> 
> diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c 
> b/drivers/serial/cpm_uart/cpm_uart_core.c
> index fb93403..79c109d 100755
> --- a/drivers/serial/cpm_uart/cpm_uart_core.c
> +++ b/drivers/serial/cpm_uart/cpm_uart_core.c
> @@ -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);
>  }

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

diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c 
b/drivers/serial/cpm_uart/cpm_uart_core.c
index a19dc7e..bc45f8a 100644
--- a/drivers/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/serial/cpm_uart/cpm_uart_core.c
@@ -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
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


RE: [PATCH] Fix cpm uart corruption with PREEMPT_RT

2008-05-20 Thread Rune Torgersen
Scott Wood wrote:
> On Tue, May 20, 2008 at 02:28:16PM -0500, Rune Torgersen wrote:
>> 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. 
>> 
> 
> We should bypass the lock when oops_in_progress is set, something
> like: 
> 

Ok, will respin.
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Fix cpm uart corruption with PREEMPT_RT

2008-05-20 Thread Scott Wood

Rune Torgersen wrote:

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.
Also only take lock if not in an oops.

Signed-off-by: Rune Torgersen <[EMAIL PROTECTED]>


Acked-by: Scott Wood <[EMAIL PROTECTED]>

-Scott
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


Re: [PATCH] Fix cpm uart corruption with PREEMPT_RT

2008-06-30 Thread Kumar Gala


On May 20, 2008, at 2:39 PM, Rune Torgersen wrote:


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.

Also only take lock if not in an oops.

Signed-off-by: Rune Torgersen <[EMAIL PROTECTED]>


applied.

- k
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev