Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: tze.yee.ng@altera.com
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v7 2/2] hwmon: add Altera SoC FPGA hardware monitoring driver
Date: Tue, 21 Jul 2026 02:26:42 +0000	[thread overview]
Message-ID: <20260721022642.845E31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <c8f4fbc1d8c3b1d161c94f66feb2ebbc038dab6d.1784599864.git.tze.yee.ng@altera.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The driver converts a timeout condition into an infinite wait on error paths, causing the calling process to hang in an unkillable D-state if the firmware fails to respond or drops the request.
--

--- Patch [2]: [PATCH v7 2/2] hwmon: add Altera SoC FPGA hardware monitoring driver ---
commit 0a6e38858fabeb08e3528c04db8dd1a253733f50
Author: Tze Yee Ng <tze.yee.ng@altera.com>

hwmon: add Altera SoC FPGA hardware monitoring driver

This commit adds a hardware monitor driver for Altera SoC FPGA devices
using the Stratix 10 service layer. Sensor channels are selected 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_sync_read(struct device *dev,
> +				   enum hwmon_sensor_types type,
> +				   struct stratix10_svc_client_msg *msg)
> +{
> +	struct socfpga_hwmon_priv *priv = dev_get_drvdata(dev);
> +	int ret;
> +
> +	reinit_completion(&priv->completion);
> +
> +	if (type == hwmon_temp)
> +		priv->client.receive_cb = socfpga_hwmon_readtemp_cb;
> +	else
> +		priv->client.receive_cb = socfpga_hwmon_readvolt_cb;
> +
> +	ret = stratix10_svc_send(priv->chan, msg);
> +	if (ret < 0)
> +		goto status_done;
> +
> +	ret = wait_for_completion_timeout(&priv->completion, HWMON_TIMEOUT);
> +	if (!ret) {
> +		dev_err(priv->client.dev, "timeout waiting for SMC call\n");
> +		/*
> +		 * stratix10_svc_done() stops the worker but does not flush
> +		 * svc_fifo. Wait for the outstanding callback before stopping
> +		 * so a leftover request cannot complete a later sensor read.
> +		 * Discard the late result and still report -ETIMEDOUT.
> +		 */
> +		wait_for_completion(&priv->completion);

[Severity: High]
Does this unconditional wait_for_completion() cause the reading process to
hang indefinitely in an unkillable D-state?

If the firmware fails to respond, or if the underlying service thread receives
a busy or rejected status from the firmware during the SMC call, the service
thread skips invoking the receive_cb callback entirely.

Because the callback is never invoked in these failure modes,
wait_for_completion_timeout() correctly expires. However, the subsequent
wait_for_completion() then blocks forever while the process still holds
priv->lock, deadlocking all future sensor reads for the device.

> +		ret = -ETIMEDOUT;
> +		goto status_done;
> +	}
> +
> +	ret = priv->last_err;
> +
> +status_done:
> +	stratix10_svc_done(priv->chan);
> +	return ret;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1784599864.git.tze.yee.ng@altera.com?part=2

  reply	other threads:[~2026-07-21  2:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-21  2:17 [PATCH v7 0/2] hwmon: add Altera SoC FPGA hardware monitoring support tze.yee.ng
2026-07-21  2:18 ` [PATCH v7 1/2] firmware: stratix10-svc: add async HWMON read commands and register socfpga-hwmon device tze.yee.ng
2026-07-21  2:30   ` sashiko-bot
2026-07-21  2:18 ` [PATCH v7 2/2] hwmon: add Altera SoC FPGA hardware monitoring driver tze.yee.ng
2026-07-21  2:26   ` sashiko-bot [this message]
2026-07-21  3:08   ` Guenter Roeck
2026-07-22  7:38     ` NG, TZE YEE

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=20260721022642.845E31F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox