platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops
authorAlexis Belmonte <alexbelm48@gmail.com>
Mon, 8 Jul 2024 12:55:55 +0000 (14:55 +0200)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 9 Jul 2024 12:16:52 +0000 (15:16 +0300)
commitd2343023349441173cefcdeb517fc7d5273b4fab
tree981b54bdb989b7c99c5879dc257efad230d5daca
parent356eda93fa48b2cd6c4a4628a6b9c94743f270f8
platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops

Fix a platform profile option switch/getter bug on some Omen and Victus
laptops dismissing userspace choice when selecting performance mode in
inadequate conditions (e.g. by being disconnected from the AC power plug)
by

   -  hooking an ACPI notify handler through the
      omen_register_powersource_event_handler method that listens to AC
      power source changes (plugging in/out the AC power plug)

   -  keeping an intermediate active_platform_profile variable that is
      set when userspace changes the platform profile setting

   -  restoring the selected platform profile kept in
      active_platform_profile when AC power is plugged back into the
      laptop through the power_supply_is_system_supplied call check,
      unless if the user decided to alter the platform profile mid-way

Add a dependency to the POWER_SUPPLY subsystem to be able to check for
power_supply_is_system_supplied.

Introduce intermediary functions to leverage platform profile <->
internal thermal profile translation code from platform_profile_omen_set
and callers.

These changes makes the module compliant with the principles defined in
the Platform Profile Selection page of the Kernel documentation on those
kind of laptops; which is to not "(...) let userspace know about any
sub-optimal conditions which are impeding reaching the requested
performance level".

Since the Omen and Victus laptops share the same embedded controller
system, the fix is applicable to both categories of laptops.

Signed-off-by: Alexis Belmonte <alexbelm48@gmail.com>
Link: https://lore.kernel.org/r/Zovh22-7B1jI7sfF@alexis-pc
[ij: Made active_platform_profile_lock static]
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/hp/Kconfig
drivers/platform/x86/hp/hp-wmi.c
This page took 0.044401 seconds and 4 git commands to generate.