From patchwork Thu Feb 1 13:29:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexis Belmonte X-Patchwork-Id: 13541082 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 128D95337D for ; Thu, 1 Feb 2024 13:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794161; cv=none; b=kgjuzK0Diq1pSTyF7yY9ciJlHe5Q1Fou5ac1HlzixfYOxTSIwlDH5/zzUpiKM4P/39gVKwhunFcSuN36J/MYFTlITVi0Xgcjo2h0A0bR0qeurpHoqQWbVkErFhfNp5udyRYrk+PTgIGJnnw3d6wcVz+7cccIHTAZgluP3lSkxaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794161; c=relaxed/simple; bh=rjtEnxHTC6cJGW1OquXbH59om/0jef5L0X/b0iDTvIo=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=TFKMcjQY97MIUf7YD8jWY6p76l8kix9N9yjWUir9qhaZLpDqgI7iOzRtEUBCpcb6v4gJ2yfAm7f2AD6WVnNH5/QwYXxwreMRoZlL+xbUrFZ2aeAtjo9gq35WGecuGcCdAUTx5sZ8E6TlD+5fn/mV+d/0xgwOMd/KiyjYIr+CLnc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WfX+otdJ; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WfX+otdJ" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-33b0e5d1e89so633704f8f.0 for ; Thu, 01 Feb 2024 05:29:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706794158; x=1707398958; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=cNcQwvNHCIU+DQiZOrjiXd+38eLr4prCzny69vZnYiQ=; b=WfX+otdJAUjIaT4edqbmcFULM8cMANKWBeWEXbH/Z/hDOdk5NgkjP3l8OZZ5G2kA0R XQVN38lSlQflCk97T6UMEwV6rpMw/CPtuUtGxX5UHmmXBEvEBBjdKJb7ucBQW9FQdLQ0 mICdfSQ3OgeWbxo240KxtVp1TW4S/2pMH10j7apqZJukh7D3bArSTcHtA+zQQ1M72LSc /D7ythjOG8c4MbliXfCx00qP81qKJRH+LlKeXf9iRizGEKbQPxE7ti8abGkd1bh4+VZQ S3G1SoaEZqKm01jorcE3eqaTQgU3MiDxgWZ3EQi1lgf61Voda+eLPKMZsnofAGY0oOaP iFaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706794158; x=1707398958; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cNcQwvNHCIU+DQiZOrjiXd+38eLr4prCzny69vZnYiQ=; b=sQzvo1S8xU/910Y2i07UeIxM1Br0+9NUB5226nrBN2o2gD6CzfqUdDqTmfk1YnZ7wq bYLuEBOV99lHVmon2QoSBZUo5RkeorXSPaPJwGlMCmMrnZI2Hf/H3IdJ+96UXXqddGhK 9UMaaVkGMDYNSa/eF97b34vsv45TOdujhpyM+LO5wJ9c1KOyDxy+1womBK3hFGM/lmph QLRMkqTtC+5JVQP51+D8HzNjYY/HiXwL1eMy0Da4VABb7YrrcC0HnLU94C9Y9fs9K96D HTPBXFERRmVdZjNBRBmNayLxfKwyDMjrEped7yeoTqJf5JfYQu1p5ZJpURL5J1GHdN7G YBQQ== X-Gm-Message-State: AOJu0YzacbZx83BqfhmalqD0GjVyyu8wNsgSGaEbVIG7OFnZelf9HxlW LLTISyKNhN3AFu7nb9jqiKTkjVm7oiAVoXu7WSNqrgPy4+/O3RH1 X-Google-Smtp-Source: AGHT+IExQAcYl2rZO0awzL7gcvhmrUEqbQO/Y4+Xfxv7aQH8oqODrCWh4HXXVglqMaTfDtGb4j0u7A== X-Received: by 2002:adf:e512:0:b0:33a:f523:8267 with SMTP id j18-20020adfe512000000b0033af5238267mr1618572wrm.47.1706794157872; Thu, 01 Feb 2024 05:29:17 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXBUsdl7rZxaykQBc8B1a1Wrss6hs5SRVdWTi4idRshcmfbloeFDW8oAc8WBj+qGfI8tK4AROwN+WYN2Zizphj566BgmNj6kACuMy6rksnEJv5q8WWiRw== Received: from alexis-pc (cust-west-par-46-193-0-235.cust.wifirst.net. [46.193.0.235]) by smtp.gmail.com with ESMTPSA id u13-20020a05600c00cd00b0040f02114906sm4390402wmm.16.2024.02.01.05.29.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:29:17 -0800 (PST) Date: Thu, 1 Feb 2024 14:29:16 +0100 From: Alexis Belmonte To: ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com Cc: platform-driver-x86@vger.kernel.org, putr4.s@gmail.com Subject: [PATCH v2 1/2] platform/x86: hp-wmi: Tidy up module source code Message-ID: Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline This commit performs four things: - fix up the GUID string inconsistency (lower case 'e') from the WMI module alias declaration/macro definition - separate GUID macros from the embedded controller offset macros - rename the description of the module to better represent what it actually achieves as a whole - add a space right before the '*' pointer qualifier to match the other array declarations This also prepares the terrain for integrating support work for boards identified as '8BAD', which corresponds to HP's Omen 17 ck2xxx models. Signed-off-by: Alexis Belmonte --- drivers/platform/x86/hp/hp-wmi.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 8ebb7be52ee7..b19039cf1966 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -29,15 +29,17 @@ #include MODULE_AUTHOR("Matthew Garrett "); -MODULE_DESCRIPTION("HP laptop WMI hotkeys driver"); +MODULE_DESCRIPTION("HP laptop WMI driver"); MODULE_LICENSE("GPL"); MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C"); -MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); +MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4"); #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" -#define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4" +#define HPWMI_BIOS_GUID "5FB7F034-2C63-45E9-BE91-3D44E2C707E4" + #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95 + #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required /* DMI board names of devices that should use the omen specific path for @@ -62,7 +64,7 @@ static const char * const omen_thermal_profile_boards[] = { * 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[] = { +static const char * const omen_thermal_profile_force_v0_boards[] = { "8607", "8746", "8747", "8749", "874A", "8748" }; From patchwork Thu Feb 1 13:29:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexis Belmonte X-Patchwork-Id: 13541083 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66B8A53377 for ; Thu, 1 Feb 2024 13:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794178; cv=none; b=icYcw+Dqn80xnvdc7+djQ+qpliTJk36MjpFwGqQg14blr50xcLmSE7RlWVwKhWqFX2iEMdCMGEz8u+A8vOA9ltWLcZQRPS6lnJor4v/gC026jI8FlLbI5hE6miYHRwp2cnV9pAsnZDuwmyb5h+l+ReroKT2WxWZyHF5xPmMN8x4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794178; c=relaxed/simple; bh=Mc+923QkDWYPrzpNIIMbYqVklIxTsX68E6rf5R4cZNw=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=MqWLzXPjCBhqAM6aMPxY0S/OGDTRVQNXIrGyUfJTM/WTf16BsShnsOxb22yeLqduCcxrXBmIY4wbYf1eaLUcsQR8bY2m0uedR6xmDi7kUtBovkGHBEo5C6J7ry6Rqe/EA9oN+stjTz7arUxcmDspgzJHXx6fcJeUdEGOPjx829U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=erp3JBxm; arc=none smtp.client-ip=209.85.221.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="erp3JBxm" Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-33ae53eb5a8so553411f8f.3 for ; Thu, 01 Feb 2024 05:29:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706794174; x=1707398974; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=FdgVStWX9l2Up/qDJ3Kmw5sZEBxKi2uvAnRmBl5psCI=; b=erp3JBxm10FtoJ9JyvNOy/XebAriyEsI31wJt0S9Wy0wVc1cvNcy0Pe8oqYj5OpQqt C8WSN2i5k606MDf04/723jTx2Gv5HHPox4ES4cULh7mvxcTf0LKJ8/11ArnStrEh/S3v qF9ewhrSdlQXWXf6EwOn9ksqTmtImtk07qgyl313tItH6Pg4dKVGmwjuYnvKYw5BSLt+ 5VmFou4E/+KcfnHa8w9qYOvuBg2w23qx0lupNa88NrJjOZTdNa1KaTn3Q5QAT+/q5nPH bOZSAoablwV35GTXM8OHCKFo60ADJVlHB8oAF6B8qLhCR0xZrFlBFFDFxRjerdx0gwJg alUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706794174; x=1707398974; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FdgVStWX9l2Up/qDJ3Kmw5sZEBxKi2uvAnRmBl5psCI=; b=j7m5q2BhNugi/2+xMgLkFg51SMDH71ApAeyoku9Dbk9Ak+hdNh1/8cx0O/DxoFqkK+ 4iYdx56kuXiPz/wEsXGR7Y1q2if8T8Ng/IcRW3mC10PXq9mOtDUqCvsRrzEEq7oeB0J3 ERyvNOxmvdrexHw7hfI6oaVLp7GsXt3c5cuHh3hGzjHafvpTzdss+eKAN4npgNLeCqE7 8HFp0kiVNWvuBsRvwkMhWRvgj0OEwavkoB0omNlAtgDH3onEcy+LRxzVi8kvqGk2OmLo 7fhIsLMQTU6q53h6imKR8CLF/s832ATDsStnO0KIkt0Zyb6/Rd5wKXV+20nnCVG6EfgG Yw+Q== X-Gm-Message-State: AOJu0Yy6tF23QysjCjux0UxoPGMAL6Q08jpSBjYHfyWFnz++C8I1UBCm /636zEG/2/h4Vw49H4KJ0RQa7sgQPaqHlrehF4+qPjltAd+RWV13 X-Google-Smtp-Source: AGHT+IG/rapsVPI5Mu/aobsECIrIYShMwdAbe5oIrSapK6E88GH1QD9BVkhRHIcPSPxXUlpdvkgfTw== X-Received: by 2002:a5d:5a92:0:b0:33b:1562:34f9 with SMTP id bp18-20020a5d5a92000000b0033b156234f9mr1683407wrb.39.1706794174575; Thu, 01 Feb 2024 05:29:34 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXrCp3OSPdWFXemWQ5ZnrDZvxj8q2Y3kjM5dixZxmIOH9kxLeYPuZqLgoRHUcWuj/7qIcOn11XTSqBsWUNpOoMX7vddXdDyteGgxNLjIwkFgez6MxCd4w== Received: from alexis-pc (cust-west-par-46-193-0-235.cust.wifirst.net. [46.193.0.235]) by smtp.gmail.com with ESMTPSA id k14-20020adfe3ce000000b0033b0924543asm3193027wrm.108.2024.02.01.05.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:29:34 -0800 (PST) Date: Thu, 1 Feb 2024 14:29:33 +0100 From: Alexis Belmonte To: ilpo.jarvinen@linux.intel.com, hdegoede@redhat.com Cc: platform-driver-x86@vger.kernel.org, putr4.s@gmail.com Subject: [PATCH v2 2/2] platform/x86: hp-wmi: Add thermal profile support for 8BAD boards Message-ID: Precedence: bulk X-Mailing-List: platform-driver-x86@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Add 8BAD to the list of boards which have thermal profile selection available. This allows the CPU to draw more power than the default TDP barrier defined by the 'balanced' thermal profile (around 50W), hence allowing it to perform better without being throttled by the embedded controller (around 130W). We first need to set the HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET to zero. This prevents the timer countdown from reaching zero, making the embedded controller "force-switch" the system's thermal profile back to 'balanced' automatically. We also need to put a number of specific flags in HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET when we're switching to another thermal profile: - for 'performance', we need to set both HP_OMEN_EC_FLAGS_TURBO and HP_OMEN_EC_FLAGS_NOTIMER; - for 'balanced' and 'powersave', we clear out the register to notify the system that we want to lower the TDP barrier as soon as possible. The third flag defined in the hp_thermal_profile_omen_flags enum, HP_OMEN_EC_FLAGS_JUSTSET, is present for completeness. To prevent potential behaviour breakage with other Omen models, a separate omen_timed_thermal_profile_boards array has been added to list which boards expose this behaviour. Performance benchmarking was done with the help of silver.urih.com and Google Chrome 120.0.6099.129, on Gnome 45.2, with the 'performance' thermal profile set: | | Performance | Stress | TDP | |------------------|-------------|------------|-------| | with my patch | P84549 | S0.1891 | 131W | | without my patch | P44084 | S0.1359 | 47W | The TDP measurements were done with the help of the s-tui utility, during the load. There is still work to be done: - tune the CPU and GPU fans to better cool down and enhance performance at the right time; right now, it seems that the fans are not properly reacting to thermal/performance events, which in turn either causes thermal throttling OR makes the fans spin way too long, even though the temperatures have lowered down - expose the CPU and GPU fan curves to user-land so that they can be controlled just like what the Omen Gaming Hub utility proposes to its users; Signed-off-by: Alexis Belmonte --- drivers/platform/x86/hp/hp-wmi.c | 61 ++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index b19039cf1966..05011aa93a7a 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -38,6 +38,8 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45E9-BE91-3D44E2C707E4"); #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" #define HPWMI_BIOS_GUID "5FB7F034-2C63-45E9-BE91-3D44E2C707E4" +#define HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET 0x62 +#define HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET 0x63 #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95 #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required @@ -57,7 +59,7 @@ static const char * const omen_thermal_profile_boards[] = { "874A", "8603", "8604", "8748", "886B", "886C", "878A", "878B", "878C", "88C8", "88CB", "8786", "8787", "8788", "88D1", "88D2", "88F4", "88FD", "88F5", "88F6", "88F7", "88FE", "88FF", "8900", "8901", "8902", "8912", - "8917", "8918", "8949", "894A", "89EB" + "8917", "8918", "8949", "894A", "89EB", "8BAD", "8A42" }; /* DMI Board names of Omen laptops that are specifically set to be thermal @@ -68,6 +70,14 @@ static const char * const omen_thermal_profile_force_v0_boards[] = { "8607", "8746", "8747", "8749", "874A", "8748" }; +/* DMI board names of Omen laptops that have a thermal profile timer which will + * cause the embedded controller to set the thermal profile back to + * "balanced" when reaching zero. + */ +static const char * const omen_timed_thermal_profile_boards[] = { + "8BAD", "8A42" +}; + /* DMI Board names of Victus laptops */ static const char * const victus_thermal_profile_boards[] = { "8A25" @@ -184,6 +194,12 @@ enum hp_thermal_profile_omen_v1 { HP_OMEN_V1_THERMAL_PROFILE_COOL = 0x50, }; +enum hp_thermal_profile_omen_flags { + HP_OMEN_EC_FLAGS_TURBO = 0x04, + HP_OMEN_EC_FLAGS_NOTIMER = 0x02, + HP_OMEN_EC_FLAGS_JUSTSET = 0x01, +}; + enum hp_thermal_profile_victus { HP_VICTUS_THERMAL_PROFILE_DEFAULT = 0x00, HP_VICTUS_THERMAL_PROFILE_PERFORMANCE = 0x01, @@ -451,7 +467,11 @@ static int hp_wmi_get_tablet_mode(void) static int omen_thermal_profile_set(int mode) { - char buffer[2] = {0, mode}; + /* The Omen Control Center actively sets the first byte of the buffer to + * 255, so let's mimic this behaviour to be as close as possible to + * the original software. + */ + char buffer[2] = {-1, mode}; int ret; ret = hp_wmi_perform_query(HPWMI_SET_PERFORMANCE_MODE, HPWMI_GM, @@ -1203,10 +1223,33 @@ static int platform_profile_omen_get(struct platform_profile_handler *pprof, return 0; } +static bool has_omen_thermal_profile_ec_timer(void) +{ + const char *board_name = dmi_get_system_info(DMI_BOARD_NAME); + + if (!board_name) + return false; + + return match_string(omen_timed_thermal_profile_boards, + ARRAY_SIZE(omen_timed_thermal_profile_boards), + board_name) >= 0; +} + +inline int omen_thermal_profile_ec_flags_set(enum hp_thermal_profile_omen_flags flags) +{ + return ec_write(HP_OMEN_EC_THERMAL_PROFILE_FLAGS_OFFSET, flags); +} + +inline int omen_thermal_profile_ec_timer_set(u8 value) +{ + return ec_write(HP_OMEN_EC_THERMAL_PROFILE_TIMER_OFFSET, value); +} + static int platform_profile_omen_set(struct platform_profile_handler *pprof, enum platform_profile_option profile) { int err, tp, tp_version; + enum hp_thermal_profile_omen_flags flags = 0; tp_version = omen_get_thermal_policy_version(); @@ -1240,6 +1283,20 @@ static int platform_profile_omen_set(struct platform_profile_handler *pprof, if (err < 0) return err; + if (has_omen_thermal_profile_ec_timer()) { + err = omen_thermal_profile_ec_timer_set(0); + if (err < 0) + return err; + + if (profile == PLATFORM_PROFILE_PERFORMANCE) + flags = HP_OMEN_EC_FLAGS_NOTIMER | + HP_OMEN_EC_FLAGS_TURBO; + + err = omen_thermal_profile_ec_flags_set(flags); + if (err < 0) + return err; + } + return 0; }