* [patch] serial: fix UART_BUG_TXEN test
@ 2006-04-05 10:23 Gerd Hoffmann
2006-04-12 9:26 ` Russell King
0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2006-04-05 10:23 UTC (permalink / raw)
To: linux kernel mailing list
[-- Attachment #1: Type: text/plain, Size: 286 bytes --]
Hi,
There is a bug in the UART_BUG_TXEN test: It gives false positives in
case the UART_IER_THRI bit is set. Fixed by explicitly clearing the
UART_IER register first.
It may trigger with an active serial console as serial console writes
set the UART_IER_THRI bit.
cheers,
Gerd
[-- Attachment #2: fix-serial-8250-UART_BUG_TXEN-test --]
[-- Type: text/plain, Size: 460 bytes --]
Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
--- linux-2.6.16/drivers/serial/8250.c.serial 2006-04-05 12:04:31.000000000 +0200
+++ linux-2.6.16/drivers/serial/8250.c 2006-04-05 12:04:49.000000000 +0200
@@ -1712,6 +1712,7 @@
* Do a quick test to see if we receive an
* interrupt when we enable the TX irq.
*/
+ serial_outp(up, UART_IER, 0);
serial_outp(up, UART_IER, UART_IER_THRI);
lsr = serial_in(up, UART_LSR);
iir = serial_in(up, UART_IIR);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] serial: fix UART_BUG_TXEN test
2006-04-05 10:23 [patch] serial: fix UART_BUG_TXEN test Gerd Hoffmann
@ 2006-04-12 9:26 ` Russell King
2006-05-07 8:24 ` Russell King
0 siblings, 1 reply; 3+ messages in thread
From: Russell King @ 2006-04-12 9:26 UTC (permalink / raw)
To: Gerd Hoffmann, Alan Cox; +Cc: linux kernel mailing list
On Wed, Apr 05, 2006 at 12:23:11PM +0200, Gerd Hoffmann wrote:
> There is a bug in the UART_BUG_TXEN test: It gives false positives in
> case the UART_IER_THRI bit is set. Fixed by explicitly clearing the
> UART_IER register first.
>
> It may trigger with an active serial console as serial console writes
> set the UART_IER_THRI bit.
Actually, I think Alan's (f91a3715db2bb44fcf08cec642e68f919b70f7f4)
idea of setting UART_IER_THRI after serial console writes is buggy.
If the serial port being used as a console is sharing its interrupt
line with other devices, then there's the very real possibility for
causing spurious interrupts.
I think that's what needs to be fixed rather than working around this
potentially buggy behaviour.
Maybe we have no option but to take the spinlock in the serial console
code, and suck it if we oops with that spinlock held.
> Signed-off-by: Gerd Hoffmann <kraxel@suse.de>
> --- linux-2.6.16/drivers/serial/8250.c.serial 2006-04-05 12:04:31.000000000 +0200
> +++ linux-2.6.16/drivers/serial/8250.c 2006-04-05 12:04:49.000000000 +0200
> @@ -1712,6 +1712,7 @@
> * Do a quick test to see if we receive an
> * interrupt when we enable the TX irq.
> */
> + serial_outp(up, UART_IER, 0);
> serial_outp(up, UART_IER, UART_IER_THRI);
> lsr = serial_in(up, UART_LSR);
> iir = serial_in(up, UART_IIR);
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] serial: fix UART_BUG_TXEN test
2006-04-12 9:26 ` Russell King
@ 2006-05-07 8:24 ` Russell King
0 siblings, 0 replies; 3+ messages in thread
From: Russell King @ 2006-05-07 8:24 UTC (permalink / raw)
To: Gerd Hoffmann, Alan Cox, linux kernel mailing list
On Wed, Apr 12, 2006 at 10:26:31AM +0100, Russell King wrote:
> On Wed, Apr 05, 2006 at 12:23:11PM +0200, Gerd Hoffmann wrote:
> > There is a bug in the UART_BUG_TXEN test: It gives false positives in
> > case the UART_IER_THRI bit is set. Fixed by explicitly clearing the
> > UART_IER register first.
> >
> > It may trigger with an active serial console as serial console writes
> > set the UART_IER_THRI bit.
>
> Actually, I think Alan's (f91a3715db2bb44fcf08cec642e68f919b70f7f4)
> idea of setting UART_IER_THRI after serial console writes is buggy.
> If the serial port being used as a console is sharing its interrupt
> line with other devices, then there's the very real possibility for
> causing spurious interrupts.
>
> I think that's what needs to be fixed rather than working around this
> potentially buggy behaviour.
>
> Maybe we have no option but to take the spinlock in the serial console
> code, and suck it if we oops with that spinlock held.
So here's the patch. I've been waiting for feedback from Alan before
sending this upstream... Nevertheless, could you (Gerd) test it please?
Thanks.
diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2200,10 +2200,17 @@ static void
serial8250_console_write(struct console *co, const char *s, unsigned int count)
{
struct uart_8250_port *up = &serial8250_ports[co->index];
+ unsigned long flags;
unsigned int ier;
+ int locked = 1;
touch_nmi_watchdog();
+ if (oops_in_progress) {
+ locked = spin_trylock_irqsave(&up->port.lock, flags);
+ } else
+ spin_lock_irqsave(&up->port.lock, flags);
+
/*
* First save the IER then disable the interrupts
*/
@@ -2221,8 +2228,10 @@ serial8250_console_write(struct console
* and restore the IER
*/
wait_for_xmitr(up, BOTH_EMPTY);
- up->ier |= UART_IER_THRI;
- serial_out(up, UART_IER, ier | UART_IER_THRI);
+ serial_out(up, UART_IER, ier);
+
+ if (locked)
+ spin_unlock_irqrestore(&up->port.lock, flags);
}
static int serial8250_console_setup(struct console *co, char *options)
--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-05-07 8:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-05 10:23 [patch] serial: fix UART_BUG_TXEN test Gerd Hoffmann
2006-04-12 9:26 ` Russell King
2006-05-07 8:24 ` Russell King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox