From: Michael Kelley <mikelley@microsoft.com>
To: kbusch@kernel.org, axboe@fb.com, hch@lst.de, sagi@grimberg.me,
linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: mikelley@microsoft.com, caroline.subramoney@microsoft.com,
riwurd@microsoft.com, nathan.obr@microsoft.com
Subject: [PATCH v3 1/2] nvme-pci: move nvme_should_reset() to core code
Date: Mon, 6 Jun 2022 17:15:14 -0700 [thread overview]
Message-ID: <1654560915-22449-1-git-send-email-mikelley@microsoft.com> (raw)
Move nvme_should_reset() to core code so it fits with a subsequent
core code patch. Tweak the interface to take a nvme_ctrl argument instead
of nvme_dev, and fixup the one reference. No functional change.
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
---
Changes since v2: None
drivers/nvme/host/core.c | 19 +++++++++++++++++++
drivers/nvme/host/nvme.h | 1 +
drivers/nvme/host/pci.c | 27 +--------------------------
3 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 72f7c95..ea9ed04 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -171,6 +171,25 @@ static inline void nvme_stop_failfast_work(struct nvme_ctrl *ctrl)
clear_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags);
}
+bool nvme_should_reset(struct nvme_ctrl *ctrl, u32 csts)
+{
+ /* If there is a reset/reinit ongoing, we shouldn't reset again. */
+ switch (ctrl->state) {
+ case NVME_CTRL_RESETTING:
+ case NVME_CTRL_CONNECTING:
+ return false;
+ default:
+ break;
+ }
+
+ /*
+ * We shouldn't reset unless the controller is on fatal error state
+ * or if we lost the communication with it.
+ */
+ return (csts & NVME_CSTS_CFS) ||
+ (ctrl->subsystem && (csts & NVME_CSTS_NSSRO));
+}
+EXPORT_SYMBOL_GPL(nvme_should_reset);
int nvme_reset_ctrl(struct nvme_ctrl *ctrl)
{
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 9b72b6e..0d7e9ac 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -762,6 +762,7 @@ int nvme_get_features(struct nvme_ctrl *dev, unsigned int fid,
u32 *result);
int nvme_set_queue_count(struct nvme_ctrl *ctrl, int *count);
void nvme_stop_keep_alive(struct nvme_ctrl *ctrl);
+bool nvme_should_reset(struct nvme_ctrl *ctrl, u32 csts);
int nvme_reset_ctrl(struct nvme_ctrl *ctrl);
int nvme_reset_ctrl_sync(struct nvme_ctrl *ctrl);
int nvme_try_sched_reset(struct nvme_ctrl *ctrl);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 5a98a7d..c57023d 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1293,31 +1293,6 @@ static void abort_endio(struct request *req, blk_status_t error)
blk_mq_free_request(req);
}
-static bool nvme_should_reset(struct nvme_dev *dev, u32 csts)
-{
- /* If true, indicates loss of adapter communication, possibly by a
- * NVMe Subsystem reset.
- */
- bool nssro = dev->subsystem && (csts & NVME_CSTS_NSSRO);
-
- /* If there is a reset/reinit ongoing, we shouldn't reset again. */
- switch (dev->ctrl.state) {
- case NVME_CTRL_RESETTING:
- case NVME_CTRL_CONNECTING:
- return false;
- default:
- break;
- }
-
- /* We shouldn't reset unless the controller is on fatal error state
- * _or_ if we lost the communication with it.
- */
- if (!(csts & NVME_CSTS_CFS) && !nssro)
- return false;
-
- return true;
-}
-
static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)
{
/* Read a config register to help see what died. */
@@ -1355,7 +1330,7 @@ static enum blk_eh_timer_return nvme_timeout(struct request *req, bool reserved)
/*
* Reset immediately if the controller is failed
*/
- if (nvme_should_reset(dev, csts)) {
+ if (nvme_should_reset(&dev->ctrl, csts)) {
nvme_warn_reset(dev, csts);
nvme_dev_disable(dev, false);
nvme_reset_ctrl(&dev->ctrl);
--
1.8.3.1
next reply other threads:[~2022-06-07 0:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 0:15 Michael Kelley [this message]
2022-06-07 0:15 ` [PATCH v3 2/2] nvme: handle persistent internal error AER from NVMe controller Michael Kelley
2022-06-07 10:35 ` Christoph Hellwig
2022-06-08 3:59 ` Michael Kelley (LINUX)
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=1654560915-22449-1-git-send-email-mikelley@microsoft.com \
--to=mikelley@microsoft.com \
--cc=axboe@fb.com \
--cc=caroline.subramoney@microsoft.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nathan.obr@microsoft.com \
--cc=riwurd@microsoft.com \
--cc=sagi@grimberg.me \
/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