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 17:11:29 +0100 [thread overview]
Message-ID: <bcf363db-8fff-4fb1-b29e-300f7b8bc090@prolan.hu> (raw)
In-Reply-To: <CAJZ5v0iS20uPhqNOnkj36rTBGQF3fecF6Hq4JU4=wz4pSzrFyg@mail.gmail.com>
Hi,
On 2025. 03. 27. 15:14, Rafael J. Wysocki wrote:
> /-- devm_pm_runtime_get_noresume()
> | /-- devm_{pm_runtime_set_active() + pm_runtime_enable() (in this order)}
> | | pm_runtime_use_autosuspend()
> | |
> | | Note that the device cannot be suspended here unless its
> runtime PM usage
> | | counter is dropped, in which it would need to be bumped up
> again later to
> | | retain the balance.
> | |
> | \-> pm_runtime_disable() + pm_runtime_set_suspended() (in this order)
> \-> pm_runtime_put_noidle()
Ah, so basically what I've done originally, just calling
`devm_pm_runtime_get_noresume()` _first_ instead of _last_, right?
> And pm_runtime_dont_use_autosuspend() is not really necessary after
> disabling runtime PM.
It was done this way in devm_pm_runtime_enable() already, see commit
b4060db9251f ("PM: runtime: Have devm_pm_runtime_enable() handle
pm_runtime_dont_use_autosuspend()"). I didn't change anything
behaviourally there.
> Also, I think that the driver could be fixed without introducing the
> new devm_ stuff which would be way simpler, so why don't you do that
> and then think about devm_?
Sure, I could quick-fix this, go through all the possible error paths
and whatnot and ref-count in my head, but it doesn't fix the underlying
problem: in order to properly use PM, you have to do a bunch of calls in
some set order, then undo them in reverse order on error and remove --
exactly the thing devm was designed for, and exactly the thing where
it's easy for a human to forget one case by accident. Thus I prefer to
use the *real* solution, devm.
Bence
next prev parent reply other threads:[~2025-03-27 16:11 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
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 [this message]
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=bcf363db-8fff-4fb1-b29e-300f7b8bc090@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®