From ffee381d827ef9d56299babc4e0342619733ac33 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Fri, 10 Nov 2017 15:51:02 -0700 Subject: [PATCH] nvme: allow a minimum of 10 seconds for shutdown Some devices may report a RTD3E time that is shorter than their actual shutdown time in practice; force the timeout to be at least 10 seconds to allow for a reasonable amount of shutdown time. This doesn't add any extra delay for devices that do complete the shutdown process within their reported RTD3E time, since we will return as soon as the device reports that it is finished shutting down. Change-Id: I365e66ba6a938400be516df170bd3ff288810caf Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/386719 Reviewed-by: Changpeng Liu Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/nvme/nvme_ctrlr.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index b50f1be15b..0184afcc3c 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -504,15 +504,14 @@ nvme_ctrlr_shutdown(struct spdk_nvme_ctrlr *ctrlr) /* * The NVMe specification defines RTD3E to be the time between * setting SHN = 1 until the controller will set SHST = 10b. - * If the device doesn't report RTD3 entry latency, pick - * 5 seconds as a reasonable amount of time to + * If the device doesn't report RTD3 entry latency, or if it + * reports RTD3 entry latency less than 10 seconds, pick + * 10 seconds as a reasonable amount of time to * wait before proceeding. */ SPDK_DEBUGLOG(SPDK_TRACE_NVME, "RTD3E = %" PRIu32 " us\n", ctrlr->cdata.rtd3e); shutdown_timeout_ms = (ctrlr->cdata.rtd3e + 999) / 1000; - if (shutdown_timeout_ms == 0) { - shutdown_timeout_ms = 5000; - } + shutdown_timeout_ms = spdk_max(shutdown_timeout_ms, 10000); SPDK_DEBUGLOG(SPDK_TRACE_NVME, "shutdown timeout = %" PRIu32 " ms\n", shutdown_timeout_ms); do {