public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-pci: Shutdown the device if D3Cold is allowed by the user
@ 2024-11-18  8:23 Manivannan Sadhasivam
  2024-11-18 12:58 ` Christoph Hellwig
  2024-11-22 22:20 ` Bjorn Helgaas
  0 siblings, 2 replies; 47+ messages in thread
From: Manivannan Sadhasivam @ 2024-11-18  8:23 UTC (permalink / raw)
  To: kbusch, axboe, hch, sagi
  Cc: linux-nvme, linux-kernel, linux-pci, andersson, konradybcio,
	Manivannan Sadhasivam

PCI core allows users to configure the D3Cold state for each PCI device
through the sysfs attribute '/sys/bus/pci/devices/.../d3cold_allowed'. This
attribute sets the 'pci_dev:d3cold_allowed' flag and could be used by users
to allow/disallow the PCI devices to enter D3Cold during system suspend.

So make use of this flag in the NVMe driver to shutdown the NVMe device
during system suspend if the user has allowed D3Cold for the device.
Existing checks in the NVMe driver decide whether to shut down the device
(based on platform/device limitations), so use this flag as the last resort
to keep the existing behavior.

The default behavior of the 'pci_dev:d3cold_allowed' flag is to allow
D3Cold and the users can disallow it through sysfs if they want.

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
 drivers/nvme/host/pci.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 4b9fda0b1d9a..a4d4687854bf 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -3287,7 +3287,8 @@ static int nvme_suspend(struct device *dev)
 	 */
 	if (pm_suspend_via_firmware() || !ctrl->npss ||
 	    !pcie_aspm_enabled(pdev) ||
-	    (ndev->ctrl.quirks & NVME_QUIRK_SIMPLE_SUSPEND))
+	    (ndev->ctrl.quirks & NVME_QUIRK_SIMPLE_SUSPEND) ||
+	    pdev->d3cold_allowed)
 		return nvme_disable_prepare_reset(ndev, true);
 
 	nvme_start_freeze(ctrl);
-- 
2.25.1


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

end of thread, other threads:[~2025-01-03 11:49 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18  8:23 [PATCH] nvme-pci: Shutdown the device if D3Cold is allowed by the user Manivannan Sadhasivam
2024-11-18 12:58 ` Christoph Hellwig
2024-11-18 14:58   ` Manivannan Sadhasivam
2024-11-22 22:20 ` Bjorn Helgaas
2024-11-23  9:01   ` Manivannan Sadhasivam
2024-11-26 17:11     ` Bjorn Andersson
2024-11-27  5:49       ` Manivannan Sadhasivam
2024-12-05 23:29     ` Bjorn Helgaas
2024-12-06  1:49       ` Bjorn Helgaas
2024-12-09 13:36         ` Christoph Hellwig
2024-12-09 14:38           ` Manivannan Sadhasivam
2024-12-12  5:59             ` Christoph Hellwig
2024-12-12 12:21               ` Rafael J. Wysocki
2024-12-12 12:49                 ` Ulf Hansson
2024-12-12 15:13                   ` Christoph Hellwig
2024-12-13 14:35                     ` Rafael J. Wysocki
2024-12-14  6:30                       ` Manivannan Sadhasivam
2024-12-16 16:23                         ` Christoph Hellwig
2024-12-16 16:42                           ` Rafael J. Wysocki
2024-12-16 16:48                             ` Manivannan Sadhasivam
2024-12-16 17:28                               ` Rafael J. Wysocki
2024-12-16 17:39                                 ` Manivannan Sadhasivam
2024-12-16 19:10                                   ` Rafael J. Wysocki
2024-12-20 15:15                             ` Konrad Dybcio
2024-12-21  3:38                               ` Manivannan Sadhasivam
2024-12-21 11:17                                 ` Konrad Dybcio
2024-12-26 16:22                                   ` Manivannan Sadhasivam
2025-01-03  7:28                               ` Christoph Hellwig
2025-01-03 11:48                                 ` Konrad Dybcio
2024-12-16 16:24                         ` Rafael J. Wysocki
2024-12-16 17:11                           ` Manivannan Sadhasivam
2024-12-16 17:35                             ` Rafael J. Wysocki
2024-12-16 17:52                               ` Manivannan Sadhasivam
2024-12-16 19:34                                 ` Rafael J. Wysocki
2024-12-16 19:40                                   ` Keith Busch
2024-12-16 19:43                                     ` Rafael J. Wysocki
2024-12-17  5:26                                   ` manivannan.sadhasivam
2024-12-17 19:45                                     ` Rafael J. Wysocki
2024-12-19  8:02                                       ` Manivannan Sadhasivam
2024-12-19 12:45                                         ` Rafael J. Wysocki
2024-12-19 16:41                                           ` Ulf Hansson
2024-12-19 18:28                                             ` Rafael J. Wysocki
2025-01-03  7:26                                               ` Christoph Hellwig
2024-12-19  6:30                                 ` Christoph Hellwig
2024-12-19  8:03                                   ` Manivannan Sadhasivam
2024-12-09 14:43         ` Manivannan Sadhasivam
2024-12-09 14:57       ` Manivannan Sadhasivam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox