linux/drivers/pci/pcie
Huacai Chen 62b6dee1b4 PCI/portdrv: Prevent LS7A Bus Master clearing on shutdown
After cc27b735ad ("PCI/portdrv: Turn off PCIe services during shutdown")
we observe hangs during poweroff/reboot on systems with LS7A chipset.

This happens because the portdrv .shutdown() method (pcie_portdrv_remove())
clears PCI_COMMAND_MASTER via pci_disable_device(), which prevents bridges
from forwarding memory or I/O Requests in the upstream direction (PCIe
r6.0, sec 7.5.1.1.3).

LS7A Root Ports have a hardware defect: clearing PCI_COMMAND_MASTER *also*
prevents the bridge from forwarding CPU MMIO requests in the downstream
direction, and these MMIO accesses to devices below the bridge happen even
after .shutdown(), e.g., to print console messages.  LS7A neither forwards
the requests nor sends an unsuccessful completion to the CPU, so the CPU
waits forever, resulting in the hang.

The purpose of .shutdown() is to disable interrupts and DMA from the
device.  PCIe ports may generate interrupts (either MSI/MSI-X or INTx) for
AER, DPC, PME, hotplug, etc., but they never perform DMA except MSI/MSI-X.
Clearing PCI_COMMAND_MASTER effectively disables MSI/MSI-X, but not INTx.

The port service driver .remove() methods clear the interrupt enables in
PCI_ERR_ROOT_COMMAND, PCI_EXP_DPC_CTL, PCI_EXP_SLTCTL, and PCI_EXP_RTCTL,
etc., which disables interrupts regardless of whether they are MSI/MSI-X or
INTx.

Add a pcie_portdrv_shutdown() method that calls all the port service driver
.remove() methods to clear the interrupt enables for each service but does
not clear Bus Mastering on the port itself.

[bhelgaas: commit log]
Link: https://lore.kernel.org/r/20230201043018.778499-2-chenhuacai@loongson.cn
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
2023-02-01 12:05:28 -06:00
..
aer_inject.c PCI/AER: Update aer-inject URL 2022-03-02 11:26:17 -06:00
aer.c PCI/AER: Add optional logging callback for correctable error 2022-12-03 13:40:56 -08:00
aspm.c PCI/ASPM: Correct LTR_L1.2_THRESHOLD computation 2022-10-05 12:12:02 -05:00
dpc.c PCI/DPC: Quirk PIO log size for certain Intel Root Ports 2022-09-27 18:13:18 -05:00
edr.c PCI/EDR: Log only ACPI_NOTIFY_DISCONNECT_RECOVER events 2020-04-24 18:33:29 -05:00
err.c PCI/ERR: Recognize disconnected devices in report_error_detected() 2022-06-08 15:08:40 -05:00
Kconfig PCI: pciehp: Enable by default if USB4 enabled 2022-11-15 09:25:21 -06:00
Makefile PCI/portdrv: Squash into portdrv.c 2022-10-24 14:57:30 -05:00
pme.c PCI/PME: Use PCI_POSSIBLE_ERROR() to check config reads 2021-11-18 14:13:18 -06:00
portdrv.c PCI/portdrv: Prevent LS7A Bus Master clearing on shutdown 2023-02-01 12:05:28 -06:00
portdrv.h PCI/portdrv: Move private things to portdrv.c 2022-10-24 14:57:30 -05:00
ptm.c PCI/PTM: Reorder functions in logical order 2022-09-12 15:29:52 -05:00
rcec.c PCI/RCEC: Fix RCiEP device to RCEC association 2021-03-10 15:10:46 -06:00