Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

platform/x86: hp-wmi: Add EC offsets to read Victus S thermal profile

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 <krishna.chomal108@gmail.com>
Link: https://patch.msgid.link/20260121182858.66363-1-krishna.chomal108@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Krishna Chomal and committed by
Ilpo Järvinen
eeeb4c98 059417ea

+96 -7
+96 -7
drivers/platform/x86/hp/hp-wmi.c
··· 46 46 #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" 47 47 #define HPWMI_BIOS_GUID "5FB7F034-2C63-45E9-BE91-3D44E2C707E4" 48 48 49 - #define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62 50 - #define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63 51 - #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95 49 + enum hp_ec_offsets { 50 + HP_EC_OFFSET_UNKNOWN = 0x00, 51 + HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET = 0x59, 52 + HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET = 0x62, 53 + HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET = 0x63, 54 + HP_OMEN_EC_THERMAL_PROFILE_OFFSET = 0x95, 55 + }; 52 56 53 57 #define HP_FAN_SPEED_AUTOMATIC 0x00 54 58 #define HP_POWER_LIMIT_DEFAULT 0x00 ··· 98 94 HP_THERMAL_PROFILE_QUIET = 0x03, 99 95 }; 100 96 97 + 101 98 struct thermal_profile_params { 102 99 u8 performance; 103 100 u8 balanced; 104 101 u8 low_power; 102 + u8 ec_tp_offset; 105 103 }; 106 104 107 105 static const struct thermal_profile_params victus_s_thermal_params = { 108 106 .performance = HP_VICTUS_S_THERMAL_PROFILE_PERFORMANCE, 109 107 .balanced = HP_VICTUS_S_THERMAL_PROFILE_DEFAULT, 110 108 .low_power = HP_VICTUS_S_THERMAL_PROFILE_DEFAULT, 109 + .ec_tp_offset = HP_EC_OFFSET_UNKNOWN, 111 110 }; 112 111 113 112 static const struct thermal_profile_params omen_v1_thermal_params = { 114 113 .performance = HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE, 115 114 .balanced = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, 116 115 .low_power = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT, 116 + .ec_tp_offset = HP_VICTUS_S_EC_THERMAL_PROFILE_OFFSET, 117 117 }; 118 118 119 119 /* ··· 1793 1785 return ret; 1794 1786 } 1795 1787 1788 + static int platform_profile_victus_s_get_ec(enum platform_profile_option *profile) 1789 + { 1790 + int ret = 0; 1791 + bool current_ctgp_state, current_ppab_state; 1792 + u8 current_dstate, current_gpu_slowdown_temp, tp; 1793 + const struct thermal_profile_params *params; 1794 + 1795 + params = active_thermal_profile_params; 1796 + if (params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) { 1797 + *profile = active_platform_profile; 1798 + return 0; 1799 + } 1800 + 1801 + ret = ec_read(params->ec_tp_offset, &tp); 1802 + if (ret) 1803 + return ret; 1804 + 1805 + /* 1806 + * We cannot use active_thermal_profile_params here, because boards 1807 + * like 8C78 have tp == 0x0 || tp == 0x1 after cold boot, but logically 1808 + * it should have tp == 0x30 || tp == 0x31, as corrected by the Omen 1809 + * Gaming Hub on windows. Hence accept both of these values. 1810 + */ 1811 + if (tp == victus_s_thermal_params.performance || 1812 + tp == omen_v1_thermal_params.performance) { 1813 + *profile = PLATFORM_PROFILE_PERFORMANCE; 1814 + } else if (tp == victus_s_thermal_params.balanced || 1815 + tp == omen_v1_thermal_params.balanced) { 1816 + /* 1817 + * Since both PLATFORM_PROFILE_LOW_POWER and 1818 + * PLATFORM_PROFILE_BALANCED share the same thermal profile 1819 + * parameter value, hence to differentiate between them, we 1820 + * query the GPU CTGP and PPAB states and compare based off of 1821 + * that. 1822 + */ 1823 + ret = victus_s_gpu_thermal_profile_get(&current_ctgp_state, 1824 + &current_ppab_state, 1825 + &current_dstate, 1826 + &current_gpu_slowdown_temp); 1827 + if (ret < 0) 1828 + return ret; 1829 + if (current_ctgp_state == 0 && current_ppab_state == 0) 1830 + *profile = PLATFORM_PROFILE_LOW_POWER; 1831 + else if (current_ctgp_state == 0 && current_ppab_state == 1) 1832 + *profile = PLATFORM_PROFILE_BALANCED; 1833 + else 1834 + return -EINVAL; 1835 + } else { 1836 + return -EINVAL; 1837 + } 1838 + 1839 + return 0; 1840 + } 1841 + 1796 1842 static int platform_profile_victus_s_set_ec(enum platform_profile_option profile) 1797 1843 { 1798 1844 struct thermal_profile_params *params; ··· 2014 1952 void *data) 2015 1953 { 2016 1954 struct acpi_bus_event *event_entry = data; 1955 + enum platform_profile_option actual_profile; 2017 1956 int err; 2018 1957 2019 1958 if (strcmp(event_entry->device_class, ACPI_AC_CLASS) != 0) 2020 1959 return NOTIFY_DONE; 2021 1960 2022 1961 pr_debug("Received power source device event\n"); 1962 + 1963 + guard(mutex)(&active_platform_profile_lock); 1964 + err = platform_profile_victus_s_get_ec(&actual_profile); 1965 + if (err < 0) { 1966 + /* 1967 + * Although we failed to get the current platform profile, we 1968 + * still want the other event consumers to process it. 1969 + */ 1970 + pr_warn("Failed to read current platform profile (%d)\n", err); 1971 + return NOTIFY_DONE; 1972 + } 2023 1973 2024 1974 /* 2025 1975 * Switching to battery power source while Performance mode is active ··· 2041 1967 * Seen on HP 16-s1034nf (board 8C9C) with F.11 and F.13 BIOS versions. 2042 1968 */ 2043 1969 2044 - if (active_platform_profile == PLATFORM_PROFILE_PERFORMANCE) { 1970 + if (actual_profile == PLATFORM_PROFILE_PERFORMANCE) { 2045 1971 pr_debug("Triggering CPU PL1/PL2 actualization\n"); 2046 1972 err = victus_s_set_cpu_pl1_pl2(HP_POWER_LIMIT_DEFAULT, 2047 1973 HP_POWER_LIMIT_DEFAULT); ··· 2152 2078 ops = &platform_profile_victus_ops; 2153 2079 } else if (is_victus_s_thermal_profile()) { 2154 2080 /* 2155 - * Being unable to retrieve laptop's current thermal profile, 2156 - * during this setup, we set it to Balanced by default. 2081 + * For an unknown EC layout board, platform_profile_victus_s_get_ec(), 2082 + * behaves like a wrapper around active_platform_profile, to avoid using 2083 + * uninitialized data, we default to PLATFORM_PROFILE_BALANCED. 2157 2084 */ 2158 - active_platform_profile = PLATFORM_PROFILE_BALANCED; 2085 + if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) { 2086 + active_platform_profile = PLATFORM_PROFILE_BALANCED; 2087 + } else { 2088 + err = platform_profile_victus_s_get_ec(&active_platform_profile); 2089 + if (err < 0) 2090 + return err; 2091 + } 2159 2092 2093 + /* 2094 + * call thermal profile write command to ensure that the 2095 + * firmware correctly sets the OEM variables 2096 + */ 2160 2097 err = platform_profile_victus_s_set_ec(active_platform_profile); 2161 2098 if (err < 0) 2162 2099 return err; ··· 2590 2505 */ 2591 2506 is_victus_s_board = true; 2592 2507 active_thermal_profile_params = id->driver_data; 2508 + if (active_thermal_profile_params->ec_tp_offset == HP_EC_OFFSET_UNKNOWN) { 2509 + 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", 2510 + dmi_get_system_info(DMI_BOARD_NAME)); 2511 + } 2593 2512 } 2594 2513 } 2595 2514