From nobody Sun Feb 8 00:49:38 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 09CC734E741 for ; Tue, 13 Jan 2026 18:26:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768328775; cv=none; b=C1kvfeL2N6UfPc9aD+m6tChxSCGAaFWqwksZjDc17brSRp9bVIiwP12RFRmwtREomv05yMrC3Q5icjzNMluvPpF7XRSAv4/O0PyFpdSZ2vc9BhBcTIqZTlPsbjGmizC77U718q74zxZb7183PF0qS0ZHwd47LnUzs5Yi5NI47Yw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768328775; c=relaxed/simple; bh=E8aqnFvM4K3Nt8zDxyQsk5TKp4feIJvooiZvLGC+yYw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JsYirMm0HnoCoUFFhiH2lAo95x0w5SgFYiBF86y5M1ZK5lbnsLgcltmGlVhvmVtscGtmaVG0t7tNk95GbzwGVKt/HV4mNy7X+eIC1J2rIjhg8yCE3OVcB4k4sxJ+AJbnmWyX5MNWfWrsGkuThkM70I+ibakliEJENT1ZeynPCWs= 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=LUbqr5th; arc=none smtp.client-ip=209.85.214.169 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="LUbqr5th" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2a12ebe4b74so74666855ad.0 for ; Tue, 13 Jan 2026 10:26:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768328773; x=1768933573; 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=J0aB7par7PXxsxJdCMBUjL222cnm/OcauYEGIjh6sLU=; b=LUbqr5thGFfcgwASLMkgVqDrIfrb/ffqsaoEPM/EvJt4dedJlgD2DdDSj6pKTAZ3J+ w2uUefFOlNNJU8c6JwJebZDe0E9Ewql/7AO2QushlrUz027qf5mgwXamUvB7CAwXv9iP mH/el1ECQvPFt+Fu7J8TTmyj6hVHHbFtK8kI02xjl71mgeG1yTebjDEr2/nUHK9N1M2U V7474ONg/GJfYzkQT8d4aroa2crPq0Puuia0WWLYLYmzRL8IxtbZCCeieMj9U8TL/oQ1 BMwdksPdsisgMUTsgue6bIbaE3Cqa+0LDmvKjlNXdRHbkXrEsdlVSG3ybHW4ZKzIC9Ne qcug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768328773; x=1768933573; 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=J0aB7par7PXxsxJdCMBUjL222cnm/OcauYEGIjh6sLU=; b=i/wB76CsAjAgOQ9zAuZqIrCiCSVIjrAaPbWzeHzZoWNscwkGT7tSFuwWiAAYRHBG9k DSyNcPGnlT/ePDJo+VchCI8BbK8GxUoambKKBNervH8R8GmE0C6iRkNvyPo8qDhCRNoN Apl7L3CJIz3NLkDlIDlte776ZrUsrbya86wkTkaB8a0wAXF0DUdOfZJb0UKd3+lOtI94 KD/vVkv830QOYL6KTVNNt2PS9EZFSNyToqoLFNYamRQb2ggffie4RjZU/o+HJwAu/Do/ YdaqHqWJxf8V8j69Gdcj4NbfS5BAJ1PMJz2fhkh4PRvpTTwluxC9m1Z8iolBx8szQV4T GR6A== X-Forwarded-Encrypted: i=1; AJvYcCUd8qxHQO4rEXINL2AJ8VwG4kBMJiaMbdocxRlBt+7t/nvvKzVq7DUVOGIfkEPJUdF11HBcjPY9CYFSYxs=@vger.kernel.org X-Gm-Message-State: AOJu0YwCVpj9gDewx2doxLJbrmrxO8y+v2vWnFRli+T/oecr+EfAYzhr rdA5DBMCQtUKNqh0dBrjcSdKlqihNO1gSsJEwqZ9B5WyGmjWdDWuzsUhY+ZQDQ== X-Gm-Gg: AY/fxX4jkhNvIV5aLqtqxzeoagnFCxjesrjL2YFnJrZfJNxKZ6trLjiQkcKEEyq7+f0 yD6rYHaYJUfItKeiGvE7TR/XzM+MSc0zPd7Myz6bfhNv6bVT6fGj6JWRkRi1uV/nXi79kykpDmt 1MyYMHJ06APS/84vlH2ve3QI0RWInKrS/KmPXYdo4PZerabZLEojcZv8M//DwzJV5nlJH2vM9Gg 82jDdcNrQbRAeFnjK5wU8o8Vc8EfN8AiXj67L6XLTrViuwrsHr7U1g2J1pclnGbnvvDvnTpcitC XM4789IEpbeLRtLEaAg9+u57i8if5bCVpNe+hDoRPYMibeNgTGTECPj4bBHRo37ZU7j4dOxEHZz txmw6s4taCDDL6Jkn3a+3U7rA9FuqqX2Ibcm9TlGVI9eHQ5TGWliLGVMkO0jBh1Nf7xdflxB12c vSsyHTWuWVYLVssHbtkmqoSD12M8iiIA== X-Google-Smtp-Source: AGHT+IGnj1FApU9S7k9sNbYjdbdsD2R4IM2jcjcEar5SqGQSsaYZ3atmHVugnqUfcfkXalG1QStcRg== X-Received: by 2002:a17:903:2a87:b0:2a1:e19:ff5 with SMTP id d9443c01a7336-2a3ee487136mr215392495ad.38.1768328773242; Tue, 13 Jan 2026 10:26:13 -0800 (PST) Received: from archlinux ([2405:201:1b:225c:eb9d:1fc0:f95c:bd90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cc88f1sm204032685ad.78.2026.01.13.10.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 10:26:12 -0800 (PST) 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 v5 1/2] platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx Date: Tue, 13 Jan 2026 23:56:03 +0530 Message-ID: <20260113182604.115211-2-krishna.chomal108@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260113182604.115211-1-krishna.chomal108@gmail.com> References: <20251218124303.22024-1-krishna.chomal108@gmail.com> <20260113182604.115211-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" HP Omen 16-wf1xxx (board ID 8C78) currently sends the incorrect Victus-specific thermal profile values via WMI, leading to a logical inconsistency when switching between platform profiles. The driver currently uses Victus S values: 0x00 =3D> Balanced / Low-Power 0x01 =3D> Performance However, Omen Gaming Hub logs / EC register inspection on Windows shows that this board is intended to use: 0x30 =3D> Balanced / Low-Power 0x31 =3D> Performance This patch corrects the thermal profile command values to match the values observed from Omen Gaming Hub logs. The performance benchmarks and peak power draw (from both CPU and GPU) show no observable change with this correction (suggesting that the firmware is currently tolerant of the incorrect values). However sending the correct values prevents potential regressions after future firmware updates. Refactor victus_s_thermal_profile_boards from a list of strings to a dmi_system_id table and move the lookup to module init. The new struct thermal_profile_params is used to store board-specific WMI parameters, allowing the driver to cache these values in a static pointer. This avoids repeated DMI string comparisons and allows marking of DMI table as __initconst. Testing on HP Omen 16-wf1xxx (board 8C78) confirmed WMI codes 0x30/0x31 are now sent, resolving the logical inconsistency and ensuring the value visible in EC registers match the Windows state for this profile. Fixes: fb146a38cb11 ("platform/x86: hp-wmi: Add Omen 16-wf1xxx fan support") Signed-off-by: Krishna Chomal --- Changes in v3: - Fixed minor formatting issues. - Renamed struct field `eco` to `low_power` for consistency. - Marked the DMI table as __initconst. - Moved DMI lookup to hp_wmi_init() and save the active thermal profile params. - Added a static boolean flag to optimize is_victus_s_thermal_profile(). Changes in v2: - Refactored `victus_s_thermal_profile_boards` to use `struct dmi_system_id` - Implemented `driver_data` to handle thermal profile parameters, replacing the conditional checks in `platform_profile_victus_s_set_ec` - Moved enum definitions for thermal profile values earlier in the file to support the new `struct thermal_profile_params`. --- drivers/platform/x86/hp/hp-wmi.c | 179 ++++++++++++++++++++++--------- 1 file changed, 127 insertions(+), 52 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index f4ea1ea05997..24d065ddfc6a 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -53,6 +53,66 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4"); =20 #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when z= ero insize is required =20 +enum hp_thermal_profile_omen_v0 { + HP_OMEN_V0_THERMAL_PROFILE_DEFAULT =3D 0x00, + HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE =3D 0x01, + HP_OMEN_V0_THERMAL_PROFILE_COOL =3D 0x02, +}; + +enum hp_thermal_profile_omen_v1 { + HP_OMEN_V1_THERMAL_PROFILE_DEFAULT =3D 0x30, + HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE =3D 0x31, + HP_OMEN_V1_THERMAL_PROFILE_COOL =3D 0x50, +}; + +enum hp_thermal_profile_omen_flags { + HP_OMEN_EC_FLAGS_TURBO =3D 0x04, + HP_OMEN_EC_FLAGS_NOTIMER =3D 0x02, + HP_OMEN_EC_FLAGS_JUSTSET =3D 0x01, +}; + +enum hp_thermal_profile_victus { + HP_VICTUS_THERMAL_PROFILE_DEFAULT =3D 0x00, + HP_VICTUS_THERMAL_PROFILE_PERFORMANCE =3D 0x01, + HP_VICTUS_THERMAL_PROFILE_QUIET =3D 0x03, +}; + +enum hp_thermal_profile_victus_s { + HP_VICTUS_S_THERMAL_PROFILE_DEFAULT =3D 0x00, + HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE =3D 0x01, +}; + +enum hp_thermal_profile { + HP_THERMAL_PROFILE_PERFORMANCE =3D 0x00, + HP_THERMAL_PROFILE_DEFAULT =3D 0x01, + HP_THERMAL_PROFILE_COOL =3D 0x02, + HP_THERMAL_PROFILE_QUIET =3D 0x03, +}; + +struct thermal_profile_params { + u8 performance; + u8 balanced; + u8 low_power; +}; + +static const struct thermal_profile_params victus_s_thermal_params =3D { + .performance =3D HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE, + .balanced =3D HP_VICTUS_S_THERMAL_PROFILE_DEFAULT, + .low_power =3D HP_VICTUS_S_THERMAL_PROFILE_DEFAULT, +}; + +static const struct thermal_profile_params omen_v1_thermal_params =3D { + .performance =3D HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE, + .balanced =3D HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, + .low_power =3D HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, +}; + +/* + * A generic pointer for the currently-active board's thermal profile + * parameters. + */ +static struct thermal_profile_params *active_thermal_profile_params; + /* DMI board names of devices that should use the omen specific path for * thermal profiles. * This was obtained by taking a look in the windows omen command center @@ -99,12 +159,40 @@ static const char * const victus_thermal_profile_board= s[] =3D { }; =20 /* DMI Board names of Victus 16-r and Victus 16-s laptops */ -static const char * const victus_s_thermal_profile_boards[] =3D { - "8BBE", "8BD4", "8BD5", - "8C78", "8C99", "8C9C", - "8D41", +static const struct dmi_system_id victus_s_thermal_profile_boards[] __init= const =3D { + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8BBE") }, + .driver_data =3D (void *)&victus_s_thermal_params, + }, + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8BD4") }, + .driver_data =3D (void *)&victus_s_thermal_params, + }, + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8BD5") }, + .driver_data =3D (void *)&victus_s_thermal_params, + }, + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8C78") }, + .driver_data =3D (void *)&omen_v1_thermal_params, + }, + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8C99") }, + .driver_data =3D (void *)&victus_s_thermal_params, + }, + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8C9C") }, + .driver_data =3D (void *)&victus_s_thermal_params, + }, + { + .matches =3D { DMI_MATCH(DMI_BOARD_NAME, "8D41") }, + .driver_data =3D (void *)&victus_s_thermal_params, + }, + {}, }; =20 +static bool is_victus_s_board; + enum hp_wmi_radio { HPWMI_WIFI =3D 0x0, HPWMI_BLUETOOTH =3D 0x1, @@ -225,42 +313,6 @@ enum hp_wireless2_bits { HPWMI_POWER_FW_OR_HW =3D HPWMI_POWER_BIOS | HPWMI_POWER_HARD, }; =20 -enum hp_thermal_profile_omen_v0 { - HP_OMEN_V0_THERMAL_PROFILE_DEFAULT =3D 0x00, - HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE =3D 0x01, - HP_OMEN_V0_THERMAL_PROFILE_COOL =3D 0x02, -}; - -enum hp_thermal_profile_omen_v1 { - HP_OMEN_V1_THERMAL_PROFILE_DEFAULT =3D 0x30, - HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE =3D 0x31, - HP_OMEN_V1_THERMAL_PROFILE_COOL =3D 0x50, -}; - -enum hp_thermal_profile_omen_flags { - HP_OMEN_EC_FLAGS_TURBO =3D 0x04, - HP_OMEN_EC_FLAGS_NOTIMER =3D 0x02, - HP_OMEN_EC_FLAGS_JUSTSET =3D 0x01, -}; - -enum hp_thermal_profile_victus { - HP_VICTUS_THERMAL_PROFILE_DEFAULT =3D 0x00, - HP_VICTUS_THERMAL_PROFILE_PERFORMANCE =3D 0x01, - HP_VICTUS_THERMAL_PROFILE_QUIET =3D 0x03, -}; - -enum hp_thermal_profile_victus_s { - HP_VICTUS_S_THERMAL_PROFILE_DEFAULT =3D 0x00, - HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE =3D 0x01, -}; - -enum hp_thermal_profile { - HP_THERMAL_PROFILE_PERFORMANCE =3D 0x00, - HP_THERMAL_PROFILE_DEFAULT =3D 0x01, - HP_THERMAL_PROFILE_COOL =3D 0x02, - HP_THERMAL_PROFILE_QUIET =3D 0x03, -}; - #define IS_HWBLOCKED(x) ((x & HPWMI_POWER_FW_OR_HW) !=3D HPWMI_POWER_FW_OR= _HW) #define IS_SWBLOCKED(x) !(x & HPWMI_POWER_SOFT) =20 @@ -1581,15 +1633,8 @@ static int platform_profile_victus_set_ec(enum platf= orm_profile_option profile) =20 static bool is_victus_s_thermal_profile(void) { - const char *board_name; - - board_name =3D dmi_get_system_info(DMI_BOARD_NAME); - if (!board_name) - return false; - - return match_string(victus_s_thermal_profile_boards, - ARRAY_SIZE(victus_s_thermal_profile_boards), - board_name) >=3D 0; + /* Initialised in driver init, hence safe to use here */ + return is_victus_s_board; } =20 static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable, @@ -1672,25 +1717,30 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2) =20 static int platform_profile_victus_s_set_ec(enum platform_profile_option p= rofile) { + struct thermal_profile_params *params; bool gpu_ctgp_enable, gpu_ppab_enable; u8 gpu_dstate; /* Test shows 1 =3D 100%, 2 =3D 50%, 3 =3D 25%, 4 =3D 12.5= % */ int err, tp; =20 + params =3D active_thermal_profile_params; + if (!params) + return -ENODEV; + switch (profile) { case PLATFORM_PROFILE_PERFORMANCE: - tp =3D HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE; + tp =3D params->performance; gpu_ctgp_enable =3D true; gpu_ppab_enable =3D true; gpu_dstate =3D 1; break; case PLATFORM_PROFILE_BALANCED: - tp =3D HP_VICTUS_S_THERMAL_PROFILE_DEFAULT; + tp =3D params->balanced; gpu_ctgp_enable =3D false; gpu_ppab_enable =3D true; gpu_dstate =3D 1; break; case PLATFORM_PROFILE_LOW_POWER: - tp =3D HP_VICTUS_S_THERMAL_PROFILE_DEFAULT; + tp =3D params->low_power; gpu_ctgp_enable =3D false; gpu_ppab_enable =3D false; gpu_dstate =3D 1; @@ -2227,6 +2277,26 @@ static int hp_wmi_hwmon_init(void) return 0; } =20 +static void __init setup_active_thermal_profile_params(void) +{ + const struct dmi_system_id *id; + + /* + * Currently only victus_s devices use the + * active_thermal_profile_params + */ + id =3D dmi_first_match(victus_s_thermal_profile_boards); + if (id) { + /* + * Marking this boolean is required to ensure that + * is_victus_s_thermal_profile() behaves like a valid + * wrapper. + */ + is_victus_s_board =3D true; + active_thermal_profile_params =3D id->driver_data; + } +} + static int __init hp_wmi_init(void) { int event_capable =3D wmi_has_guid(HPWMI_EVENT_GUID); @@ -2254,6 +2324,11 @@ static int __init hp_wmi_init(void) goto err_destroy_input; } =20 + /* + * Setup active board's thermal profile parameters before + * starting platform driver probe. + */ + setup_active_thermal_profile_params(); err =3D platform_driver_probe(&hp_wmi_driver, hp_wmi_bios_setup); if (err) goto err_unregister_device; --=20 2.52.0 From nobody Sun Feb 8 00:49:38 2026 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (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 958EE34F26F for ; Tue, 13 Jan 2026 18:26:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768328778; cv=none; b=LZb1QYAMGbuVz69Fnbl4/exR8196bnQuV96QlvtzsEldk8SHlb6riWfnmwcAyH8Q+otCy+vEEspHB0hp60gU7McVgj3Uhq7BTxpz03aHeEZKmc31D+89K9bfsrCidz8JW4SB5fPVBoHBzflB1sF6+QWs2DEgF2RkFRAwRgFKDds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768328778; c=relaxed/simple; bh=DwQNfw6cZyGJZF5IAN670+qVflaIjDjVdpRAsMYNz2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HM7KExFuzd2oeMDg/GSQUlDhg/Z7fOJw1mDHVaJQPWYH9ZKUgDnMXuXprZkEdpxvjpFeKIQ/RaPC7Zhdy/uFgb7s+W3EE0IFEVS42ffDUlOJrnJUZygJWcW26yDJBTdCbDb9Zm7FVjtSCy1TwqdAuadb5bKJAxH1cyRVQedvigI= 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=iyOB/iV/; arc=none smtp.client-ip=209.85.215.172 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="iyOB/iV/" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-c54f700b5b1so2959344a12.0 for ; Tue, 13 Jan 2026 10:26:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768328776; x=1768933576; 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=ZS/mPA/vlF4BtYp8bPWIloT1FKakXdQ4i992J5xL31k=; b=iyOB/iV/bKMK9n+RnkjnVxJfr/45Pfixu1aoLYiLwY5dSUobEspudFAGLr3jkQ2WVj m99Ke1sQ6AWBsHQ0sz6Gmmq+DhpGQrn7ouQUNVTa0u4b4Ci7C0aiiNYowUAeCxhIBTHR dc190g6B6oCbxooPJIQpY4WMn25XDmdiMT3P75d6H270108rsVJQ5pm7kBHxIKwBXLsD m3AEIxE9krjdiJH4LoGRjUnLtfX66Ln41zTQ6I+0e2P8VRtnpRHEOUekZ2RlAHcwDU3K SLHCu/bvnl8ZjBIujcQlpbP5LCka0NZib1esQT3fsgNcomKIIYdOXHqbiubWyfQ4mGc3 kAUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768328776; x=1768933576; 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=ZS/mPA/vlF4BtYp8bPWIloT1FKakXdQ4i992J5xL31k=; b=PJLJ8Jn2CnDWGGHcZkO+cxSpyMwiIr7xjQddCn3x7Q1EZltfbAK6plRJAzKJW5I5ej +e8WBReg0FPSowx3kPwZZp644P4Hp5Z78DGKKgNmjebkqVgYZbSWLQETXK6NXLAaSAWf ApMvtj0SOR8TjrnYZV8u5PFInEuo+VWCjZZEBumK2EC1+GIEL0RTNChHYcGofgX8wuf0 ok7pdqIzzF/QXvf3Cfv/ylajdhmPRQggxr6dg3m63dmL6HIgp8syXjfVto2gdFuoANwx SyxOMmD0jLLeJzJUc8szeyaSvC+naWnZ+6pb/WpTI3TceCOQISgVL3I/yR3+O4v/qy8h oK6g== X-Forwarded-Encrypted: i=1; AJvYcCU3G1oRtD/HClmcuJHyr7hHgInuzCGLDViLmLH1+bdA2tWdjpKtmoA1uLhsfwV/mrz9rjBRPTwAfcBic38=@vger.kernel.org X-Gm-Message-State: AOJu0YwRwzNk2lJzXUOTDTBUz9x4FnD8qx/eClheNNY0HconE+fBIfTQ ojLnY7UPrvVTukqTow1N3DKfbXm/A8amMLoj/SurMdXXQodwgjiVO50lhtsV2w== X-Gm-Gg: AY/fxX5i0qwxAxp5oNobapb4KqX8SRzj5E6rhAoLHvvmLWAjMjkCLYArENjCv4iFV/m qRtMcAGPt7DjVzXCRjkTdCwtyD5HMclL5cyF9SVQHalQKEKbIDexELZl4888XLlH60vi13RCH1w NzQKiMZIEiI8vKkGD0Hsd/pkUnvUPOWB4Cywg6FpKApUYHRFfCCVC+x4rLaDTRJWLltKkbf8xj/ BpfZYpmqrC5jZ4czkN0yr3atEfSPGQyRXZMaKf87xRjFWGmHV/txqp3vG4L4SORQ5heM9IgwdG4 6qQgSwTPAp+b5KZeZ0PffVi03+AnxFbPh28wUpJFbOII1IW339Cf9WHmZU4ccNp6khbu8TmpQ3f TUwYkLQXt0W2P1vvh0Z1fjfc8iSKKnE8xFxwU6sKrSdU/99y8LIXwqv9WuAxUbR0SBQ2giSoQqE VJr/mhJ3h0JyDjXy6ihW8= X-Google-Smtp-Source: AGHT+IGbQe3BFdyPjZ0mYCnBRYst/nWiLac+fIk8dG2DOWGAZhMmGXiOkSBMOhvRRCUUQYCxcnlU3w== X-Received: by 2002:a17:902:d708:b0:2a2:f2e6:cc54 with SMTP id d9443c01a7336-2a3ee424bfbmr141181825ad.4.1768328775724; Tue, 13 Jan 2026 10:26:15 -0800 (PST) Received: from archlinux ([2405:201:1b:225c:eb9d:1fc0:f95c:bd90]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a3e3cc88f1sm204032685ad.78.2026.01.13.10.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 10:26:15 -0800 (PST) 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 v5 2/2] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile Date: Tue, 13 Jan 2026 23:56:04 +0530 Message-ID: <20260113182604.115211-3-krishna.chomal108@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260113182604.115211-1-krishna.chomal108@gmail.com> References: <20251218124303.22024-1-krishna.chomal108@gmail.com> <20260113182604.115211-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" The current implementation for Victus S thermal profiles only supports setting the profile. The driver was missing the logic to read the hardware state, meaning it would default to "Balanced" on driver load, overriding the currently active profile. Furthermore, the driver could not detect if the firmware reset the profile on a power source change. Add platform_profile_victus_s_get_ec() to read the current thermal profile state directly from EC offset 0x59. Since both Balanced and Low-Power profiles share the same thermal profile value, differentiate them by querying the GPU CTGP and PPAB states via existing functions. Additionally, update the power source event notifier to use the actual hardware state when re-trigger CPU power limits actualization. Testing on HP Omen 16-wf1xxx (board ID 8C78) confirmed that the thermal profile is now persistent across driver loads and power source change events. Signed-off-by: Krishna Chomal --- Changes in v5: - Improved platform_profile_victus_s_get_ec() to support multiple EC layouts by iteratively probing offsets. Changes in v4: - Fixed platform_profile_victus_s_get_ec() to use both victus_s_thermal_params and omen_v1_thermal_params instead of active_thermal_params to fix regression caused in v3. - Handle err after calling victus_s_gpu_thermal_profile_get(). - Fixed a wrong function call in victus_s_powersource_event(). Changes in v3: - New patch in this series --- drivers/platform/x86/hp/hp-wmi.c | 100 +++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 11 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 24d065ddfc6a..ed52c697d2ea 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -13,6 +13,7 @@ =20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 +#include #include #include #include @@ -44,6 +45,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4"); #define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62 #define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63 #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95 +#define HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET 0x59 =20 #define HP_FAN_SPEED_AUTOMATIC 0x00 #define HP_POWER_LIMIT_DEFAULT 0x00 @@ -640,6 +642,12 @@ static bool is_omen_thermal_profile(void) board_name) >=3D 0; } =20 +static bool is_victus_s_thermal_profile(void) +{ + /* Initialised in driver init, hence safe to use here */ + return is_victus_s_board; +} + static int omen_get_thermal_policy_version(void) { unsigned char buffer[8] =3D { 0 }; @@ -1631,12 +1639,6 @@ static int platform_profile_victus_set_ec(enum platf= orm_profile_option profile) return 0; } =20 -static bool is_victus_s_thermal_profile(void) -{ - /* Initialised in driver init, hence safe to use here */ - return is_victus_s_board; -} - static int victus_s_gpu_thermal_profile_get(bool *ctgp_enable, bool *ppab_enable, u8 *dstate, @@ -1715,6 +1717,68 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2) return ret; } =20 +static int platform_profile_victus_s_get_ec(enum platform_profile_option *= profile) +{ + int ret, i; + bool current_ctgp_state, current_ppab_state; + u8 current_dstate, current_gpu_slowdown_temp, tp; + static const u8 tp_ec_offsets[2] =3D { HP_OMEN_EC_THERMAL_PROFILE_OFFSET, + HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET }; + + /* + * Victus S devices have more than 1 EC layouts, hence we cannot directly + * call omen_thermal_profile_get() like other platform_profile_*_get_ec() + * variants, since it would only resolve to that 1 type of board. Hence + * we iteratively query a set of candidates: tp_ec_offsets[] until we + * find a valid thermal profile. + */ + for (i =3D 0 ; i < ARRAY_SIZE(tp_ec_offsets) ; i++) { + ret =3D ec_read(tp_ec_offsets[i], &tp); + if (ret) + return ret; + + /* + * We cannot use active_thermal_profile_params here, because boards + * like 8C78 have tp =3D=3D 0x0 || tp =3D=3D 0x1 after cold boot, but lo= gically + * it should have tp =3D=3D 0x30 || tp =3D=3D 0x31, as corrected by the = Omen + * Gaming Hub on windows. Hence accept both of these values. + */ + if (tp =3D=3D victus_s_thermal_params.performance || + tp =3D=3D omen_v1_thermal_params.performance) { + *profile =3D PLATFORM_PROFILE_PERFORMANCE; + return 0; + } else if (tp =3D=3D victus_s_thermal_params.balanced || + tp =3D=3D omen_v1_thermal_params.balanced) { + /* + * Since both PLATFORM_PROFILE_LOW_POWER and + * PLATFORM_PROFILE_BALANCED share the same thermal + * profile parameter value, hence to differentiate + * between them, we query the GPU CTGP and PPAB states + * and compare based off of that. + */ + ret =3D victus_s_gpu_thermal_profile_get(¤t_ctgp_state, + ¤t_ppab_state, + ¤t_dstate, + ¤t_gpu_slowdown_temp); + if (ret < 0) + return ret; + + if (current_ctgp_state =3D=3D 0 && current_ppab_state =3D=3D 0) { + *profile =3D PLATFORM_PROFILE_LOW_POWER; + return 0; + } else if (current_ctgp_state =3D=3D 0 && current_ppab_state =3D=3D 1) { + *profile =3D PLATFORM_PROFILE_BALANCED; + return 0; + } else { + return -EINVAL; + } + } + } + + /* Failed to get thermal profile from all EC offsets */ + return -EINVAL; +} + static int platform_profile_victus_s_set_ec(enum platform_profile_option p= rofile) { struct thermal_profile_params *params; @@ -1882,6 +1946,7 @@ static int victus_s_powersource_event(struct notifier= _block *nb, void *data) { struct acpi_bus_event *event_entry =3D data; + enum platform_profile_option actual_profile; int err; =20 if (strcmp(event_entry->device_class, ACPI_AC_CLASS) !=3D 0) @@ -1889,6 +1954,17 @@ static int victus_s_powersource_event(struct notifie= r_block *nb, =20 pr_debug("Received power source device event\n"); =20 + guard(mutex)(&active_platform_profile_lock); + err =3D platform_profile_victus_s_get_ec(&actual_profile); + if (err < 0) { + /* + * Although we failed to get the current platform profile, we + * still want the other event consumers to process it. + */ + pr_warn("Failed to read current platform profile (%d)\n", err); + return NOTIFY_DONE; + } + /* * Switching to battery power source while Performance mode is active * needs manual triggering of CPU power limits. Same goes when switching @@ -1897,7 +1973,7 @@ static int victus_s_powersource_event(struct notifier= _block *nb, * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions. */ =20 - if (active_platform_profile =3D=3D PLATFORM_PROFILE_PERFORMANCE) { + if (actual_profile =3D=3D PLATFORM_PROFILE_PERFORMANCE) { pr_debug("Triggering CPU PL1/PL2 actualization\n"); err =3D victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT, HP_POWER_LIMIT_DEFAULT); @@ -2007,12 +2083,14 @@ static int thermal_profile_setup(struct platform_de= vice *device) =20 ops =3D &platform_profile_victus_ops; } else if (is_victus_s_thermal_profile()) { + err =3D platform_profile_victus_s_get_ec(&active_platform_profile); + if (err < 0) + return err; + /* - * Being unable to retrieve laptop's current thermal profile, - * during this setup, we set it to Balanced by default. + * call thermal profile write command to ensure that the + * firmware correctly sets the OEM variables */ - active_platform_profile =3D PLATFORM_PROFILE_BALANCED; - err =3D platform_profile_victus_s_set_ec(active_platform_profile); if (err < 0) return err; --=20 2.52.0 From nobody Sun Feb 8 00:49:38 2026 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (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 C0F3138B983 for ; Wed, 21 Jan 2026 18:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769020161; cv=none; b=bZBTUimSsOJNqK8mpqV2AiJHE7y+bZhupfxINknOrsi+WS00WP/9AugLcKcHBxeGyY7AUHhXOMsZAPXbKVKnjqRemzxPxvp5U5BW8B5BmeFQc9Y/L/RBi8HT+ubYlxmAiBQrml6Jv3Bof8o+9yy/Ft12U0LS0FGrOhuUM1YoReQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769020161; c=relaxed/simple; bh=svWYAOEp6ij6g+8vL15ysVMAJrFDV6PpHu6arYfSljY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z0i9BEBh/GJnFmfyM5Q8OpT4P03yd3Z6a6bh48iFO7eZgQ3j4jAIbmFkblDP4gA8yHPmuIypVuWLg7DrB/SgPuf5CQeyJWH5mTCNNV8njik1Dm6foYwicGwK4E4HiEBhaCDWKG0xR/c28ylVociPNIwWcDvjrs/6SbB5fOhzs8A= 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=kl4k3gWV; arc=none smtp.client-ip=209.85.214.176 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="kl4k3gWV" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2a75a4a140eso766845ad.3 for ; Wed, 21 Jan 2026 10:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769020158; x=1769624958; 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=8Xl3aa6opPUprRkwoBGqbq15zpYR77lS9AnPKKGuIhw=; b=kl4k3gWV0DUMiu6q/PgEt278CRVqC8CkYxgZpfOwQkpIoU8E1vLLRPflqrBNBbJCu7 0J6MeEHe7bcS1EVYfFj/Pbr1jkkS190VbE3LXiFt+YaZXHJ5HSRFgG17RPBBWhWGe3rd XD2tsxyAHNa0xZdVqXJSILEBrpnQZ7U6QXPzmywsQKXy6MtxQgXRZpjbh2P0oSqbSPQA D38Dm1AiTjUZ+oQegZZFQdWXNoeW9mE1vIRqPZz3hPGfuqPD0z+eb3uscR4ljPPUayok qHNoUm2UrQHjMCUa8iMKuSuIk7AtUOTqhmckq6B7vNVXc2+V3cmuVdH4Rz2l4qaTqnio oB8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769020158; x=1769624958; 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=8Xl3aa6opPUprRkwoBGqbq15zpYR77lS9AnPKKGuIhw=; b=KBLIVbELR1dYVfjwa6ehRkGed7etikv1DgPaONG+z8gQio+39OFobsmmNIFh4r4lYE 1nAURqyc1eFdl0XYuMZdCBLBw0IKuAurlcczcArC0gzHbEnAH05b7LowoCPPGj95Usy0 96XUnVReBQyp0T7zyfY18IF3Hf7IXeKjTBlgol7nEp58Uz9hD4OAw9lUaCZp6Cad7+0S 9OTdaPebppUyazOV6twX/Rpz4P23WInnT2cFQ5pREdt4NsXC6vPLiEIIKkJxd8I11hX/ Q0YFYq/xFHEdubVT4lMrRZaCcAlgJIuUWe3qYCDNtRi5mYJUdeF88WSRvMS5UZXI01cB Csfg== X-Forwarded-Encrypted: i=1; AJvYcCVgQarbBffnFxtXromOUfZrCBDig0HR0t8lQUSjg48tgVEUyQUZIfyMWwCl2rWMgMvCuKh+pAtWM8tTa80=@vger.kernel.org X-Gm-Message-State: AOJu0Ywr0z+7eGZ6ahI9grdM4gkdONMLJylrrGk66msQgqCHBMwSxGIn Rks8rToYPeO6pv1hOurWriLVz58ArOpuZT8fEXlV8xEnFXzwptXfObSk X-Gm-Gg: AZuq6aLdOJKh8mjBe/B5zNSe14KaXLZWXzBxH83dOZHzjh7usDqP4wd2yzMH9io/c02 K/jad7esM657BIkpO08saA29hI9So9iffn8YR27gWKhi095qATyPs9WB8xXfP1TXmi92+knhfId I+USTaPz/pfKstxupzESSawalxsM/3tL2eCo4EsesAHrHzLXd9sYhzzPx0ioWklXHcUqS0t0O3E Glt3KrF+g0dRD+mPqlA7pCmOSBDtQMV2s/PzEPvabnP+Mmy0SmaVBehyBmMaTpas7ipw7Px2r9q AX5+yJdxKST7cmd2Kp+1mjfCgdEyS+Z5Lr7nVd1A4r83o+2x4GXfAkSi2Z0uHnuWV4knOFZPdFb KAWAA25haowdIlKh/lyCG1DctQhBYnR8E/qq7oinnYJt7rB6/OzpyTdjWbI20Lezl2ZrBFGyr4r D31dN7GSarZRebty7dAtM= X-Received: by 2002:a17:902:ecc6:b0:2a0:afeb:fbbb with SMTP id d9443c01a7336-2a768b7a743mr49195465ad.1.1769020157611; Wed, 21 Jan 2026 10:29:17 -0800 (PST) Received: from archlinux ([2405:201:1b:225c:9e18:7101:be84:75eb]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a7193dc83dsm162051195ad.50.2026.01.21.10.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 10:29:16 -0800 (PST) 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 v6] platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile Date: Wed, 21 Jan 2026 23:58:58 +0530 Message-ID: <20260121182858.66363-1-krishna.chomal108@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260113182604.115211-1-krishna.chomal108@gmail.com> References: <20260113182604.115211-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" The current implementation for Victus S thermal profiles only supports setting the profile. The driver was missing the logic to read the hardware state, meaning it would default to "Balanced" on driver load, overriding the currently active profile. Furthermore, the driver could not detect if the firmware reset the profile on a power source change. Statically store the known EC offsets for reading thermal profile in the new .ec_tp_offset field of struct thermal_profile_params. Implement platform_profile_victus_s_get_ec() to use this offset to read the real hardware state. Additionally, update the power source event notifier to use the actual hardware state when re-triggering CPU power limits actualization. Testing on HP Omen 16-wf1xxx (board ID 8C78) confirmed that the thermal profile is now persistent across driver loads and power source change events. Signed-off-by: Krishna Chomal --- NOTE: Patch 1/2 of the v5 series (platform/x86: hp-wmi: fix platform profile values for Omen 16-wf1xxx) is already accepted into pdx86/for-next. This v6 contains only the remaining logic for EC readback and is based on the for-next branch. Changes in v6: - Update struct thermal_profile_params to include .ec_tp_offset field. - Use this field for reading from the embedded-controller. - Add a pr_warn for "unknown ec layout" boards once during init. Changes in v5: - Improved platform_profile_victus_s_get_ec() to support multiple EC layouts by iteratively probing offsets. Changes in v4: - Fixed platform_profile_victus_s_get_ec() to use both victus_s_thermal_params and omen_v1_thermal_params instead of active_thermal_params to fix regression caused in v3. - Handle err after calling victus_s_gpu_thermal_profile_get(). - Fixed a wrong function call in victus_s_powersource_event(). Changes in v3: - New patch in this series. --- drivers/platform/x86/hp/hp-wmi.c | 103 ++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-= wmi.c index 31c6cca6ec34..304d9ac63c8a 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -46,9 +46,13 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4"); #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" #define HPWMI_BIOS_GUID "5FB7F034-2C63-45E9-BE91-3D44E2C707E4" =20 -#define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62 -#define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63 -#define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95 +enum hp_ec_offsets { + HP_EC_OFFSET_UNKNOWN =3D 0x00, + HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET =3D 0x59, + HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET =3D 0x62, + HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET =3D 0x63, + HP_OMEN_EC_THERMAL_PROFILE_OFFSET =3D 0x95, +}; =20 #define HP_FAN_SPEED_AUTOMATIC 0x00 #define HP_POWER_LIMIT_DEFAULT 0x00 @@ -94,22 +98,26 @@ enum hp_thermal_profile { HP_THERMAL_PROFILE_QUIET =3D 0x03, }; =20 + struct thermal_profile_params { u8 performance; u8 balanced; u8 low_power; + u8 ec_tp_offset; }; =20 static const struct thermal_profile_params victus_s_thermal_params =3D { .performance =3D HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE, .balanced =3D HP_VICTUS_S_THERMAL_PROFILE_DEFAULT, .low_power =3D HP_VICTUS_S_THERMAL_PROFILE_DEFAULT, + .ec_tp_offset =3D HP_EC_OFFSET_UNKNOWN, }; =20 static const struct thermal_profile_params omen_v1_thermal_params =3D { .performance =3D HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE, .balanced =3D HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, .low_power =3D HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, + .ec_tp_offset =3D HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET, }; =20 /* @@ -1785,6 +1793,60 @@ static int victus_s_set_cpu_pl1_pl2(u8 pl1, u8 pl2) return ret; } =20 +static int platform_profile_victus_s_get_ec(enum platform_profile_option *= profile) +{ + int ret =3D 0; + bool current_ctgp_state, current_ppab_state; + u8 current_dstate, current_gpu_slowdown_temp, tp; + const struct thermal_profile_params *params; + + params =3D active_thermal_profile_params; + if (params->ec_tp_offset =3D=3D HP_EC_OFFSET_UNKNOWN) { + *profile =3D active_platform_profile; + return 0; + } + + ret =3D ec_read(params->ec_tp_offset, &tp); + if (ret) + return ret; + + /* + * We cannot use active_thermal_profile_params here, because boards + * like 8C78 have tp =3D=3D 0x0 || tp =3D=3D 0x1 after cold boot, but log= ically + * it should have tp =3D=3D 0x30 || tp =3D=3D 0x31, as corrected by the O= men + * Gaming Hub on windows. Hence accept both of these values. + */ + if (tp =3D=3D victus_s_thermal_params.performance || + tp =3D=3D omen_v1_thermal_params.performance) { + *profile =3D PLATFORM_PROFILE_PERFORMANCE; + } else if (tp =3D=3D victus_s_thermal_params.balanced || + tp =3D=3D omen_v1_thermal_params.balanced) { + /* + * Since both PLATFORM_PROFILE_LOW_POWER and + * PLATFORM_PROFILE_BALANCED share the same thermal profile + * parameter value, hence to differentiate between them, we + * query the GPU CTGP and PPAB states and compare based off of + * that. + */ + ret =3D victus_s_gpu_thermal_profile_get(¤t_ctgp_state, + ¤t_ppab_state, + ¤t_dstate, + ¤t_gpu_slowdown_temp); + if (ret < 0) + return ret; + if (current_ctgp_state =3D=3D 0 && current_ppab_state =3D=3D 0) + *profile =3D PLATFORM_PROFILE_LOW_POWER; + else if (current_ctgp_state =3D=3D 0 && current_ppab_state =3D=3D 1) + *profile =3D PLATFORM_PROFILE_BALANCED; + else + return -EINVAL; + } else { + return -EINVAL; + } + + return 0; +} + static int platform_profile_victus_s_set_ec(enum platform_profile_option p= rofile) { struct thermal_profile_params *params; @@ -1952,6 +2014,7 @@ static int victus_s_powersource_event(struct notifier= _block *nb, void *data) { struct acpi_bus_event *event_entry =3D data; + enum platform_profile_option actual_profile; int err; =20 if (strcmp(event_entry->device_class, ACPI_AC_CLASS) !=3D 0) @@ -1959,6 +2022,17 @@ static int victus_s_powersource_event(struct notifie= r_block *nb, =20 pr_debug("Received power source device event\n"); =20 + guard(mutex)(&active_platform_profile_lock); + err =3D platform_profile_victus_s_get_ec(&actual_profile); + if (err < 0) { + /* + * Although we failed to get the current platform profile, we + * still want the other event consumers to process it. + */ + pr_warn("Failed to read current platform profile (%d)\n", err); + return NOTIFY_DONE; + } + /* * Switching to battery power source while Performance mode is active * needs manual triggering of CPU power limits. Same goes when switching @@ -1967,7 +2041,7 @@ static int victus_s_powersource_event(struct notifier= _block *nb, * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions. */ =20 - if (active_platform_profile =3D=3D PLATFORM_PROFILE_PERFORMANCE) { + if (actual_profile =3D=3D PLATFORM_PROFILE_PERFORMANCE) { pr_debug("Triggering CPU PL1/PL2 actualization\n"); err =3D victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT, HP_POWER_LIMIT_DEFAULT); @@ -2078,11 +2152,22 @@ static int thermal_profile_setup(struct platform_de= vice *device) ops =3D &platform_profile_victus_ops; } else if (is_victus_s_thermal_profile()) { /* - * Being unable to retrieve laptop's current thermal profile, - * during this setup, we set it to Balanced by default. + * For an unknown EC layout board, platform_profile_victus_s_get_ec(), + * behaves like a wrapper around active_platform_profile, to avoid using + * uninitialized data, we default to PLATFORM_PROFILE_BALANCED. */ - active_platform_profile =3D PLATFORM_PROFILE_BALANCED; + if (active_thermal_profile_params->ec_tp_offset =3D=3D HP_EC_OFFSET_UNKN= OWN) { + active_platform_profile =3D PLATFORM_PROFILE_BALANCED; + } else { + err =3D platform_profile_victus_s_get_ec(&active_platform_profile); + if (err < 0) + return err; + } =20 + /* + * call thermal profile write command to ensure that the + * firmware correctly sets the OEM variables + */ err =3D platform_profile_victus_s_set_ec(active_platform_profile); if (err < 0) return err; @@ -2505,6 +2590,10 @@ static void __init setup_active_thermal_profile_para= ms(void) */ is_victus_s_board =3D true; active_thermal_profile_params =3D id->driver_data; + if (active_thermal_profile_params->ec_tp_offset =3D=3D HP_EC_OFFSET_UNKN= OWN) { + pr_warn("Unknown EC layout for board %s. Thermal profile readback will = be disabled. Please report this to platform-driver-x86@vger.kernel.org\n", + dmi_get_system_info(DMI_BOARD_NAME)); + } } } =20 --=20 2.52.0