From: Andy Lutomirski Date: Thu, 29 Jun 2017 09:59:21 +0000 (+0800) Subject: nvme: Add nvme_core.force_apst to ignore the NO_APST quirk X-Git-Tag: Ubuntu-4.10.0-29.33~61 X-Git-Url: https://git.proxmox.com/?p=mirror_ubuntu-zesty-kernel.git;a=commitdiff_plain;h=4e7cd63b8e733ad663ae459c5a912fa29132309c nvme: Add nvme_core.force_apst to ignore the NO_APST quirk BugLink: https://bugs.launchpad.net/bugs/1699004 We're probably going to be stuck quirking APST off on an over-broad range of devices for 4.11. Let's make it easy to override the quirk for testing. Signed-off-by: Andy Lutomirski Reviewed-by: Christoph Hellwig Signed-off-by: Jens Axboe (backported from commit c35e30b4727b390ce7a6dd7ead31335320c2b83e) Signed-off-by: Kai-Heng Feng Acked-by: Seth Forshee Acked-by: Stefan Bader Signed-off-by: Thadeu Lima de Souza Cascardo --- diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0acb533e5069..cdda12bd1676 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -62,6 +62,10 @@ module_param(default_ps_max_latency_us, ulong, 0644); MODULE_PARM_DESC(default_ps_max_latency_us, "max power saving latency for new devices; use PM QOS to change per device"); +static bool force_apst; +module_param(force_apst, bool, 0644); +MODULE_PARM_DESC(force_apst, "allow APST for newly enumerated devices even if quirked off"); + static LIST_HEAD(nvme_ctrl_list); static DEFINE_SPINLOCK(dev_list_lock); @@ -1448,6 +1452,11 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) } } + if (force_apst && (ctrl->quirks & NVME_QUIRK_NO_DEEPEST_PS)) { + dev_warn(ctrl->dev, "forcibly allowing all power states due to nvme_core.force_apst -- use at your own risk\n"); + ctrl->quirks &= ~NVME_QUIRK_NO_DEEPEST_PS; + } + ctrl->vid = le16_to_cpu(id->vid); ctrl->oncs = le16_to_cpup(&id->oncs); atomic_set(&ctrl->abort_limit, id->acl + 1); @@ -1469,7 +1478,16 @@ int nvme_init_identify(struct nvme_ctrl *ctrl) ctrl->npss = id->npss; prev_apsta = ctrl->apsta; - ctrl->apsta = (ctrl->quirks & NVME_QUIRK_NO_APST) ? 0 : id->apsta; + if (ctrl->quirks & NVME_QUIRK_NO_APST) { + if (force_apst && id->apsta) { + dev_warn(ctrl->dev, "forcibly allowing APST due to nvme_core.force_apst -- use at your own risk\n"); + ctrl->apsta = 1; + } else { + ctrl->apsta = 0; + } + } else { + ctrl->apsta = id->apsta; + } memcpy(ctrl->psd, id->psd, sizeof(ctrl->psd)); if (ctrl->ops->is_fabrics) {