From: sashiko-bot@kernel.org
To: tze.yee.ng@altera.com
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v8 2/2] hwmon: add Altera SoC FPGA hardware monitoring driver
Date: Thu, 23 Jul 2026 06:15:03 +0000 [thread overview]
Message-ID: <20260723061515.BAA0E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <d29d05f8bc25a89a0dbf59c8a0bb705f676a58a0.1784785709.git.tze.yee.ng@altera.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Timeouts in both synchronous and asynchronous read paths abandon pending requests without flushing queues or canceling them, causing permanent data desynchronization or hangs for subsequent reads.
--
--- Patch [2]: [PATCH v8 2/2] hwmon: add Altera SoC FPGA hardware monitoring driver ---
commit 467543c9f9e3893d8c84995c5e7bc8bab31dfb20
Author: Tze Yee Ng <tze.yee.ng@altera.com>
hwmon: add Altera SoC FPGA hardware monitoring driver
This commit adds a hardware monitoring driver for Altera SoC FPGA devices
using the Stratix 10 service layer. It supports temperature and voltage
sensors based on the service layer compatible string.
> diff --git a/drivers/hwmon/socfpga-hwmon.c b/drivers/hwmon/socfpga-hwmon.c
> new file mode 100644
> --- /dev/null
> +++ b/drivers/hwmon/socfpga-hwmon.c
[ ... ]
> +static int socfpga_hwmon_async_read(struct device *dev,
> + enum hwmon_sensor_types type,
> + struct stratix10_svc_client_msg *msg)
> +{
[ ... ]
> + ret = -ETIMEDOUT;
> + while (!time_after(jiffies, deadline)) {
> + status = stratix10_svc_async_poll(priv->chan, handle, &data);
> + if (status == -EAGAIN) {
> + /* still in progress */
> + } else if (status < 0) {
> + ret = status;
> + break;
> + } else if (status == 0) {
> + ret = 0;
> + break;
> + }
> + usleep_range(HWMON_RETRY_SLEEP_US, HWMON_RETRY_SLEEP_US * 2);
> + }
> +
> + if (ret) {
> + dev_err(dev, "Failed to get async response\n");
> + goto done;
> + }
[ ... ]
> +done:
> + stratix10_svc_async_done(priv->chan, handle);
> + return ret;
> +}
[Severity: High]
If the polling loop times out, this calls stratix10_svc_async_done() which
immediately frees the job ID via ida_free().
Since the firmware might still be processing this request, could the next
async read reuse this job ID and intercept the delayed completion of this
timed-out request?
[ ... ]
> +static int socfpga_hwmon_sync_read(struct device *dev,
> + enum hwmon_sensor_types type,
> + struct stratix10_svc_client_msg *msg)
> +{
[ ... ]
> + ret = wait_for_completion_timeout(&priv->completion, HWMON_TIMEOUT);
> + if (!ret) {
> + dev_err(priv->client.dev, "timeout waiting for SMC call\n");
> + ret = -ETIMEDOUT;
> + goto status_done;
> + }
> +
> + ret = priv->last_err;
> +
> +status_done:
> + stratix10_svc_done(priv->chan);
> + return ret;
> +}
[Severity: High]
If wait_for_completion_timeout() times out, this calls stratix10_svc_done(),
which stops the worker thread via kthread_stop() without flushing the pending
message from the channel's svc_fifo.
If the worker thread evaluates kthread_should_stop() before dequeuing the
message, will the stale message stay in the queue?
If so, could the next read spawn a new thread that dequeues the stale message
and returns wrong data (like returning a voltage reading for a temperature
request)?
Also, if the worker thread is stuck inside the SMC call, won't kthread_stop()
block indefinitely, hanging the reader process?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784785709.git.tze.yee.ng@altera.com?part=2
prev parent reply other threads:[~2026-07-23 6:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 6:02 [PATCH v8 0/2] hwmon: add Altera SoC FPGA hardware monitoring support tze.yee.ng
2026-07-23 6:02 ` [PATCH v8 1/2] firmware: stratix10-svc: add async HWMON read commands and register socfpga-hwmon device tze.yee.ng
2026-07-23 6:14 ` sashiko-bot
2026-07-23 6:02 ` [PATCH v8 2/2] hwmon: add Altera SoC FPGA hardware monitoring driver tze.yee.ng
2026-07-23 6:15 ` sashiko-bot [this message]
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=20260723061515.BAA0E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tze.yee.ng@altera.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.