PCI: hv: Fix a race condition when removing the device
authorLong Li <longli@microsoft.com>
Wed, 12 May 2021 08:06:40 +0000 (01:06 -0700)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Thu, 3 Jun 2021 17:28:48 +0000 (18:28 +0100)
commit94d22763207ac6633612b8d8e0ca4fba0f7aa139
treef93d65deb83f01b40dcc20f6b5e10ed43a2887cc
parent6efb943b8616ec53a5e444193dccf1af9ad627b5
PCI: hv: Fix a race condition when removing the device

On removing the device, any work item (hv_pci_devices_present() or
hv_pci_eject_device()) scheduled on workqueue hbus->wq may still be running
and race with hv_pci_remove().

This can happen because the host may send PCI_EJECT or PCI_BUS_RELATIONS(2)
and decide to rescind the channel immediately after that.

Fix this by flushing/destroying the workqueue of hbus before doing hbus remove.

Link: https://lore.kernel.org/r/1620806800-30983-1-git-send-email-longli@linuxonhyperv.com
Signed-off-by: Long Li <longli@microsoft.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
drivers/pci/controller/pci-hyperv.c