]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
nvme: honor RTD3 Entry Latency for shutdowns
authorMartin K. Petersen <martin.petersen@oracle.com>
Thu, 5 Oct 2017 20:09:50 +0000 (13:09 -0700)
committerChuck Anderson <chuck.anderson@oracle.com>
Mon, 23 Oct 2017 04:36:06 +0000 (21:36 -0700)
If an NVMe controller reports RTD3 Entry Latency larger than
shutdown_timeout, up to a maximum of 60 seconds, 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@oracle.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
[hch: removed do_div, made transition time local scope]
Signed-off-by: Christoph Hellwig <hch@lst.de>
(cherry picked from commit 07fbd32a6b215d8b2fc01ccc89622207b9b782fd)

Orabug: 26999048

Signed-off-by: Ashok Vairavan<ashok.vairavan@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h

index c34d816f6eb0a2a368031ec669243e05ba8fd756..92bfaa3f34ed36a49a457aa4c364d7ce849c4b14 100644 (file)
@@ -1014,7 +1014,7 @@ EXPORT_SYMBOL_GPL(nvme_enable_ctrl);
 
 int nvme_shutdown_ctrl(struct nvme_ctrl *ctrl)
 {
-       unsigned long timeout = SHUTDOWN_TIMEOUT + jiffies;
+       unsigned long timeout = jiffies + (ctrl->shutdown_timeout * HZ);
        u32 csts;
        int ret;
 
@@ -1126,6 +1126,20 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 
        nvme_set_queue_limits(ctrl, ctrl->admin_q);
 
+       if (id->rtd3e) {
+               /* us -> s */
+               u32 transition_time = le32_to_cpu(id->rtd3e) / 1000000;
+
+               ctrl->shutdown_timeout = clamp_t(unsigned int, transition_time,
+                                                shutdown_timeout, 60);
+
+               if (ctrl->shutdown_timeout != shutdown_timeout)
+                       dev_warn(ctrl->device,
+                                "Shutdown timeout set to %u seconds\n",
+                                ctrl->shutdown_timeout);
+       } else
+               ctrl->shutdown_timeout = shutdown_timeout;
+
        kfree(id);
        return 0;
 }
index 6a32e3e3b0c06b12aa393607ee7995eed0ccf081..2c7e04fcc871161d038b597df646b61745030f19 100644 (file)
@@ -122,6 +122,7 @@ struct nvme_ctrl {
        u8 event_limit;
        u8 vwc;
        u32 vs;
+       unsigned int shutdown_timeout;
        bool subsystem;
        unsigned long quirks;
        struct work_struct scan_work;