Skip to contentSkip to conversation

nvme: do not try to reconfigure APST when the controller is not live

PATCH In review Christoph Hellwig 3 participants 4 messages Apr 9, 2021 – May 1, 2021 NVMe

lore
Share & tools
lore

Christoph Hellwig

author maintainer
#0 lore raw

PATCH 1/1 nvme: do not try to reconfigure APST when the controller is not live

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")
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -1
index 63a1e6cc27acab..f3c7b1cb2c7c8c 100644
@@ -2740,7 +2740,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);
 	}
 }
 
Signature · 7 lines
2.30.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme
author maintainer
#1 lore raw

ping?

Quoted 34 lines · Christoph Hellwig

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")
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -1
index 63a1e6cc27acab..f3c7b1cb2c7c8c 100644
@@ -2740,7 +2740,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);
 	}
 }
 
Signature · 7 lines
2.30.1


_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

---end quoted text---

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

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")

Looks good.

Quoted 21 lines
---
 drivers/nvme/host/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +2 -1
index 63a1e6cc27acab..f3c7b1cb2c7c8c 100644
@@ -2740,7 +2740,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);
 	}
 }
 
Signature · 1 line
2.30.1

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme

Reviewed-by on v1 1/1
#3 lore raw
In reply to Christoph Hellwig
Quoted 18 lines · Christoph Hellwig

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")
---
  drivers/nvme/host/core.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/nvme/host/core.c +0 -0
index 63a1e6cc27acab..f3c7b1cb2c7c8c 100644

drivers/nvme/host/core.c static void nvme_set_latency_tolerance(struct device *dev, s32 val) · line 2747

Quoted 9 lines
drivers/nvme/host/core.c +2 -1
@@ -2740,7 +2740,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);
  	}
  }
 

Cheers,

Hannes

Signature · 9 lines
Dr. Hannes Reinecke                Kernel Storage Architect
[email protected]                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

_______________________________________________
Linux-nvme mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-nvme