All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] platform/x86: hp-wmi: add support for thermal policy
       [not found] <20200917214957.GD29136@mtg-dev.jf.intel.com>
@ 2020-10-04 21:13 ` Elia Devito
  2020-10-05  8:57   ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Elia Devito @ 2020-10-04 21:13 UTC (permalink / raw)
  Cc: mgross, Elia Devito, Darren Hart, Andy Shevchenko, Hans de Goede,
	platform-driver-x86, linux-kernel

HP Spectre notebooks (and probably other model as well)
support up to 4 thermal policy:
 - HP Recommended
 - Performance
 - Cool
 - Quiet

at least on HP Spectre x360 Convertible 15-df0xxx the firmware sets the
thermal policy to default but hardcode the odvp0 variable to 1, this causes
thermald to choose the wrong DPTF profile witch result in low performance
when notebook is on AC, calling thermal policy write command allow firmware
to correctly set the odvp0 variable.

Signed-off-by: Elia Devito <eliadevito@gmail.com>
---
 drivers/platform/x86/hp-wmi.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index 1762f335bac9..6e448a79caee 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -81,6 +81,7 @@ enum hp_wmi_commandtype {
 	HPWMI_FEATURE2_QUERY		= 0x0d,
 	HPWMI_WIRELESS2_QUERY		= 0x1b,
 	HPWMI_POSTCODEERROR_QUERY	= 0x2a,
+	HPWMI_THERMAL_POLICY_QUERY	= 0x4c
 };
 
 enum hp_wmi_command {
@@ -861,6 +862,26 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
 	return err;
 }
 
+static int thermal_policy_setup(struct platform_device *device)
+{
+	int err, tp;
+
+	tp = hp_wmi_read_int(HPWMI_THERMAL_POLICY_QUERY);
+	if (tp < 0)
+		return tp;
+
+	/*
+	 * call thermal policy write command to ensure that the firmware correctly
+	 * sets the OEM variables for the DPTF
+	 */
+	err = hp_wmi_perform_query(HPWMI_THERMAL_POLICY_QUERY, HPWMI_WRITE, &tp,
+							   sizeof(tp), 0);
+	if (err)
+		return err;
+
+	return 0;
+}
+
 static int __init hp_wmi_bios_setup(struct platform_device *device)
 {
 	/* clear detected rfkill devices */
@@ -872,6 +893,8 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
 	if (hp_wmi_rfkill_setup(device))
 		hp_wmi_rfkill2_setup(device);
 
+	thermal_policy_setup(device);
+
 	return 0;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] platform/x86: hp-wmi: add support for thermal policy
  2020-10-04 21:13 ` [PATCH v2] platform/x86: hp-wmi: add support for thermal policy Elia Devito
@ 2020-10-05  8:57   ` Andy Shevchenko
  2020-10-07 14:02     ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2020-10-05  8:57 UTC (permalink / raw)
  To: Elia Devito
  Cc: Mark Gross, Darren Hart, Andy Shevchenko, Hans de Goede,
	Platform Driver, Linux Kernel Mailing List

On Mon, Oct 5, 2020 at 12:14 AM Elia Devito <eliadevito@gmail.com> wrote:
>
> HP Spectre notebooks (and probably other model as well)
> support up to 4 thermal policy:
>  - HP Recommended
>  - Performance
>  - Cool
>  - Quiet
>
> at least on HP Spectre x360 Convertible 15-df0xxx the firmware sets the
> thermal policy to default but hardcode the odvp0 variable to 1, this causes
> thermald to choose the wrong DPTF profile witch result in low performance
> when notebook is on AC, calling thermal policy write command allow firmware
> to correctly set the odvp0 variable.
>
> Signed-off-by: Elia Devito <eliadevito@gmail.com>
> ---
>  drivers/platform/x86/hp-wmi.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
> index 1762f335bac9..6e448a79caee 100644
> --- a/drivers/platform/x86/hp-wmi.c
> +++ b/drivers/platform/x86/hp-wmi.c
> @@ -81,6 +81,7 @@ enum hp_wmi_commandtype {
>         HPWMI_FEATURE2_QUERY            = 0x0d,
>         HPWMI_WIRELESS2_QUERY           = 0x1b,
>         HPWMI_POSTCODEERROR_QUERY       = 0x2a,

> +       HPWMI_THERMAL_POLICY_QUERY      = 0x4c

Usually we leave a comma that next change won't add any unnecessary churn.
I don't think this comment requires a v2 right now (may be satisfied
when applied), but if any other comments come and need to be
addressed, then this should be included as well.

>  };
>
>  enum hp_wmi_command {
> @@ -861,6 +862,26 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
>         return err;
>  }
>
> +static int thermal_policy_setup(struct platform_device *device)
> +{
> +       int err, tp;
> +
> +       tp = hp_wmi_read_int(HPWMI_THERMAL_POLICY_QUERY);
> +       if (tp < 0)
> +               return tp;
> +
> +       /*
> +        * call thermal policy write command to ensure that the firmware correctly
> +        * sets the OEM variables for the DPTF
> +        */
> +       err = hp_wmi_perform_query(HPWMI_THERMAL_POLICY_QUERY, HPWMI_WRITE, &tp,
> +                                                          sizeof(tp), 0);
> +       if (err)
> +               return err;
> +
> +       return 0;
> +}
> +
>  static int __init hp_wmi_bios_setup(struct platform_device *device)
>  {
>         /* clear detected rfkill devices */
> @@ -872,6 +893,8 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
>         if (hp_wmi_rfkill_setup(device))
>                 hp_wmi_rfkill2_setup(device);
>
> +       thermal_policy_setup(device);
> +
>         return 0;
>  }
>
> --
> 2.26.2
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] platform/x86: hp-wmi: add support for thermal policy
  2020-10-05  8:57   ` Andy Shevchenko
