Re: [PATCH] platform/x86: acer-wmi: improve platform profile handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 02, 2025 at 12:20:36PM +0530, Hridesh MG wrote:
> On Thu, Jan 2, 2025 at 2:28 AM Armin Wolf <W_Armin@xxxxxx> wrote:
> > > @@ -1946,12 +2038,10 @@ static int acer_thermal_profile_change(void)
> > >               u8 current_tp;
> > >               int tp, err;
> > >               u64 on_AC;
> > > -             acpi_status status;
> > > -
> > > -             err = ec_read(ACER_PREDATOR_V4_THERMAL_PROFILE_EC_OFFSET,
> > > -                           &current_tp);
> > >
> > > -             if (err < 0)
> > > +             err = WMID_gaming_get_misc_setting(ACER_WMID_MISC_SETTING_PLATFORM_PROFILE,
> > > +                                                &current_tp);
> > > +             if (err)
> > >                       return err;
> > >
> > >               /* Check power source */
> > > @@ -1962,54 +2052,52 @@ static int acer_thermal_profile_change(void)
> > >               switch (current_tp) {
> > >               case ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO:
> > >                       if (!on_AC)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED;
> > >                       else if (cycle_gaming_thermal_profile)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_ECO_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_ECO;
> > >                       else
> > >                               tp = last_non_turbo_profile;
> > >                       break;
> > >               case ACER_PREDATOR_V4_THERMAL_PROFILE_PERFORMANCE:
> > >                       if (!on_AC)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED;
> > >                       else
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
> > >                       break;
> > >               case ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED:
> > >                       if (!on_AC)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_ECO_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_ECO;
> > >                       else if (cycle_gaming_thermal_profile)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_PERFORMANCE_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_PERFORMANCE;
> > >                       else
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
> > >                       break;
> > >               case ACER_PREDATOR_V4_THERMAL_PROFILE_QUIET:
> > >                       if (!on_AC)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED;
> > >                       else if (cycle_gaming_thermal_profile)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED;
> > >                       else
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
> > >                       break;
> > >               case ACER_PREDATOR_V4_THERMAL_PROFILE_ECO:
> > >                       if (!on_AC)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_BALANCED;
> > >                       else if (cycle_gaming_thermal_profile)
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_QUIET_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_QUIET;
> > >                       else
> > > -                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO_WMI;
> > > +                             tp = ACER_PREDATOR_V4_THERMAL_PROFILE_TURBO;
> > >                       break;
> > >               default:
> > >                       return -EOPNOTSUPP;
> > >               }
> >
> > This needs a bit more work, since you might accidentally select unsupported platform profiles this way.
> >
> > Using platform_profile_cycle() would make sense here, but we still need to handle "on_AC". I however wonder
> > if that is really necessary.
> >
> >From my testing, what I've found out is that even if we don't handle
> on_AC, the profile is still set but the hardware will not put the
> changes into effect until we plug in AC.

This is interesting.

Do you perhaps know if users expect a thermal profile change on AC
connect/disconnect events on Windows? This would solve this discussion
[1].

~ Kurt

[1] https://lore.kernel.org/platform-driver-x86/20241210001657.3362-6-W_Armin@xxxxxx/

> 
> I've incorporated the rest of the changes into v2, thanks for the feedback!
> 
> --
> Thanks,
> Hridesh MG




[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux