Re: UART/TTY console deadlock

From: Kurt Kanzenbach
Date: Wed Jul 08 2020 - 03:40:24 EST


On Mon Jul 06 2020, Sergey Senozhatsky wrote:
> On (20/07/06 13:31), Kurt Kanzenbach wrote:
>> >> @@ -2275,6 +2275,7 @@ int serial8250_do_startup(struct uart_port *port)
>> >>
>> >> if (port->irq && !(up->port.flags & UPF_NO_THRE_TEST)) {
>> >> unsigned char iir1;
>> >> +
>> >> /*
>> >> * Test for UARTs that do not reassert THRE when the
>> >> * transmitter is idle and the interrupt has already
>> >> @@ -2284,8 +2285,6 @@ int serial8250_do_startup(struct uart_port *port)
>> >> * allow register changes to become visible.
>> >> */
>> >> spin_lock_irqsave(&port->lock, flags);
>> >> - if (up->port.irqflags & IRQF_SHARED)
>> >> - disable_irq_nosync(port->irq);
>> >>
>> >> wait_for_xmitr(up, UART_LSR_THRE);
>> >> serial_port_out_sync(port, UART_IER, UART_IER_THRI);
>> >> @@ -2297,8 +2296,6 @@ int serial8250_do_startup(struct uart_port *port)
>> >> iir = serial_port_in(port, UART_IIR);
>> >> serial_port_out(port, UART_IER, 0);
>> >>
>> >> - if (port->irqflags & IRQF_SHARED)
>> >> - enable_irq(port->irq);
>> >> spin_unlock_irqrestore(&port->lock, flags);
>> >>
>> >> /*
>> >
>> > ...which effectively is a revert of
>> >
>> > 768aec0b5bcc ("serial: 8250: fix shared interrupts issues with SMP and
>> > RT kernels")
>>
>> Please, don't revert that commit. I've faced the same issue as described
>> in the commit log. There is hardware available with shared UART
>> interrupt lines.
>
> Will this patch break that hardware?
> https://lore.kernel.org/lkml/20200702051213.GB3450@xxxxxxxxxxxxxxxxxxxxxxxx/

I'm not sure how this patch will help with the situation. Because at the
point of that THRE test the irq handler isn't registered. It's
registered a few lines below (up->ops->setup_irq()) meaning the irq line
has to be disabled if shared. Otherwise the kernel might detect a
spurious irq and disables it. That's at least my understanding of the
problem (see commit message from 54e53b2e8081 ("tty: serial: 8250: pass
IRQ shared flag to UART ports")).

Thanks,
Kurt

Attachment: signature.asc
Description: PGP signature