nvme: Add nvme_core.force_apst to ignore the NO_APST quirk
authorAndy Lutomirski <luto@kernel.org>
Fri, 21 Apr 2017 23:19:24 +0000 (16:19 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 25 Apr 2017 04:03:46 +0000 (22:03 -0600)
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 <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/nvme/host/core.c

index 3c9547b94541f1b94e5b662a9e1fab3b92cbf8a0..d5e0906262ead5dd9f202385d7ace81444c25a0f 100644 (file)
@@ -61,6 +61,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);
 
@@ -1562,6 +1566,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->oacs = le16_to_cpu(id->oacs);
        ctrl->vid = le16_to_cpu(id->vid);
        ctrl->oncs = le16_to_cpup(&id->oncs);
@@ -1584,7 +1593,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) {