@ 2020-10-07 14:02     ` Hans de Goede
  2020-10-07 16:21       ` Barnabás Pőcze
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-10-07 14:02 UTC (permalink / raw)
  To: Andy Shevchenko, Elia Devito
  Cc: Mark Gross, Darren Hart, Andy Shevchenko, Platform Driver,
	Linux Kernel Mailing List

Hi,

On 10/5/20 10:57 AM, Andy Shevchenko wrote:
> On Mon, Oct 5, 2020 at 12:14 AM Elia Devito <eliadevito@gmail.com> wrote:
>>
>> HP Spectre notebooks (and probably other model as well)
>> support up to 4 thermal policy:
>>   - HP Recommended
>>   - Performance
>>   - Cool
>>   - Quiet
>>
>> at least on HP Spectre x360 Convertible 15-df0xxx the firmware sets the
>> thermal policy to default but hardcode the odvp0 variable to 1, this causes
>> thermald to choose the wrong DPTF profile witch result in low performance
>> when notebook is on AC, calling thermal policy write command allow firmware
>> to correctly set the odvp0 variable.
>>
>> Signed-off-by: Elia Devito <eliadevito@gmail.com>
>> ---
>>   drivers/platform/x86/hp-wmi.c | 23 +++++++++++++++++++++++
>>   1 file changed, 23 insertions(+)
>>
>> diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
>> index 1762f335bac9..6e448a79caee 100644
>> --- a/drivers/platform/x86/hp-wmi.c
>> +++ b/drivers/platform/x86/hp-wmi.c
>> @@ -81,6 +81,7 @@ enum hp_wmi_commandtype {
>>          HPWMI_FEATURE2_QUERY            = 0x0d,
>>          HPWMI_WIRELESS2_QUERY           = 0x1b,
>>          HPWMI_POSTCODEERROR_QUERY       = 0x2a,
> 
>> +       HPWMI_THERMAL_POLICY_QUERY      = 0x4c
> 
> Usually we leave a comma that next change won't add any unnecessary churn.
> I don't think this comment requires a v2 right now (may be satisfied
> when applied), but if any other comments come and need to be
> addressed, then this should be included as well.

I've fixed this up while applying this to my review-hans branch, so
there is no need to send out a new version.

Elia, Thank you for your patch, I've applied this patch to me review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Once I've run some tests on this branch the patches there will be added
to the platform-drivers-x86/for-next branch and eventually will be
included in the pdx86 pull-request to Linus for the next merge-window.

Regards,

Hans



