From nobody Tue Apr 7 12:54:06 2026 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 221022FB97B for ; Sun, 5 Apr 2026 14:45:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400323; cv=none; b=YukyXXH4Z1GZNadqAnDLwHz6PZfH2Uu2FlQEAze8xS0xd2BhTBDFmAWk/WJm0S+CgtuWFG5FHgIlF8bO+oPMr/i1YD+ngwzmC5OgD5Cc2H96bIaEgZMAJy3LOyiY7/iE8hhaWta6ida8Rc4Hm1hb7qvKQ9X6il7Np3qsBKuF5pg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775400323; c=relaxed/simple; bh=U9Ed+suttjno51XBUYSnT0699GezdZBqktDkjIeo3Ls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=USkpOeN1//Wcy3uDd/FWvNeT9pYpuQeV8mes5KXggXuW61+hOmDYzga9jh0A0QSMylkqIxTwT71XPTr4Im7VD35dhpL9PddJsntaqd6Jky0ZxsF6D7V+sfzRUBASE6LGLc0IJsBho11dbhzN7PfVFIRZYP0GuWSsMOJIrIzvMeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kkqaPUnF; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kkqaPUnF" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-43b8822fc05so197240f8f.1 for ; Sun, 05 Apr 2026 07:45:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775400319; x=1776005119; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qcDE+lrXl8P386IFXCKLCz+1una+WdqnP+gxsxxcZkI=; b=kkqaPUnFO9pZBUkfbwn5y5r2nTOYT/hFh2q4EbcJwfYeDz/WP9xeu757OaMf+x9vTA VNtwxOywwWs/eaPNykjaX7O8C4+4gRk08ZaKNihPfi+4/qpY0sf7l0+DpbunJ80vEroo ZShhFAgIHnIXUZNB5jibrY8n2+nW3QA52sStqkgwxYKuEBftfEQCk1LWSN88mbmkOkKv st/tEr9jA5Iwvl0LjE+U48rvrNpID+wTnUywT3kW5zgu4keovt4WNDzf4IGrrquMqgy+ eAW/ovaGT7gesA4KabUsl2uCZWXNsBGphaklIKQYvchFtvhY4QoylSVR54C9AvG2Kt6z q5wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775400319; x=1776005119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=qcDE+lrXl8P386IFXCKLCz+1una+WdqnP+gxsxxcZkI=; b=m3HF5iQFvMAxF7oSpcJpdeD2ZgpKb6S350ycI/ep0TM4WSFd1JTum2prO1NwdV9yG1 dyx9RlyCm7byrxm8BCe9XMzemF2v5+iv+2b66XIkiwK055UwmAKxOVgHSowHIjHtxAbf pKZsobhlElJNd3NYVHjmHVVwg64Qe3NoP8rOAGYQItdES5Ir6gcIRzGbpk44ObmMqTpC aU6pg5zUrRxuki94gyQHl/hrbeU7nsevue405u/nMme165qhlvJBa8U5wttud0nhFsf8 oFp5axGwquckmnUq0q5c33g6o2QPUjoy0FwYfWSQSSsUTOQ62HfcM6c67MzaZl1KcPHk 8WBg== X-Forwarded-Encrypted: i=1; AJvYcCVPXf063ommeVLSFISNBxIHc/wkq4QWmXx1vE44k5/XdsCy6TfKBlR74YFAYAzcghuJs4ZdkMCE9FItRvU=@vger.kernel.org X-Gm-Message-State: AOJu0Yx4OYuBiWIcJlIuLW53BoVy1xn1aJvgb3b3sHZiRabwmbiZEwIy A5fEyu27nDZJfywoMkEeyQ0wJFn5L6bk82+k5/gOMpE87iz/394qm1Ak X-Gm-Gg: AeBDies1/wek0MR8q4agk/tc+5juCKWJIdKZcuSgdbh7/hoYJvpnI/pgGMb163aCQMc gr0wvveYM5WXpzV1eg/ZCWY3gpOrOP0rVk+5tV6xtUlTC12QAR63qKbwpL2C/b+WiMPI6uYjtIn UMDPkD61mX+B0LixtMNAgTAIJfMFIHlxVePMi9XA32CN2Ihxm1Is4hEmFF5dMEmAtpvuoiKEj4E YmZ29Hi/g58rpb2fxyYD6MbUUupbfYpIsgFXtYryzGsQ8VZdZr3E03CvWd9OqtR6MQratdG5h0D eKbgFiAztHDQAKyUC0YyGYCeAoBqooChN4dT3m0k2FyAljPY5VMMIjv7VylpMnoCFqqbi7OXuKr 9XSLkE7rsfkJh6AXgCih+pq3OzvP9sh0nyfPMXpMIj4w5nhAtVl8fkBg+lV1rP+e14HFeb9WfGv kj07Eww6D++/lcseQ9kepRN1dfZnxEATTFF1gJeCf/2nCHHrX7hoX4kMng+UKDil1T8vX07w== X-Received: by 2002:a05:6000:2995:20b0:43d:deb:79b7 with SMTP id ffacd0b85a97d-43d292d35bbmr4818846f8f.6.1775400319380; Sun, 05 Apr 2026 07:45:19 -0700 (PDT) Received: from fridge.local ([2a00:1d35:c836:5700:77d9:f36f:3748:d642]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d1e4f1a99sm35698799f8f.32.2026.04.05.07.45.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Apr 2026 07:45:19 -0700 (PDT) From: Emre Cecanpunar To: platform-driver-x86@vger.kernel.org Cc: hansg@kernel.org, ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, krishna.chomal108@gmail.com, edip@medip.dev, emreleno@gmail.com Subject: [PATCH v3 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation Date: Sun, 5 Apr 2026 17:44:59 +0300 Message-ID: <20260405144502.24944-5-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260405144502.24944-1-emreleno@gmail.com> References: <20260405144502.24944-1-emreleno@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable gpu_delta was declared as u8. If the firmware specifies a GPU RPM lower than the CPU RPM, subtracting them causes an underflow (e.g. 10 - 20 =3D 246), which forces the GPU fan to remain clamped at U8_MAX (100% speed) during operation. Change gpu_delta to int and use signed arithmetic. Existing signed logic in hp_wmi_fan_speed_set() correctly handles negative deltas. Fixes: 46be1453e6e6 ("platform/x86: hp-wmi: add manual fan control for Vict= us S models") Suggested-by: Ilpo J=C3=A4rvinen Signed-off-by: Emre Cecanpunar --- Changes in v2: - Drop the if (gpu_delta < 0) guard and pr_warn. A negative delta is valid firmware behavior on boards where CPU_RPM > GPU_RPM. Store gpu_delta as int in struct hp_wmi_hwmon_priv so the existing signed arithmetic and clamp_val() in hp_wmi_fan_speed_set() handle the negative case correctly without saturating at U8_MAX. Changes in v3: - Removed unnecessary explicit (int) casts. C's integer promotion rules already convert u8 operands to int for arithmetic; the fix only requires storing the result in an int variable. drivers/platform/x86/hp/hp-wmi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 2932cab9aa78..db72ad9da0a5 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -455,7 +455,7 @@ enum pwm_modes { struct hp_wmi_hwmon_priv { u8 min_rpm; u8 max_rpm; - u8 gpu_delta; + int gpu_delta; u8 mode; u8 pwm; struct delayed_work keep_alive_dwork; @@ -2549,8 +2549,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hw= mon_priv *priv) { u8 fan_data[128] =3D { 0 }; struct victus_s_fan_table *fan_table; - u8 min_rpm, max_rpm, gpu_delta; - int ret; + u8 min_rpm, max_rpm; + int gpu_delta, ret; =20 /* Default behaviour on hwmon init is automatic mode */ priv->mode =3D PWM_MODE_AUTO; @@ -2572,7 +2572,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hw= mon_priv *priv) =20 min_rpm =3D fan_table->entries[0].cpu_rpm; max_rpm =3D fan_table->entries[fan_table->header.num_entries - 1].cpu_rpm; - gpu_delta =3D fan_table->entries[0].gpu_rpm - fan_table->entries[0].cpu_r= pm; + gpu_delta =3D fan_table->entries[0].gpu_rpm - + fan_table->entries[0].cpu_rpm; priv->min_rpm =3D min_rpm; priv->max_rpm =3D max_rpm; priv->gpu_delta =3D gpu_delta; --=20 2.53.0