From nobody Sat Apr 4 00:05:59 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 2346A37C11C for ; Sun, 22 Mar 2026 19:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774206440; cv=none; b=Cnk7oDZKynohTG7vGxBh2GDOwTysUNXle3Ro3DEZyJ2WzUiKHB9IBiezfGB1NC/Si+LCJ1U4VEizEppVP7hvJ1ukhAqCmm6Cx/7zpEeV45YeFK1MFYNlardSTpbjMW/rFJxk4e1w8qW24i+5VTUEF8DGyuTd22wLSoStIEp3Yow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774206440; c=relaxed/simple; bh=b2Yu4QNmTqQ7VgOgSC58XEL8/pOhTJNoN/AnRGyQ49M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i5zN5iUF4644IoGSLO8W5EhpiPI5PLtQlmjtxF2huWXV/WStFyUNpsjRU4Fb8M7XSZUuaFB17qEBDzDJCNB7XVybhQEHPgXuVP9STeElCTJr00NueWOuzLH6dpB+8uqwII3elgRM0WDRTPs29EBbB627YZQ6uTP6/Ie9WDOQs3I= 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=bR+p1Vu/; arc=none smtp.client-ip=209.85.128.47 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="bR+p1Vu/" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-486fca3245cso4969685e9.2 for ; Sun, 22 Mar 2026 12:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774206437; x=1774811237; 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=eC4Vcl8jB5v5qB0mNZx8g21iRBAwUU3PRlx8EqzAROA=; b=bR+p1Vu/bRkhme126AfZM/SUnsFPy9UNrWb4wRUYcvszF76z6NF+0I3nkwc6x2/4ID Dgs9NFzguZhhxn693eVoPuN/p8u5HiYEnxgU8EhqnH0184lM1UQg9bvoIWTAESPPsRKy 5lsA4Et4gI4JhXQCa/za/CdaHDh8jy3RQaXaUmVsLdQDsXAIZOVaRNVs2Op8Bu3EnyhC VFLrkhuEQAjaE7mT/KDRYrWGdFaMNBqXYwLsGXgAbOasc7FeIOxbYA/SoryUhb6bv8Ud apAHDZE8FFqrHOrXCOerCiT4us5ux9ZnJt3xDvAIm4em1somUevVtLwaZ2mWkLwEG/Q/ 0Piw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774206437; x=1774811237; 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=eC4Vcl8jB5v5qB0mNZx8g21iRBAwUU3PRlx8EqzAROA=; b=gKdJ2y3ju3R52tFeAAxoGZTvaYKM5/rx8x38X6g6o6d1/bKipYxZ1ArNiKGujD6mjs BVpXJGnqiasEBGF/f5q9ZcoAdY3nCka8xDZA4myIYDdINJZpmc32m9GYMTj/5JdrzawA xq3jcBj8xflKi2Sb05zZtBNB3J2DB0288tU8rejeAfA/psnTZs0JmakuQr5rYXnvcmCF u8D3nNzd8zhCJL7HKBZJpsg3kwwXHEk09slyXgZerdpQI7S5CAngug8+ncFimRsSAEeW raSLfaI8HDXSIlnwY1VTr2sqAnj6ZUnlFVO6gOZ58RJkjxWilcdL/EWyneOY/nV64nP2 NlQA== X-Forwarded-Encrypted: i=1; AJvYcCULqrIJfRykapJIV5/p9q0IDupQ5qKaAMIkU1Y+90cS57MIfvRTv+uWTW68p2CNG2Os5QV3YV8e7MWf1Q0=@vger.kernel.org X-Gm-Message-State: AOJu0Ywho2D+/RLzFhor9MMxEmRWpbEj42/K7vZYDRsG508rcZRKpvkW Q9N6hIX5sz7m366c69ue7bX/9ZH/uLCVM24NKnJqZRYnLRHt/UdP7/Ht X-Gm-Gg: ATEYQzwLip24jjRka8gd0MbUIL1uzxADXZXMZX9EUhY5EMqLBI06D5u9wJb36HKQ/Sc NBKHOXzlLLEWe5n2jzIyvhqlZIwHlEUhSB2Xs5NNqwJWtn9YRvznnVQF+nNj0tOqWKhidOXNHNx e4v+30ENVThILDjujrzVivXbRx74CuY8kU+Zc3DebaF/0j92dZ4tvwsTKKbPAgofF8+Ry+qA+kR JaIpSc5NG2YZAMQGnATDRmllO0k8/fKOGBYbged09vFsfSgfZhSAXNWK2vGa9pOjn8P0lAtD6PE OAaFQCc9/rLXevYuHY4Futj9b8ySVj2g4ndOfyUfn7yj4jTCU0eTk2ZCP+PJM+JUYI+QOLwIKDu VyIsS0Xwsd9FUqiL2aIpFLeM8jhb/FElZ9Abbjmjsyvm51vl9KJD16XSyJdl8Gb7mPKatU6y/5J cIRsUY8uV6q8T/OPOCkHEQvTEnTuEGaiGl4wz7zQaLJwFKZ9eDZfdq6TLc3CUALsiHfeiZf1A= X-Received: by 2002:a05:600c:3105:b0:485:3bc7:a224 with SMTP id 5b1f17b1804b1-486ff01b279mr83078485e9.6.1774206437259; Sun, 22 Mar 2026 12:07:17 -0700 (PDT) Received: from localhost.localdomain ([46.155.1.197]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-486fe868cb1sm63340595e9.5.2026.03.22.12.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Mar 2026 12:07:16 -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, Emre Cecanpunar Subject: [PATCH v2 4/5] platform/x86: hp-wmi: fix u8 underflow in gpu_delta calculation Date: Sun, 22 Mar 2026 22:06:23 +0300 Message-ID: <20260322190624.35162-5-emreleno@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260322190624.35162-1-emreleno@gmail.com> References: <20260322190624.35162-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" gpu_delta was declared as u8 and computed as the difference of two u8 fan RPM values from the firmware fan table. If gpu_rpm < cpu_rpm, the subtraction wraps around modulo 256, producing a large positive value (e.g. 10 - 20 =3D 246 as u8). This value is then added to every requested fan speed in hp_wmi_fan_speed_set(), causing the GPU fan to be clamped to U8_MAX on almost every write. Change gpu_delta to int in both struct hp_wmi_hwmon_priv and hp_wmi_setup_fan_settings(), and perform the subtraction in signed arithmetic. hp_wmi_fan_speed_set() already uses signed arithmetic with clamp_val(), so a negative delta correctly results in a lower GPU fan speed rather than saturating at U8_MAX. 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. 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 a29f34588055..af57cb0dbf9e 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -436,7 +436,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; @@ -2530,8 +2530,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; /* Default behaviour on hwmon init is automatic mode */ priv->mode =3D PWM_MODE_AUTO; @@ -2553,7 +2553,8 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_hw= mon_priv *priv) 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 (int)fan_table->entries[0].gpu_rpm - + (int)fan_table->entries[0].cpu_rpm; priv->min_rpm =3D min_rpm; priv->max_rpm =3D max_rpm; priv->gpu_delta =3D gpu_delta; -- 2.53.0