]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
nvme: explicitly disable APST on quirked devices
authorKai-Heng Feng <kai.heng.feng@canonical.com>
Thu, 29 Jun 2017 09:59:22 +0000 (17:59 +0800)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 14 Jul 2017 13:24:24 +0000 (10:24 -0300)
BugLink: https://bugs.launchpad.net/bugs/1699004
A user reports APST is enabled, even when the NVMe is quirked or with
option "default_ps_max_latency_us=0".

The current logic will not set APST if the device is quirked. But the
NVMe in question will enable APST automatically.

Separate the logic "apst is supported" and "to enable apst", so we can
use the latter one to explicitly disable APST at initialiaztion.

BugLink: https://bugs.launchpad.net/bugs/1699004
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Keith Busch <keith.busch@intel.com>
(backported from commit 76a5af841755a0427229a6a77ca83781d61e5b2a)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
drivers/nvme/host/core.c
drivers/nvme/host/nvme.h

index cdda12bd1676294e27c7261731443a77573d6b9c..c50e8cf92c8b535a801b98747436652b68b10e74 100644 (file)
@@ -1246,7 +1246,7 @@ static void nvme_configure_apst(struct nvme_ctrl *ctrl)
        if (!table)
                return;
 
-       if (ctrl->ps_max_latency_us == 0) {
+       if (!ctrl->apst_enabled || ctrl->ps_max_latency_us == 0) {
                /* Turn off APST. */
                apste = 0;
                dev_dbg(ctrl->device, "APST disabled\n");
@@ -1410,7 +1410,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
        u64 cap;
        int ret, page_shift;
        u32 max_hw_sectors;
-       u8 prev_apsta;
+       bool prev_apst_enabled;
 
        ret = ctrl->ops->reg_read32(ctrl, NVME_REG_VS, &ctrl->vs);
        if (ret) {
@@ -1477,16 +1477,17 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
        ctrl->kas = le16_to_cpu(id->kas);
 
        ctrl->npss = id->npss;
-       prev_apsta = ctrl->apsta;
+       ctrl->apsta = id->apsta;
+       prev_apst_enabled = ctrl->apst_enabled;
        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;
+                       dev_warn(ctrl->device, "forcibly allowing APST due to nvme_core.force_apst -- use at your own risk\n");
+                       ctrl->apst_enabled = true;
                } else {
-                       ctrl->apsta = 0;
+                       ctrl->apst_enabled = false;
                }
        } else {
-               ctrl->apsta = id->apsta;
+               ctrl->apst_enabled = id->apsta;
        }
        memcpy(ctrl->psd, id->psd, sizeof(ctrl->psd));
 
@@ -1514,9 +1515,9 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 
        kfree(id);
 
-       if (ctrl->apsta && !prev_apsta)
+       if (ctrl->apst_enabled && !prev_apst_enabled)
                dev_pm_qos_expose_latency_tolerance(ctrl->device);
-       else if (!ctrl->apsta && prev_apsta)
+       else if (!ctrl->apst_enabled && prev_apst_enabled)
                dev_pm_qos_hide_latency_tolerance(ctrl->device);
 
        nvme_configure_apst(ctrl);
index 6ace64f855f473df62a3fa8e156a3d8b40626fe0..7596ae072b5c578d1935d98f838c8d6331a22a5b 100644 (file)
@@ -166,6 +166,7 @@ struct nvme_ctrl {
 
        /* Power saving configuration */
        u64 ps_max_latency_us;
+       bool apst_enabled;
 
        /* Fabrics only */
        u16 sqsize;