linux/drivers/tty/serial/8250
Andy Shevchenko 7febbcbc48 serial: 8250: Check UPF_IRQ_SHARED in advance
The commit 54e53b2e80
  ("tty: serial: 8250: pass IRQ shared flag to UART ports")
nicely explained the problem:

---8<---8<---

On some systems IRQ lines between multiple UARTs might be shared. If so, the
irqflags have to be configured accordingly. The reason is: The 8250 port startup
code performs IRQ tests *before* the IRQ handler for that particular port is
registered. This is performed in serial8250_do_startup(). This function checks
whether IRQF_SHARED is configured and only then disables the IRQ line while
testing.

This test is performed upon each open() of the UART device. Imagine two UARTs
share the same IRQ line: On is already opened and the IRQ is active. When the
second UART is opened, the IRQ line has to be disabled while performing IRQ
tests. Otherwise an IRQ might handler might be invoked, but the IRQ itself
cannot be handled, because the corresponding handler isn't registered,
yet. That's because the 8250 code uses a chain-handler and invokes the
corresponding port's IRQ handling routines himself.

Unfortunately this IRQF_SHARED flag isn't configured for UARTs probed via device
tree even if the IRQs are shared. This way, the actual and shared IRQ line isn't
disabled while performing tests and the kernel correctly detects a spurious
IRQ. So, adding this flag to the DT probe solves the issue.

Note: The UPF_SHARE_IRQ flag is configured unconditionally. Therefore, the
IRQF_SHARED flag can be set unconditionally as well.

Example stack trace by performing `echo 1 > /dev/ttyS2` on a non-patched system:

|irq 85: nobody cared (try booting with the "irqpoll" option)
| [...]
|handlers:
|[<ffff0000080fc628>] irq_default_primary_handler threaded [<ffff00000855fbb8>] serial8250_interrupt
|Disabling IRQ #85

---8<---8<---

But unfortunately didn't fix the root cause. Let's try again here by moving
IRQ flag assignment from serial_link_irq_chain() to serial8250_do_startup().

This should fix the similar issue reported for 8250_pnp case.

Since this change we don't need to have custom solutions in 8250_aspeed_vuart
and 8250_of drivers, thus, drop them.

Fixes: 1c2f04937b ("serial: 8250: add IRQ trigger support")
Reported-by: Li RongQing <lirongqing@baidu.com>
Cc: Kurt Kanzenbach <kurt@linutronix.de>
Cc: Vikram Pandita <vikram.pandita@ti.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: stable <stable@vger.kernel.org>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
Link: https://lore.kernel.org/r/20200211135559.85960-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-12 11:56:44 -08:00
..
8250.h tty/serial/8250: use mctrl_gpio helpers 2019-06-21 10:18:43 +02:00
8250_accent.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_acorn.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_aspeed_vuart.c serial: 8250: Check UPF_IRQ_SHARED in advance 2020-02-12 11:56:44 -08:00
8250_bcm2835aux.c serial: 8250_bcm2835aux: Document struct bcm2835aux_data 2020-01-22 10:22:31 +01:00
8250_boca.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_core.c serial: 8250: Check UPF_IRQ_SHARED in advance 2020-02-12 11:56:44 -08:00
8250_dma.c serial: 8250: factor out serial8250_{set,clear}_THRI() helpers 2019-06-18 09:36:55 +02:00
8250_dw.c serial: 8250_dw: Avoid double error messaging when IRQ absent 2019-11-04 17:45:31 +01:00
8250_dwlib.c serial: 8250_dw: split Synopsys DesignWare 8250 common functions 2019-09-04 12:43:52 +02:00
8250_dwlib.h serial: 8250_dw: split Synopsys DesignWare 8250 common functions 2019-09-04 12:43:52 +02:00
8250_early.c serial: 8250_early: Setup divider when uartclk is passed 2018-04-25 14:56:12 +02:00
8250_em.c headers: separate linux/mod_devicetable.h from linux/platform_device.h 2018-07-07 17:52:26 +02:00
8250_exar.c tty/serial: 8250_exar: use true,false for bool variable 2020-01-14 14:34:04 +01:00
8250_exar_st16c554.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_fintek.c serial: 8250_fintek: Make fintek_8250_set_termios static 2019-03-28 00:29:03 +09:00
8250_fourport.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_fsl.c tty/serial: Migrate 8250_fsl to use has_sysrq 2019-12-18 15:04:42 +01:00
8250_gsc.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
8250_hp300.c tty: add SPDX identifiers to all remaining files in drivers/tty/ 2017-11-08 13:08:12 +01:00
8250_hub6.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_ingenic.c Serial: Ingenic: Add support for the X1000. 2019-01-30 09:31:30 +01:00
8250_ioc3.c Fix up remaining devm_ioremap_nocache() in SGI IOC3 8250 UART driver 2020-02-08 14:19:39 -08:00
8250_lpc18xx.c tty: Remove dev_err() usage after platform_get_irq() 2019-09-04 12:43:49 +02:00
8250_lpss.c serial: 8250_lpss: Switch over to MSI interrupts 2019-10-04 14:58:05 +02:00
8250_men_mcb.c drivers: mcb: use symbol namespaces 2019-11-03 19:54:53 +01:00
8250_mid.c tty: serial: Remove redundant license text 2017-11-08 13:08:12 +01:00
8250_mtk.c serial: 8250-mtk: Use platform_get_irq_optional() for optional irq 2019-11-04 17:45:32 +01:00
8250_of.c serial: 8250: Check UPF_IRQ_SHARED in advance 2020-02-12 11:56:44 -08:00
8250_omap.c TTY/Serial driver updates for 5.6-rc1 2020-01-29 10:13:27 -08:00
8250_pci.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
8250_pnp.c serial: 8250_pnp: Move to struct dev_pm_ops 2019-09-04 12:43:46 +02:00
8250_port.c serial: 8250: Check UPF_IRQ_SHARED in advance 2020-02-12 11:56:44 -08:00
8250_pxa.c serial: 8250_pxa: honor the port number from devicetree 2019-02-26 12:30:44 +01:00
8250_uniphier.c tty: Remove dev_err() usage after platform_get_irq() 2019-09-04 12:43:49 +02:00
Kconfig The main MIPS changes for 5.6: 2020-01-31 11:28:31 -08:00
Makefile mfd: ioc3: Add driver for SGI IOC3 chip 2020-01-09 15:30:59 -08:00
serial_cs.c drivers/tty: add error handling for pcmcia_loop_config 2018-06-28 21:23:44 +09:00