All of lore.kernel.org
 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 3/6] eth: fbnic: cache hwmon sensor readings
Date: Tue, 01 Sep 2026 21:23:03 +0000	[thread overview]
Message-ID: <20260901212303.BF69B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831212234.1212971-4-limzhineng2@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Using `time_is_after_eq_jiffies()` with a past timestamp causes up to 24.8 days of stale cache hits due to integer wrap-around.
--

commit 7ed3f7f9496f73d45331fe15e8dabb135858cab0
Author: Zinc Lim <limzhineng2@gmail.com>

eth: fbnic: cache hwmon sensor readings

This commit caches hwmon sensor readings for the remainder of the current
jiffy to avoid flooding the firmware mailbox with quick, successive IPC
messages when polling attributes at a high rate.

> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
[ ... ]
>  static int fbnic_hwmon_sensor_read(struct fbnic_dev *fbd, int id, long *val)
>  {
[ ... ]
> +
> +	if (*cached != FBNIC_SENSOR_NO_DATA &&
> +	    time_is_after_eq_jiffies(cache->last_read)) {
> +		*val = *cached;
> +		return 0;
>  	}

[Severity: Medium]
Does this cache validity check safely handle long periods of inactivity?

Using time_is_after_eq_jiffies() with a past timestamp can cause up to 24.8
days of stale cache hits due to integer wrap-around.

On 32-bit architectures, if the sensor is not read for more than 24.8 days
(assuming HZ=1000), the difference between the current jiffies and
cache->last_read wraps around the 32-bit signed boundary and becomes positive.

When this happens, the time_is_after_eq_jiffies() macro in
fbnic_hwmon_sensor_read() evaluates to true, causing the driver to serve
completely stale temperature and voltage data for the next 24.8 days instead
of properly refreshing the hardware state.

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

  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 [this message]
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
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 3/6] eth: fbnic: cache hwmon sensor readings 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=20260901212303.BF69B1F000E9@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.