linux/drivers/pci/host
Dexuan Cui de0aa7b2f9 PCI: hv: Fix 2 hang issues in hv_compose_msi_msg()
1. With the patch "x86/vector/msi: Switch to global reservation mode",
the recent v4.15 and newer kernels always hang for 1-vCPU Hyper-V VM
with SR-IOV. This is because when we reach hv_compose_msi_msg() by
request_irq() -> request_threaded_irq() ->__setup_irq()->irq_startup()
-> __irq_startup() -> irq_domain_activate_irq() -> ... ->
msi_domain_activate() -> ... -> hv_compose_msi_msg(), local irq is
disabled in __setup_irq().

Note: when we reach hv_compose_msi_msg() by another code path:
pci_enable_msix_range() -> ... -> irq_domain_activate_irq() -> ... ->
hv_compose_msi_msg(), local irq is not disabled.

hv_compose_msi_msg() depends on an interrupt from the host.
With interrupts disabled, a UP VM always hangs in the busy loop in
the function, because the interrupt callback hv_pci_onchannelcallback()
can not be called.

We can do nothing but work it around by polling the channel. This
is ugly, but we don't have any other choice.

2. If the host is ejecting the VF device before we reach
hv_compose_msi_msg(), in a UP VM, we can hang in hv_compose_msi_msg()
forever, because at this time the host doesn't respond to the
CREATE_INTERRUPT request. This issue exists the first day the
pci-hyperv driver appears in the kernel.

Luckily, this can also by worked around by polling the channel
for the PCI_EJECT message and hpdev->state, and by checking the
PCI vendor ID.

Note: actually the above 2 issues also happen to a SMP VM, if
"hbus->hdev->channel->target_cpu == smp_processor_id()" is true.

Fixes: 4900be8360 ("x86/vector/msi: Switch to global reservation mode")
Tested-by: Adrian Suhov <v-adsuho@microsoft.com>
Tested-by: Chris Valean <v-chvale@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Acked-by: Haiyang Zhang <haiyangz@microsoft.com>
Cc: <stable@vger.kernel.org>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Jack Morgenstein <jackm@mellanox.com>
2018-03-16 18:19:01 +00:00
..
Kconfig PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller 2018-01-31 11:13:27 +00:00
Makefile PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller 2018-01-31 11:13:27 +00:00
pci-aardvark.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pci-ftpci100.c pci-v4.15-changes 2017-11-15 15:01:28 -08:00
pci-host-common.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pci-host-generic.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pci-hyperv.c PCI: hv: Fix 2 hang issues in hv_compose_msi_msg() 2018-03-16 18:19:01 +00:00
pci-mvebu.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pci-rcar-gen2.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pci-tegra.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pci-thunder-ecam.c PCI: Add SPDX GPL-2.0 to replace COPYING boilerplate 2018-01-28 15:48:54 -06:00
pci-thunder-pem.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pci-v3-semi.c PCI: Add SPDX GPL-2.0 when no license was specified 2018-01-26 11:45:16 -06:00
pci-versatile.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pci-xgene-msi.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
pci-xgene.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pcie-altera-msi.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pcie-altera.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pcie-iproc-bcma.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pcie-iproc-msi.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pcie-iproc-platform.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pcie-iproc.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pcie-iproc.h Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pcie-mediatek.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00
pcie-rcar.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pcie-rockchip.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
pcie-tango.c pci-v4.15-changes 2017-11-15 15:01:28 -08:00
pcie-xilinx-nwl.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
pcie-xilinx.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
vmd.c PCI: Add SPDX GPL-2.0 to replace GPL v2 boilerplate 2018-01-28 15:48:29 -06:00