Linux Power Management development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Raag Jadav <raag.jadav@intel.com>
Cc: bhelgaas@google.com, jarkko.nikula@linux.intel.com,
	mika.westerberg@linux.intel.com,
	andriy.shevchenko@linux.intel.com,
	stanislaw.gruszka@linux.intel.com, lukas@wunner.de,
	rafael@kernel.org, ilpo.jarvinen@linux.intel.com,
	linux-pci@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	sashal@kernel.org
Subject: Re: [PATCH v2] PCI / PM: Really allow runtime PM without callback functions
Date: Thu, 29 Feb 2024 16:00:08 -0600	[thread overview]
Message-ID: <20240229220008.GA364904@bhelgaas> (raw)
In-Reply-To: <20240227062648.16579-1-raag.jadav@intel.com>

On Tue, Feb 27, 2024 at 11:56:48AM +0530, Raag Jadav wrote:
> Commit c5eb1190074c ("PCI / PM: Allow runtime PM without callback
> functions") tried to eliminate the need for runtime PM callbacks by
> modifying pci_pm_runtime_suspend() and pci_pm_runtime_resume(), but
> didn't modify pci_pm_runtime_idle() with relevant changes, which still
> returns -ENOSYS if the driver supplies no runtime PM callbacks.
> 
> Modify pci_pm_runtime_idle() such that it allows PCI device power state
> transitions without runtime PM callbacks and complete the original
> intention of commit c5eb1190074c ("PCI / PM: Allow runtime PM without
> callback functions").
> 
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> Acked-by: Rafael J. Wysocki <rafael@kernel.org>
> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>

Applied to pci/pm for v6.9, thanks!

I updated the commit log to try to clarify which drivers would be
affected.  Now that I worked through those details, I see that it was
all there from the beginning and it just took a long time to sink into
my head:

    PCI/PM: Allow runtime PM with no PM callbacks at all

    Commit c5eb1190074c ("PCI / PM: Allow runtime PM without callback
    functions") eliminated the need for PM callbacks in
    pci_pm_runtime_suspend() and pci_pm_runtime_resume(), but
    didn't do the same for pci_pm_runtime_idle().

    Therefore, runtime suspend worked as long as the driver implemented at
    least one PM callback.  But if the driver doesn't implement any PM
    callbacks at all (driver->pm is NULL), pci_pm_runtime_idle() returned
    -ENOSYS, which prevented runtime suspend.

    Modify pci_pm_runtime_idle() to allow PCI device power state transitions
    without runtime PM callbacks and complete the original intention of commit
    c5eb1190074c ("PCI / PM: Allow runtime PM without callback functions").

Bjorn

> ---
> 
> This is not marked for linux-stable for the need of extensive testing
> and can be backported after a few releases if no issues are reported.
> 
> Changes since v1:
> - Update commit message and tags
> 
>  drivers/pci/pci-driver.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index 51ec9e7e784f..bb7f6775b350 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -1382,10 +1382,7 @@ static int pci_pm_runtime_idle(struct device *dev)
>  	if (!pci_dev->driver)
>  		return 0;
>  
> -	if (!pm)
> -		return -ENOSYS;
> -
> -	if (pm->runtime_idle)
> +	if (pm && pm->runtime_idle)
>  		return pm->runtime_idle(dev);
>  
>  	return 0;
> -- 
> 2.35.3
> 

      reply	other threads:[~2024-02-29 22:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  6:26 [PATCH v2] PCI / PM: Really allow runtime PM without callback functions Raag Jadav
2024-02-29 22:00 ` Bjorn Helgaas [this message]

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=20240229220008.GA364904@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mika.westerberg@linux.intel.com \
    --cc=raag.jadav@intel.com \
    --cc=rafael@kernel.org \
    --cc=sashal@kernel.org \
    --cc=stanislaw.gruszka@linux.intel.com \
    /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