From: Takashi Iwai <tiwai@suse.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>, Linux PM <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
Alex Williamson <alex.williamson@redhat.com>,
Bjorn Helgaas <helgaas@kernel.org>,
Zhang Qilong <zhangqilong3@huawei.com>,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH v2 1/3] PM: runtime: Add auto-cleanup macros for "resume and get" operations
Date: Mon, 22 Sep 2025 15:32:36 +0200 [thread overview]
Message-ID: <87348eobnv.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAJZ5v0hSBDg4fD7Gy6yEX31xO-3USJG_jFps71BRJJ2f0Oh90A@mail.gmail.com>
On Mon, 22 Sep 2025 14:50:32 +0200,
Rafael J. Wysocki wrote:
>
> On Mon, Sep 22, 2025 at 10:38 AM Takashi Iwai <tiwai@suse.de> wrote:
> >
> > On Sat, 20 Sep 2025 12:54:58 +0200,
> > Rafael J. Wysocki wrote:
> > >
> > > From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> > >
> > > It is generally useful to be able to automatically drop a device's
> > > runtime PM usage counter incremented by runtime PM operations that
> > > resume a device and bump up its usage counter [1].
> > >
> > > To that end, add DEFINE_CLASS() macros allowing pm_runtime_put()
> > > and pm_runtime_put_autosuspend() to be used for the auto-cleanup in
> > > those cases.
> > >
> > > Simply put, a piece of code like below:
> > >
> > > pm_runtime_get_sync(dev);
> > > .....
> > > pm_runtime_put(dev);
> > > return 0;
> > >
> > > can be transformed with CLASS() like:
> > >
> > > CLASS(pm_runtime_get_active, pm)(dev);
> > > if (IS_ERR(pm))
> > > return PTR_ERR(pm);
> > > .....
> > > return 0;
> > >
> > > (note the new resume error handling).
> >
> > Do we still allow the code without the error check even using CLASS()?
> > Although the error check should be handled, it's not mandatory for
> > now. That said, the above example could be still in a form like:
> >
> > CLASS(pm_runtime_get_active, pm)(dev);
> > .....
> > return 0;
> >
> > while adding the proper error check is recommended?
>
> I'd rather not encourage doing this.
>
> While it may still produce working code in some cases, one needs to
> remember that in case of a runtime resume error it will be running
> without a runtime PM reference it has attempted to acquire.
Fair enough. Then it'd be also good to mention that in the
description, too.
thanks,
Takashi
next prev parent reply other threads:[~2025-09-22 13:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-20 10:49 [PATCH v2 0/3] PM: runtime: Auto-cleanup macros for runtime PM Rafael J. Wysocki
2025-09-20 10:54 ` [PATCH v2 1/3] PM: runtime: Add auto-cleanup macros for "resume and get" operations Rafael J. Wysocki
2025-09-22 8:38 ` Takashi Iwai
2025-09-22 12:50 ` Rafael J. Wysocki
2025-09-22 13:32 ` Takashi Iwai [this message]
2025-09-22 13:44 ` Rafael J. Wysocki
2025-09-22 14:07 ` Takashi Iwai
2025-09-22 14:16 ` Rafael J. Wysocki
2025-09-20 10:56 ` [PATCH v2 2/3] PCI/sysfs: Use runtime PM class macro for auto-cleanup Rafael J. Wysocki
2025-09-20 10:56 ` [PATCH v2 3/3] PM: runtime: Drop DEFINE_FREE() for pm_runtime_put 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=87348eobnv.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alex.williamson@redhat.com \
--cc=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=zhangqilong3@huawei.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