Re: Serial: UART_BUG_TXEN race conditions

From: Russell King
Date: Mon Jun 26 2006 - 16:24:33 EST


On Mon, Jun 26, 2006 at 10:07:47PM +0200, Ingo van Lil wrote:
> Correct me if I'm mistaken, but I see two possible race conditions with
> that piece of code:
>
> 1. What if the IIR actually equals UART_IIR_THRI at that point? The
> read access will clear the interrupt condition and the workaround
> will effect the actual opposite of its intention: Neither
> serial8250_start_tx() nor the interrupt handler will start
> transmitting characters for the ring buffer.

Gah, looks like you're right - reading the IIR will clear the transmit
pending interrupt, so we should probably just load the transmitter up
with characters anyway if the TEMT bit is set.

> 2. What if an interrupt is triggered shortly after reading the IIR?
> Both serial8250_start_tx() and the interrupt handler will start
> a transmission simultaneously.

This function is run under the port spinlock, so the interrupt handler
will be held off until it completes.

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 Serial core
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/