> 
>>   };
>>
>>   enum hp_wmi_command {
>> @@ -861,6 +862,26 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
>>          return err;
>>   }
>>
>> +static int thermal_policy_setup(struct platform_device *device)
>> +{
>> +       int err, tp;
>> +
>> +       tp = hp_wmi_read_int(HPWMI_THERMAL_POLICY_QUERY);
>> +       if (tp < 0)
>> +               return tp;
>> +
>> +       /*
>> +        * call thermal policy write command to ensure that the firmware correctly
>> +        * sets the OEM variables for the DPTF
>> +        */
>> +       err = hp_wmi_perform_query(HPWMI_THERMAL_POLICY_QUERY, HPWMI_WRITE, &tp,
>> +                                                          sizeof(tp), 0);
>> +       if (err)
>> +               return err;
>> +
>> +       return 0;
>> +}
>> +
>>   static int __init hp_wmi_bios_setup(struct platform_device *device)
>>   {
>>          /* clear detected rfkill devices */
>> @@ -872,6 +893,8 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)
>>          if (hp_wmi_rfkill_setup(device))
>>                  hp_wmi_rfkill2_setup(device);
>>
>> +       thermal_policy_setup(device);
>> +
>>          return 0;
>>   }
>>
>> --
>> 2.26.2
>>
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] platform/x86: hp-wmi: add support for thermal policy
  2020-10-07 14:02     ` Hans de Goede
@ 2020-10-07 16:21       ` Barnabás Pőcze
  2020-10-07 17:30         ` Hans de Goede
  0 siblings, 1 reply; 6+ messages in thread
From: Barnabás Pőcze @ 2020-10-07 16:21 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andy Shevchenko, Elia Devito, Mark Gross, Darren Hart,
	Platform Driver, Linux Kernel Mailing List

Hi

2020. október 7., szerda 16:02 keltezéssel, Hans de Goede írta:
> [...]
> Elia, Thank you for your patch, I've applied this patch to me review-hans branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
> [...]

I don't know if the problem is on my end, but opening that url
results in an "Invalid branch: review-hans" error.


Thanks,
Barnabás Pőcze

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] platform/x86: hp-wmi: add support for thermal policy
  2020-10-07 16:21       ` Barnabás Pőcze
@ 2020-10-07 17:30         ` Hans de Goede
  2020-10-07 17:32           ` Barnabás Pőcze
  0 siblings, 1 reply; 6+ messages in thread
From: Hans de Goede @ 2020-10-07 17:30 UTC (permalink / raw)
  To: Barnabás Pőcze
  Cc: Andy Shevchenko, Elia Devito, Mark Gross, Darren Hart,
	Platform Driver, Linux Kernel Mailing List

Hi,

On 10/7/20 6:21 PM, Barnabás Pőcze wrote:
> Hi
> 
> 2020. október 7., szerda 16:02 keltezéssel, Hans de Goede írta:
>> [...]
>> Elia, Thank you for your patch, I've applied this patch to me review-hans branch:
>> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
>> [...]
> 
> I don't know if the problem is on my end, but opening that url
> results in an "Invalid branch: review-hans" error.

Since I'm just getting up2speed in my new role today, I have never pushed
that branch out yet, hence the error.

I've pushed it out now, the mirrors which actually serve
the http interface can lag a bit, so give it 10 minutes and
then it should be there.

Regards,

Hans


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] platform/x86: hp-wmi: add support for thermal policy
  2020-10-07 17:30         ` Hans de Goede
@ 2020-10-07 17:32           ` Barnabás Pőcze
  0 siblings, 0 replies; 6+ messages in thread
From: Barnabás Pőcze @ 2020-10-07 17:32 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Andy Shevchenko, Elia Devito, Mark Gross, Darren Hart,
	Platform Driver, Linux Kernel Mailing List

Hi

2020. október 7., szerda 19:30 keltezéssel, Hans de Goede írta:
> [...]
> Since I'm just getting up2speed in my new role today, I have never pushed
> that branch out yet, hence the error.
>
> I've pushed it out now, the mirrors which actually serve
> the http interface can lag a bit, so give it 10 minutes and
> then it should be there.
> [...]


I see, thanks!


Regards,
Barnabás Pőcze

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-07 17:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200917214957.GD29136@mtg-dev.jf.intel.com>
2020-10-04 21:13 ` [PATCH v2] platform/x86: hp-wmi: add support for thermal policy Elia Devito
2020-10-05  8:57   ` Andy Shevchenko
2020-10-07 14:02     ` Hans de Goede
2020-10-07 16:21       ` Barnabás Pőcze
2020-10-07 17:30         ` Hans de Goede
2020-10-07 17:32           ` Barnabás Pőcze

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.