PCI/switchtec: Error out MRPC execution when MMIO reads fail
authorKelvin Cao <kelvin.cao@microchip.com>
Thu, 14 Oct 2021 14:18:55 +0000 (14:18 +0000)
committerBjorn Helgaas <bhelgaas@google.com>
Thu, 14 Oct 2021 14:22:47 +0000 (09:22 -0500)
commit1a323bd071dd81c9c136c06fad9e02c403b48aca
treed759731ef3d682ad319bb875741c9c7101c06438
parente4e737bb5c170df6135a127739a9e6148ee3da82
PCI/switchtec: Error out MRPC execution when MMIO reads fail

A firmware hard reset may be initiated by various mechanisms including a
UART interface, TWI sideband interface from BMC, MRPC command from
userspace, etc. The switchtec management driver is unaware of these
resets.

The reset clears PCI state including the BARs and Memory Space Enable
bits, so the device no longer responds to the MMIO accesses the driver
uses to operate it.

MMIO reads to the device will fail with a PCIe error. When the root
complex handles that error, it typically fabricates ~0 data to complete
the CPU read.

Check for this sort of error by reading the device ID from MMIO space.
This ID can never be ~0, so if we see that value, it probably means the
PCIe Memory Read failed and we should return an error indication to the
application using the switchtec driver.

Link: https://lore.kernel.org/r/20211014141859.11444-2-kelvin.cao@microchip.com
Signed-off-by: Kelvin Cao <kelvin.cao@microchip.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/switch/switchtec.c