aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDexuan Cui <decui@microsoft.com>2016-11-10 02:19:52 -0500
committerBjorn Helgaas <bhelgaas@google.com>2016-11-16 17:46:44 -0500
commite74d2ebdda33b3bdd1826b5b92e9aa45bdf92bb3 (patch)
tree77333536f5741d3117d404b403f3123d098d6b11
parent17978524a636d007e6b929304ae3eb5ea0371019 (diff)
PCI: hv: Delete the device earlier from hbus->children for hot-remove
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>
-rw-r--r--drivers/pci/host/pci-hyperv.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index b1747469a32c..a63c3a4f6c7c 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1582,6 +1582,10 @@ static void hv_eject_device_work(struct work_struct *work)
1582 pci_dev_put(pdev); 1582 pci_dev_put(pdev);
1583 } 1583 }
1584 1584
1585 spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
1586 list_del(&hpdev->list_entry);
1587 spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
1588
1585 memset(&ctxt, 0, sizeof(ctxt)); 1589 memset(&ctxt, 0, sizeof(ctxt));
1586 ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; 1590 ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message;
1587 ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE; 1591 ejct_pkt->message_type.type = PCI_EJECTION_COMPLETE;
@@ -1590,10 +1594,6 @@ static void hv_eject_device_work(struct work_struct *work)
1590 sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt, 1594 sizeof(*ejct_pkt), (unsigned long)&ctxt.pkt,
1591 VM_PKT_DATA_INBAND, 0); 1595 VM_PKT_DATA_INBAND, 0);
1592 1596
1593 spin_lock_irqsave(&hpdev->hbus->device_list_lock, flags);
1594 list_del(&hpdev->list_entry);
1595 spin_unlock_irqrestore(&hpdev->hbus->device_list_lock, flags);
1596
1597 put_pcichild(hpdev, hv_pcidev_ref_childlist); 1597 put_pcichild(hpdev, hv_pcidev_ref_childlist);
1598 put_pcichild(hpdev, hv_pcidev_ref_pnp); 1598 put_pcichild(hpdev, hv_pcidev_ref_pnp);
1599 put_hvpcibus(hpdev->hbus); 1599 put_hvpcibus(hpdev->hbus);