public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	kbusch@kernel.org, axboe@kernel.dk, sagi@grimberg.me,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, andersson@kernel.org,
	konradybcio@kernel.org, "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH] nvme-pci: Shutdown the device if D3Cold is allowed by the user
Date: Mon, 9 Dec 2024 20:08:21 +0530	[thread overview]
Message-ID: <20241209143821.m4dahsaqeydluyf3@thinkpad> (raw)
In-Reply-To: <20241209133606.GA18172@lst.de>

On Mon, Dec 09, 2024 at 02:36:06PM +0100, Christoph Hellwig wrote:
> On Thu, Dec 05, 2024 at 07:49:34PM -0600, Bjorn Helgaas wrote:
> > Oops, I think I got this part backwards.  The patch uses PCI PM if
> > d3cold_allowed is set, and it's set by default, so it does what you
> > need for the Qualcomm platform *without* user intervention.
> > 
> > But I guess using the flag allows users in other situations to force
> > use of NVMe power management by clearing d3cold_allowed via sysfs.
> > Does that mean some unspecified other platforms might only work
> > correctly with that user intervention?
> 
> Still seems awkward to overload fields like this.
> 
> The istory here is the the NVMe internal power states are significantly
> better for the SSDs.  It avoid shutting down the SSD frequently, which
> creates a lot of extra erase cycles and reduces life time.  It also
> prevents the SSD from performing maintainance operations while the host
> system is idle, which is the perfect time for them.  But the idea of
> putting all periphals into D3 is gaining a lot of ground because it
> makes the platform vendors life a lot simpler at the cost of others.

No, I disagree with the last comment. When the system goes to low power mode
(like S2R/hibernate), it *does* makes a lot of sense to put the devices into
D3Cold to save power. Using NVMe or other endpoint devices internal power states
only matters when the system is idle (which is not S2R/hibernate). This is what
ACPI is doing currently.

Then one might suggest to check the suspend state using
'pm_suspend_target_state' in device drivers and decide to keep the devices in
D3Cold. Unfortunately, it won't work for Qcom platforms as most of them (except
chromebooks) don't have S2R (a.k.a PSCI_SYSTEM_SUSPEND), but only S2Idle.

When it comes to non-Qcom platforms based on devicetree, they also cannot power
down the NVMe device during suspend (as they cannot satisfy existing checks in
nvme_suspend()).

The current reality is that most of the devicetree platforms *do* want to power
down the NVMe during suspend. Only when NVMe is used in an OS like Android, we
might not want to do so (that's something for future, but still a possibility). 

So this is how I ended up using the existing 'd3cold_allowed' attribute as it
allows the devices to be powered down by default and if the OS doesn't want to
do so, it can tweak the attribute from userspace (similar to UFS in Android).

The flexibility of this attribute is that it just acts as a hint for the device
drivers. If the device driver doesn't want to do D3Cold (when used as a wakeup
source etc...) it can still opt out (assuming that the platform would also honor
the wakeup capability of the device).

- Mani

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2024-12-09 14:38 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241209143821.m4dahsaqeydluyf3@thinkpad \
    --to=manivannan.sadhasivam@linaro.org \
    --cc=andersson@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=helgaas@kernel.org \
    --cc=kbusch@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sagi@grimberg.me \
    --cc=ulf.hansson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox