From: Dexuan Cui <decui@microsoft.com>
To: "bhelgaas@google.com" <bhelgaas@google.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
KY Srinivasan <kys@microsoft.com>,
Stephen Hemminger <sthemmin@microsoft.com>,
"olaf@aepfle.de" <olaf@aepfle.de>,
"apw@canonical.com" <apw@canonical.com>,
"jasowang@redhat.com" <jasowang@redhat.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>,
"driverdev-devel@linuxdriverproject.org"
<driverdev-devel@linuxdriverproject.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
Jack Morgenstein <jackm@mellanox.com>,
"Michael Kelley \(EOSG\)" <Michael.H.Kelley@microsoft.com>,
"marcelo.cerri@canonical.com" <marcelo.cerri@canonical.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>
Subject: [PATCH v3 5/6] PCI: hv: hv_pci_devices_present(): only queue a new work when necessary
Date: Tue, 6 Mar 2018 18:21:55 +0000 [thread overview]
Message-ID: <20180306182128.23281-6-decui@microsoft.com> (raw)
In-Reply-To: <20180306182128.23281-1-decui@microsoft.com>
If there is a pending work, we just need to add the new dr into
the dr_list.
This is suggested by Michael Kelley.
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Jack Morgenstein <jackm@mellanox.com>
Cc: stable@vger.kernel.org
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Michael Kelley (EOSG) <Michael.H.Kelley@microsoft.com>
---
drivers/pci/host/pci-hyperv.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/host/pci-hyperv.c b/drivers/pci/host/pci-hyperv.c
index 3a385212f666..265ba11e53e2 100644
--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -1733,6 +1733,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)
@@ -1756,11 +1757,21 @@ 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);
- get_hvpcibus(hbus);
- queue_work(hbus->wq, &dr_wrk->wrk);
+ if (pending_dr) {
+ kfree(dr_wrk);
+ } else {
+ get_hvpcibus(hbus);
+ queue_work(hbus->wq, &dr_wrk->wrk);
+ }
}
/**
--
2.7.4
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2018-03-06 18:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 18:21 [PATCH v3 0/6] some fixes to the pci-hyperv driver Dexuan Cui
2018-03-06 18:21 ` [PATCH v3 1/6] PCI: hv: fix a comment typo in _hv_pcifront_read_config() Dexuan Cui
2018-03-09 19:36 ` Haiyang Zhang
2018-03-06 18:21 ` [PATCH v3 2/6] PCI: hv: hv_eject_device_work(): remove the bogus test Dexuan Cui
2018-03-06 18:29 ` Michael Kelley (EOSG)
2018-03-09 19:37 ` Haiyang Zhang
2018-03-06 18:21 ` [PATCH v3 3/6] PCI: hv: serialize the present/eject work items Dexuan Cui
2018-03-06 18:30 ` Michael Kelley (EOSG)
2018-03-09 19:37 ` Haiyang Zhang
2018-03-06 18:21 ` [PATCH v3 4/6] PCI: hv: remove hbus->enum_sem Dexuan Cui
2018-03-06 18:31 ` Michael Kelley (EOSG)
2018-03-09 19:37 ` Haiyang Zhang
2018-03-06 18:21 ` Dexuan Cui [this message]
2018-03-06 18:31 ` [PATCH v3 5/6] PCI: hv: hv_pci_devices_present(): only queue a new work when necessary Michael Kelley (EOSG)
2018-03-09 19:37 ` Haiyang Zhang
2018-03-06 18:21 ` [PATCH v3 6/6] PCI: hv: fix 2 hang issues in hv_compose_msi_msg() Dexuan Cui
2018-03-06 18:32 ` Michael Kelley (EOSG)
2018-03-07 12:34 ` Lorenzo Pieralisi
2018-03-07 21:40 ` Dexuan Cui
2018-03-13 18:23 ` Dexuan Cui
2018-03-13 18:31 ` Lorenzo Pieralisi
2018-03-14 11:50 ` Lorenzo Pieralisi
2018-03-14 17:17 ` Dexuan Cui
2018-03-09 19:38 ` Haiyang Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180306182128.23281-6-decui@microsoft.com \
--to=decui@microsoft.com \
--cc=Michael.H.Kelley@microsoft.com \
--cc=apw@canonical.com \
--cc=bhelgaas@google.com \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=haiyangz@microsoft.com \
--cc=jackm@mellanox.com \
--cc=jasowang@redhat.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=marcelo.cerri@canonical.com \
--cc=olaf@aepfle.de \
--cc=stable@vger.kernel.org \
--cc=sthemmin@microsoft.com \
--cc=vkuznets@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).