From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: 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>, Takashi Iwai <tiwai@suse.de>,
Zhang Qilong <zhangqilong3@huawei.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
"Dan Williams" <dan.j.williams@intel.com>
Subject: Re: [PATCH v1 2/3] PCI/sysfs: Use PM runtime class macro for auto cleanup in reset_method_store()
Date: Fri, 26 Sep 2025 14:49:47 +0100 [thread overview]
Message-ID: <20250926144947.00002f75@huawei.com> (raw)
In-Reply-To: <2245131.irdbgypaU6@rafael.j.wysocki>
On Fri, 19 Sep 2025 18:38:42 +0200
"Rafael J. Wysocki" <rafael@kernel.org> wrote:
> From: Takashi Iwai <tiwai@suse.de>
>
> The newly introduced class macro can simplify the code.
>
> Also, add the proper error handling for the PM runtime get.
>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> [ rjw: Adjust subject and error handling ]
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> drivers/pci/pci-sysfs.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -1475,8 +1475,9 @@ static ssize_t reset_method_store(struct
> 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;
Hi Rafael,
Why this approach rather than treating runtime pm state like a conditional
lock (we use it much like one) and using ACQUIRE() / ACQUIRE_ERR()?
Ultimately that's a wrapper around the same infrastructure but
perhaps neater as it removes need to have that explicit magic pmdev.
+CC Dan as he can probably remember the discussions around ACQUIRE()
vs the way you have here better than I can.
In general great that you've done this. Was on my list too, but I didn't
get around to actually spinning the patches! This is going to be
very useful indeed.
Jonathan
>
> if (sysfs_streq(buf, "default")) {
> pci_init_reset_methods(pdev);
>
>
>
>
>
next prev parent reply other threads:[~2025-09-26 13:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-19 16:34 [PATCH v1 0/3] PM: runtime: Auto-cleanup macros for pm_runtime_resume_and_get() Rafael J. Wysocki
2025-09-19 16:35 ` [PATCH v1 1/3] PM: runtime: Add auto-cleanup " Rafael J. Wysocki
2025-09-19 16:38 ` [PATCH v1 2/3] PCI/sysfs: Use PM runtime class macro for auto cleanup in reset_method_store() Rafael J. Wysocki
2025-09-26 13:49 ` Jonathan Cameron [this message]
2025-09-26 14:36 ` Rafael J. Wysocki
2025-09-26 18:13 ` dan.j.williams
2025-09-26 18:23 ` Rafael J. Wysocki
2025-09-19 16:40 ` [PATCH v1 3/3] PM: runtime: Drop DEFINE_FREE() for pm_runtime_put Rafael J. Wysocki
2025-09-20 6:37 ` [PATCH v1 0/3] PM: runtime: Auto-cleanup macros for pm_runtime_resume_and_get() 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=20250926144947.00002f75@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=dan.j.williams@intel.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=tiwai@suse.de \
--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