Message ID | 20120910041404.GI29537@lizard (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sun, 9 Sep 2012 21:14:04 -0700 Anton Vorontsov <anton.vorontsov@linaro.org> wrote: > It's all pretty straightforward, except for TXIM interrupt. The interrupt > has meaning "ready to transmit", so it's almost always raised, and the > only way to silence it is to mask it. But that's OK, ops->start_tx will > unmask it. > > Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> > --- > drivers/tty/serial/amba-pl011.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c > index 88e2df2..7522d97 100644 > --- a/drivers/tty/serial/amba-pl011.c > +++ b/drivers/tty/serial/amba-pl011.c > @@ -1308,6 +1308,18 @@ static void pl011_put_poll_char(struct uart_port *port, > writew(ch, uap->port.membase + UART01x_DR); > } > > +static void pl011_clear_irqs(struct uart_port *port) > +{ > + struct uart_amba_port *uap = (struct uart_amba_port *)port; > + unsigned char __iomem *regs = uap->port.membase; > + > + writew(readw(regs + UART011_MIS), regs + UART011_ICR); > + /* > + * There is no way to clear TXIM, this is "ready to transmit IRQ", so > + * we simply mask it. ops->start_tx will unmask it. > + */ Not if you race here with the transmit start it won't.
On Mon, Sep 10, 2012 at 12:17:02PM +0100, Alan Cox wrote: [...] > > +static void pl011_clear_irqs(struct uart_port *port) > > +{ > > + struct uart_amba_port *uap = (struct uart_amba_port *)port; > > + unsigned char __iomem *regs = uap->port.membase; > > + > > + writew(readw(regs + UART011_MIS), regs + UART011_ICR); > > + /* > > + * There is no way to clear TXIM, this is "ready to transmit IRQ", so > > + * we simply mask it. ops->start_tx will unmask it. > > + */ > > Not if you race here with the transmit start it won't. True, the race is possible. But I guess there will be no harm: only non-polling code uses ->start_tx(), but then we don't care, the port is used for NMI debugger, so the worst that can happen, is that we'll get another NMI just after the race, and so we'll mask it again. And once we release the port from KDB, we never call this function anymore (since normal IRQ routine will be called instead). I guess I need to add some commens about this. Thanks!
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 88e2df2..7522d97 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c @@ -1308,6 +1308,18 @@ static void pl011_put_poll_char(struct uart_port *port, writew(ch, uap->port.membase + UART01x_DR); } +static void pl011_clear_irqs(struct uart_port *port) +{ + struct uart_amba_port *uap = (struct uart_amba_port *)port; + unsigned char __iomem *regs = uap->port.membase; + + writew(readw(regs + UART011_MIS), regs + UART011_ICR); + /* + * There is no way to clear TXIM, this is "ready to transmit IRQ", so + * we simply mask it. ops->start_tx will unmask it. + */ + writew(readw(regs + UART011_IMSC) & ~UART011_TXIM, regs + UART011_IMSC); +} #endif /* CONFIG_CONSOLE_POLL */ static int pl011_hwinit(struct uart_port *port) @@ -1713,6 +1725,7 @@ static struct uart_ops amba_pl011_pops = { .poll_init = pl011_hwinit, .poll_get_char = pl011_get_poll_char, .poll_put_char = pl011_put_poll_char, + .clear_irqs = pl011_clear_irqs, #endif };
It's all pretty straightforward, except for TXIM interrupt. The interrupt has meaning "ready to transmit", so it's almost always raised, and the only way to silence it is to mask it. But that's OK, ops->start_tx will unmask it. Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org> --- drivers/tty/serial/amba-pl011.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)