nvme: honor RTD3 Entry Latency for shutdowns
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>
This commit is contained in:
parent
5228b3280b
commit
07fbd32a6b
|
@ -1458,7 +1458,7 @@ EXPORT_SYMBOL_GPL(nvme_enable_ctrl);
|
||||||
|
|
||||||
int nvme_shutdown_ctrl(struct nvme_ctrl *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;
|
u32 csts;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1826,6 +1826,20 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
|
||||||
ctrl->sgls = le32_to_cpu(id->sgls);
|
ctrl->sgls = le32_to_cpu(id->sgls);
|
||||||
ctrl->kas = le16_to_cpu(id->kas);
|
ctrl->kas = le16_to_cpu(id->kas);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
ctrl->npss = id->npss;
|
ctrl->npss = id->npss;
|
||||||
ctrl->apsta = id->apsta;
|
ctrl->apsta = id->apsta;
|
||||||
prev_apst_enabled = ctrl->apst_enabled;
|
prev_apst_enabled = ctrl->apst_enabled;
|
||||||
|
|
|
@ -162,6 +162,7 @@ struct nvme_ctrl {
|
||||||
u16 kas;
|
u16 kas;
|
||||||
u8 npss;
|
u8 npss;
|
||||||
u8 apsta;
|
u8 apsta;
|
||||||
|
unsigned int shutdown_timeout;
|
||||||
unsigned int kato;
|
unsigned int kato;
|
||||||
bool subsystem;
|
bool subsystem;
|
||||||
unsigned long quirks;
|
unsigned long quirks;
|
||||||
|
|
Loading…
Reference in New Issue