From: Keith Busch <keith.busch@intel.com>
To: linux-pci@vger.kernel.org, alex.williamson@redhat.com,
bhelgaas@google.com
Cc: Keith Busch <keith.busch@intel.com>
Subject: [PATCHv2 2/2] NVMe: Implement pci reset callback
Date: Mon, 13 Jan 2014 15:26:28 -0700 [thread overview]
Message-ID: <1389651988-27392-3-git-send-email-keith.busch@intel.com> (raw)
In-Reply-To: <1389651988-27392-1-git-send-email-keith.busch@intel.com>
Initiates nvme controller reset sequence when pci layer notifies of slot
reset. The driver's slot_reset handling is skipped if the nvme polling
kthread happened to try accessing a device register while the reset was in
progress, which would have scheduled the nvme device to be reset anyway.
Signed-off-by: Keith Busch <keith.busch@intel.com>
---
drivers/block/nvme-core.c | 36 ++++++++++++++++++++++++++++++++++--
include/linux/nvme.h | 1 +
2 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index b59a93a..1f5c18a 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -1750,6 +1750,7 @@ static int nvme_kthread(void *data)
dev->initialized) {
if (work_busy(&dev->reset_work))
continue;
+ dev->reset = 1;
list_del_init(&dev->node);
dev_warn(&dev->pci_dev->dev,
"Failed status, reset controller\n");
@@ -2088,6 +2089,7 @@ static int nvme_dev_map(struct nvme_dev *dev)
}
dev->db_stride = 1 << NVME_CAP_STRIDE(readq(&dev->bar->cap));
dev->dbs = ((void __iomem *)dev->bar) + 4096;
+ dev->reset = 0;
return 0;
@@ -2265,7 +2267,10 @@ static void nvme_dev_shutdown(struct nvme_dev *dev)
list_del_init(&dev->node);
spin_unlock(&dev_list_lock);
- if (!dev->bar || (dev->bar && readl(&dev->bar->csts) == -1)) {
+ if (!dev->bar || (dev->bar && readl(&dev->bar->csts) == -1) ||
+ dev->reset) {
+ if (dev->bar)
+ nvme_shutdown_ctrl(dev);
for (i = dev->queue_count - 1; i >= 0; i--) {
struct nvme_queue *nvmeq = dev->queues[i];
nvme_suspend_queue(nvmeq);
@@ -2575,7 +2580,6 @@ static void nvme_remove(struct pci_dev *pdev)
#define nvme_error_detected NULL
#define nvme_dump_registers NULL
#define nvme_link_reset NULL
-#define nvme_slot_reset NULL
#define nvme_error_resume NULL
static int nvme_suspend(struct device *dev)
@@ -2599,6 +2603,34 @@ static int nvme_resume(struct device *dev)
return 0;
}
+
+/**
+ * nvme_slot_reset - handle nvme device that has been reset
+ * @pdev: pci device that has been through a pci slot or function reset
+ *
+ * Called by pci error recovery. We assume the device is in a state requiring
+ * initialization, so set the device reset flag first to prevent wasting time
+ * taking the controller offline with admin commands that we expect to timeout.
+ */
+static pci_ers_result_t nvme_slot_reset(struct pci_dev *pdev)
+{
+ struct nvme_dev *dev = pci_get_drvdata(pdev);
+
+ spin_lock(&dev_list_lock);
+ if (!work_busy(&dev->reset_work)) {
+ list_del_init(&dev->node);
+ dev->reset = 1;
+ } else {
+ spin_unlock(&dev_list_lock);
+ return PCI_ERS_RESULT_RECOVERED;
+ }
+ spin_unlock(&dev_list_lock);
+
+ nvme_dev_reset(dev);
+ return dev->initialized ? PCI_ERS_RESULT_RECOVERED :
+ PCI_ERS_RESULT_DISCONNECT;
+}
+
static SIMPLE_DEV_PM_OPS(nvme_dev_pm_ops, nvme_suspend, nvme_resume);
static const struct pci_error_handlers nvme_err_handler = {
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index 69ae03f..febce6f 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -97,6 +97,7 @@ struct nvme_dev {
u16 oncs;
u16 abort_limit;
u8 initialized;
+ u8 reset;
};
/*
--
1.7.10.4
next prev parent reply other threads:[~2014-01-13 22:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-13 22:26 [PATCHv2 0/2] PCI: driver function reset notification Keith Busch
2014-01-13 22:26 ` [PATCHv2 1/2] PCI: call pci reset callback to pci_driver on FLR Keith Busch
2014-01-13 22:26 ` Keith Busch [this message]
2014-01-16 18:49 ` [PATCHv2 0/2] PCI: driver function reset notification Bjorn Helgaas
2014-01-16 19:10 ` Alex Williamson
2014-01-16 20:38 ` Keith Busch
2014-01-17 17:26 ` Bjorn Helgaas
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=1389651988-27392-3-git-send-email-keith.busch@intel.com \
--to=keith.busch@intel.com \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).