Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Zac Lanzon" <lanzonza@gmail.com>
Cc: linux-hwmon@vger.kernel.org
Subject: Re: [PATCH 2/2] hwmon: (asus_rog_ryujin) Add pwm1_enable for the Ryujin III pump
Date: Sun, 27 Sep 2026 12:19:31 +0000	[thread overview]
Message-ID: <20260927121932.72AAE1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927120927.72810-3-lanzonza@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] hwmon: asus_rog_ryujin: massive msleep() due to jiffies wrap-around
--

commit 9b0f4985a76174c3f4abba0e61bb854848b7c94c
Author: Zac Lanzon <lanzonza@gmail.com>

hwmon: (asus_rog_ryujin) Add pwm1_enable for the Ryujin III pump

This commit adds pwm1_enable support to the asus_rog_ryujin driver to expose 
and control the pump source. It also introduces delays to wait between source 
changes to ensure the cooler processes the commands correctly.

> diff --git a/drivers/hwmon/asus_rog_ryujin.c b/drivers/hwmon/asus_rog_ryujin.c
> index ba188e8679347..c89d854b2ae92 100644
> --- a/drivers/hwmon/asus_rog_ryujin.c
> +++ b/drivers/hwmon/asus_rog_ryujin.c

[ ... ]

> @@ -313,6 +330,46 @@ static int rog_ryujin_read_string(struct device *dev, enum hwmon_sensor_types ty
>  	return 0;
>  }
>  
> +/*
> + * Send a set cooler duty command. If it changes the pump control source, first
> + * wait until RYUJIN_SOURCE_CHANGE_INTERVAL has passed since the last change,
> + * then wait for the cooler duty report to show the new source, so that success
> + * means the change took effect.
> + */
> +static int rog_ryujin_write_cooler_duty(struct rog_ryujin_data *priv, const u8 *set_cmd)
> +{
> +	u8 source = set_cmd[RYUJIN_SET_COOLER_CHANNEL_OFFSET];
> +	unsigned long now, next, timeout;
> +	int ret;
> +
> +	if (!priv->info->duty_channel || source == priv->pump_source)
> +		return rog_ryujin_execute_cmd(priv, set_cmd, SET_CMD_LENGTH,
> +					      &priv->cooler_duty_set);
> +
> +	now = jiffies;
> +	next = priv->source_changed + msecs_to_jiffies(RYUJIN_SOURCE_CHANGE_INTERVAL);
> +	if (time_before(now, next))
> +		msleep(jiffies_to_msecs(next - now));

[Severity: Medium]
Is there a risk of a massive unintended sleep here due to a jiffies 
wrap-around? 

On 32-bit systems, if the elapsed time since priv->source_changed exceeds 
2^31 jiffies (for example, if there are no source changes for 24.8 days at 
HZ=1000), time_before() can wrap and return true. This would feed a very 
large wrapped value from next - now into msleep(), causing a thread hang 
when a write to the cooler duty attribute is attempted.

Checking the elapsed time via unsigned subtraction, such as 
now - priv->source_changed < msecs_to_jiffies(RYUJIN_SOURCE_CHANGE_INTERVAL), 
prevents this wrap-around issue.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927120927.72810-1-lanzonza@gmail.com?part=2

  reply	other threads:[~2026-09-27 12:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 12:09 [PATCH 0/2] hwmon: (asus_rog_ryujin) Ryujin III pump control source Zac Lanzon
2026-09-27 12:09 ` [PATCH 1/2] hwmon: (asus_rog_ryujin) Fix pump control source on the Ryujin III Zac Lanzon
2026-09-27 12:16   ` sashiko-bot
2026-09-27 12:09 ` [PATCH 2/2] hwmon: (asus_rog_ryujin) Add pwm1_enable for the Ryujin III pump Zac Lanzon
2026-09-27 12:19   ` sashiko-bot [this message]
2026-09-27 12:47     ` Zac Lanzon

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=20260927121932.72AAE1F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=lanzonza@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