alistair23-linux/drivers/pci/controller
Dexuan Cui 340d455699 PCI: hv: Add pci_destroy_slot() in pci_devices_present_work(), if necessary
When we hot-remove a device, usually the host sends us a PCI_EJECT message,
and a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.

When we execute the quick hot-add/hot-remove test, the host may not send
us the PCI_EJECT message if the guest has not fully finished the
initialization by sending the PCI_RESOURCES_ASSIGNED* message to the
host, so it's potentially unsafe to only depend on the
pci_destroy_slot() in hv_eject_device_work() because the code path

create_root_hv_pci_bus()
 -> hv_pci_assign_slots()

is not called in this case. Note: in this case, the host still sends the
guest a PCI_BUS_RELATIONS message with bus_rel->device_count == 0.

In the quick hot-add/hot-remove test, we can have such a race before
the code path

pci_devices_present_work()
 -> new_pcichild_device()

adds the new device into the hbus->children list, we may have already
received the PCI_EJECT message, and since the tasklet handler

hv_pci_onchannelcallback()

may fail to find the "hpdev" by calling

get_pcichild_wslot(hbus, dev_message->wslot.slot)

hv_pci_eject_device() is not called; Later, by continuing execution

create_root_hv_pci_bus()
 -> hv_pci_assign_slots()

creates the slot and the PCI_BUS_RELATIONS message with
bus_rel->device_count == 0 removes the device from hbus->children, and
we end up being unable to remove the slot in

hv_pci_remove()
 -> hv_pci_remove_slots()

Remove the slot in pci_devices_present_work() when the device
is removed to address this race.

pci_devices_present_work() and hv_eject_device_work() run in the
singled-threaded hbus->wq, so there is not a double-remove issue for the
slot.

We cannot offload hv_pci_eject_device() from hv_pci_onchannelcallback()
to the workqueue, because we need the hv_pci_onchannelcallback()
synchronously call hv_pci_eject_device() to poll the channel
ringbuffer to work around the "hangs in hv_compose_msi_msg()" issue
fixed in commit de0aa7b2f9 ("PCI: hv: Fix 2 hang issues in
hv_compose_msi_msg()")

Fixes: a15f2c08c7 ("PCI: hv: support reporting serial number as slot information")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
[lorenzo.pieralisi@arm.com: rewritten commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Reviewed-by:  Michael Kelley <mikelley@microsoft.com>
Cc: stable@vger.kernel.org
2019-03-26 19:42:20 +00:00
..
dwc pci-v5.1-changes 2019-03-09 14:57:08 -08:00
Kconfig PCI: altera: Enable driver on ARM64 2019-03-04 12:22:19 +00:00
Makefile
pci-aardvark.c PCI: aardvark: Make symbol 'advk_pci_bridge_emul_ops' static 2019-03-01 15:23:06 +00:00
pci-ftpci100.c
pci-host-common.c
pci-host-generic.c
pci-hyperv.c PCI: hv: Add pci_destroy_slot() in pci_devices_present_work(), if necessary 2019-03-26 19:42:20 +00:00
pci-mvebu.c PCI: pci-bridge-emul: Extend pci_bridge_emul_init() with flags 2019-02-22 10:51:14 +00:00
pci-rcar-gen2.c
pci-tegra.c
pci-thunder-ecam.c
pci-thunder-pem.c
pci-v3-semi.c
pci-versatile.c
pci-xgene-msi.c
pci-xgene.c
pcie-altera-msi.c
pcie-altera.c PCI: altera: Add Stratix 10 PCIe support 2019-03-04 12:22:03 +00:00
pcie-cadence-ep.c PCI: cadence: Remove pci_epf_linkup() from Cadence EP driver 2019-02-15 10:02:38 +00:00
pcie-cadence-host.c
pcie-cadence.c pci-v4.20-changes 2018-10-25 06:50:48 -07:00
pcie-cadence.h
pcie-iproc-bcma.c
pcie-iproc-msi.c cross-tree: phase out dma_zalloc_coherent() 2019-01-08 07:58:37 -05:00
pcie-iproc-platform.c
pcie-iproc.c
pcie-iproc.h
pcie-mediatek.c PCI: mediatek: Enlarge PCIe2AHB window size to support 4GB DRAM 2019-03-01 11:22:21 +00:00
pcie-mobiveil.c
pcie-rcar.c PCI: rcar: Add the initialization of PCIe link in resume_noirq() 2019-03-26 11:14:13 +00:00
pcie-rockchip-ep.c PCI: rockchip: Remove pci_epf_linkup() from Rockchip EP driver 2019-02-15 10:02:50 +00:00
pcie-rockchip-host.c
pcie-rockchip.c
pcie-rockchip.h
pcie-tango.c
pcie-xilinx-nwl.c
pcie-xilinx.c
vmd.c PCI/VMD: Configure MPS settings before adding devices 2019-01-30 11:00:04 +00:00