linux/drivers/tty/serial
Mario Kleiner 341abd693d serial: 8250_pci: Avoid irq sharing for MSI(-X) interrupts.
This attempts to fix a bug found with a serial port card which uses
an MCS9922 chip, one of the 4 models for which MSI-X interrupts are
currently supported. I don't possess such a card, and i'm not
experienced with the serial subsystem, so this patch is based on what
i think i found as a likely reason for failure, based on walking the
user who actually owns the card through some diagnostic.

The user who reported the problem finds the following in his dmesg
output for the relevant ttyS4 and ttyS5:

[    0.580425] serial 0000:02:00.0: enabling device (0000 -> 0003)
[    0.601448] 0000:02:00.0: ttyS4 at I/O 0x3010 (irq = 125, base_baud = 115200) is a ST16650V2
[    0.603089] serial 0000:02:00.1: enabling device (0000 -> 0003)
[    0.624119] 0000:02:00.1: ttyS5 at I/O 0x3000 (irq = 126, base_baud = 115200) is a ST16650V2
...
[    6.323784] genirq: Flags mismatch irq 128. 00000080 (ttyS5) vs. 00000000 (xhci_hcd)
[    6.324128] genirq: Flags mismatch irq 128. 00000080 (ttyS5) vs. 00000000 (xhci_hcd)
...

Output of setserial -a:

/dev/ttyS4, Line 4, UART: 16650V2, Port: 0x3010, IRQ: 127
	Baud_base: 115200, close_delay: 50, divisor: 0
	closing_wait: 3000
	Flags: spd_normal skip_test

This suggests to me that the serial driver wants to register and share a
MSI/MSI-X irq 128 with the xhci_hcd driver, whereas the xhci driver does
not want to share the irq, as flags 0x00000080 (== IRQF_SHARED) from the
serial port driver means to share the irq, and this mismatch ends in some
failed irq init?

With this setup, data reception works very unreliable, with dropped data,
already at a transmission rate of only a 16 Bytes chunk every 1/120th of
a second, ie. 1920 Bytes/sec, presumably due to rx fifo overflow due to
mishandled or not used at all rx irq's?

See full discussion thread with attempted diagnosis at:

https://psychtoolbox.discourse.group/t/issues-with-iscan-serial-port-recording/3886

Disabling the use of MSI interrupts for the serial port pci card did
fix the reliability problems. The user executed the following sequence
of commands to achieve this:

echo 0000:02:00.0 | sudo tee /sys/bus/pci/drivers/serial/unbind
echo 0000:02:00.1 | sudo tee /sys/bus/pci/drivers/serial/unbind

echo 0 | sudo tee /sys/bus/pci/devices/0000:02:00.0/msi_bus
echo 0 | sudo tee /sys/bus/pci/devices/0000:02:00.1/msi_bus

echo 0000:02:00.0 | sudo tee /sys/bus/pci/drivers/serial/bind
echo 0000:02:00.1 | sudo tee /sys/bus/pci/drivers/serial/bind

This resulted in the following log output:

[   82.179021] pci 0000:02:00.0: MSI/MSI-X disallowed for future drivers
[   87.003031] pci 0000:02:00.1: MSI/MSI-X disallowed for future drivers
[   98.537010] 0000:02:00.0: ttyS4 at I/O 0x3010 (irq = 17, base_baud = 115200) is a ST16650V2
[  103.648124] 0000:02:00.1: ttyS5 at I/O 0x3000 (irq = 18, base_baud = 115200) is a ST16650V2

This patch attempts to fix the problem by disabling irq sharing when
using MSI irq's. Note that all i know for sure is that disabling MSI
irq's fixed the problem for the user, so this patch could be wrong and
is untested. Please review with caution, keeping this in mind.

