X86 platform drivers
 help / color / mirror / Atom feed
From: Kurt Borja <kuurtb@gmail.com>
To: kuurtb@gmail.com
Cc: ilpo.jarvinen@linux.intel.com, w_armin@gmx.de,
	hdegoede@redhat.com, linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org, Dell.Client.Kernel@dell.com
Subject: [PATCH 4/5] alienware-wmi: create_thermal_profile no longer brute-forces IDs
Date: Mon, 11 Nov 2024 15:36:23 -0300	[thread overview]
Message-ID: <20241111183623.14691-1-kuurtb@gmail.com> (raw)
In-Reply-To: <20241111183308.14081-3-kuurtb@gmail.com>

WMAX_METHOD_THERMAL_INFORMATION has a *system description* operation
that outputs a buffer with the following structure:

out[0] -> Number of fans
out[1] -> Number of sensors
out[2] -> 0x00
out[3] -> Number of thermal modes

This is now used by create_thermal_profile to retrieve available thermal
codes instead of brute-forcing every ID.

Tested on an Alienware x15 R1. Verified by checking ACPI tables of
supported models.

Signed-off-by: Kurt Borja <kuurtb@gmail.com>
---
 drivers/platform/x86/dell/alienware-wmi.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/dell/alienware-wmi.c b/drivers/platform/x86/dell/alienware-wmi.c
index 36d182f217e2..77465ed9b449 100644
--- a/drivers/platform/x86/dell/alienware-wmi.c
+++ b/drivers/platform/x86/dell/alienware-wmi.c
@@ -68,6 +68,7 @@ enum WMAX_CONTROL_STATES {
 };
 
 enum WMAX_THERMAL_INFORMATION_OPERATIONS {
+	WMAX_OPERATION_SYS_DESCRIPTION		= 0x02,
 	WMAX_OPERATION_LIST_IDS			= 0x03,
 	WMAX_OPERATION_CURRENT_PROFILE		= 0x0B,
 };
@@ -1110,13 +1111,22 @@ static int thermal_profile_set(struct platform_profile_handler *pprof,
 static int create_thermal_profile(void)
 {
 	u32 out_data;
+	u8 sys_desc[4];
+	u32 first_mode;
 	enum wmax_thermal_mode mode;
 	enum platform_profile_option profile;
 	int ret;
 
-	for (u8 i = 0x2; i <= 0xD; i++) {
+	ret = wmax_thermal_information(WMAX_OPERATION_SYS_DESCRIPTION,
+				       0, (u32 *) &sys_desc);
+	if (ret < 0)
+		return ret;
+
+	first_mode = sys_desc[0] + sys_desc[1];
+
+	for (u32 i = 0; i < sys_desc[3]; i++) {
 		ret = wmax_thermal_information(WMAX_OPERATION_LIST_IDS,
-					       i, &out_data);
+					       i + first_mode, &out_data);
 
 		if (ret == -EIO)
 			return ret;
-- 
2.47.0


  parent reply	other threads:[~2024-11-11 18:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 18:33 [PATCH 0/5] Better thermal mode probing + support for 9 models Kurt Borja
2024-11-11 18:35 ` [PATCH 1/5] alienware-wmi: order alienware_quirks[] alphabetically Kurt Borja
2024-11-11 18:35 ` [PATCH 2/5] alienware-wmi: extends the list of supported models Kurt Borja
2024-11-11 18:36 ` [PATCH 3/5] alienware-wmi: Adds support to Alienware x17 R2 Kurt Borja
2024-11-11 18:36 ` Kurt Borja [this message]
2024-11-11 18:36 ` [PATCH 5/5] Documentation: alienware-wmi: Describe THERMAL_INFORMATION operation 0x02 Kurt Borja
2024-11-12 10:53 ` [PATCH 0/5] Better thermal mode probing + support for 9 models Ilpo Järvinen
2024-11-16 15:03 ` Ilpo Järvinen
2024-11-16 15:23   ` Kurt Borja

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=20241111183623.14691-1-kuurtb@gmail.com \
    --to=kuurtb@gmail.com \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=hdegoede@redhat.com \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=w_armin@gmx.de \
    /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