Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 948373b3 authored by Dexuan Cui's avatar Dexuan Cui Committed by Lorenzo Pieralisi
Browse files

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: default avatarDexuan Cui <decui@microsoft.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
Acked-by: default avatarHaiyang 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>
parent fca288c0
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1789,6 +1789,7 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus,
	struct hv_dr_state *dr;
	struct hv_dr_work *dr_wrk;
	unsigned long flags;
	bool pending_dr;

	dr_wrk = kzalloc(sizeof(*dr_wrk), GFP_NOWAIT);
	if (!dr_wrk)
@@ -1812,12 +1813,22 @@ static void hv_pci_devices_present(struct hv_pcibus_device *hbus,
	}

	spin_lock_irqsave(&hbus->device_list_lock, flags);
	/*
	 * If pending_dr is true, we have already queued a work,
	 * which will see the new dr. Otherwise, we need to
	 * queue a new work.
	 */
	pending_dr = !list_empty(&hbus->dr_list);
	list_add_tail(&dr->list_entry, &hbus->dr_list);
	spin_unlock_irqrestore(&hbus->device_list_lock, flags);

	if (pending_dr) {
		kfree(dr_wrk);
	} else {
		get_hvpcibus(hbus);
		queue_work(hbus->wq, &dr_wrk->wrk);
	}
}

/**
 * hv_eject_device_work() - Asynchronously handles ejection