From: sashiko-bot@kernel.org
To: "Zinc Lim" <limzhineng2@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH net-next 5/6] eth: fbnic: report temperature and voltage alarms via hwmon
Date: Wed, 22 Jul 2026 22:17:59 +0000 [thread overview]
Message-ID: <20260722221800.770DE1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260721221540.648272-6-limzhineng2@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Unpopulated alarm attributes trigger unnecessary firmware reads instead of being rejected up front.
- [Medium] Hardware monitoring alarms are improperly computed in software by the driver.
--
--- Patch [5]: [PATCH net-next 5/6] eth: fbnic: report temperature and voltage alarms via hwmon ---
commit 6d735c75df1c02d16911aecd205cd4bf98b0bb3b
Author: Zinc Lim <limzhineng2@gmail.com>
eth: fbnic: report temperature and voltage alarms via hwmon
Building on the temperature and voltage thresholds stored in
fbnic_fw_cap, expose alarm attributes through the hwmon interface:
temp1_{min,max,crit}_alarm and in0_{min,max}_alarm.
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> index 4938f7b391402..c5cddd9cef124 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
[ ... ]
> @@ -87,34 +87,84 @@ static int fbnic_hwmon_read_threshold(long thr, long *val)
> return 0;
> }
>
> +static int fbnic_hwmon_read_alarm(long a, long b, long *val)
> +{
> + if (a == FBNIC_SENSOR_NO_DATA || b == FBNIC_SENSOR_NO_DATA)
> + return -ENODATA;
> +
> + *val = a >= b;
[Severity: Medium]
Is it intentional to compute alarms in software by comparing the live
sensor reading against the threshold here?
According to the hwmon sysfs ABI documentation, drivers should not make
comparisons of readings to thresholds themselves. Alarms are expected to be
hardware-latched indications that can catch transient spikes between polls.
If the hardware does not support latched alarms, should these alarm
attributes be omitted entirely so user-space tools can handle their own
software threshold comparisons?
> + return 0;
> +}
> +
> static int fbnic_hwmon_temp_read(struct fbnic_dev *fbd, u32 attr, long *val)
> {
> + int err;
> +
> switch (attr) {
> - case hwmon_temp_input:
> - return fbnic_hwmon_sensor_read(fbd, FBNIC_SENSOR_TEMP, val);
> case hwmon_temp_min:
> return fbnic_hwmon_read_threshold(fbd->fw_cap.temp.min, val);
> case hwmon_temp_max:
> return fbnic_hwmon_read_threshold(fbd->fw_cap.temp.max, val);
> case hwmon_temp_crit:
> return fbnic_hwmon_read_threshold(fbd->fw_cap.temp.crit, val);
> + case hwmon_temp_input:
> + case hwmon_temp_min_alarm:
> + case hwmon_temp_max_alarm:
> + case hwmon_temp_crit_alarm:
> + break;
> default:
> return -EOPNOTSUPP;
> }
> +
> + err = fbnic_hwmon_sensor_read(fbd, FBNIC_SENSOR_TEMP, val);
[Severity: Medium]
The commit message notes that unsupported attributes are rejected up front,
but does this code fall through for unpopulated alarm thresholds and trigger
a blocking firmware read before eventually returning -ENODATA?
If fbd->fw_cap.temp.min is FBNIC_SENSOR_NO_DATA, reading
hwmon_temp_min_alarm will hit the break statement above, execute this
sensor read, and then fail later inside fbnic_hwmon_read_alarm().
Could we check the threshold value up front before issuing the mailbox
request?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721221540.648272-1-limzhineng2@gmail.com?part=5
next prev parent reply other threads:[~2026-07-22 22:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 22:15 [PATCH net-next 0/6] eth: fbnic: expand hwmon sensor support Zinc Lim
2026-07-21 22:15 ` [PATCH net-next 1/6] eth: fbnic: move sensor read logic out of fbnic_mac Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 2/6] eth: fbnic: expose all hwmon attributes unconditionally as read-only Zinc Lim
2026-07-22 22:18 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 3/6] eth: fbnic: cache hwmon sensor readings Zinc Lim
2026-07-22 22:17 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 4/6] eth: fbnic: report temperature and voltage thresholds via hwmon Zinc Lim
2026-07-22 22:18 ` sashiko-bot
2026-07-21 22:15 ` [PATCH net-next 5/6] eth: fbnic: report temperature and voltage alarms " Zinc Lim
2026-07-22 22:17 ` sashiko-bot [this message]
2026-07-21 22:15 ` [PATCH net-next 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events Zinc Lim
2026-07-22 22:18 ` sashiko-bot
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=20260722221800.770DE1F00A3D@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=limzhineng2@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=sashiko-reviews@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 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.