nvme: do not try to reconfigure APST when the controller is not live
authorChristoph Hellwig <hch@lst.de>
Fri, 9 Apr 2021 09:46:12 +0000 (11:46 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 21 Apr 2021 17:13:16 +0000 (19:13 +0200)
Do not call nvme_configure_apst when the controller is not live, given
that nvme_configure_apst will fail due the lack of an admin queue when
the controller is being torn down and nvme_set_latency_tolerance is
called from dev_pm_qos_hide_latency_tolerance.

Fixes: 510a405d945b("nvme: fix memory leak for power latency tolerance")
Reported-by: Peng Liu <liupeng17@lenovo.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/host/core.c

index d6fd447..11d343c 100644 (file)
@@ -2321,7 +2321,8 @@ static void nvme_set_latency_tolerance(struct device *dev, s32 val)
 
        if (ctrl->ps_max_latency_us != latency) {
                ctrl->ps_max_latency_us = latency;
-               nvme_configure_apst(ctrl);
+               if (ctrl->state == NVME_CTRL_LIVE)
+                       nvme_configure_apst(ctrl);
        }
 }