X86 platform drivers
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Benjamin Berg <bberg@redhat.com>,
	Elia Devito <eliadevito@gmail.com>,
	Mark Pearson <mpearson@lenovo.com>
Cc: Bastien Nocera <hadess@hadess.net>,
	Jared Dominguez <jaredz@redhat.com>,
	platform-driver-x86@vger.kernel.org,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: RFC: offering a standardized (/sys/class) userspace API for selecting system/laptop performance-profiles
Date: Thu, 17 Sep 2020 14:45:43 +0200	[thread overview]
Message-ID: <35c8dd96-2e68-ac34-d1a5-78262a573287@redhat.com> (raw)
In-Reply-To: <b62caf7d0d7c78bfb7487cda969f55de30253a5c.camel@redhat.com>

Hi,

On 9/17/20 2:22 PM, Benjamin Berg wrote:
> Hi,
> 
> On Thu, 2020-09-17 at 13:22 +0200, Hans de Goede wrote:
>> The big question is what do we do if there are more then 3 profiles?
> 
> The Intel p-state driver has the 4 modes:
>   * performance
>   * balance_performance
>   * balance_power
>   * power
> 
> This seems to also match what windows does with their power slider,
> there the modes are mapped to integer values:
>   * power: 25
>   * balance_power: 50
>   * balance_performance: 75
>   * performance: 100
> 
> Which appears to be the same as what newer DPTF versions use. For older
> DPTF versions this is done through OEM variables, which also appear to
> have 4 separate states usually. The MS power slider seems to define the
> four possible modes:
>   * Battery Saver
>   * Better Battery
>   * Better Performance
>   * Best Performance
> 
> https://docs.microsoft.com/en-us/windows-hardware/customize/desktop/customize-power-slider#set-default-power-slider-mode
> 
>> One option would be something like the following:
>>
>> cat /sys/class/system_performance_profile/thinkpad_acpi/performance_profile
>>
>> low-power [balanced] performance
> 
> I guess userspace is responsible for setting all drivers to the correct
> state when the user changes a global system setting?

Yes.

>> cat /sys/class/system_performance_profile/thinkpad_acpi/extra_performance_profiles
>>
>> extra-low-power balanced-performance-mix
>>
>> So we add an optional extra_performance_profiles sysfs attribute and we ask all
>> drivers implemeting this class to implement at least the 3 standard profiles
>> (by mapping 3 of their options to these) and optional they can offer extra
>> profiles (with free form names) in the extra_performance_profiles
>> sysfs attribute under the class-device.
> 
> I think it would be good if userspace can figure out where such these
> extra profiles would be sorted in on the "power save -- performance"
> scale. Assigning an integer in the range of 0-100 might be a solution
> for that.

Interesting, maybe the primary interface should even be an integer in
that range, so for each system_performance_profile class-device we
would then have the following attributes:

mappings (ro) - This attribute gives a list of valid performance-profile-values
              In the form of "<integer-value> <description-string>\n", e.g.:

              25 Low Power
              50 Balanced
              100 Performance

value (rw) - Integer in the range 0 (lowest performance setting) - 100
              (highest performance setting). Note most drivers will only
              support a number of specific discrete values, see the mappings
              attribute. Userspace may write an arbitrary value between 0
              and 100, this will be rounded to the closest supported discrete
              value.

value_string (ro) - String representation of the currently active value,
              this is a shortcut for looking up the string in the mappings
              attribute yourself.

lap_mode (ro) - <lap_mode text here>

Something like p-p-daemon would then just interact with the value and lap_mode
fields, ignoring the mappings. It would then also need to do some rounding of
its own when reading value to map things back to its own internal levels.
One issue for p-p-d here might be that it writes its internal integer value
corresponding to say "Low power", then reads back a value and when rounding
that to its own discrete steps ends up at a different level then "Low power".
This can be avoid by using the mappings file to get the supported discrete values
and then only generate mappings for the discrete values to its own internal
discrete steps once and always use those mappings, thus always writing a
supported discrete value, avoiding rounding issues.

I think that this will give us a nice and flexible interface. Note if
anyone disagrees, or has a better idea please speak up. Once we have
decided on what the interface is going to be, we are effectively stuck
with it.

Regards,

Hans








> 
> Benjamin
> 
>> The idea behind putting the extra profiles in a separate sysfs-attribute
>> is that reading the main performance_profile attribute will always show
>> one selected, even if one of the extra profiles is actually in use,
>> then the driver should also show the closest standardized profile as
>> being active.
>>
>> This will allow userspace code to always rely on the standard interface
>> both for getting a representation of the currently active profile as well
>> as for setting the active profile.
>>
>> Elia, Mark, I assume that both of you want to get your patches for this
>> upstream sooner, rather then later. But I think we should put them on
>> hold until we have an agreement on a shared userspace API for this.
>>
>> I would like to think that the above proposal is a good start,
>> if we can quickly (*) decide on an userspace API here
>>
>> Regards,
>>
>> Hans
>>
>> p.s.
>>
>> I guess we should also add an optional lap_mode sysfs attribute
>> to the class-device, to have all the info for the Thinkpads in
>> one place.
>>
>>
>> *) but not too quickly, it is important we get this right
>>


  reply	other threads:[~2020-09-17 12:47 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-17 11:22 RFC: offering a standardized (/sys/class) userspace API for selecting system/laptop performance-profiles Hans de Goede
2020-09-17 11:50 ` Bastien Nocera
2020-09-17 12:51   ` Hans de Goede
2020-09-17 13:00     ` Bastien Nocera
2020-09-17 13:50     ` Benjamin Berg
2020-09-17 13:54       ` Hans de Goede
2020-09-17 14:10         ` Benjamin Berg
2020-09-17 16:58           ` [External] " Mark Pearson
2020-09-17 17:03             ` Hans de Goede
2020-09-17 17:16               ` Mark Pearson
2020-09-17 18:16                 ` Benjamin Berg
2020-09-21  9:03                   ` Elia Devito
2020-09-22 10:43                     ` Hans de Goede
2020-09-24  2:10                       ` Mark Pearson
2020-09-24  8:21                         ` Hans de Goede
2020-09-24 11:48                     ` Benjamin Berg
2020-09-22 10:30                 ` Hans de Goede
2020-09-24  1:44                   ` Mark Pearson
2020-09-17 13:36   ` Mark Pearson
2020-09-17 14:04     ` Hans de Goede
2020-09-17 16:51       ` Mark Pearson
2020-09-17 12:22 ` Benjamin Berg
2020-09-17 12:45   ` Hans de Goede [this message]
2020-09-17 13:07     ` Bastien Nocera
2020-09-17 13:46       ` Hans de Goede
2020-09-17 13:02 ` Barnabás Pőcze
2020-09-17 13:24   ` Hans de Goede
2020-09-17 13:28     ` Bastien Nocera
2020-09-17 13:51       ` Hans de Goede
2020-09-17 13:59     ` Benjamin Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35c8dd96-2e68-ac34-d1a5-78262a573287@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bberg@redhat.com \
    --cc=eliadevito@gmail.com \
    --cc=hadess@hadess.net \
    --cc=jaredz@redhat.com \
    --cc=mpearson@lenovo.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox