linux-stable/drivers/tty
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
..
hvc TTY / Serial patches for 5.14-rc1 2021-07-05 14:08:24 -07:00
ipwireless ipwireless: remove unused ipw_tty::closing 2021-06-15 14:02:43 +02:00
serdev tty: serdev: core: Fix misspelled function name __serdev_device_driver_register() 2021-05-20 17:05:34 +02:00
serial serial: 8250_pci: Avoid irq sharing for MSI(-X) interrupts. 2021-07-30 13:06:19 +02:00
vt Merge 5.13-rc4 into tty-next 2021-05-31 09:44:28 +02:00
amiserial.c tty: make tty_operations::chars_in_buffer return uint 2021-05-13 18:29:11 +02:00
ehv_bytechan.c tty: make tty_operations::write_room return uint 2021-05-13 17:03:20 +02:00
goldfish.c tty: make tty_operations::chars_in_buffer return uint 2021-05-13 18:29:11 +02:00
Kconfig This pull request contains the following changes for UML: 2021-07-09 10:19:13 -07:00
Makefile tty: remove broken r3964 line discipline 2021-05-13 16:57:15 +02:00
mips_ejtag_fdc.c tty: make tty_operations::chars_in_buffer return uint 2021-05-13 18:29:11 +02:00
moxa.c tty: make tty_operations::chars_in_buffer return uint 2021-05-13 18:29:11 +02:00
moxa.h
mxser.c mxser: introduce mxser_16550A_or_MUST helper 2021-06-18 13:10:03 +02:00
n_gsm.c tty: n_gsm: Fix function naming and provide missing param descriptions 2021-05-20 17:06:17 +02:00
n_hdlc.c tty: n_hdlc: Fix a little doc-rot in n_hdlc_tty_read() 2021-05-20 17:06:17 +02:00
n_null.c tty: make tty_ldisc_ops a param in tty_unregister_ldisc 2021-05-13 16:57:16 +02:00
n_tty.c tty: drop tty_ldisc_ops::refcount 2021-05-13 16:57:17 +02:00
nozomi.c tty: nozomi: Fix the error handling path of 'nozomi_card_init()' 2021-05-27 15:20:02 +02:00
pty.c tty: pty: correct function name pty_resize() 2021-05-20 16:33:06 +02:00
synclink_gt.c tty: make use of tty_get_{char,frame}_size 2021-06-15 14:03:27 +02:00
sysrq.c tty/sysrq: Fix issues of code indent should use tabs 2021-04-10 10:33:00 +02:00
tty.h tty: clean include/linux/tty.h up 2021-04-15 10:32:17 +02:00
tty_audit.c tty: audit: move some local functions out of tty.h 2021-04-15 10:24:58 +02:00
tty_baudrate.c tty: tty_baudrate: Fix coding style issues of block comments 2021-05-13 18:29:12 +02:00
tty_buffer.c tty: tty_buffer: Fix incorrectly documented function __tty_buffer_request_room() 2021-05-20 17:06:15 +02:00
tty_io.c tty: fix kernel-doc for {start,stop}_tty 2021-05-20 16:59:14 +02:00
tty_ioctl.c tty: make tty_get_{char,frame}_size available 2021-06-15 14:03:26 +02:00
tty_jobctrl.c tty: tty_jobctrl: Fix 2 incorrectly documented functions 2021-05-20 17:06:15 +02:00
tty_ldisc.c tty: tty_ldisc: fix doc warnings in tty_ldisc.c 2021-06-09 14:43:23 +02:00
tty_ldsem.c
tty_mutex.c tty: move some internal tty lock enums and functions out of tty.h 2021-04-15 10:26:58 +02:00
tty_port.c tty: tty_port: Fix coding style issues of block comments 2021-05-13 18:29:13 +02:00
ttynull.c tty: make tty_operations::write_room return uint 2021-05-13 17:03:20 +02:00
vcc.c TTY / Serial patches for 5.14-rc1 2021-07-05 14:08:24 -07:00