From: martin.petersen@oracle.com (Martin K. Petersen)
Subject: [PATCH] nvme: Honor RTD3 Entry Latency for shutdowns
Date: Wed, 16 Aug 2017 15:55:52 -0400 [thread overview]
Message-ID: <20170816195552.22492-1-martin.petersen@oracle.com> (raw)
If an NVMe controller reports RTD3 Entry Latency bigger than
shutdown_timeout, use that value to set the shutdown timer. Otherwise
fall back to the module parameter which defaults to 5 seconds.
Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>
---
drivers/nvme/host/core.c | 18 +++++++++++++++++-
drivers/nvme/host/nvme.h | 1 +
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b7dfbbeccb47..ed8f286f24bd 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1465,7 +1465,7 @@ EXPORT_SYMBOL_GPL(nvme_enable_ctrl);
int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl)
{
- unsigned long timeout = jiffies + (shutdown_timeout * HZ);
+ unsigned long timeout = jiffies + (ctrl->shutdown_timeout * HZ);
u32 csts;
int ret;
@@ -1833,6 +1833,22 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
ctrl->sgls = le32_to_cpu(id->sgls);
ctrl->kas = le16_to_cpu(id->kas);
+ if (ctrl->vs >= NVME_VS(1, 2, 0)) {
+ u32 transition_time = le32_to_cpu(id->rtd3e);
+
+ do_div(transition_time, 1000000); /* us -> s */
+
+ if (transition_time > shutdown_timeout) {
+ ctrl->shutdown_timeout = transition_time;
+ dev_warn(ctrl->device,
+ "Shutdown timeout set to %u seconds\n",
+ ctrl->shutdown_timeout);
+ }
+ }
+
+ if (!ctrl->shutdown_timeout)
+ ctrl->shutdown_timeout = shutdown_timeout;
+
ctrl->npss = id->npss;
ctrl->apsta = id->apsta;
prev_apst_enabled = ctrl->apst_enabled;
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h
index 2c8a02be46fd..9b959ee18cb6 100644
--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -162,6 +162,7 @@ struct nvme_ctrl {
u16 kas;
u8 npss;
u8 apsta;
+ unsigned int shutdown_timeout;
unsigned int kato;
bool subsystem;
unsigned long quirks;
--
2.13.0
next reply other threads:[~2017-08-16 19:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 19:55 Martin K. Petersen [this message]
2017-08-16 20:25 ` [PATCH] nvme: Honor RTD3 Entry Latency for shutdowns Scott Bauer
2017-08-16 20:49 ` Martin K. Petersen
2017-08-17 15:01 ` Keith Busch
2017-08-17 17:06 ` Martin K. Petersen
2017-08-17 17:42 ` Scott Bauer
2017-08-23 22:32 ` [PATCH v2] " Martin K. Petersen
2017-08-24 9:02 ` Christoph Hellwig
2017-08-25 2:26 ` Martin K. Petersen
2017-08-25 2:26 ` [PATCH v3] " Martin K. Petersen
2017-08-25 7:41 ` Christoph Hellwig
2017-08-25 14:15 ` Martin K. Petersen
2017-08-25 19:56 ` Keith Busch
2017-08-25 23:14 ` [PATCH v4] " Martin K. Petersen
2017-08-28 6:05 ` Sagi Grimberg
2017-08-28 14:22 ` Keith Busch
2017-08-25 23:16 ` [PATCH v3] " Martin K. Petersen
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=20170816195552.22492-1-martin.petersen@oracle.com \
--to=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.