From nobody Wed Apr 1 22:05:31 2026 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.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 C56DA3DEAE3 for ; Wed, 1 Apr 2026 11:18:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775042293; cv=none; b=E4Fb1mG7ZHcGRMpQdwRMH8zsVY6eLzx50eJkorpfw6foNRA/l12T3Y6pNU779y8ZCUSwkHk9WT9H0KvMXGfivtIxBOsyWWRgTMq8tHswwE0Ds8EYVcj0EW31/bDYgnBeyg3C1r1PV1CUeomPi6rboXggIEqKWtUnbHcxgSikpYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775042293; c=relaxed/simple; bh=JPbB3lxSCXRaYUR+xW47osXy0IVHVCaCGPKYGLISgBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oFAHmtmBqv2bhEw8BbMidX2qrZkop9rki3t9iEvvPVLvpso4bte1UerC/jLWCvncl/+97ri+wnkTjbkf9uLgwnFaO9UqBgkQj5wRt1R5xbqKicxvx2KsDNi1+ojwMYPgwuruV6P4yMc88S5zupkV21QDHvdYeGegI8SWQdTO2cw= 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=l/z9Bv0O; arc=none smtp.client-ip=209.85.216.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="l/z9Bv0O" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-35d9749c26dso3203160a91.2 for ; Wed, 01 Apr 2026 04:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775042292; x=1775647092; 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=o8J9smKGowWMdR9oHje2W97PGn5/bAbt4cYk0bUF6U8=; b=l/z9Bv0OhWZn2idL3w9vT0dzaAoFYBrCYl73UBuDQYhH3BuL0791/extEym5JNGBBO r9WMFLTHKgyRx/beb8FhQ0OK+BzrpVbLzeRZ0PcCRxq+oqmoZbnJRYS8o/YeTmCU4rPu Zm9zxtvIl0J0rS/cVXdCMFCxNnNchOMUKSrWsz2/dDFlg1f168hT8WwE2zDKE4Thh+5U B/vz2yMJj7ysD9kojZtxbxXHVAn/tvcxJRu4B3GsQL439XfcHRYvI0I0XKlRAeFB3wRJ DLoU5BYgFeM/tnn3gkdg+ZqE6nIIAtIshQmRUKi7cxXZ1hprqkD3q3wBz4ZyXYusVcuW 4I7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775042292; x=1775647092; 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=o8J9smKGowWMdR9oHje2W97PGn5/bAbt4cYk0bUF6U8=; b=rZA9Qspa8SZsv01Qc41v6a4Ot5ojcXbkrm3zIC91Gaquwr9RNqNWps2RJW2caOh5Xk peGfP1052KkiM+wLYXLZmZAEFegBLfGOljPv/XDNSOlINfWl5yAaAINECkiE+xy7KHe0 GE91mK0DhlkSAF6aYJhntHaM99OPsfn9RuOO2owai8iWUwQE+/MOBOVxEHGywPx/IkwH Ao6Vr4RMG1kRQduZJPHcW2rnFxnYX+xJgQ0BVeLGUDuObe2yEYOt+GDPBxXTeAYx+T+s qYWW7nw/mmDgtFI0QloO7tF+//cRB6ap1aTdBzL4BP4dpX8rk2D48VT4HRI0OCrAende HZ7A== X-Forwarded-Encrypted: i=1; AJvYcCVxYO9TV8pzE79m+BF2gXoTt9VwpDTxsZLocRvxPLj50ET182VcSRcSQqrGs8USVTpvpsRg4O6NQoNu0bQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyFyVZSriAsGNOXwMFAfVD+aeGr6p+dESNf3nAs8re0YlEa99BX VFRafAJ+nPMKioP/I1ssD58z3Qouqw6utzpdfEF9AfoglrTzHJ39httD X-Gm-Gg: ATEYQzwXoiPfPKqorc7lAb18qdO43xcAnyYnR0OpnRlyulpXg/oWSxrfiNP40GCN+i9 KMRsOQ8jsgMPXY8nS7v/qDAuNGtbamjQmXCs12T4L+xEcWFpKORd8u6HFQ3DdzEXopZqQgPUwtn FrO8K6YzgzPjppsu3Y6Rp+pFkXoAeCSpyfcsxakHSlf7FOtEPE6RhNqeoSr9nxiT1sdJsZepwvF KfqC0oadU/GRDoW4N/U0TEBtmK7PKW34YyUEuWv0RgkidSTbdQXgFt6Wi7f0ohadTsUM5/eWPte Ff7mUQc4WVeqyZIvF9SWEjriARaJwWp3jWAt7GsjuY/854k6nL/EtOKkqiiJzEL68JoXn9ltrIh I0J2awxnn73TMrWcjqBRpx/t/jVEKKy7WHHdfRmbDE01RB+G0V3XpZiqVsq9R+aSM+A8eqZIAkx aK0CPUGma4GH0bclVwmfkOgd4vov0feoxnM+gaBDQ/0bsGQzDY3hXv9saX0MN9uxxCRrLFCX6ky 1S88nPIHHzWlqet/LDA X-Received: by 2002:a17:90b:1fc4:b0:359:f22:8879 with SMTP id 98e67ed59e1d1-35dc6f90b2amr3127278a91.22.1775042291968; Wed, 01 Apr 2026 04:18:11 -0700 (PDT) Received: from archlinux ([2405:201:1b:225c:eb9d:1fc0:f95c:bd90]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-35dcafd004fsm1889689a91.12.2026.04.01.04.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Apr 2026 04:18:11 -0700 (PDT) From: Krishna Chomal To: ilpo.jarvinen@linux.intel.com, hansg@kernel.org Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Krishna Chomal Subject: [PATCH 1/4] platform/x86: hp-wmi: fix fan table parsing Date: Wed, 1 Apr 2026 16:47:45 +0530 Message-ID: <20260401111748.106970-2-krishna.chomal108@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260401111748.106970-1-krishna.chomal108@gmail.com> References: <20260401111748.106970-1-krishna.chomal108@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" For Victus S devices, the BIOS fan table header was being incorrectly parsed as: struct { u8 unknown; u8 num_entries; } The first field should be num_fans and the second should be unknown. It is pure coincidence that interpreting an "unknown" field as "num_entries" worked on multiple device, however for board 8D87 (in an upcoming patch), this assumption fails, and the hp-wmi driver fails to load. We fix this by correcting the header definition and compensating for num_entries by parsing each entry of the fan table until an all-NULL row is obtained, mirroring the behavior of OMEN Gaming Hub on Windows. Fixes: 46be1453e6e6 ("platform/x86: hp-wmi: add manual fan control for Vict= us S models") Signed-off-by: Krishna Chomal --- drivers/platform/x86/hp/hp-wmi.c | 41 +++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 304d9ac63c8a..d630b7f6e146 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -433,14 +433,14 @@ struct hp_wmi_hwmon_priv { }; =20 struct victus_s_fan_table_header { + u8 num_fans; u8 unknown; - u8 num_entries; } __packed; =20 struct victus_s_fan_table_entry { u8 cpu_rpm; u8 gpu_rpm; - u8 unknown; + u8 noise_db; } __packed; =20 struct victus_s_fan_table { @@ -2514,7 +2514,9 @@ 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 cpu_rpm, gpu_rpm, noise_db; + int ret, num_entries, i; + size_t header_size, entry_size; =20 /* Default behaviour on hwmon init is automatic mode */ priv->mode =3D PWM_MODE_AUTO; @@ -2529,13 +2531,36 @@ static int hp_wmi_setup_fan_settings(struct hp_wmi_= hwmon_priv *priv) return ret; =20 fan_table =3D (struct victus_s_fan_table *)fan_data; - if (fan_table->header.num_entries =3D=3D 0 || - sizeof(struct victus_s_fan_table_header) + - sizeof(struct victus_s_fan_table_entry) * fan_table->header.num_entri= es > sizeof(fan_data)) + if (fan_table->header.num_fans =3D=3D 0) + return -EINVAL; + + header_size =3D sizeof(struct victus_s_fan_table_header); + entry_size =3D sizeof(struct victus_s_fan_table_entry); + num_entries =3D (sizeof(fan_data) - header_size) / entry_size; + min_rpm =3D U8_MAX; + max_rpm =3D 0; + + for (i =3D 0 ; i < num_entries ; i++) { + cpu_rpm =3D fan_table->entries[i].cpu_rpm; + gpu_rpm =3D fan_table->entries[i].gpu_rpm; + noise_db =3D fan_table->entries[i].noise_db; + + /* + * On some devices, the fan table is truncated with an all-zero row, + * hence we stop parsing here. + */ + if (cpu_rpm =3D=3D 0 && gpu_rpm =3D=3D 0 && noise_db =3D=3D 0) + break; + + if (cpu_rpm < min_rpm) + min_rpm =3D cpu_rpm; + if (cpu_rpm > max_rpm) + max_rpm =3D cpu_rpm; + } + + if (min_rpm =3D=3D U8_MAX || max_rpm =3D=3D 0) return -EINVAL; =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; priv->min_rpm =3D min_rpm; priv->max_rpm =3D max_rpm; --=20 2.53.0