public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Takashi Iwai <tiwai@suse.de>,
	linux-pm@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] PCI: Use PM runtime class macro for the auto cleanup
Date: Sat, 20 Sep 2025 08:33:34 +0200	[thread overview]
Message-ID: <871po18wg1.wl-tiwai@suse.de> (raw)
In-Reply-To: <CAJZ5v0jbr8WKp3+POEMy_mz2daWMGDPWHGMhWc-Ac=rcPAzDkg@mail.gmail.com>

On Fri, 19 Sep 2025 20:39:04 +0200,
Rafael J. Wysocki wrote:
> 
> On Fri, Sep 19, 2025 at 6:32 PM Takashi Iwai <tiwai@suse.de> wrote:
> >
> > Use the newly introduced class macro to simplify the code.
> > Also, add the proper error handling for the PM runtime get errors,
> > too.
> >
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > ---
> >  drivers/pci/pci-sysfs.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> > index 5eea14c1f7f5..08e5cf2ba73e 100644
> > --- a/drivers/pci/pci-sysfs.c
> > +++ b/drivers/pci/pci-sysfs.c
> > @@ -1475,8 +1475,9 @@ static ssize_t reset_method_store(struct device *dev,
> >                 return count;
> >         }
> >
> > -       pm_runtime_get_sync(dev);
> > -       struct device *pmdev __free(pm_runtime_put) = dev;
> > +       CLASS(pm_runtime_resume_and_get, pmdev)(dev);
> > +       if (IS_ERR(pmdev))
> > +               return -ENXIO;
> >
> >         if (sysfs_streq(buf, "default")) {
> >                 pci_init_reset_methods(pdev);
> > --
> 
> I've just realized that this patch won't work and the reason why is
> that __pm_runtime_resume() returns an error if runtime PM is disabled
> for a device, so pmdev above will be an error pointer in that case.

Good catch, this was completely forgotten...

> One possible approach may be to make pm_runtime_resume_and_get_dev()
> return 0 and bump up the usage counter for devices with runtime PM
> disabled.

Sounds reasonable.


thanks,

Takashi

  reply	other threads:[~2025-09-20  6:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19 16:31 [PATCH 0/3] PM: runtime: New class macros for auto-cleanup Takashi Iwai
2025-09-19 16:31 ` [PATCH 1/3] PM: runtime: Define class helpers for automatic PM runtime cleanup Takashi Iwai
2025-09-19 17:04   ` Rafael J. Wysocki
2025-09-19 16:31 ` [PATCH 2/3] PCI: Use PM runtime class macro for the auto cleanup Takashi Iwai
2025-09-19 18:39   ` Rafael J. Wysocki
2025-09-20  6:33     ` Takashi Iwai [this message]
2025-09-19 16:31 ` [PATCH 3/3] PM: runtime: Drop unused pm_runtime_free __free() definition Takashi Iwai
2025-09-19 16:44 ` [PATCH 0/3] PM: runtime: New class macros for auto-cleanup Rafael J. Wysocki
2025-09-20  6:36   ` Takashi Iwai

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=871po18wg1.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=bhelgaas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.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