This is a note to let you know that I've just added the patch titled serial: 8250_pci: Detach low-level driver during PCI error recovery to the 4.4-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: serial-8250_pci-detach-low-level-driver-during-pci-error-recovery.patch and it can be found in the queue-4.4 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Tue Mar 28 13:59:27 CEST 2017 From: Sumit Semwal <sumit.semwal@xxxxxxxxxx> Date: Sat, 25 Mar 2017 21:48:19 +0530 Subject: serial: 8250_pci: Detach low-level driver during PCI error recovery To: stable@xxxxxxxxxxxxxxx Cc: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Sasha Levin <alexander.levin@xxxxxxxxxxx>, Sumit Semwal <sumit.semwal@xxxxxxxxxx> Message-ID: <1490458699-24484-20-git-send-email-sumit.semwal@xxxxxxxxxx> From: Sumit Semwal <sumit.semwal@xxxxxxxxxx> From: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxxxxxxx> [ Upstream commit f209fa03fc9d131b3108c2e4936181eabab87416 ] 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@xxxxxxxxxxxxxxxxxx> for valuable input on this one over one year ago. Signed-off-by: Gabriel Krisman Bertazi <krisman@xxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Sasha Levin <alexander.levin@xxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Signed-off-by: Sumit Semwal <sumit.semwal@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/tty/serial/8250/8250_pci.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -57,6 +57,7 @@ struct serial_private { unsigned int nr; void __iomem *remapped_bar[PCI_NUM_BAR_RESOURCES]; struct pci_serial_quirk *quirk; + const struct pciserial_board *board; int line[0]; }; @@ -4058,6 +4059,7 @@ pciserial_init_ports(struct pci_dev *dev } } priv->nr = i; + priv->board = board; return priv; err_deinit: @@ -4068,7 +4070,7 @@ err_out: } EXPORT_SYMBOL_GPL(pciserial_init_ports); -void pciserial_remove_ports(struct serial_private *priv) +void pciserial_detach_ports(struct serial_private *priv) { struct pci_serial_quirk *quirk; int i; @@ -4088,7 +4090,11 @@ void pciserial_remove_ports(struct seria quirk = find_quirk(priv->dev); if (quirk->exit) quirk->exit(priv->dev); +} +void pciserial_remove_ports(struct serial_private *priv) +{ + pciserial_detach_ports(priv); kfree(priv); } EXPORT_SYMBOL_GPL(pciserial_remove_ports); @@ -5819,7 +5825,7 @@ static pci_ers_result_t serial8250_io_er return PCI_ERS_RESULT_DISCONNECT; if (priv) - pciserial_suspend_ports(priv); + pciserial_detach_ports(priv); pci_disable_device(dev); @@ -5844,9 +5850,18 @@ static pci_ers_result_t serial8250_io_sl static void serial8250_io_resume(struct pci_dev *dev) { struct serial_private *priv = pci_get_drvdata(dev); + const struct pciserial_board *board; - if (priv) - pciserial_resume_ports(priv); + if (!priv) + return; + + board = priv->board; + kfree(priv); + priv = pciserial_init_ports(dev, board); + + if (!IS_ERR(priv)) { + pci_set_drvdata(dev, priv); + } } static const struct pci_error_handlers serial8250_err_handler = { Patches currently in stable-queue which might be from sumit.semwal@xxxxxxxxxx are queue-4.4/pci-add-comments-about-rom-bar-updating.patch queue-4.4/acpi-blacklist-make-dell-latitude-3350-ethernet-work.patch queue-4.4/s390-zcrypt-introduce-cex6-toleration.patch queue-4.4/block-allow-write_same-commands-with-the-sg_io-ioctl.patch queue-4.4/pci-do-any-vf-bar-updates-before-enabling-the-bars.patch queue-4.4/x86-hyperv-handle-unknown-nmis-on-one-cpu-when-unknown_nmi_panic.patch queue-4.4/serial-8250_pci-detach-low-level-driver-during-pci-error-recovery.patch queue-4.4/xen-do-not-re-use-pirq-number-cached-in-pci-device-msi-msg-data.patch queue-4.4/pci-separate-vf-bar-updates-from-standard-bar-updates.patch queue-4.4/pci-ignore-bar-updates-on-virtual-functions.patch queue-4.4/pci-update-bars-using-property-bits-appropriate-for-type.patch queue-4.4/vfio-spapr-postpone-allocation-of-userspace-version-of-tce-table.patch queue-4.4/pci-don-t-update-vf-bars-while-vf-memory-space-is-enabled.patch queue-4.4/igb-workaround-for-igb-i210-firmware-issue.patch queue-4.4/pci-remove-pci_resource_bar-and-pci_iov_resource_bar.patch queue-4.4/pci-decouple-ioresource_rom_enable-and-pci_rom_address_enable.patch queue-4.4/acpi-blacklist-add-_rev-quirks-for-dell-precision-5520-and-3520.patch queue-4.4/igb-add-i211-to-i210-phy-workaround.patch queue-4.4/uvcvideo-uvc_scan_fallback-for-webcams-with-broken-chain.patch