serial: 8250_pci: Detach low-level driver during PCI error recovery
authorGabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Mon, 28 Nov 2016 21:34:42 +0000 (19:34 -0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Apr 2017 05:15:06 +0000 (07:15 +0200)
commitc7293aedb4990eef20cdf74c5b51b6f351ddf025
treed14a5f359f0c9f42846b5bdcb26ed73709babe39
parentd233e2efc6d76dd4c28042ff5f06eefa0e833503
serial: 8250_pci: Detach low-level driver during PCI error recovery

commit f209fa03fc9d131b3108c2e4936181eabab87416 upstream.

During a PCI error recovery, like the ones provoked by EEH in the ppc64
platform, all IO to the device must be blocked while the recovery is
completed.  Current 8250_pci implementation only suspends the port
instead of detaching it, which doesn't prevent incoming accesses like
TIOCMGET and TIOCMSET calls from reaching the device.  Those end up
racing with the EEH recovery, crashing it.  Similar races were also
observed when opening the device and when shutting it down during
recovery.

This patch implements a more robust IO blockage for the 8250_pci
recovery by unregistering the port at the beginning of the procedure and
re-adding it afterwards.  Since the port is detached from the uart
layer, we can be sure that no request will make through to the device
during recovery.  This is similar to the solution used by the JSM serial
driver.

I thank Peter Hurley <peter@hurleysoftware.com> for valuable input on
this one over one year ago.

Signed-off-by: Gabriel Krisman Bertazi <krisman@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/8250/8250_pci.c