mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Csókás Bence" <csokas.bence@prolan.hu>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Varshini Rajendran" <varshini.rajendran@microchip.com>,
	Tudor Ambarus <tudor.ambarus@linaro.org>,
	Mark Brown <broonie@kernel.org>, <linux-spi@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	"Len Brown" <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Danilo Krummrich <dakr@kernel.org>,
	"Alexander Dahl" <ada@thorsis.com>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>,
	Pavel Machek <pavel@kernel.org>
Subject: Re: [PATCH v5 1/2] pm: runtime: Add new devm functions
Date: Thu, 27 Mar 2025 10:02:24 +0100	[thread overview]
Message-ID: <3e6d7071-1ba9-484c-9dcb-c5da6ad1ffe3@prolan.hu> (raw)
In-Reply-To: <CAJZ5v0hJZBxU6SSq9C8gp2peETFWu0jbhrM82B5GvQkVXPR+9Q@mail.gmail.com>

Hi,

On 2025. 03. 26. 18:38, Rafael J. Wysocki wrote:
> I said I didn't like it and I'm still not liking it.

You didn't really elaborate further, but now I'm glad I could understand 
your dislike.

> The problem is that the primary role of pm_runtime_set_active() is to
> prepare the device for enabling runtime PM, so in the majority of
> cases it should be followed by pm_runtime_enable().  It is also not
> always necessary to call pm_runtime_set_suspended() after disabling
> runtime PM for a device, like when the device has been
> runtime-suspended before disabling runtime PM for it.  This is not
> like releasing a resource that has been allocated and using devm for
> it in the above way is at least questionable.
> 
> Now, there is a reason why calling pm_runtime_set_suspended() on a
> device after disabling runtime PM for it is a good idea at all.
> Namely, disabling runtime PM alone does not release the device's
> suppliers or its parent, so if you want to release them after
> disabling runtime PM for the device, you need to do something more.
> I'm thinking that this is a  mistake in the design of the runtime PM
> core.

Well, this is the order in which the original driver worked before 
anyways. As a quick fix, would it work if we created a devm function 
that would pm_runtime_set_active(), immediately followed by 
pm_runtime_enable(), and on cleanup it would pm_runtime_set_suspended() 
followed by pm_runtime_disable_action() (i.e. 
pm_runtime_dont_use_autosuspend() and pm_runtime_disable())?

> If there were functions like pm_runtime_enable_in_state() (taking an
> additional state argument and acquiring all of the necessary
> references on the parent and suppliers of the target device) and
> pm_runtime_disable_and_forget() (that in addition to disabling runtime
> PM would drop the references acquired by the former), then it would
> make a perfect sense to provide a devm variant of
> pm_runtime_enable_in_state() with the cleanup action pointing to
> pm_runtime_disable_and_forget().
> 
> If this helps, I can do some work on providing
> pm_runtime_enable_in_state() and pm_runtime_disable_and_forget() or
> equivalent.

I mean sure, if that's something you want to work on, but it sounds like 
it would entail much more work, plus it wouldn't be easy to backport it 
to 6.14.y stable later.

Bence


  reply	other threads:[~2025-03-27  9:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17  9:34 [PATCH v5 0/2] Add more devm_ functions to fix PM imbalance in spi/atmel-quadspi.c Bence Csókás
2025-03-17  9:34 ` [PATCH v5 1/2] pm: runtime: Add new devm functions Bence Csókás
2025-03-26 17:38   ` Rafael J. Wysocki
2025-03-27  9:02     ` Csókás Bence [this message]
2025-03-27 11:08       ` Rafael J. Wysocki
2025-03-27 13:24         ` Csókás Bence
2025-03-27 14:14           ` Rafael J. Wysocki
2025-03-27 16:11             ` Csókás Bence
2025-03-27 16:45               ` Rafael J. Wysocki
2025-03-17  9:34 ` [PATCH v5 2/2] spi: atmel-quadspi: Fix unbalanced pm_runtime by using devm_ API Bence Csókás

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=3e6d7071-1ba9-484c-9dcb-c5da6ad1ffe3@prolan.hu \
    --to=csokas.bence@prolan.hu \
    --cc=ada@thorsis.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=broonie@kernel.org \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pavel@kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rafael@kernel.org \
    --cc=tudor.ambarus@linaro.org \
    --cc=varshini.rajendran@microchip.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

all inboxes | Powered by JetHome®