From: Jeremy Allison <jallison@ciq.com>
To: jallison@ciq.com, jra@samba.org, tansuresh@google.com,
hch@lst.de, gregkh@linuxfoundation.org, rafael@kernel.org,
bhelgaas@google.com, sagi@grimberg.me, djeffery@redhat.com
Cc: linux-nvme@lists.infradead.org
Subject: [PATCH 4/5] nvme: Add a new exported function nvme_ctrl_shutdown_start()
Date: Wed, 7 Feb 2024 13:40:43 -0800 [thread overview]
Message-ID: <20240207214044.2374295-5-jallison@ciq.com> (raw)
In-Reply-To: <20240207214044.2374295-1-jallison@ciq.com>
Sets the shutdown bit but doesn't wait for ready.
Use from nvme_disable_ctrl(). Export nvme_wait_ready()
so we can call it from drivers/nvme/host/pci.c.
Signed-off-by: Jeremy Allison <jallison@ciq.com>
---
drivers/nvme/host/core.c | 22 ++++++++++++++++------
drivers/nvme/host/nvme.h | 3 +++
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 60537c9224bf..b7695f472fab 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2260,7 +2260,7 @@ const struct block_device_operations nvme_bdev_ops = {
.pr_ops = &nvme_pr_ops,
};
-static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
+int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
u32 timeout, const char *op)
{
unsigned long timeout_jiffies = jiffies + timeout * HZ;
@@ -2286,18 +2286,28 @@ static int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
return ret;
}
+EXPORT_SYMBOL_GPL(nvme_wait_ready);
+
+int nvme_ctrl_shutdown_start(struct nvme_ctrl *ctrl)
+{
+ ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
+ ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;
+ return ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config);
+}
+EXPORT_SYMBOL_GPL(nvme_ctrl_shutdown_start);
int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown)
{
int ret;
- ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
- if (shutdown)
- ctrl->ctrl_config |= NVME_CC_SHN_NORMAL;
- else
+ if (shutdown) {
+ ret = nvme_ctrl_shutdown_start(ctrl);
+ } else {
+ ctrl->ctrl_config &= ~NVME_CC_SHN_MASK;
ctrl->ctrl_config &= ~NVME_CC_ENABLE;
+ ret = ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config);
+ }
- ret = ctrl->ops->reg_write32(ctrl, NVME_REG_CC, ctrl->ctrl_config);
if (ret)
return ret;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 7b87763e2f8a..f52cb3d1d9c7 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -759,6 +759,9 @@ blk_status_t nvme_host_path_error(struct request *req);
bool nvme_cancel_request(struct request *req, void *data);
void nvme_cancel_tagset(struct nvme_ctrl *ctrl);
void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl);
+int nvme_wait_ready(struct nvme_ctrl *ctrl, u32 mask, u32 val,
+ u32 timeout, const char *op);
+int nvme_ctrl_shutdown_start(struct nvme_ctrl *ctrl);
bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl,
enum nvme_ctrl_state new_state);
int nvme_disable_ctrl(struct nvme_ctrl *ctrl, bool shutdown);
--
2.39.3
next prev parent reply other threads:[~2024-02-07 21:41 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-07 21:40 Make NVME shutdown two-pass - Version 6 Jeremy Allison
2024-02-07 21:40 ` [PATCH 1/5] driver core: Support two-pass driver shutdown Jeremy Allison
2024-02-07 21:40 ` [PATCH 2/5] PCI: Support two-pass shutdown Jeremy Allison
2024-02-07 21:59 ` Bjorn Helgaas
2024-02-07 22:02 ` Jeremy Allison
2024-02-07 21:40 ` [PATCH 3/5] nvme: Change 'bool shutdown' to an enum shutdown_type in nvme_dev_disable() Jeremy Allison
2024-02-12 7:01 ` Christoph Hellwig
2024-02-07 21:40 ` Jeremy Allison [this message]
2024-02-12 7:07 ` [PATCH 4/5] nvme: Add a new exported function nvme_ctrl_shutdown_start() Christoph Hellwig
2024-02-07 21:40 ` [PATCH 5/5] nvme: Add two-pass shutdown support Jeremy Allison
2024-02-12 7:08 ` Christoph Hellwig
2024-02-07 22:00 ` Make NVME shutdown two-pass - Version 6 Bjorn Helgaas
2024-02-07 22:03 ` Jeremy Allison
2024-02-08 18:02 ` David Jeffery
2024-02-08 18:28 ` Jeremy Allison
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=20240207214044.2374295-5-jallison@ciq.com \
--to=jallison@ciq.com \
--cc=bhelgaas@google.com \
--cc=djeffery@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=jra@samba.org \
--cc=linux-nvme@lists.infradead.org \
--cc=rafael@kernel.org \
--cc=sagi@grimberg.me \
--cc=tansuresh@google.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