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, 25 Aug 2026 17:51:26 +0000 [thread overview]
Message-ID: <20260825175126.9B0591F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260824175059.2485048-4-limzhineng2@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Signed subtraction wrap-around in `time_is_after_eq_jiffies()` causes hwmon sensor readings to freeze for 24.8 days on 32-bit architectures.
--
--- Patch [3]: [PATCH net-next v2 3/6] eth: fbnic: cache hwmon sensor readings ---
commit 976f9fc351b80235f704002eae4e7012534c286d
Author: Zinc Lim <limzhineng2@gmail.com>
eth: fbnic: cache hwmon sensor readings
This commit introduces caching for hardware monitoring sensor readings in the
fbnic driver. It caches the temperature and voltage for the remainder of the
current jiffy to prevent flooding the firmware mailbox during rapid polling.
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> index 38bb26cb8e6cb..f35cb00650937 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_hwmon.c
[ ... ]
> @@ -25,26 +26,32 @@ static umode_t fbnic_hwmon_is_visible(const void *drvdata,
>
> static int fbnic_hwmon_sensor_read(struct fbnic_dev *fbd, int id, long *val)
> {
> + struct fbnic_hwmon_cache *cache = &fbd->hwmon_cache;
> struct fbnic_fw_completion *fw_cmpl;
> int err = 0;
> - s32 *sensor;
> -
> - fw_cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_TSENE_READ_RESP);
> - if (!fw_cmpl)
> - return -ENOMEM;
> + s32 *cached;
>
> switch (id) {
> case FBNIC_SENSOR_TEMP:
> - sensor = &fw_cmpl->u.tsene.millidegrees;
> + cached = &cache->temp_mdeg;
> break;
> case FBNIC_SENSOR_VOLTAGE:
> - sensor = &fw_cmpl->u.tsene.millivolts;
> + cached = &cache->volt_mv;
> break;
> default:
> - err = -EINVAL;
> - goto exit_free;
> + return -EINVAL;
> + }
> +
> + if (*cached != FBNIC_SENSOR_NO_DATA &&
> + time_is_after_eq_jiffies(cache->last_read)) {
[Severity: High]
On 32-bit architectures, if the sensor isn't read for over 24.8 days, will
time_is_after_eq_jiffies() evaluate the wrapped signed subtraction as a
false cache hit?
If this condition evaluates to true under those circumstances, the function
returns early without updating cache->last_read. Does this mean the sensor
readings will continue to falsely hit the cache, causing the temperature
and voltage values to remain frozen for the next 24.8 days?
> + *val = *cached;
> + return 0;
> }
>
> + fw_cmpl = fbnic_fw_alloc_cmpl(FBNIC_TLV_MSG_ID_TSENE_READ_RESP);
> + if (!fw_cmpl)
> + return -ENOMEM;
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260824175059.2485048-1-limzhineng2@gmail.com?part=3
next prev parent reply other threads:[~2026-08-25 17:51 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
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 1/6] eth: fbnic: move sensor read logic out of fbnic_mac Zinc Lim
2026-08-25 17:51 ` sashiko-bot
2026-08-24 17:50 ` [PATCH net-next v2 2/6] eth: fbnic: expose all hwmon attributes unconditionally as read-only Zinc Lim
2026-08-25 17:51 ` sashiko-bot
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 [this message]
2026-08-24 17:50 ` [PATCH net-next v2 4/6] eth: fbnic: report temperature and voltage thresholds via hwmon Zinc Lim
2026-08-25 17:51 ` sashiko-bot
2026-08-24 17:50 ` [PATCH net-next v2 5/6] eth: fbnic: report temperature and voltage alarms " Zinc Lim
2026-08-25 17:51 ` sashiko-bot
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
2026-08-24 20:02 ` [PATCH net-next v2 0/6] eth: fbnic: expand hwmon sensor support Jakub Kicinski
-- strict thread matches above, loose matches on Subject: below --
2026-08-31 21:22 Zinc Lim
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
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=20260825175126.9B0591F00A3D@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.