lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 14 Mar 2022 17:21:58 +0100
From:   Enver Balalic <balalic.enver@...il.com>
To:     Hans de Goede <hdegoede@...hat.com>
Cc:     markgross@...nel.org, platform-driver-x86@...r.kernel.org,
        linux-kernel@...r.kernel.org, pobrn@...tonmail.com
Subject: Re: [PATCH v2] platform/x86: hp-wmi: support omen thermal profile
 policy v1

Hi,

On Mon, Mar 14, 2022 at 04:27:50PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 3/14/22 13:14, Enver Balalic wrote:
> > As it turns out, these laptops have 2 thermal profile versions.
> > A previous patch added support for v0, this patch adds support
> > for v1 thermal policies that are in use on some devices.
> > We obtain the thermal policy version by querying the get system
> > design data WMI call and looking at the fourth byte it returns,
> > except if the system board DMI Board ID is in a specific array
> > that the windows command center app overrides to thermal policy
> > v0 for some reason.
> > 
> > - V1
> >   Initial Patch
> > - V2
> >   Rename V0 thermal policy values to HP_OMEN_V0_THERMAL_PROFILE_
> >   for consistency with the V1 thermal policy values.
> >   Fix issue where instead of forcing certain boards to V0, they
> >   were being forced to V1.
> >   Drop unnecessary newline additions.
> > 
> > Signed-off-by: Enver Balalic <balalic.enver@...il.com>
> > ---
> >  drivers/platform/x86/hp-wmi.c | 81 +++++++++++++++++++++++++++++------
> >  1 file changed, 67 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
> > index c56c8864961d..0109ddc84be7 100644
> > --- a/drivers/platform/x86/hp-wmi.c
> > +++ b/drivers/platform/x86/hp-wmi.c
> > @@ -57,6 +57,14 @@ static const char * const omen_thermal_profile_boards[] = {
> >  	"8917", "8918", "8949", "894A", "89EB"
> >  };
> >  
> > +/* DMI Board names of Omen laptops that are specifically set to be thermal
> > + * profile version 0 by the Omen Command Center app, regardless of what
> > + * the get system design information WMI call returns
> > + */
> > +static const char *const omen_thermal_profile_force_v0_boards[] = {
> > +	"8607", "8746", "8747", "8749", "874A", "8748"
> > +};
> > +
> >  enum hp_wmi_radio {
> >  	HPWMI_WIFI	= 0x0,
> >  	HPWMI_BLUETOOTH	= 0x1,
> > @@ -117,6 +125,7 @@ enum hp_wmi_gm_commandtype {
> >  	HPWMI_SET_PERFORMANCE_MODE = 0x1A,
> >  	HPWMI_FAN_SPEED_MAX_GET_QUERY = 0x26,
> >  	HPWMI_FAN_SPEED_MAX_SET_QUERY = 0x27,
> > +	HPWMI_GET_SYSTEM_DESIGN_DATA = 0x28,
> >  };
> >  
> >  enum hp_wmi_command {
> > @@ -151,10 +160,16 @@ enum hp_wireless2_bits {
> >  	HPWMI_POWER_FW_OR_HW	= HPWMI_POWER_BIOS | HPWMI_POWER_HARD,
> >  };
> >  
> > -enum hp_thermal_profile_omen {
> > -	HP_OMEN_THERMAL_PROFILE_DEFAULT     = 0x00,
> > -	HP_OMEN_THERMAL_PROFILE_PERFORMANCE = 0x01,
> > -	HP_OMEN_THERMAL_PROFILE_COOL        = 0x02,
> > +enum hp_thermal_profile_omen_v1 {
> > +	HP_OMEN_V1_THERMAL_PROFILE_DEFAULT	= 0x30,
> > +	HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE	= 0x31,
> > +	HP_OMEN_V1_THERMAL_PROFILE_COOL		= 0x50,
> > +};
> > +
> > +enum hp_thermal_profile_omen_v0 {
> > +	HP_OMEN_V0_THERMAL_PROFILE_DEFAULT     = 0x00,
> > +	HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE = 0x01,
> > +	HP_OMEN_V0_THERMAL_PROFILE_COOL        = 0x02,
> >  };
> 
> IMHO it would be more logical to list the v0 settings above
> the v1 settings, rather then the other way around.
> 
> I've fixed this up while merging this patch:
> 
> Thank you for your patch, I've applied this patch to my review-hans 
> branch:
> https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
> 
> Note it will show up in my review-hans branch once I've pushed my
> local branch there, which might take a while.
> 
> 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
> 
Thank you.
> 
> >  
> >  enum hp_thermal_profile {
> > @@ -407,9 +422,6 @@ static int omen_thermal_profile_set(int mode)
> >  	char buffer[2] = {0, mode};
> >  	int ret;
> >  
> > -	if (mode < 0 || mode > 2)
> > -		return -EINVAL;
> > -
> >  	ret = hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM,
> >  				   &buffer, sizeof(buffer), 0);
> >  
> > @@ -431,6 +443,30 @@ static bool is_omen_thermal_profile(void)
> >  			    board_name) >= 0;
> >  }
> >  
> > +static int omen_get_thermal_policy_version(void)
> > +{
> > +	unsigned char buffer[8] = { 0 };
> > +	int ret;
> > +
> > +	const char *board_name = dmi_get_system_info(DMI_BOARD_NAME);
> > +
> > +	if (board_name) {
> > +		int matches = match_string(omen_thermal_profile_force_v0_boards,
> > +			ARRAY_SIZE(omen_thermal_profile_force_v0_boards),
> > +			board_name);
> > +		if (matches >= 0)
> > +			return 0;
> > +	}
> > +
> > +	ret = hp_wmi_perform_query(HPWMI_GET_SYSTEM_DESIGN_DATA, HPWMI_GM,
> > +				   &buffer, sizeof(buffer), sizeof(buffer));
While I was looking at the other changes to the hp-wmi driver
on your review-hans branch, I noticed this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=review-hans&id=be9d73e64957bbd31ee9a0d11adc0f720974c558
(is this the proper way to link to a commit in a patch email response?)

Based on this, I think the input buffer size here should be 0.
Do you want me to make another patch for this or will you check 
and commit it directly instead?
> > +
> > +	if (ret)
> > +		return ret < 0 ? ret : -EINVAL;
> > +
> > +	return buffer[3];
> > +}
> > +
> >  static int omen_thermal_profile_get(void)
> >  {
> >  	u8 data;
> > @@ -1053,13 +1089,16 @@ static int platform_profile_omen_get(struct platform_profile_handler *pprof,
> >  		return tp;
> >  
> >  	switch (tp) {
> > -	case HP_OMEN_THERMAL_PROFILE_PERFORMANCE:
> > +	case HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE:
> > +	case HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE:
> >  		*profile = PLATFORM_PROFILE_PERFORMANCE;
> >  		break;
> > -	case HP_OMEN_THERMAL_PROFILE_DEFAULT:
> > +	case HP_OMEN_V0_THERMAL_PROFILE_DEFAULT:
> > +	case HP_OMEN_V1_THERMAL_PROFILE_DEFAULT:
> >  		*profile = PLATFORM_PROFILE_BALANCED;
> >  		break;
> > -	case HP_OMEN_THERMAL_PROFILE_COOL:
> > +	case HP_OMEN_V0_THERMAL_PROFILE_COOL:
> > +	case HP_OMEN_V1_THERMAL_PROFILE_COOL:
> >  		*profile = PLATFORM_PROFILE_COOL;
> >  		break;
> >  	default:
> > @@ -1072,17 +1111,31 @@ static int platform_profile_omen_get(struct platform_profile_handler *pprof,
> >  static int platform_profile_omen_set(struct platform_profile_handler *pprof,
> >  				     enum platform_profile_option profile)
> >  {
> > -	int err, tp;
> > +	int err, tp, tp_version;
> > +
> > +	tp_version = omen_get_thermal_policy_version();
> > +
> > +	if (tp_version < 0 || tp_version > 1)
> > +		return -EOPNOTSUPP;
> >  
> >  	switch (profile) {
> >  	case PLATFORM_PROFILE_PERFORMANCE:
> > -		tp = HP_OMEN_THERMAL_PROFILE_PERFORMANCE;
> > +		if (tp_version == 0)
> > +			tp = HP_OMEN_V0_THERMAL_PROFILE_PERFORMANCE;
> > +		else
> > +			tp = HP_OMEN_V1_THERMAL_PROFILE_PERFORMANCE;
> >  		break;
> >  	case PLATFORM_PROFILE_BALANCED:
> > -		tp = HP_OMEN_THERMAL_PROFILE_DEFAULT;
> > +		if (tp_version == 0)
> > +			tp = HP_OMEN_V0_THERMAL_PROFILE_DEFAULT;
> > +		else
> > +			tp = HP_OMEN_V1_THERMAL_PROFILE_DEFAULT;
> >  		break;
> >  	case PLATFORM_PROFILE_COOL:
> > -		tp = HP_OMEN_THERMAL_PROFILE_COOL;
> > +		if (tp_version == 0)
> > +			tp = HP_OMEN_V0_THERMAL_PROFILE_COOL;
> > +		else
> > +			tp = HP_OMEN_V1_THERMAL_PROFILE_COOL;
> >  		break;
> >  	default:
> >  		return -EOPNOTSUPP;
> 
Thanks,
Enver.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