Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zinc Lim" <limzhineng2@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH net-next v2 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events
Date: Tue, 01 Sep 2026 21:23:05 +0000	[thread overview]
Message-ID: <20260901212305.8B8611F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831212234.1212971-7-limzhineng2@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Unpopulated firmware thresholds (FBNIC_SENSOR_NO_DATA / S32_MIN) are incorrectly evaluated as crossed, causing wrong alarms to be attributed.
- [Medium] Calling synchronize_irq() with an uninitialized or freed IRQ vector (0) can block on unrelated system interrupts.
--

commit 29bf1cd49123c450c788d4c7179ddacd012338e7
Author: Zinc Lim <limzhineng2@gmail.com>

eth: fbnic: firmware notifies hwmon on sensor threshold events

This patch handles firmware notifications for sensor threshold events, parsing
the IPC message and mapping it to the corresponding hwmon alarm. It also adds
concurrency guards to the hwmon registration and teardown paths.

[ ... ]
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> index c5cddd9cef124..3f33522fcfd2b 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
[ ... ]
> @@ -214,22 +216,75 @@ void fbnic_hwmon_register(struct fbnic_dev *fbd)
>  void fbnic_hwmon_unregister(struct fbnic_dev *fbd)
>  {
> +	struct device *hwmon;
> +
>  	if (!IS_REACHABLE(CONFIG_HWMON) || !fbd->hwmon)
>  		return;
>  
> -	hwmon_device_unregister(fbd->hwmon);
> -	fbd->hwmon = NULL;
> +	hwmon = fbd->hwmon;
> +	/* Pair with READ_ONCE() in fbnic_hwmon_notify_event(). Publish NULL
> +	 * and wait for any in-flight FW mailbox IRQ handler to finish so it
> +	 * cannot dereference the hwmon device after we unregister it.
> +	 */
> +	WRITE_ONCE(fbd->hwmon, NULL);
> +	synchronize_irq(fbd->fw_msix_vector);

[Severity: Medium]
Could this call block on unrelated system interrupts if the vector is 0?

During device suspend, fbnic_pm_suspend() frees the mailbox IRQ and sets
fbd->fw_msix_vector = 0. If the device is subsequently removed (e.g., via
hotplug or driver unload while suspended), fbnic_remove() calls
fbnic_hwmon_unregister() which then unconditionally calls
synchronize_irq(0).

On architectures like x86, IRQ 0 is a valid system interrupt (such as the
PIT timer). Will this cause the driver to pointlessly block waiting for
the timer interrupt handler to finish?

> +
> +	hwmon_device_unregister(hwmon);
> +}
> +
> +void fbnic_hwmon_notify_event(struct fbnic_dev *fbd, int id, long val)
> +{
> +	enum hwmon_sensor_types type;
> +	struct device *hwmon;
> +	s32 attr = -1;
> +
> +	if (!IS_REACHABLE(CONFIG_HWMON))
> +		return;
> +
> +	switch (id) {
> +	case FBNIC_SENSOR_TEMP:
> +		type = hwmon_temp;
> +
> +		if (val <= fbd->fw_cap.temp.min)
> +			attr = hwmon_temp_min_alarm;
> +		else if (val >= fbd->fw_cap.temp.crit)
> +			attr = hwmon_temp_crit_alarm;
> +		else if (val >= fbd->fw_cap.temp.max)
> +			attr = hwmon_temp_max_alarm;

[Severity: High]
Does this logic correctly handle unpopulated firmware thresholds?

If a limit such as fbd->fw_cap.temp.crit is unpopulated, it is stored as
FBNIC_SENSOR_NO_DATA (S32_MIN). Since any valid sensor reading will be
greater than S32_MIN, the condition (val >= fbd->fw_cap.temp.crit) will
evaluate to true.

Can this falsely trigger hwmon_temp_crit_alarm for normal sensor values
and mask other valid alarms like hwmon_temp_max_alarm? Should we verify
that the threshold is valid (!= FBNIC_SENSOR_NO_DATA) before comparing it
against the sensor reading?

> +
> +		break;
> +	case FBNIC_SENSOR_VOLTAGE:
> +		type = hwmon_in;
> +
> +		if (val <= fbd->fw_cap.volt.min)
> +			attr = hwmon_in_min_alarm;
> +		else if (val >= fbd->fw_cap.volt.max)
> +			attr = hwmon_in_max_alarm;

[Severity: High]
Does the same issue apply here for missing voltage maximum thresholds?

If fbd->fw_cap.volt.max is FBNIC_SENSOR_NO_DATA (S32_MIN), will this
incorrectly trigger an alarm for any valid voltage reading?

> +
> +		break;
> +	default:
> +		return;
> +	}
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831212234.1212971-1-limzhineng2@gmail.com?part=6

  reply	other threads:[~2026-09-01 21:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 21:22 [PATCH net-next v2 0/6] eth: fbnic: expand hwmon sensor support Zinc Lim
2026-08-31 21:22 ` [PATCH net-next v2 1/6] eth: fbnic: move sensor read logic out of fbnic_mac Zinc Lim
2026-09-01 21:23   ` sashiko-bot
2026-08-31 21:22 ` [PATCH net-next v2 2/6] eth: fbnic: expose all hwmon attributes unconditionally as read-only Zinc Lim
2026-09-01 21:23   ` sashiko-bot
2026-09-03  3:24   ` [net-next,v2,2/6] " netdev-bot+sashiko
2026-08-31 21:22 ` [PATCH net-next v2 3/6] eth: fbnic: cache hwmon sensor readings Zinc Lim
2026-09-01 21:23   ` sashiko-bot
2026-09-03  3:24   ` [net-next,v2,3/6] " netdev-bot+sashiko
2026-09-04 21:46     ` Jakub Kicinski
2026-08-31 21:22 ` [PATCH net-next v2 4/6] eth: fbnic: report temperature and voltage thresholds via hwmon Zinc Lim
2026-09-01 21:23   ` sashiko-bot
2026-09-03  3:24   ` [net-next,v2,4/6] " netdev-bot+sashiko
2026-08-31 21:22 ` [PATCH net-next v2 5/6] eth: fbnic: report temperature and voltage alarms " Zinc Lim
2026-09-01 21:23   ` sashiko-bot
2026-09-03  3:24   ` [net-next,v2,5/6] " netdev-bot+sashiko
2026-08-31 21:22 ` [PATCH net-next v2 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events Zinc Lim
2026-09-01 21:23   ` sashiko-bot [this message]
2026-09-03  3:24   ` [net-next,v2,6/6] " netdev-bot+sashiko
  -- strict thread matches above, loose matches on Subject: below --
2026-08-24 17:50 [PATCH net-next v2 0/6] eth: fbnic: expand hwmon sensor support Zinc Lim
2026-08-24 17:50 ` [PATCH net-next v2 6/6] eth: fbnic: firmware notifies hwmon on sensor threshold events Zinc Lim
2026-08-25 17:51   ` 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=20260901212305.8B8611F000E9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox