PCI: hv: Delete the device earlier from hbus->children for hot-remove
authorDexuan Cui <decui@microsoft.com>
Thu, 10 Nov 2016 07:19:52 +0000 (07:19 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Aug 2019 07:33:30 +0000 (09:33 +0200)
commita8d9c5dc9499a3753d438d3be60b002b521fdc0c
tree1dc0e4bbf94a7e959f3429d573b9778db25a8753
parent029cc4f0f075de930e9a4ee13e73c4d37b1fecd9
PCI: hv: Delete the device earlier from hbus->children for hot-remove

commit e74d2ebdda33b3bdd1826b5b92e9aa45bdf92bb3 upstream.

After we send a PCI_EJECTION_COMPLETE message to the host, the host will
immediately send us a PCI_BUS_RELATIONS message with
relations->device_count == 0, so pci_devices_present_work(), running on
another thread, can find the being-ejected device, mark the
hpdev->reported_missing to true, and run list_move_tail()/list_del() for
the device -- this races hv_eject_device_work() -> list_del().

Move the list_del() in hv_eject_device_work() to an earlier place, i.e.,
before we send PCI_EJECTION_COMPLETE, so later the
pci_devices_present_work() can't see the device.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Jake Oshins <jakeo@microsoft.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/pci/host/pci-hyperv.c