From: Keith Busch <keith.busch@intel.com>
To: linux-nvme@lists.infradead.org, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org
Cc: Keith Busch <keith.busch@intel.com>
Subject: [PATCH 2/2] NVMe: Complete shutdown asynchronously
Date: Thu, 8 May 2014 12:07:34 -0600 [thread overview]
Message-ID: <1399572454-30239-3-git-send-email-keith.busch@intel.com> (raw)
In-Reply-To: <1399572454-30239-1-git-send-email-keith.busch@intel.com>
Some devices may take a long time to complete a shutdown. The driver
can perform the device shutdown asynchronously so multiple devices may
be done in parallel and speed up the overall system shutdown.
PCI disables MSI/MSI-x after the driver's .shutdown returns, so the
driver enables the INTx irq if performing the shutdown asynchronously.
Signed-off-by: Keith Busch <keith.busch@intel.com>
---
drivers/block/nvme-core.c | 28 ++++++++++++++++++++++++++--
include/linux/nvme.h | 1 +
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index cd8a8bc7..a9982b8 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -13,6 +13,7 @@
*/
#include <linux/nvme.h>
+#include <linux/async.h>
#include <linux/bio.h>
#include <linux/bitops.h>
#include <linux/blkdev.h>
@@ -1401,7 +1402,7 @@ static int nvme_shutdown_ctrl(struct nvme_dev *dev)
cc = (readl(&dev->bar->cc) & ~NVME_CC_SHN_MASK) | NVME_CC_SHN_NORMAL;
writel(cc, &dev->bar->cc);
- timeout = 2 * HZ + jiffies;
+ timeout = 20 * HZ + jiffies;
while ((readl(&dev->bar->csts) & NVME_CSTS_SHST_MASK) !=
NVME_CSTS_SHST_CMPLT) {
msleep(100);
@@ -2739,6 +2740,7 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev->reset_workfn = nvme_reset_failed_dev;
INIT_WORK(&dev->reset_work, nvme_reset_workfn);
dev->pci_dev = pdev;
+ dev->intx_irq = pdev->irq;
pci_set_drvdata(pdev, dev);
result = nvme_set_instance(dev);
if (result)
@@ -2791,10 +2793,32 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
return result;
}
+static void nvme_async_shutdown(void *data, async_cookie_t cookie)
+{
+ struct nvme_dev *dev = data;
+ nvme_dev_shutdown(dev);
+ free_irq(dev->intx_irq, raw_nvmeq(dev, 0));
+}
+
static void nvme_shutdown(struct pci_dev *pdev)
{
struct nvme_dev *dev = pci_get_drvdata(pdev);
- nvme_dev_shutdown(dev);
+ struct nvme_queue *adminq = raw_nvmeq(dev, 0);
+ bool use_async = true;
+
+ /* MSI/MSI-x are disabled after returning from this function */
+ if (dev->pci_dev->msi_enabled || dev->pci_dev->msix_enabled) {
+ if (request_irq(dev->intx_irq, nvme_irq, IRQF_SHARED,
+ adminq->irqname, adminq))
+ use_async = false;
+ else
+ pci_intx(dev->pci_dev, 1);
+ }
+ if (!use_async)
+ nvme_dev_shutdown(dev);
+ else
+ async_schedule_domain(nvme_async_shutdown, dev,
+ &shutdown_domain);
}
static void nvme_remove(struct pci_dev *pdev)
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 1813cfd..3df7c48 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -80,6 +80,7 @@ struct nvme_dev {
unsigned queue_count;
unsigned online_queues;
unsigned max_qid;
+ unsigned intx_irq;
int q_depth;
u32 db_stride;
u32 ctrl_config;
--
1.7.10.4
prev parent reply other threads:[~2014-05-08 18:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 18:07 [PATCH 0/2] Asynchronous device shutdown Keith Busch
2014-05-08 18:07 ` [PATCH 1/2] driver-core: allow asynchronous " Keith Busch
2014-05-08 19:03 ` Greg KH
2014-05-08 18:07 ` Keith Busch [this message]
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=1399572454-30239-3-git-send-email-keith.busch@intel.com \
--to=keith.busch@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
/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