From: sashiko-bot@kernel.org
To: "Jihong Min" <hurryman2212@gmail.com>
Cc: linux-hwmon@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 2/2] hwmon: add AMD Promontory 21 xHCI temperature sensor support
Date: Fri, 08 May 2026 21:52:46 +0000 [thread overview]
Message-ID: <20260508215247.71919C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508143910.14673-3-hurryman2212@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Using pm_runtime_put_noidle() can permanently prevent the PCI device from runtime-suspending.
- [Low] The local hwmon->lock mutex is redundant and violates the hwmon subsystem locking architecture.
--
commit 62e33fab546f8b14b0cd80683aa504672db60e64
Author: Jihong Min <hurryman2212@gmail.com>
hwmon: add AMD Promontory 21 xHCI temperature sensor support
This commit adds an auxiliary-bus hwmon driver to expose the temperature
sensor on AMD Promontory 21 xHCI controllers. It reads the sensor value
through a vendor-specific index/data register pair in the PCI MMIO BAR.
> diff --git a/drivers/hwmon/prom21-xhci.c b/drivers/hwmon/prom21-xhci.c
> new file mode 100644
> index 0000000000000..f91303ce3428d
> --- /dev/null
> +++ b/drivers/hwmon/prom21-xhci.c
> @@ -0,0 +1,250 @@
[ ... ]
> +static int prom21_xhci_read_temp_raw_restore_index(struct prom21_xhci *hwmon,
> + u8 *raw)
> +{
> + struct device *dev = &hwmon->pdev->dev;
> + bool pm_ref;
> + u32 index;
> + u32 data;
> + int ret;
> +
> + ret = prom21_xhci_pm_get(hwmon, &pm_ref);
> + if (ret)
> + return ret;
> +
> + mutex_lock(&hwmon->lock);
Is this private mutex redundant here?
According to the hardware monitoring subsystem guidelines, the hwmon core
automatically serializes sysfs operations for attributes registered via the
info parameter of hwmon_device_register_with_info().
Since this driver registers its only attribute (temp1_input) via the info
parameter and does not access the hardware from interrupt handlers or other
asynchronous paths, does it need its own serialization?
> + index = readl(hwmon->regs + PROM21_INDEX);
> + /* Select the PROM21 temperature register through the vendor index. */
> + writel(PROM21_TEMP_REG, hwmon->regs + PROM21_INDEX);
> + data = readl(hwmon->regs + PROM21_DATA);
> + /* Restore the previous vendor index register value. */
> + writel(index, hwmon->regs + PROM21_INDEX);
> + readl(hwmon->regs + PROM21_INDEX);
> + mutex_unlock(&hwmon->lock);
> +
> + if (pm_ref) {
> + /*
> + * Drop only the reference taken by pm_runtime_get_if_active().
> + * Do not mark the device busy or schedule autosuspend from the
> + * hwmon path; sensor polling must not keep the xHCI PCI device
> + * active.
> + */
> + pm_runtime_put_noidle(dev);
Can using pm_runtime_put_noidle() permanently prevent the PCI device from
runtime-suspending?
If the xHCI driver drops its own runtime PM reference concurrently (e.g., via
pm_runtime_put_autosuspend()), the PM core's idle check sees usage_count > 0,
returns -EAGAIN, and skips scheduling the autosuspend timer.
This code then calls pm_runtime_put_noidle(), which decrements usage_count
to 0 but intentionally bypasses queueing an idle check or notifying the PM
core.
Could this leave the xHCI controller permanently in the RPM_ACTIVE state with
a usage_count of 0 and no pending autosuspend timer until the next PM state
change?
To safely drop the reference without resetting the autosuspend timer, should
this use pm_runtime_put() instead, which properly queues an asynchronous
idle check?
> + }
> +
> + *raw = data & 0xff;
> + if (!*raw || *raw == 0xff)
> + return -ENODATA;
> +
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508143910.14673-1-hurryman2212@gmail.com?part=2
next prev parent reply other threads:[~2026-05-08 21:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 14:39 [PATCH v4 0/2] AMD Promontory 21 xHCI temperature sensor support Jihong Min
2026-05-08 14:39 ` [PATCH v4 1/2] usb: xhci-pci: add AMD Promontory 21 PCI glue Jihong Min
2026-05-08 16:40 ` Mario Limonciello
2026-05-08 17:39 ` Jihong Min
2026-05-08 17:42 ` Mario Limonciello
2026-05-08 17:48 ` Jihong Min
2026-05-08 18:11 ` Jihong Min
2026-05-08 18:15 ` Guenter Roeck
2026-05-08 18:39 ` Jihong Min
2026-05-09 5:34 ` Jihong Min
2026-05-09 5:52 ` Mario Limonciello
2026-05-09 6:54 ` Jihong Min
2026-05-08 14:39 ` [PATCH v4 2/2] hwmon: add AMD Promontory 21 xHCI temperature sensor support Jihong Min
2026-05-08 15:45 ` Guenter Roeck
2026-05-08 17:37 ` Jihong Min
2026-05-08 16:51 ` Mario Limonciello
2026-05-08 17:40 ` Jihong Min
2026-05-08 21:52 ` sashiko-bot [this message]
2026-05-09 5:18 ` Jihong Min
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=20260508215247.71919C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hurryman2212@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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