public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Jon Hunter <jonathanh@nvidia.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Linux PCI <linux-pci@vger.kernel.org>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Kevin Xie <kevin.xie@starfivetech.com>,
	"linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>
Subject: Re: [PATCH v1] PM: sleep: core: Synchronize runtime PM status of parents and children
Date: Fri, 7 Feb 2025 17:26:30 +0100	[thread overview]
Message-ID: <Z6Y0NlW40yHTIlzm@hovoldconsulting.com> (raw)
In-Reply-To: <Z6YviAFD4Az3EIBa@hovoldconsulting.com>

On Fri, Feb 07, 2025 at 05:06:32PM +0100, Johan Hovold wrote:
> On Fri, Feb 07, 2025 at 04:41:18PM +0100, Rafael J. Wysocki wrote:
> > On Fri, Feb 7, 2025 at 3:45 PM Johan Hovold <johan@kernel.org> wrote:
> > > On Fri, Feb 07, 2025 at 02:50:29PM +0100, Johan Hovold wrote:
> 
> > > Ok, so the driver data is never set and runtime PM is never enabled for
> > > this simple bus device, which uses pm_runtime_force_suspend() for system
> > > sleep.
> > 
> > This is kind of confusing.  Why use pm_runtime_force_suspend() if
> > runtime PM is never enabled and cannot really work?
> 
> It's only done for some buses that this driver handles. The driver is
> buggy; I'm preparing a fix for it regardless of the correctness of the
> commit that now triggered this.

Hmm. The driver implementation is highly odd, but actually works as long
as the runtime PM status is left at 'suspended' (as
pm_runtime_force_resume() won't enable runtime PM unless it was enabled
before suspend).

So we'd strictly only need something like the below if we are going to
keep the set_active propagation.

Johan


diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c
index 5dea31769f9a..d8e029e7e53f 100644
--- a/drivers/bus/simple-pm-bus.c
+++ b/drivers/bus/simple-pm-bus.c
@@ -109,9 +109,29 @@ static int simple_pm_bus_runtime_resume(struct device *dev)
 	return 0;
 }
 
+static int simple_pm_bus_suspend(struct device *dev)
+{
+	struct simple_pm_bus *bus = dev_get_drvdata(dev);
+
+	if (!bus)
+		return 0;
+
+	return pm_runtime_force_suspend(dev);
+}
+
+static int simple_pm_bus_resume(struct device *dev)
+{
+	struct simple_pm_bus *bus = dev_get_drvdata(dev);
+
+	if (!bus)
+		return 0;
+
+	return pm_runtime_force_resume(dev);
+}
+
 static const struct dev_pm_ops simple_pm_bus_pm_ops = {
 	RUNTIME_PM_OPS(simple_pm_bus_runtime_suspend, simple_pm_bus_runtime_resume, NULL)
-	NOIRQ_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
+	NOIRQ_SYSTEM_SLEEP_PM_OPS(simple_pm_bus_suspend, simple_pm_bus_resume)
 };
 
 #define ONLY_BUS	((void *) 1) /* Match if the device is only a bus. */

  reply	other threads:[~2025-02-07 16:26 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-28 19:24 [PATCH v1] PM: sleep: core: Synchronize runtime PM status of parents and children Rafael J. Wysocki
2025-01-29  8:31 ` Johan Hovold
2025-01-29 11:52 ` Ulf Hansson
2025-01-29 15:55   ` Rafael J. Wysocki
2025-01-29 16:42     ` Ulf Hansson
2025-01-29 16:58       ` Rafael J. Wysocki
2025-01-30 11:11         ` Ulf Hansson
2025-01-30 13:19           ` Rafael J. Wysocki
2025-01-31 10:01             ` Ulf Hansson
2025-02-01 12:35               ` Rafael J. Wysocki
2025-02-03 12:12                 ` Ulf Hansson
2025-02-07 13:38 ` Jon Hunter
2025-02-07 13:50   ` Johan Hovold
2025-02-07 14:45     ` Johan Hovold
2025-02-07 15:41       ` Rafael J. Wysocki
2025-02-07 16:06         ` Johan Hovold
2025-02-07 16:26           ` Johan Hovold [this message]
2025-02-07 18:14             ` Rafael J. Wysocki
2025-02-08 12:10               ` Rafael J. Wysocki
2025-02-08 16:42                 ` Johan Hovold
2025-02-08 17:43                   ` Rafael J. Wysocki

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=Z6Y0NlW40yHTIlzm@hovoldconsulting.com \
    --to=johan@kernel.org \
    --cc=helgaas@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=kevin.xie@starfivetech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=stern@rowland.harvard.edu \
    --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