diff options
author | Dexuan Cui <decui@microsoft.com> | 2018-03-15 10:22:00 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2018-03-16 14:19:03 -0400 |
commit | 948373b3ed1bcf05a237c24675b84804315aff14 (patch) | |
tree | 3a430eb260acb32104a68197d127c9ccd01c46b6 | |
parent | fca288c0153b2b97114b9081bc3c33c3735145b6 (diff) |
PCI: hv: Only queue new work items in hv_pci_devices_present() if necessary
If there is pending work in hv_pci_devices_present() we just need to add
the new dr entry into the dr_list. Add a check to detect pending work
items and update the code to skip queuing work if pending work items
are detected.
Signed-off-by: Dexuan Cui <decui@microsoft.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Acked-by: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Jack Morgenstein <jackm@mellanox.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
-rw-r--r-- | drivers/pci/host/pci-hyperv.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c index 0dc2ecdbbe45..50cdefe3f6d3 100644 --- a/drivers/pci/host/pci-hyperv.c +++ b/drivers/pci/host/pci-hyperv.c | |||
@@ -1789,6 +1789,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, | |||
1789 | struct hv_dr_state *dr; | 1789 | struct hv_dr_state *dr; |
1790 | struct hv_dr_work *dr_wrk; | 1790 | struct hv_dr_work *dr_wrk; |
1791 | unsigned long flags; | 1791 | unsigned long flags; |
1792 | bool pending_dr; | ||
1792 | 1793 | ||
1793 | dr_wrk = kzalloc(sizeof(*dr_wrk), GFP_NOWAIT); | 1794 | dr_wrk = kzalloc(sizeof(*dr_wrk), GFP_NOWAIT); |
1794 | if (!dr_wrk) | 1795 | if (!dr_wrk) |
@@ -1812,11 +1813,21 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus, | |||
1812 | } | 1813 | } |
1813 | 1814 | ||
1814 | spin_lock_irqsave(&hbus->device_list_lock, flags); | 1815 | spin_lock_irqsave(&hbus->device_list_lock, flags); |
1816 | /* | ||
1817 | * If pending_dr is true, we have already queued a work, | ||
1818 | * which will see the new dr. Otherwise, we need to | ||
1819 | * queue a new work. | ||
1820 | */ | ||
1821 | pending_dr = !list_empty(&hbus->dr_list); | ||
1815 | list_add_tail(&dr->list_entry, &hbus->dr_list); | 1822 | list_add_tail(&dr->list_entry, &hbus->dr_list); |
1816 | spin_unlock_irqrestore(&hbus->device_list_lock, flags); | 1823 | spin_unlock_irqrestore(&hbus->device_list_lock, flags); |
1817 | 1824 | ||
1818 | get_hvpcibus(hbus); | 1825 | if (pending_dr) { |
1819 | queue_work(hbus->wq, &dr_wrk->wrk); | 1826 | kfree(dr_wrk); |
1827 | } else { | ||
1828 | get_hvpcibus(hbus); | ||
1829 | queue_work(hbus->wq, &dr_wrk->wrk); | ||
1830 | } | ||
1820 | } | 1831 | } |
1821 | 1832 | ||
1822 | /** | 1833 | /** |