All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: Avoid to go into d3cold if device can't use npss.
@ 2021-05-20  3:33 ` Koba Ko
  0 siblings, 0 replies; 30+ messages in thread
From: Koba Ko @ 2021-05-20  3:33 UTC (permalink / raw)
  To: Keith Busch, Jens Axboe, Christoph Hellwig, Sagi Grimberg,
	linux-nvme, linux-kernel, Henrik Juul Hansen

During suspend, if the device can't use npss, driver would put
controller to shutdown simply and let host to control power management.
After resume, host can't change power state of the closed controller
from D3cold to D0.
For these devices, just avoid to go deeper than d3hot.

Tested-by: Henrik Juul Hansen <hjhansen2020@gmail.com>
Signed-off-by: Koba Ko <koba.ko@canonical.com>
---
 drivers/nvme/host/pci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index a29b170701fc..caaf52051689 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -26,6 +26,7 @@
 #include <linux/io-64-nonatomic-hi-lo.h>
 #include <linux/sed-opal.h>
 #include <linux/pci-p2pdma.h>
+#include <linux/pm_runtime.h>
 
 #include "trace.h"
 #include "nvme.h"
@@ -2958,6 +2959,15 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	dev_info(dev->ctrl.device, "pci function %s\n", dev_name(&pdev->dev));
 
+	if (pm_suspend_via_firmware() || !dev->ctrl.npss ||
+	    !pcie_aspm_enabled(pdev) ||
+	    dev->nr_host_mem_descs ||
+	    (dev->ctrl.quirks & NVME_QUIRK_SIMPLE_SUSPEND)) {
+		pdev->d3cold_allowed = false;
+		pci_d3cold_disable(pdev);
+		pm_runtime_resume(&pdev->dev);
+	}
+
 	nvme_reset_ctrl(&dev->ctrl);
 	async_schedule(nvme_async_probe, dev);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2021-05-27 12:09 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20  3:33 [PATCH] nvme-pci: Avoid to go into d3cold if device can't use npss Koba Ko
2021-05-20  3:33 ` Koba Ko
2021-05-25  7:44 ` Christoph Hellwig
2021-05-25  7:44   ` Christoph Hellwig
2021-05-25 16:49   ` Kai-Heng Feng
2021-05-25 16:49     ` Kai-Heng Feng
2021-05-25 20:14   ` Bjorn Helgaas
2021-05-25 20:14     ` Bjorn Helgaas
2021-05-26  2:02   ` Koba Ko
2021-05-26  2:02     ` Koba Ko
2021-05-26  2:49     ` Keith Busch
2021-05-26  2:49       ` Keith Busch
2021-05-26 12:11       ` Kai-Heng Feng
2021-05-26 12:11         ` Kai-Heng Feng
2021-05-26 12:59         ` Christoph Hellwig
2021-05-26 12:59           ` Christoph Hellwig
2021-05-26 14:21           ` Kai-Heng Feng
2021-05-26 14:21             ` Kai-Heng Feng
2021-05-26 14:28             ` Christoph Hellwig
2021-05-26 14:28               ` Christoph Hellwig
2021-05-26 14:47               ` Kai-Heng Feng
2021-05-26 14:47                 ` Kai-Heng Feng
2021-05-26 15:06                 ` Bjorn Helgaas
2021-05-26 15:06                   ` Bjorn Helgaas
2021-05-26 16:24                   ` Kai-Heng Feng
2021-05-26 16:24                     ` Kai-Heng Feng
2021-05-27 11:40                     ` Christoph Hellwig
2021-05-27 11:40                       ` Christoph Hellwig
2021-05-27 12:08                       ` Kai-Heng Feng
2021-05-27 12:08                         ` Kai-Heng Feng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.