Fixes: 8428413b1d ("serial: 8250_pci: Implement MSI(-X) support")
Cc: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de>
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Link: https://lore.kernel.org/r/20210729043306.18528-1-mario.kleiner.de@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-30 13:06:19 +02:00
..
8250 serial: 8250_pci: Avoid irq sharing for MSI(-X) interrupts. 2021-07-30 13:06:19 +02:00
cpm_uart tty: make use of tty_get_{char,frame}_size 2021-06-15 14:03:27 +02:00
jsm Merge 5.12-rc6 into tty-next 2021-04-05 08:59:21 +02:00
21285.c tty: serial: 21285: fix lockup on open 2020-10-28 13:39:14 +01:00
altera_jtaguart.c serial: altera_jtaguart: drop low-latency workaround 2021-04-22 12:09:24 +02:00
altera_uart.c serial: altera_uart: drop low-latency workaround 2021-04-22 12:09:24 +02:00
amba-pl010.c serial: amba-pl010: drop low-latency workaround 2021-04-22 12:09:24 +02:00
amba-pl011.c serial: drop irq-flags initialisations 2021-05-20 16:24:05 +02:00
amba-pl011.h
apbuart.c serial: apbuart: drop low-latency workaround 2021-04-22 12:09:25 +02:00
apbuart.h
ar933x_uart.c serial: ar933x: drop low-latency workaround 2021-04-22 12:09:25 +02:00
arc_uart.c tty: cumulate and document tty_struct::flow* members 2021-05-13 16:57:16 +02:00
atmel_serial.c tty: serial: atmel: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:11 +02:00
atmel_serial.h tty: serial: Use the correct style for SPDX License Identifier 2020-03-07 09:52:01 +01:00
bcm63xx_uart.c serial: bcm63xx: drop low-latency workaround 2021-04-22 12:09:25 +02:00
clps711x.c
digicolor-usart.c
dz.c tty: serial: dz: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:11 +02:00
dz.h
earlycon-arm-semihost.c
earlycon-riscv-sbi.c
earlycon.c earlycon: simplify earlycon-table implementation 2020-12-04 15:49:48 +01:00
fsl_linflexuart.c tty: serial: linflexuart: Remove unnecessary '|' operation and add error count 2020-11-06 17:12:30 +01:00
fsl_lpuart.c tty: serial: fsl_lpuart: fix the wrong return value in lpuart32_get_mctrl 2021-07-29 17:05:59 +02:00
icom.c tty: serial: icom: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:11 +02:00
icom.h tty: serial: Use the correct style for SPDX License Identifier 2020-03-07 09:52:01 +01:00
imx_earlycon.c tty: serial: imx: add imx earlycon driver 2020-07-29 17:11:02 +02:00
imx.c serial: imx: Add DMA buffer configuration via DT 2021-06-04 15:11:16 +02:00
ip22zilog.c tty: serial: ip22zilog: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
ip22zilog.h
Kconfig Revert "tty: serial: Add UART driver for Cortina-Access platform" 2021-06-24 14:46:32 +02:00
kgdb_nmi.c serial: kgdb_nmi: remove redundant initialization of variable c 2021-05-20 16:22:09 +02:00
kgdboc.c Linux 5.8-rc6 2020-07-20 09:39:11 +02:00
lantiq.c tty/serial/lantiq: convert comma to semicolon 2020-12-28 16:10:50 +01:00
liteuart.c serial: liteuart: Add support for earlycon 2021-05-20 16:35:01 +02:00
lpc32xx_hs.c serial: lpc32xx_hs: drop low-latency workaround 2021-04-22 12:09:25 +02:00
Makefile Revert "tty: serial: Add UART driver for Cortina-Access platform" 2021-06-24 14:46:32 +02:00
max310x.c serial: max310x: Unprepare and disable clock in error path 2021-07-21 12:51:54 +02:00
max3100.c tty_port: drop last traces of low_latency 2021-01-07 16:17:32 +01:00
mcf.c serial: mcf: drop low-latency workaround 2021-04-22 12:09:25 +02:00
men_z135_uart.c tty: serial, fix kernel-doc 2020-08-18 13:51:18 +02:00
meson_uart.c tty: serial: meson: retrieve port FIFO size from DT 2021-05-20 16:11:20 +02:00
milbeaut_usio.c
mpc52xx_uart.c serial: mpc52xx_uart: drop low-latency workaround 2021-04-22 12:09:25 +02:00
mps2-uart.c
msm_serial.c serial: msm_serial: drop low-latency workaround 2021-04-22 12:09:25 +02:00
mux.c tty: serial: mux: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
mvebu-uart.c serial: mvebu-uart: remove unused member nb from struct mvebu_uart 2021-06-25 13:53:51 +02:00
mxs-auart.c tty: make use of tty_get_{char,frame}_size 2021-06-15 14:03:27 +02:00
omap-serial.c serial: drop irq-flags initialisations 2021-05-20 16:24:05 +02:00
owl-uart.c serial: owl: drop low-latency workaround 2021-04-22 12:09:25 +02:00
pch_uart.c serial: pch_uart: fix build error with !CONFIG_DEBUG_FS 2021-03-23 10:31:09 +01:00
pic32_uart.c serial: pic32_uart: Use uart_console() helper 2020-03-12 10:00:22 +01:00
pic32_uart.h tty: serial: Use the correct style for SPDX License Identifier 2020-03-07 09:52:01 +01:00
pmac_zilog.c tty: serial: pmac_zilog: include <linux/io.h> insteiad of <asm/io.h> 2021-05-13 18:29:12 +02:00
pmac_zilog.h tty: serial: pmac_zilog: Remove unused disposable variable 'garbage' 2020-11-13 15:28:27 +01:00
pxa.c
qcom_geni_serial.c serial: qcom_geni_serial: use DT aliases according to DT bindings 2021-06-24 14:51:28 +02:00
rda-uart.c serial: rda: drop low-latency workaround 2021-04-22 12:09:26 +02:00
rp2.c serial: rp2: use 'request_firmware' instead of 'request_firmware_nowait' 2021-05-21 20:34:02 +02:00
sa1100.c serial: sa1100: drop low-latency workaround 2021-04-22 12:09:26 +02:00
samsung_tty.c tty: serial: samsung_tty: remove set but not used variables 2021-05-13 16:10:53 +02:00
sb1250-duart.c tty: serial: sb1250-duart: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
sc16is7xx.c serial: sc16is7xx: Use devm_clk_get_optional() 2021-05-20 16:30:40 +02:00
sccnxp.c
serial_core.c tty: make tty_get_{char,frame}_size available 2021-06-15 14:03:26 +02:00
serial_mctrl_gpio.c serial: mctrl_gpio: Fix passing zero to 'ERR_PTR' warning 2020-11-06 17:12:05 +01:00
serial_mctrl_gpio.h tty: serial: Use the correct style for SPDX License Identifier 2020-03-07 09:52:01 +01:00
serial_txx9.c tty: serial: txx9: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
serial-tegra.c serial: tegra: Only print FIFO error message when an error occurs 2021-07-21 12:53:00 +02:00
sh-sci.c tty: make use of tty_get_{char,frame}_size 2021-06-15 14:03:27 +02:00
sh-sci.h serial: sh-sci: Add support for RZ/G2L SoC 2021-06-04 15:12:40 +02:00
sifive.c serial: sifive: drop low-latency workaround 2021-04-22 12:09:26 +02:00
sprd_serial.c serial: sprd: remove redundant sprd_port cleanup 2020-03-18 12:20:04 +01:00
st-asc.c tty: serial: st-asc: Demote a kernel-doc formatting abuse 2021-05-20 17:06:17 +02:00
stm32-usart.c tty: make use of tty_get_{char,frame}_size 2021-06-15 14:03:27 +02:00
stm32-usart.h serial: stm32: add FIFO threshold configuration 2021-04-22 12:11:25 +02:00
suncore.c
sunhv.c Revert "serial: sunhv: Initialize lock for non-registered console" 2020-07-21 18:21:49 +02:00
sunsab.c tty: serial: sunsab: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
sunsab.h
sunsu.c tty: serial: sunsu: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
sunzilog.c tty: serial: sunzilog: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
sunzilog.h
tegra-tcu.c serial: tegra-tcu: Reorder channel initialization 2021-06-15 14:02:06 +02:00
timbuart.c serial: timbuart: drop low-latency workaround 2021-04-22 12:09:26 +02:00
timbuart.h tty: serial: Use the correct style for SPDX License Identifier 2020-03-07 09:52:01 +01:00
uartlite.c serial: tty: uartlite: fix console setup 2021-06-04 15:11:45 +02:00
ucc_uart.c firmware: replace HOTPLUG with UEVENT in FW_ACTION defines 2021-05-13 16:14:45 +02:00
vr41xx_siu.c tty: serial: vr41xx_siu: include <linux/io.h> instead of <asm/io.h> 2021-05-13 18:29:12 +02:00
vt8500_serial.c serial: vt8500: drop low-latency workaround 2021-04-22 12:09:26 +02:00
xilinx_uartps.c serial: Prefer unsigned int to bare use of unsigned 2021-06-24 14:51:45 +02:00
zs.c
zs.h