From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yw1-f174.google.com (mail-yw1-f174.google.com [209.85.128.174]) (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 3CCAA19C575; Sat, 8 Feb 2025 05:16:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991817; cv=none; b=JLlYbNah6kkyyJnbEuwviTA7rgn9WKCjmgI4/Xow8WshhD1D7fu8CWTXuPXFfI2ayfHRCMCediz/SC+ahyvN6qKDhxcbbPwO2R2mKFCj+mOGQ7Is9aZlfaI4MW6pLTiu9pblOwXnmy3DFk77LTArmdLgXu2DLV2OfaiVAPTlj2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991817; c=relaxed/simple; bh=CclR2zP51Vl2XP9krUrp2FtQuhvpQLSjVgVeaMYr8gg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fE8Wav9DJhHJ2rDlbif/XlfIZsW5NxErl1iFklLt4gNe8B0eCE5kVwvZnOcjkqraLAB66K1sFtH3PYETZv2UkF94O9EHpr6hZHDiDNBGr7o+5aresyXMyseTiR0ieT2HUdPlC62N4VSaxL6x9u+atfO8tYGtfc5715yptKboo+g= 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=arqcgK1E; arc=none smtp.client-ip=209.85.128.174 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="arqcgK1E" Received: by mail-yw1-f174.google.com with SMTP id 00721157ae682-6f6ca3e8cdbso20152997b3.3; Fri, 07 Feb 2025 21:16:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991814; x=1739596614; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=reOJEJmAPqGgT5VUsgZzgMWXgtWntXKkjeFR4fQ93jY=; b=arqcgK1ECVoI1RCzngXzq5Wm88d5Jt4btdxksOaH52P6QuiQjD+6RDi8Jdx5/cBLpu 1ITP51Qtmyn22waTELaGsJhyIbTDGnept68lfE8oFPx4TAImIaKcmB7JSz7nxbYXqwfc jR+7gXcjtSEYyyLCZzOGYOV8Q2jQKR1eWkR0JT+6gw6Zh/miRSFld7lOMbTH0cvGOYf+ pIhnzdJccO5zwJRNMInxp5yYanqrZ/tIm0BspWsoetLDh85JekwxuD4risVa2p62bYDO +BLOPvwCkvBUO6HgAynCDeXdEozmCo4KFcVD3Dy9p4KbUUOxrp+aCt4EzVt+x0hJsD2F XsNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991814; x=1739596614; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=reOJEJmAPqGgT5VUsgZzgMWXgtWntXKkjeFR4fQ93jY=; b=T1nWO/CP77EFwI4umvaOpulgGIrt2p8I/+nmKuZ/L9zVhArSvxywU1P27hGKSpqjDu nR4IKAp5/bycFSWVsMPQeSMhMSVUgBsSlO5ht0Y82trKZRwP0CX3+0jArWfJweeg1O7z uJNcbuJ7OtdYIQGdABPCYJfisaKEfwBZXhOcrudcZQb6BajS/11QVcYQ6NMM7+fC6SZN Hi9X1mYGX6jzn/+xE0agyOfTMYVUAiG9zi2yxkp7zGsJKemPXTbhSTLBYj2Vy9TC/Ede csobvYskN8www107iDYMG5Zj/zqT1GAHi2kzUzjxNHmIPjk21lLVKSmdSFi+uX59AKNh +KtQ== X-Forwarded-Encrypted: i=1; AJvYcCV9ucDZNSYO2qpuXzFLGnZfdpEGWsuTLT/9gdx9UItBm+5yJZMAYKhx8sysdYCZL4xelg2msBXJqB0NanQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyzxZX2d36QQRRvgHtWm6C/eaBsnNnk2B7/tVLnLKGWB2UE8BgU ooSD664TUzKU1C6J0CFWrLlc96SoYClCEwU1ybw6XJHR7XgwZm5ixjddOg== X-Gm-Gg: ASbGncuyF7jbo5rPVO0Rl8gEAylswzcJDwi135cu2CAzUlxfZ2qVaL/JGHyvlmqST3u rZ/uNZFIsNJ9vjrTDL8t0XcBqYHsIOJLD1uAR/7Qqd8sQD8zAfbROx1TxnORWwOelEy7+hjoskM CQlITpsyJ0RlEAxJaJMRr/4k2ziSFnQ9xcqqT1xaK00QVOekPIE24TeKTWaxGLhK4Emjq9/P1lg 4GtatORd8fdwWNJbm6LvpIWmiNyKVlJMl09zWBCEzzdvagykXRFWqx5N6ZM3xGPu2dK2kcSDLeA /EytY9erEuexrfY03mDAmTM= X-Google-Smtp-Source: AGHT+IGWKse8+5JFxCLGwfBTL/aJgg/lWHub6k713qvjhhY3m3qwiexRdEgnSTAmcBuqD841VnDjoA== X-Received: by 2002:a05:690c:9989:b0:6ef:5ca3:d0d9 with SMTP id 00721157ae682-6f9b2878ce1mr58702687b3.20.1738991814002; Fri, 07 Feb 2025 21:16:54 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.16.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:16:53 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 01/10] platform/x86: alienware-wmi-wmax: Rename thermal related symbols Date: Sat, 8 Feb 2025 00:16:05 -0500 Message-ID: <20250208051614.10644-2-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The "thermal" features of the WMAX WMI device are only present on the host device if the ACPI _UID is "AWCC". Replace WMAX prefixes with "AWCC" to reflect this relationship. Thermal profiles with WMAX_PROFILE_BASIC prefix are also renamed to WMAX_PROFILE_LEGACY because they are only supported in older versions of this WMI device. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- .../platform/x86/dell/alienware-wmi-wmax.c | 173 +++++++++--------- 1 file changed, 87 insertions(+), 86 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 3d3014b5adf0..ed70e12d73d7 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -24,16 +24,17 @@ #define WMAX_METHOD_DEEP_SLEEP_STATUS 0x0C #define WMAX_METHOD_BRIGHTNESS 0x3 #define WMAX_METHOD_ZONE_CONTROL 0x4 -#define WMAX_METHOD_THERMAL_INFORMATION 0x14 -#define WMAX_METHOD_THERMAL_CONTROL 0x15 -#define WMAX_METHOD_GAME_SHIFT_STATUS 0x25 =20 -#define WMAX_THERMAL_MODE_GMODE 0xAB +#define AWCC_METHOD_THERMAL_INFORMATION 0x14 +#define AWCC_METHOD_THERMAL_CONTROL 0x15 +#define AWCC_METHOD_GAME_SHIFT_STATUS 0x25 =20 -#define WMAX_FAILURE_CODE 0xFFFFFFFF -#define WMAX_THERMAL_TABLE_MASK GENMASK(7, 4) -#define WMAX_THERMAL_MODE_MASK GENMASK(3, 0) -#define WMAX_SENSOR_ID_MASK BIT(8) +#define AWCC_THERMAL_MODE_GMODE 0xAB + +#define AWCC_FAILURE_CODE 0xFFFFFFFF +#define AWCC_THERMAL_TABLE_MASK GENMASK(7, 4) +#define AWCC_THERMAL_MODE_MASK GENMASK(3, 0) +#define AWCC_SENSOR_ID_MASK BIT(8) =20 static bool force_platform_profile; module_param_unsafe(force_platform_profile, bool, 0); @@ -151,38 +152,38 @@ static const struct dmi_system_id awcc_dmi_table[] __= initconst =3D { }, }; =20 -enum WMAX_THERMAL_INFORMATION_OPERATIONS { - WMAX_OPERATION_SYS_DESCRIPTION =3D 0x02, - WMAX_OPERATION_LIST_IDS =3D 0x03, - WMAX_OPERATION_CURRENT_PROFILE =3D 0x0B, +enum AWCC_THERMAL_INFORMATION_OPERATIONS { + AWCC_OP_GET_SYSTEM_DESCRIPTION =3D 0x02, + AWCC_OP_GET_RESOURCE_ID =3D 0x03, + AWCC_OP_GET_CURRENT_PROFILE =3D 0x0B, }; =20 -enum WMAX_THERMAL_CONTROL_OPERATIONS { - WMAX_OPERATION_ACTIVATE_PROFILE =3D 0x01, +enum AWCC_THERMAL_CONTROL_OPERATIONS { + AWCC_OP_ACTIVATE_PROFILE =3D 0x01, }; =20 -enum WMAX_GAME_SHIFT_STATUS_OPERATIONS { - WMAX_OPERATION_TOGGLE_GAME_SHIFT =3D 0x01, - WMAX_OPERATION_GET_GAME_SHIFT_STATUS =3D 0x02, +enum AWCC_GAME_SHIFT_STATUS_OPERATIONS { + AWCC_OP_TOGGLE_GAME_SHIFT =3D 0x01, + AWCC_OP_GET_GAME_SHIFT_STATUS =3D 0x02, }; =20 -enum WMAX_THERMAL_TABLES { - WMAX_THERMAL_TABLE_BASIC =3D 0x90, - WMAX_THERMAL_TABLE_USTT =3D 0xA0, +enum AWCC_THERMAL_TABLES { + AWCC_THERMAL_TABLE_LEGACY =3D 0x90, + AWCC_THERMAL_TABLE_USTT =3D 0xA0, }; =20 -enum wmax_thermal_mode { - THERMAL_MODE_USTT_BALANCED, - THERMAL_MODE_USTT_BALANCED_PERFORMANCE, - THERMAL_MODE_USTT_COOL, - THERMAL_MODE_USTT_QUIET, - THERMAL_MODE_USTT_PERFORMANCE, - THERMAL_MODE_USTT_LOW_POWER, - THERMAL_MODE_BASIC_QUIET, - THERMAL_MODE_BASIC_BALANCED, - THERMAL_MODE_BASIC_BALANCED_PERFORMANCE, - THERMAL_MODE_BASIC_PERFORMANCE, - THERMAL_MODE_LAST, +enum awcc_thermal_profile { + AWCC_PROFILE_USTT_BALANCED, + AWCC_PROFILE_USTT_BALANCED_PERFORMANCE, + AWCC_PROFILE_USTT_COOL, + AWCC_PROFILE_USTT_QUIET, + AWCC_PROFILE_USTT_PERFORMANCE, + AWCC_PROFILE_USTT_LOW_POWER, + AWCC_PROFILE_LEGACY_QUIET, + AWCC_PROFILE_LEGACY_BALANCED, + AWCC_PROFILE_LEGACY_BALANCED_PERFORMANCE, + AWCC_PROFILE_LEGACY_PERFORMANCE, + AWCC_PROFILE_LAST, }; =20 struct wmax_led_args { @@ -210,20 +211,20 @@ struct wmax_u32_args { struct awcc_priv { struct wmi_device *wdev; struct device *ppdev; - enum wmax_thermal_mode supported_thermal_profiles[PLATFORM_PROFILE_LAST]; + enum awcc_thermal_profile supported_thermal_profiles[PLATFORM_PROFILE_LAS= T]; }; =20 -static const enum platform_profile_option wmax_mode_to_platform_profile[TH= ERMAL_MODE_LAST] =3D { - [THERMAL_MODE_USTT_BALANCED] =3D PLATFORM_PROFILE_BALANCED, - [THERMAL_MODE_USTT_BALANCED_PERFORMANCE] =3D PLATFORM_PROFILE_BALANCED_PE= RFORMANCE, - [THERMAL_MODE_USTT_COOL] =3D PLATFORM_PROFILE_COOL, - [THERMAL_MODE_USTT_QUIET] =3D PLATFORM_PROFILE_QUIET, - [THERMAL_MODE_USTT_PERFORMANCE] =3D PLATFORM_PROFILE_PERFORMANCE, - [THERMAL_MODE_USTT_LOW_POWER] =3D PLATFORM_PROFILE_LOW_POWER, - [THERMAL_MODE_BASIC_QUIET] =3D PLATFORM_PROFILE_QUIET, - [THERMAL_MODE_BASIC_BALANCED] =3D PLATFORM_PROFILE_BALANCED, - [THERMAL_MODE_BASIC_BALANCED_PERFORMANCE] =3D PLATFORM_PROFILE_BALANCED_P= ERFORMANCE, - [THERMAL_MODE_BASIC_PERFORMANCE] =3D PLATFORM_PROFILE_PERFORMANCE, +static const enum platform_profile_option awcc_mode_to_platform_profile[AW= CC_PROFILE_LAST] =3D { + [AWCC_PROFILE_USTT_BALANCED] =3D PLATFORM_PROFILE_BALANCED, + [AWCC_PROFILE_USTT_BALANCED_PERFORMANCE] =3D PLATFORM_PROFILE_BALANCED_PE= RFORMANCE, + [AWCC_PROFILE_USTT_COOL] =3D PLATFORM_PROFILE_COOL, + [AWCC_PROFILE_USTT_QUIET] =3D PLATFORM_PROFILE_QUIET, + [AWCC_PROFILE_USTT_PERFORMANCE] =3D PLATFORM_PROFILE_PERFORMANCE, + [AWCC_PROFILE_USTT_LOW_POWER] =3D PLATFORM_PROFILE_LOW_POWER, + [AWCC_PROFILE_LEGACY_QUIET] =3D PLATFORM_PROFILE_QUIET, + [AWCC_PROFILE_LEGACY_BALANCED] =3D PLATFORM_PROFILE_BALANCED, + [AWCC_PROFILE_LEGACY_BALANCED_PERFORMANCE] =3D PLATFORM_PROFILE_BALANCED_= PERFORMANCE, + [AWCC_PROFILE_LEGACY_PERFORMANCE] =3D PLATFORM_PROFILE_PERFORMANCE, }; =20 static struct awcc_quirks *awcc; @@ -444,26 +445,26 @@ const struct attribute_group wmax_deepsleep_attribute= _group =3D { * Thermal Profile control * - Provides thermal profile control through the Platform Profile API */ -static bool is_wmax_thermal_code(u32 code) +static bool is_awcc_thermal_mode(u32 code) { - if (code & WMAX_SENSOR_ID_MASK) + if (code & AWCC_SENSOR_ID_MASK) return false; =20 - if ((code & WMAX_THERMAL_MODE_MASK) >=3D THERMAL_MODE_LAST) + if ((code & AWCC_THERMAL_MODE_MASK) >=3D AWCC_PROFILE_LAST) return false; =20 - if ((code & WMAX_THERMAL_TABLE_MASK) =3D=3D WMAX_THERMAL_TABLE_BASIC && - (code & WMAX_THERMAL_MODE_MASK) >=3D THERMAL_MODE_BASIC_QUIET) + if ((code & AWCC_THERMAL_TABLE_MASK) =3D=3D AWCC_THERMAL_TABLE_LEGACY && + (code & AWCC_THERMAL_MODE_MASK) >=3D AWCC_PROFILE_LEGACY_QUIET) return true; =20 - if ((code & WMAX_THERMAL_TABLE_MASK) =3D=3D WMAX_THERMAL_TABLE_USTT && - (code & WMAX_THERMAL_MODE_MASK) <=3D THERMAL_MODE_USTT_LOW_POWER) + if ((code & AWCC_THERMAL_TABLE_MASK) =3D=3D AWCC_THERMAL_TABLE_USTT && + (code & AWCC_THERMAL_MODE_MASK) <=3D AWCC_PROFILE_USTT_LOW_POWER) return true; =20 return false; } =20 -static int wmax_thermal_information(struct wmi_device *wdev, u8 operation, +static int awcc_thermal_information(struct wmi_device *wdev, u8 operation, u8 arg, u32 *out_data) { struct wmax_u32_args in_args =3D { @@ -474,21 +475,21 @@ static int wmax_thermal_information(struct wmi_device= *wdev, u8 operation, }; int ret; =20 - ret =3D alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_INFORMATION, + ret =3D alienware_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, &in_args, sizeof(in_args), out_data); if (ret < 0) return ret; =20 - if (*out_data =3D=3D WMAX_FAILURE_CODE) + if (*out_data =3D=3D AWCC_FAILURE_CODE) return -EBADRQC; =20 return 0; } =20 -static int wmax_thermal_control(struct wmi_device *wdev, u8 profile) +static int awcc_thermal_control(struct wmi_device *wdev, u8 profile) { struct wmax_u32_args in_args =3D { - .operation =3D WMAX_OPERATION_ACTIVATE_PROFILE, + .operation =3D AWCC_OP_ACTIVATE_PROFILE, .arg1 =3D profile, .arg2 =3D 0, .arg3 =3D 0, @@ -496,18 +497,18 @@ static int wmax_thermal_control(struct wmi_device *wd= ev, u8 profile) u32 out_data; int ret; =20 - ret =3D alienware_wmi_command(wdev, WMAX_METHOD_THERMAL_CONTROL, + ret =3D alienware_wmi_command(wdev, AWCC_METHOD_THERMAL_CONTROL, &in_args, sizeof(in_args), &out_data); if (ret) return ret; =20 - if (out_data =3D=3D WMAX_FAILURE_CODE) + if (out_data =3D=3D AWCC_FAILURE_CODE) return -EBADRQC; =20 return 0; } =20 -static int wmax_game_shift_status(struct wmi_device *wdev, u8 operation, +static int awcc_game_shift_status(struct wmi_device *wdev, u8 operation, u32 *out_data) { struct wmax_u32_args in_args =3D { @@ -518,46 +519,46 @@ static int wmax_game_shift_status(struct wmi_device *= wdev, u8 operation, }; int ret; =20 - ret =3D alienware_wmi_command(wdev, WMAX_METHOD_GAME_SHIFT_STATUS, + ret =3D alienware_wmi_command(wdev, AWCC_METHOD_GAME_SHIFT_STATUS, &in_args, sizeof(in_args), out_data); if (ret < 0) return ret; =20 - if (*out_data =3D=3D WMAX_FAILURE_CODE) + if (*out_data =3D=3D AWCC_FAILURE_CODE) return -EOPNOTSUPP; =20 return 0; } =20 -static int thermal_profile_get(struct device *dev, - enum platform_profile_option *profile) +static int awcc_platform_profile_get(struct device *dev, + enum platform_profile_option *profile) { struct awcc_priv *priv =3D dev_get_drvdata(dev); u32 out_data; int ret; =20 - ret =3D wmax_thermal_information(priv->wdev, WMAX_OPERATION_CURRENT_PROFI= LE, + ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_CURRENT_PROFILE, 0, &out_data); =20 if (ret < 0) return ret; =20 - if (out_data =3D=3D WMAX_THERMAL_MODE_GMODE) { + if (out_data =3D=3D AWCC_THERMAL_MODE_GMODE) { *profile =3D PLATFORM_PROFILE_PERFORMANCE; return 0; } =20 - if (!is_wmax_thermal_code(out_data)) + if (!is_awcc_thermal_mode(out_data)) return -ENODATA; =20 - out_data &=3D WMAX_THERMAL_MODE_MASK; - *profile =3D wmax_mode_to_platform_profile[out_data]; + out_data &=3D AWCC_THERMAL_MODE_MASK; + *profile =3D awcc_mode_to_platform_profile[out_data]; =20 return 0; } =20 -static int thermal_profile_set(struct device *dev, - enum platform_profile_option profile) +static int awcc_platform_profile_set(struct device *dev, + enum platform_profile_option profile) { struct awcc_priv *priv =3D dev_get_drvdata(dev); =20 @@ -565,8 +566,8 @@ static int thermal_profile_set(struct device *dev, u32 gmode_status; int ret; =20 - ret =3D wmax_game_shift_status(priv->wdev, - WMAX_OPERATION_GET_GAME_SHIFT_STATUS, + ret =3D awcc_game_shift_status(priv->wdev, + AWCC_OP_GET_GAME_SHIFT_STATUS, &gmode_status); =20 if (ret < 0) @@ -574,8 +575,8 @@ static int thermal_profile_set(struct device *dev, =20 if ((profile =3D=3D PLATFORM_PROFILE_PERFORMANCE && !gmode_status) || (profile !=3D PLATFORM_PROFILE_PERFORMANCE && gmode_status)) { - ret =3D wmax_game_shift_status(priv->wdev, - WMAX_OPERATION_TOGGLE_GAME_SHIFT, + ret =3D awcc_game_shift_status(priv->wdev, + AWCC_OP_TOGGLE_GAME_SHIFT, &gmode_status); =20 if (ret < 0) @@ -583,21 +584,21 @@ static int thermal_profile_set(struct device *dev, } } =20 - return wmax_thermal_control(priv->wdev, + return awcc_thermal_control(priv->wdev, priv->supported_thermal_profiles[profile]); } =20 -static int thermal_profile_probe(void *drvdata, unsigned long *choices) +static int awcc_platform_profile_probe(void *drvdata, unsigned long *choic= es) { enum platform_profile_option profile; struct awcc_priv *priv =3D drvdata; - enum wmax_thermal_mode mode; + enum awcc_thermal_profile mode; u8 sys_desc[4]; u32 first_mode; u32 out_data; int ret; =20 - ret =3D wmax_thermal_information(priv->wdev, WMAX_OPERATION_SYS_DESCRIPTI= ON, + ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_SYSTEM_DESCRIPTI= ON, 0, (u32 *) &sys_desc); if (ret < 0) return ret; @@ -605,7 +606,7 @@ static int thermal_profile_probe(void *drvdata, unsigne= d long *choices) first_mode =3D sys_desc[0] + sys_desc[1]; =20 for (u32 i =3D 0; i < sys_desc[3]; i++) { - ret =3D wmax_thermal_information(priv->wdev, WMAX_OPERATION_LIST_IDS, + ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_RESOURCE_ID, i + first_mode, &out_data); =20 if (ret =3D=3D -EIO) @@ -614,11 +615,11 @@ static int thermal_profile_probe(void *drvdata, unsig= ned long *choices) if (ret =3D=3D -EBADRQC) break; =20 - if (!is_wmax_thermal_code(out_data)) + if (!is_awcc_thermal_mode(out_data)) continue; =20 - mode =3D out_data & WMAX_THERMAL_MODE_MASK; - profile =3D wmax_mode_to_platform_profile[mode]; + mode =3D out_data & AWCC_THERMAL_MODE_MASK; + profile =3D awcc_mode_to_platform_profile[mode]; priv->supported_thermal_profiles[profile] =3D out_data; =20 set_bit(profile, choices); @@ -629,7 +630,7 @@ static int thermal_profile_probe(void *drvdata, unsigne= d long *choices) =20 if (awcc->gmode) { priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =3D - WMAX_THERMAL_MODE_GMODE; + AWCC_THERMAL_MODE_GMODE; =20 set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); } @@ -638,9 +639,9 @@ static int thermal_profile_probe(void *drvdata, unsigne= d long *choices) } =20 static const struct platform_profile_ops awcc_platform_profile_ops =3D { - .probe =3D thermal_profile_probe, - .profile_get =3D thermal_profile_get, - .profile_set =3D thermal_profile_set, + .probe =3D awcc_platform_profile_probe, + .profile_get =3D awcc_platform_profile_get, + .profile_set =3D awcc_platform_profile_set, }; =20 static int awcc_platform_profile_init(struct wmi_device *wdev) --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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 2890E1A2543; Sat, 8 Feb 2025 05:16:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991818; cv=none; b=lErj632GLwaVbZmzhq1DCrCoKlOwGdC4Md98XXrgXzpPztTxoUHOLWI8Owgm6OXKP6hPtN3kej83RcnJSehF6gAYcrK4DqeCEciCVFH6YQtKG1fd9mnHX3jaPtDaQVw/wr6ZDbK0CPI7ZuVV5T3TFpYLywGTg4QAEnbG8m+BEzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991818; c=relaxed/simple; bh=rFO1Ir2kxvm4ytz3DRnBwxmehRM/X9eIKqxxVfduUS0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UdnMJM+rZVOb2RquQUikuxacvGAOCkGeiEqdKKsS2csttBl1iNA80uGrKmisWl+HqdjB8UyyQyk94KAy5+yPlb4orh0UP4ZjpwwZhCpKr0XPACJVwrje5sBnLb4BPQnqPSyTuxWlMqc4AXgcyv4/7AlJpWHZZI17aKA1Q6YrnIc= 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=CqB2igEs; arc=none smtp.client-ip=209.85.219.181 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="CqB2igEs" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e5b22d35268so2563346276.3; Fri, 07 Feb 2025 21:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991816; x=1739596616; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ziKlG74+FykDx2qVs72IwbcctC+93P49F74KIGbxq/I=; b=CqB2igEsKK3Iebr2whgYAPo6tbdrgT/q+QewkkiTRKEB5lyzuT1ILRck40rycDVHEP KmRklhW/3m7Hgn0V7e7sbdiKQqVUL2YADYPNDts3ladYEWdauT13zykcXNj83B3Nct+r psVqDmwkbxxgLTbM/V1NVz2RP4m/sJteGXwzeiO9IZmNn0arnoI5mN/fwiMvtxL0QBCp j0mLyZRcqrGN/h7DuxViVj5KxVSdhnci7/8ifYxbuCNCiDT9r3qnBRNA0ELUurq7Coa3 Q7p+ezmUncCZwu0UOIw8SLR8jhyarFLCyHBgPI8OvCNYOrPjUseaKd9FSEQBL8J8/VQB /1qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991816; x=1739596616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ziKlG74+FykDx2qVs72IwbcctC+93P49F74KIGbxq/I=; b=H3JixrQ4YXFCi2Xdyb92FMGw5tFGDC4P+/pLnm9XO6EJ3Sb4rRfz7smFWFyOb0pY0J XIcrZyBiwbQ7uDHT67zg3AeL9FjAK0w1l9wEZycveq7vb1hAbdh3y2bAH6UiGO6HFrfi 7Ipu5ukaoZVMwLw3ah4Ebbo7H11UQ4SvzObrpruPY6msbKe/G275ydHwJaJPnhCW/nep euJOP6q/5IrgiSNYp7zai+Adn3HPOYfZsN9XdUJPqWYwWteApyP/n7ksN6Z9kDQ41Q77 N10enpi0z3AkBDuOpg9TkmnjAGLUB4E8hetXG1MFv3knQXwpuDR7gAo8tvmHV2TVN2kw iAJg== X-Forwarded-Encrypted: i=1; AJvYcCWZj3MJvnGfcB7N4KBDyUVEQlMLZe7iMZvZVe8fOXAkUt20/PHmI/gcKblRw9EfL/ZL+2lGZNrV7RSBdKg=@vger.kernel.org X-Gm-Message-State: AOJu0YxNvLOWOyWY7MgjpdNavs74Ub95SkENrUdGLgP3+CL1hfwOs0uC akQdfDRJuxYim8VsL6v9XRbcj7RnBfZdbkf547K8K7+hb6liN0QT X-Gm-Gg: ASbGncuz8BcQ0fhdXIPVOVwf5d3Ni9BRYOljOIj4ssTU6EppqPt8uz1UGtIbfkdoA6q j4DNnjT8BG+Of2ZnqF/LArKRpKcUVARRVrZoP4LCeJDVbUAKSdrugKQLpm17xOiFzDrIsScdXu0 lyLQsY4QYGH4zvpTCZ7ighjaPeR5ajj+4xTpyAcmztwLrG42OgKIxtdMt/77VaICnSyejZSCt5Z CCIC7RFZ9SKM9z+cstSoe3EQ191Wjloi21l+dXS6BZDdgwKr3JS+Hf9EcCxewhH4FXI964hsKnv FGWZFs44mN3qTktxcUENgXU= X-Google-Smtp-Source: AGHT+IE8Fx8YRBAVDg371LAxr4DfqFtRvNYV8dsAeJXPCUKQaTkChI9lKBZ2U8CLL2jtI469zEdNzA== X-Received: by 2002:a05:6902:2101:b0:e58:341d:50d6 with SMTP id 3f1490d57ef6-e5b4628600bmr4910120276.35.1738991815985; Fri, 07 Feb 2025 21:16:55 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:16:55 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 02/10] platform/x86: alienware-wmi-wmax: Refactor is_awcc_thermal_mode() Date: Sat, 8 Feb 2025 00:16:06 -0500 Message-ID: <20250208051614.10644-3-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Refactor is_awcc_thermal_mode() to use FIELD_GET() instead of bitwise operations. Drop the check for BIT(8) sensor flag and rename it to is_awcc_thermal_profile_id(). Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- .../platform/x86/dell/alienware-wmi-wmax.c | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index ed70e12d73d7..7f0aa88221d6 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -34,7 +34,7 @@ #define AWCC_FAILURE_CODE 0xFFFFFFFF #define AWCC_THERMAL_TABLE_MASK GENMASK(7, 4) #define AWCC_THERMAL_MODE_MASK GENMASK(3, 0) -#define AWCC_SENSOR_ID_MASK BIT(8) +#define AWCC_RESOURCE_ID_MASK GENMASK(7, 0) =20 static bool force_platform_profile; module_param_unsafe(force_platform_profile, bool, 0); @@ -168,8 +168,8 @@ enum AWCC_GAME_SHIFT_STATUS_OPERATIONS { }; =20 enum AWCC_THERMAL_TABLES { - AWCC_THERMAL_TABLE_LEGACY =3D 0x90, - AWCC_THERMAL_TABLE_USTT =3D 0xA0, + AWCC_THERMAL_TABLE_LEGACY =3D 0x9, + AWCC_THERMAL_TABLE_USTT =3D 0xA, }; =20 enum awcc_thermal_profile { @@ -445,20 +445,18 @@ const struct attribute_group wmax_deepsleep_attribute= _group =3D { * Thermal Profile control * - Provides thermal profile control through the Platform Profile API */ -static bool is_awcc_thermal_mode(u32 code) +static bool is_awcc_thermal_profile_id(u8 code) { - if (code & AWCC_SENSOR_ID_MASK) - return false; + u8 table =3D FIELD_GET(AWCC_THERMAL_TABLE_MASK, code); + u8 mode =3D FIELD_GET(AWCC_THERMAL_MODE_MASK, code); =20 - if ((code & AWCC_THERMAL_MODE_MASK) >=3D AWCC_PROFILE_LAST) + if (mode >=3D AWCC_PROFILE_LAST) return false; =20 - if ((code & AWCC_THERMAL_TABLE_MASK) =3D=3D AWCC_THERMAL_TABLE_LEGACY && - (code & AWCC_THERMAL_MODE_MASK) >=3D AWCC_PROFILE_LEGACY_QUIET) + if (table =3D=3D AWCC_THERMAL_TABLE_LEGACY && mode >=3D AWCC_PROFILE_LEGA= CY_QUIET) return true; =20 - if ((code & AWCC_THERMAL_TABLE_MASK) =3D=3D AWCC_THERMAL_TABLE_USTT && - (code & AWCC_THERMAL_MODE_MASK) <=3D AWCC_PROFILE_USTT_LOW_POWER) + if (table =3D=3D AWCC_THERMAL_TABLE_USTT && mode <=3D AWCC_PROFILE_USTT_L= OW_POWER) return true; =20 return false; @@ -548,7 +546,7 @@ static int awcc_platform_profile_get(struct device *dev, return 0; } =20 - if (!is_awcc_thermal_mode(out_data)) + if (!is_awcc_thermal_profile_id(out_data)) return -ENODATA; =20 out_data &=3D AWCC_THERMAL_MODE_MASK; @@ -597,6 +595,7 @@ static int awcc_platform_profile_probe(void *drvdata, u= nsigned long *choices) u32 first_mode; u32 out_data; int ret; + u8 id; =20 ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_SYSTEM_DESCRIPTI= ON, 0, (u32 *) &sys_desc); @@ -615,12 +614,14 @@ static int awcc_platform_profile_probe(void *drvdata,= unsigned long *choices) if (ret =3D=3D -EBADRQC) break; =20 - if (!is_awcc_thermal_mode(out_data)) + /* Some IDs have a BIT(8) flag that should be ignored */ + id =3D FIELD_GET(AWCC_RESOURCE_ID_MASK, out_data); + if (!is_awcc_thermal_profile_id(id)) continue; =20 - mode =3D out_data & AWCC_THERMAL_MODE_MASK; + mode =3D FIELD_GET(AWCC_THERMAL_MODE_MASK, id); profile =3D awcc_mode_to_platform_profile[mode]; - priv->supported_thermal_profiles[profile] =3D out_data; + priv->supported_thermal_profiles[profile] =3D id; =20 set_bit(profile, choices); } --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) (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 D12E61A5B9D; Sat, 8 Feb 2025 05:16:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991820; cv=none; b=P0YKBD91kFIezUoneFjw4cQyVWXZCy+OubKChRzjeA0VFT+g1bpv5E7bqKnLANJb/UEaYOg+dVTXTRdTjFedVGLVosAf9Chg70HfcsiU0lCkk+v34NAQfwolMcuaO0sMibiJOi+W9MXtZ7h3QQ+KRl1iC766ZgkL4f6e0zl6QMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991820; c=relaxed/simple; bh=nI7FgGy/u+gMITPMdKClt3nhKrK1SXiymvwzKMU4lKo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EisQbuYuRHvrTX5aofisHWADaA9S4uxNO0t6ckZa1USbO3mTWRt4mNAy6j4kQloKDAD4szFX8rPLZmurqMwgULZCdIP6cTt2hrkbBrq8aZhOzhgWtjwGZDFTUDZ4V2OH7Nps+tsOTt17wcK5q+BST6gzf9Rb+GmFEqfEE4d1AmE= 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=aU8tU/kv; arc=none smtp.client-ip=209.85.219.172 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="aU8tU/kv" Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-e4419a47887so2151072276.0; Fri, 07 Feb 2025 21:16:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991818; x=1739596618; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E2/ZbQaS7tudFA0bnX4MRV45fdFtTe7iOxVt9wUYReY=; b=aU8tU/kvAETNmsV7C7BezRSARh4/+7GIY9IYrCekhcgIaHLLjvvoQs5tcGmf+sbrJB UGPAIwmuAMYyvS2QIVe+hZ57//v9U3du/62+GBtL7Yz1KuSnSFuUG6/5j19zlbFuoAJO NYGTI4x6QX4q1VNcBbO1VJSE+0puWjy7EGr4srbXs5UDtJP2BDr5fTB7YgcmF3SUJeOw fpvHpGFu5BWYmYFRzh8Fyp9MKZa98+X9otxJJUBmog/4Xt56Dy6aVxNYkOVrq7BPD9g4 dsTzobk1u6ADiyznvDRvApexL45EcNz+Xd306DpcQauYKqlzYnVOnpZTcROaZkic3zHL QgVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991818; x=1739596618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E2/ZbQaS7tudFA0bnX4MRV45fdFtTe7iOxVt9wUYReY=; b=ZbFdU7mhH2TURj0w9YGYy3LYAcBtVDylHas1TD0EthN4XYTmjqShbKJm6GTbzC3nqW 3mXG+RNThrqkhrwRaXXlooi5ZMQQyouUBfw+l1Gmsp4Lsv8Jw4kMBlWxcLIPgEIehD4v 1fPZQ2B2VOuy/FcaMKhPZkbGthI+tkwEPagqKMDs/jmqNxEJY/sjMlASB6nWgcOwDDEz NX9KA1Fp2x1Dl6j51j14W+qEwv5aTg+iFzyMAzMfHNvxyx3AXlElK+cQLAq9tVdVlu/d TsObIp8+Db/TMkmj18OURUt/LUgdAjkQGE7/lH6sTmzpd+ayryfBvxKyQG1XvZylF4o/ 4w3w== X-Forwarded-Encrypted: i=1; AJvYcCWynGMFTpX2w6Q2n5QEhm++yGffXS5ryGoaWYogucyyExWEgCKospIMwwotrj3QuINuZuGI9JuRb+yPrxE=@vger.kernel.org X-Gm-Message-State: AOJu0Yxrq2qQGu/U2kv0NiiezervWLFQCmFS/gdotPGJ0AJ0cUAeIF1H Iw/S5Worxl+3HqzGYSEnGo13ip81UoWNgF3Xuw5bNs/HLCvzzT+n X-Gm-Gg: ASbGncv3sR7HWdIk8SzK+B4/A6j/fk/szikMBOVn4COJJoIkLOPIBiNZKY9jN36e8g0 TKRDXEyM6pFG0/a/0dpCmNkBjKwVS9PC1/7HxRL98PJ6tjnX6KfdXG13uToUgLl/LbdhxlAFqUt CiZQz25qOAAoSyDDF/v7qVuOIP9JFx0gkJZnE4lGSqPVtxav0oWJpo6IXxNdeortfbokgtljSwV 0yZ4S8lSY7vHuRuRipVA0PiLQ+9L2T/Ut+ExKuu9eJqHhJ7R6/OLe/1I64N9w+LXJDqRbCNI7L6 OOmGMMQj3bmQJNVX1MdzyMQ= X-Google-Smtp-Source: AGHT+IGWwiLJOyK+4R8azb8TXlvlewJs/Oya5AYFHe5PNT8EH8cTaLZ3Qb+qs4Mgs2kSV/kG+AlfEw== X-Received: by 2002:a05:6902:1b85:b0:e4d:25c6:c3b2 with SMTP id 3f1490d57ef6-e5b46175f3bmr5696643276.7.1738991817828; Fri, 07 Feb 2025 21:16:57 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:16:57 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 03/10] platform/x86: alienware-wmi-wmax: Improve internal AWCC API Date: Sat, 8 Feb 2025 00:16:07 -0500 Message-ID: <20250208051614.10644-4-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Inline all AWCC WMI helper methods and directly return the newly introduced __awcc_wmi_command() to simplify implementation. Additionally make wmax_u32_args __packed, additional failure code and add a helper with documentation for AWCC_OP_GET_RESOURCE_ID. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- .../platform/x86/dell/alienware-wmi-wmax.c | 104 +++++++++++------- 1 file changed, 63 insertions(+), 41 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 7f0aa88221d6..57897a0f4296 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -32,6 +32,7 @@ #define AWCC_THERMAL_MODE_GMODE 0xAB =20 #define AWCC_FAILURE_CODE 0xFFFFFFFF +#define AWCC_FAILURE_CODE_2 0xFFFFFFFE #define AWCC_THERMAL_TABLE_MASK GENMASK(7, 4) #define AWCC_THERMAL_MODE_MASK GENMASK(3, 0) #define AWCC_RESOURCE_ID_MASK GENMASK(7, 0) @@ -206,7 +207,7 @@ struct wmax_u32_args { u8 arg1; u8 arg2; u8 arg3; -}; +} __packed; =20 struct awcc_priv { struct wmi_device *wdev; @@ -442,8 +443,7 @@ const struct attribute_group wmax_deepsleep_attribute_g= roup =3D { }; =20 /* - * Thermal Profile control - * - Provides thermal profile control through the Platform Profile API + * AWCC Helpers */ static bool is_awcc_thermal_profile_id(u8 code) { @@ -462,72 +462,95 @@ static bool is_awcc_thermal_profile_id(u8 code) return false; } =20 -static int awcc_thermal_information(struct wmi_device *wdev, u8 operation, - u8 arg, u32 *out_data) +static int __awcc_wmi_command(struct wmi_device *wdev, u32 method_id, + struct wmax_u32_args *args, u32 *out) { - struct wmax_u32_args in_args =3D { - .operation =3D operation, - .arg1 =3D arg, - .arg2 =3D 0, - .arg3 =3D 0, - }; int ret; =20 - ret =3D alienware_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, - &in_args, sizeof(in_args), out_data); - if (ret < 0) + ret =3D alienware_wmi_command(wdev, method_id, args, sizeof(*args), out); + if (ret) return ret; =20 - if (*out_data =3D=3D AWCC_FAILURE_CODE) + if (*out =3D=3D AWCC_FAILURE_CODE || *out =3D=3D AWCC_FAILURE_CODE_2) return -EBADRQC; =20 return 0; } =20 -static int awcc_thermal_control(struct wmi_device *wdev, u8 profile) +static inline int awcc_thermal_information(struct wmi_device *wdev, u8 ope= ration, + u8 arg, u32 *out) { - struct wmax_u32_args in_args =3D { - .operation =3D AWCC_OP_ACTIVATE_PROFILE, - .arg1 =3D profile, + struct wmax_u32_args args =3D { + .operation =3D operation, + .arg1 =3D arg, .arg2 =3D 0, .arg3 =3D 0, }; - u32 out_data; - int ret; =20 - ret =3D alienware_wmi_command(wdev, AWCC_METHOD_THERMAL_CONTROL, - &in_args, sizeof(in_args), &out_data); - if (ret) - return ret; + return __awcc_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, &args, o= ut); +} =20 - if (out_data =3D=3D AWCC_FAILURE_CODE) - return -EBADRQC; +static inline int awcc_thermal_control(struct wmi_device *wdev, u8 profile) +{ + struct wmax_u32_args args =3D { + .operation =3D AWCC_OP_ACTIVATE_PROFILE, + .arg1 =3D profile, + .arg2 =3D 0, + .arg3 =3D 0, + }; + u32 out; =20 - return 0; + return __awcc_wmi_command(wdev, AWCC_METHOD_THERMAL_CONTROL, &args, &out); } =20 -static int awcc_game_shift_status(struct wmi_device *wdev, u8 operation, - u32 *out_data) +static inline int awcc_game_shift_status(struct wmi_device *wdev, u8 opera= tion, + u32 *out) { - struct wmax_u32_args in_args =3D { + struct wmax_u32_args args =3D { .operation =3D operation, .arg1 =3D 0, .arg2 =3D 0, .arg3 =3D 0, }; - int ret; =20 - ret =3D alienware_wmi_command(wdev, AWCC_METHOD_GAME_SHIFT_STATUS, - &in_args, sizeof(in_args), out_data); - if (ret < 0) - return ret; + return __awcc_wmi_command(wdev, AWCC_METHOD_GAME_SHIFT_STATUS, &args, out= ); +} =20 - if (*out_data =3D=3D AWCC_FAILURE_CODE) - return -EOPNOTSUPP; +/** + * awcc_op_get_resource_id - Get the resource ID at a given index + * @wdev: AWCC WMI device + * @index: Index + * @out: Value returned by the WMI call + * + * Get the resource ID at a given index. Resource IDs are listed in the + * following order: + * + * - Fan IDs + * - Sensor IDs + * - Unknown IDs + * - Thermal Profile IDs + * + * The total number of IDs of a given type can be obtained with + * AWCC_OP_GET_SYSTEM_DESCRIPTION. + * + * Return: 0 on success, -errno on failure + */ +static inline int awcc_op_get_resource_id(struct wmi_device *wdev, u8 inde= x, u32 *out) +{ + struct wmax_u32_args args =3D { + .operation =3D AWCC_OP_GET_RESOURCE_ID, + .arg1 =3D index, + .arg2 =3D 0, + .arg3 =3D 0, + }; =20 - return 0; + return __awcc_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, &args, o= ut); } =20 +/* + * Thermal Profile control + * - Provides thermal profile control through the Platform Profile API + */ static int awcc_platform_profile_get(struct device *dev, enum platform_profile_option *profile) { @@ -605,8 +628,7 @@ static int awcc_platform_profile_probe(void *drvdata, u= nsigned long *choices) first_mode =3D sys_desc[0] + sys_desc[1]; =20 for (u32 i =3D 0; i < sys_desc[3]; i++) { - ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_RESOURCE_ID, - i + first_mode, &out_data); + ret =3D awcc_op_get_resource_id(priv->wdev, i + first_mode, &out_data); =20 if (ret =3D=3D -EIO) return ret; --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 642B01ABEC7; Sat, 8 Feb 2025 05:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991823; cv=none; b=Y0OBK0XvK43Gb064iU4prHxwUuCfO5AtmFuM18h5qj3/3xcqEpTPZ4WmImjlAQYPYzwNrLLyI0kgGRPcWAl1JnjiiceE6V3B/A7BQCPMlU0l8KqrCfppvBarUSC9flg1hBueGf1K8nhbaWaQ0Oud6eWOGBynO60K4/h9ZsdntGo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991823; c=relaxed/simple; bh=0KSHupGOBgYOmFdNIreIK/QT2kr+uVPilbRT7ogzeQ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AhXz1fJ4x7LyWk3GbMOE7/I5MQ/FyljQbLPmd3mdEaDRN9e6EvvhmfyQOGWraoUH+rlPGEgaMDWq4QeemRpZUfyQ4EY8Nw3b8WknuykaULIW2cVfzg7I6cDD6JRdxPmG+Ovj2SymDOOioNlCusN3JWdtZWVVMavkhQuhvFJqT7Q= 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=lwy8F9uD; arc=none smtp.client-ip=209.85.219.176 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="lwy8F9uD" Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e53ef7462b6so2390610276.3; Fri, 07 Feb 2025 21:17:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991820; x=1739596620; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mL0o1E0ZrpQj6F5YrHl7y+57sG0AVLmpDEujQJqimLI=; b=lwy8F9uDmhyS70pGJfhRAKUuKHS921HtSH4799Ut9bos0pl18vteMzOTJ1CD6uW7E5 dhO4Hns1frI21aOXuloZ6pUzVRBcd4JW00EwC3vvazgGhIKmC06WmifDWbwLerAtcbRM C+5pcbBuulXXEkSyENpPpBwcxjA+FXu7PlrU1PXwC2QlufHNcsGVugSKSbpvr2sxiRTq GySP2hBPEH4HY5HHzlipuMjUBeY6GVgUkK3gzsAmW+4bsg1rl2fgpjS6K4JFPdFtomG+ xo/fHdWe5HcsBUoePC9VIFViF4BBBUCjYii+JJFmQV8OG76LCLGlzTIlZc57wL7AInI4 h+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991820; x=1739596620; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mL0o1E0ZrpQj6F5YrHl7y+57sG0AVLmpDEujQJqimLI=; b=T8IjBF9U6GJyAGc1LrLbumsQvFoFjcSWRxML0TrbOQcPfrCSl0Kb4aX1Ir05OFHVvj iNeFRE0EdoUGgfsOkZXbh1brAhbppWIqCcISwntKkEx2OLl/pAbB0gVC89dhrDo4ZSPZ W2eUMmEs+n3PYOP/0S1TAcjjEXeHKQ5avtA3Te2Z2ZSzHuLD7C1p9LwW5COGcJZ7d7iV gqXPetyeWwFeUsj5Fl4bQ6x4o2QKR6Gssrj4WmffRog74Nmvts+RzWYJkf1HVgLYzSQb wTo88Pq7kH1N2c+DMexhu4wt7hrwfcaxhMLKYAIPf+p/cBwxbE90svTqeZ8rHV6yvFJD P97g== X-Forwarded-Encrypted: i=1; AJvYcCVcgIIbFj+H5Aui7wh6SBgA7HDE0Y2aa5u8Wb2Yd8YLbZmlsiFYxEiFbzZ7NxX/68Q2pbqHzMa15Zr3828=@vger.kernel.org X-Gm-Message-State: AOJu0Yyw7WVf2gmux/VEeb9UXLiuAnBhDVXfWny02w2hSiU2l/6KsAcz auYKKf6ru1Pt3ksVTvoQb33PZizfNTmK6C/quFAsji9CROqwVyaK X-Gm-Gg: ASbGncsBumQMIETFHbNJVkxN3XnyYD31/D6fOkhYc5r4uzUBlk+LrhpsbZmRdHNqMf5 6tlAldotdcDEn/LLZdl0SNgR09UAHK+sHou0dvxKj2ssNAM2DK2uNbyEi5jZIjM9ppMNO06iDv/ roJ6lKWKIMEmD9CeJqYJL2r1Xq3UDEEAdltwLLWt9oLlp3uY2A3d/7I7aJHg5if206Y5Xhzie79 My/MYGvCl9r3V6u9i9Ogl83s9Igz+W1sz3AY73Kd8WkwUjU7Pf4u5HAhzyaLFY7cCqI9AzXziF8 Nu/atT7FCaWz7GXPEstOtPM= X-Google-Smtp-Source: AGHT+IG/9d8oLIAckNjS/PepLkF71XB6GaYD3HwYj6XFmSZHuIa9XnVe8fd1To9WBR4Awtl3OJHRFw== X-Received: by 2002:a05:6902:1691:b0:e5b:2245:9d6d with SMTP id 3f1490d57ef6-e5b4619ef87mr5711450276.13.1738991820176; Fri, 07 Feb 2025 21:17:00 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:16:59 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 04/10] platform/x86: alienware-wmi-wmax: Modify supported_thermal_profiles[] Date: Sat, 8 Feb 2025 00:16:08 -0500 Message-ID: <20250208051614.10644-5-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rename supported_thermal_profiles[] -> supported_profiles[] and change it's type to u8 because it stores AWCC thermal IDs. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- drivers/platform/x86/dell/alienware-wmi-wmax.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 57897a0f4296..4a8335d90b5d 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -212,7 +212,7 @@ struct wmax_u32_args { struct awcc_priv { struct wmi_device *wdev; struct device *ppdev; - enum awcc_thermal_profile supported_thermal_profiles[PLATFORM_PROFILE_LAS= T]; + u8 supported_profiles[PLATFORM_PROFILE_LAST]; }; =20 static const enum platform_profile_option awcc_mode_to_platform_profile[AW= CC_PROFILE_LAST] =3D { @@ -606,7 +606,7 @@ static int awcc_platform_profile_set(struct device *dev, } =20 return awcc_thermal_control(priv->wdev, - priv->supported_thermal_profiles[profile]); + priv->supported_profiles[profile]); } =20 static int awcc_platform_profile_probe(void *drvdata, unsigned long *choic= es) @@ -643,7 +643,7 @@ static int awcc_platform_profile_probe(void *drvdata, u= nsigned long *choices) =20 mode =3D FIELD_GET(AWCC_THERMAL_MODE_MASK, id); profile =3D awcc_mode_to_platform_profile[mode]; - priv->supported_thermal_profiles[profile] =3D id; + priv->supported_profiles[profile] =3D id; =20 set_bit(profile, choices); } @@ -652,7 +652,7 @@ static int awcc_platform_profile_probe(void *drvdata, u= nsigned long *choices) return -ENODEV; =20 if (awcc->gmode) { - priv->supported_thermal_profiles[PLATFORM_PROFILE_PERFORMANCE] =3D + priv->supported_profiles[PLATFORM_PROFILE_PERFORMANCE] =3D AWCC_THERMAL_MODE_GMODE; =20 set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (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 996AE1B0406; Sat, 8 Feb 2025 05:17:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991825; cv=none; b=SwT9IeRaX/6Xr8P2z1jCR91tG+DcCMQbs0vEMeRbRa46J+zpcmR01dhMDXtU8B0pLjxdw+JN0g5VWnpOplynHlCf6dx2tUKg5VZF283Loj1p6EhKIlx5QkKz2HvWkDRDAdGbTC+AKOZm35GZEYyLLK0+rnj6F0MlsqR9p7PLiPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991825; c=relaxed/simple; bh=veRVDVSaWPMKYXKn2D3ut9WJXqVYipXaTrijz24ZORk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NxO953e/0y03CWlJcoOYDv+QV/SiWLEhXQH7PhFF76l0WdQ5d1tCumN8uU433VXHl2bqYExI4j+qF1k79wt01jSYKYFw3X+yosno4XB7oN/MLusTmQfK5c7/70RbkaM9WSccCdRv8PQzRovu2euZIqFpZp+ACDzlf6Jyv2IYlMw= 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=QpsbC4BI; arc=none smtp.client-ip=209.85.219.173 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="QpsbC4BI" Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-e5b32f64ffeso2377403276.3; Fri, 07 Feb 2025 21:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991822; x=1739596622; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vnq6bctUyMKnKWzXF4tir00PhIfIZPwMmmwSRfd2GRg=; b=QpsbC4BIlYPOymgxWV7DLDxcZpePyTveV4eBXNNmUq4quIMVm98QVHuRoVT3suPu3A cZ+1TWv7LeOAUMUqG3yYbSgcH/y4FQmSg0OJncTXr+HWlMKoqYOAKjjBQj+3bdvljoQG CvGaLoFq2y6kF06Fy34gM+bJv41nLqBQXgCkG7M2KOrgV/4CUlFfH5m8sp6g4+GRK2Ln qgHc/iOC+y+nnG2cGRymA8rJ71l/NY+TBlBaE0GMi2C7W+F/MwFx8heHfDcZNNe6iwjI L8sxu9Imt9x9Lv87AcUA94l8jgBCnmW9w67q8hU+uvJbb4s2rc9kWsJtAFaPKRUPasWE Kqig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991822; x=1739596622; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vnq6bctUyMKnKWzXF4tir00PhIfIZPwMmmwSRfd2GRg=; b=sXO3JmoaLAWbbK6dABOy6YzpbWOYJJrSmTH6nSqOwHsrteJquaLIxK0lPy7kGYsLpL rKLAbRoDeMDV6c5ImOOv2any1f7MCOpN92bjlVnSp2nnV3TZ5rx1JcfJpnQ3aFikiXY1 eiKNoA7YPnL8tK1H2uRYpIQMCizdSFuvUFiROXHZ91RoW1SUNmdmAxXw9BLxhy090pPT 3lPUmxhlZUZj32BgiiJweMi+SpwJO9t4PixlJqFCkahk0/Lc/1zbw1EcS3atKHuKNrPs 2W1BQRO9HCPZQfdFJ3kKOE2SWpo+b7nyWC/ukwlcaslE5MbmUJoL11OkjltOpuwOg+mM O9Jw== X-Forwarded-Encrypted: i=1; AJvYcCU+T28kxKcJOSgaTGrKW5ATFoFNfMEcg0l0ArxQkSYJy5s2xuYCbFHV/VrVwukRi1KOC7guVwtyfVLO0fM=@vger.kernel.org X-Gm-Message-State: AOJu0YzCqoRWEjE1otDtKxcPZ4MjUkY/mLERU4KLS1iW8hqoa0QAK0Kc T74/ZSrWHnqLt+1PHzLxHf4g1mfiUmiWoIyDPRYRyiN04by3FAuW X-Gm-Gg: ASbGncvyL3vkM4WYJcAcKkU0X9to3nL8MhVuKF6FVEDJ6kIndNPuCb8PlDMioEhlmya 0BFxz0NSdHPAtknYAJ4JZTa3cq4qKIC8BQ3qCG1arWnn2PRdJdWvvqccZTcvpYhGYsNqU4YeUJ7 xeVqBN1FpyaiHQFwqd6E+/da5MVF2Y6Maza+XMq+M41IWui8V8fnHcNjpwbTplYwRVOE6Av7Bdg 7ogsdLQ1tXSiffytkQ+FVgmBQZE6IyUVNPiFAj56MXP5rXSDMllpJq06U7zbw/ixzGt6v1vfdPn qCrv0Bh3Y43hgY/b4fGUMqE= X-Google-Smtp-Source: AGHT+IG+C3Xv8lxo9hkllBJCbQGk+5SdWM2eyu6+rZItbSJyTlRuSzISKfOtNsALBmDQVkv7Cwb/dQ== X-Received: by 2002:a05:6902:2412:b0:e5a:c5d6:3943 with SMTP id 3f1490d57ef6-e5b4606740bmr5139658276.0.1738991822473; Fri, 07 Feb 2025 21:17:02 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.17.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:17:01 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 05/10] platform/x86: alienware-wmi-wmax: Improve platform profile probe Date: Sat, 8 Feb 2025 00:16:09 -0500 Message-ID: <20250208051614.10644-6-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Get and store the AWCC system description in alienware_awcc_setup() instead of awcc_platform_profile_probe() and add a check for integer overflows to avoid misbehaviors. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- .../platform/x86/dell/alienware-wmi-wmax.c | 56 ++++++++++++++----- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 4a8335d90b5d..e8fe16da036a 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include "alienware-wmi.h" @@ -211,6 +212,17 @@ struct wmax_u32_args { =20 struct awcc_priv { struct wmi_device *wdev; + union { + u32 system_description; + struct { + u8 fan_count; + u8 temp_count; + u8 unknown_count; + u8 profile_count; + } __packed; + u8 res_count[4]; + } __packed; + struct device *ppdev; u8 supported_profiles[PLATFORM_PROFILE_LAST]; }; @@ -614,32 +626,35 @@ static int awcc_platform_profile_probe(void *drvdata,= unsigned long *choices) enum platform_profile_option profile; struct awcc_priv *priv =3D drvdata; enum awcc_thermal_profile mode; - u8 sys_desc[4]; - u32 first_mode; + u8 id, offset =3D 0; u32 out_data; int ret; - u8 id; - - ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_SYSTEM_DESCRIPTI= ON, - 0, (u32 *) &sys_desc); - if (ret < 0) - return ret; - - first_mode =3D sys_desc[0] + sys_desc[1]; =20 - for (u32 i =3D 0; i < sys_desc[3]; i++) { - ret =3D awcc_op_get_resource_id(priv->wdev, i + first_mode, &out_data); + /* + * Thermal profile IDs are listed last at offset + * fan_count + temp_count + unknown_count + */ + for (u32 i =3D 0; i < ARRAY_SIZE(priv->res_count) - 1; i++) + offset +=3D priv->res_count[i]; =20 + for (u32 i =3D 0; i < priv->profile_count; i++) { + ret =3D awcc_op_get_resource_id(priv->wdev, i + offset, &out_data); if (ret =3D=3D -EIO) return ret; =20 + /* + * Some devices report an incorrect number of thermal profiles + * so the resource ID list may end prematurely + */ if (ret =3D=3D -EBADRQC) break; =20 /* Some IDs have a BIT(8) flag that should be ignored */ id =3D FIELD_GET(AWCC_RESOURCE_ID_MASK, out_data); - if (!is_awcc_thermal_profile_id(id)) + if (!is_awcc_thermal_profile_id(id)) { + dev_dbg(&priv->wdev->dev, "Unmapped thermal profile ID 0x%02x\n", id); continue; + } =20 mode =3D FIELD_GET(AWCC_THERMAL_MODE_MASK, id); profile =3D awcc_mode_to_platform_profile[mode]; @@ -680,12 +695,27 @@ static int awcc_platform_profile_init(struct wmi_devi= ce *wdev) static int alienware_awcc_setup(struct wmi_device *wdev) { struct awcc_priv *priv; + u8 tot =3D 0; int ret; =20 priv =3D devm_kzalloc(&wdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; =20 + ret =3D awcc_thermal_information(wdev, AWCC_OP_GET_SYSTEM_DESCRIPTION, + 0, &priv->system_description); + if (ret < 0) + return ret; + + /* Sanity check */ + for (u32 i =3D 0; i < ARRAY_SIZE(priv->res_count); i++) { + if (check_add_overflow(tot, priv->res_count[i], &tot)) { + dev_err(&wdev->dev, "Malformed system description: %u\n", + priv->system_description); + return -ENXIO; + } + } + priv->wdev =3D wdev; dev_set_drvdata(&wdev->dev, priv); =20 --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (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 E74361B3922; Sat, 8 Feb 2025 05:17:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991827; cv=none; b=ASGYs3IBju7N42PU7B2GJ7KOegW+PLV0bJ8JxAr2Wwhg0Fi1Hrr/Ir5V4Jj/0AtQcrlczZl6TsZpYCRxVqT/OaTfdr0fAnHGjLltL9Gl7HqtBjgb1rpFlYQdwr7/+lR24rGZou021ID/y+rtk7gVkDVJyoI57cAxhbdSs7I8VkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991827; c=relaxed/simple; bh=lmhfuJDeNTjIlJTma8WvjlJSgiyHo9d5BVUAl3W7jTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G4iMIsBuoR+RgJV3xezUUo9GhAgewHNFrZLW6QOcQF5WFWfMtqQWAD4tbTGA/RMKYPB6kQdZaSRa7EJYgtruK3YTFfDelGkasBZHa1Prmp9QSK4J/o3Rumj+Hgv+xdJQtAWv2u5//5iqdbzZTgVLvAlyT14Ldy8ontERI4rDTko= 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=HMqPv5RO; arc=none smtp.client-ip=209.85.219.182 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="HMqPv5RO" Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e5b4d615362so1062259276.2; Fri, 07 Feb 2025 21:17:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991825; x=1739596625; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pYmtWyIkQq37U/LlTeUKDeWLlebq2kAcdgNlDr4ssg8=; b=HMqPv5RO+4os7J+Pe4dkWJ2vpJzoAEc3WFXlF86Ph8exhp9R29FDwAvxh+bAAgahek Wsp1omazxFSGr+nmlxR7Zc5MbSvOJlpIgLeZSK+nHcA1WFo+jpVhc0lVGajaegsp1FvU RuvfL/cUnwELo1zJ9jQWShynpDuxc5sfMcrVuyrTcWsl4PW53y8+whESCCRu06lbCmHm SJFtOZ5XxhCGOeosuCG6e1muNUbvOvXOTRBUKjUD9KIBGBsvq7TGZvN3xfVIkVrE89JS QI8+3hr6IBUbsNbdx4XdXcjJch+n2Nubl3c7C4+2hbjgED0Vx63pK/WTRJF9oTIs5sCb w1Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991825; x=1739596625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pYmtWyIkQq37U/LlTeUKDeWLlebq2kAcdgNlDr4ssg8=; b=VBF6utCih21prv8MSl8sC8gH40OcAWEWfToAoTKGmL7B22hIZbJwGdrzvGoSLZ8it9 aSco3IW2BKGZWs1djUru00+egi4xYKJG+QP4mn68PnD1Umor8jD+vrn6sLzm+y61F8DC shechbjWn288syi/1NzgCr5vx9wYI4o6m36yXsPuuRE2VCg6NHABH4/CE6VgGjnvwMgV 4g9kSki34oNd8u0kJbXoGtru36O3MR2kJkm41xoz2vd7+7vP7bXra9CXa6xifSFhIWyW rZ9wDXuuewjRsY71GpedrMk23HAx1zkwugamxIdUhfjj2YYPSaHq34fdmrvIqG2CVPFc 4qvQ== X-Forwarded-Encrypted: i=1; AJvYcCUx45lBDTr+8LrrqEBqIcxV/Al9sBuCQZ4iZLn3/ci7MkXsez9g0fDiTuDqiIN+p4fhI6wT0gAtDxHOyIg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/+GlAKh4Q+TIPHVsmz5Ph+DAVvPOGS7iJmOxG0cfbreEWFZcG WLoqd6jd8lv9Tepvtv/HgFWh9npJWBITYtqsag3n2qjugnGLqOtB X-Gm-Gg: ASbGncuTkAIkQfffctu8E5NesIyzTloNDceXJqGgQpsLqYbxLADIJfAz1ik9R3e+Jmg MDIYik84h9Ve/YwYeUnYEYoFGXtBCAcRpjBYivh747d0Ke54G5I/Sx6ZmfZC1Y5SNglxentaavX 9FcHMnlMyGl3Agt4Tu9XEKcDj0JgQAVizl4MfX5Gj82iODHHdeEETi05PKTOGWTE3dhx0EIs/XT PhoF88lX2J+Sm83zYVhCNABYocEKyWZiB66bsoOMKxEh/hQ7cMuapgw3O0MgZkdHPhLW7jnu/LQ jfKgG8BaA/zjYetx6OxPpqk= X-Google-Smtp-Source: AGHT+IGW8in8FCTBqeP8WWUMYlcfcijAg3QlJOLFHVjT+rc0fmVMVb9cuBPAeBQ0yHB8aQAZTDz82g== X-Received: by 2002:a05:6902:1ac5:b0:e5b:3af0:d4bc with SMTP id 3f1490d57ef6-e5b462564dbmr4605343276.37.1738991824923; Fri, 07 Feb 2025 21:17:04 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:17:04 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 06/10] platform/x86: alienware-wmi-wmax: Add support for the "custom" thermal profile Date: Sat, 8 Feb 2025 00:16:10 -0500 Message-ID: <20250208051614.10644-7-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All models with the "AWCC" WMAX device support a "custom" thermal profile. In some models this profile signals user-space that the user wants to manually control the fans, which are always unlocked. In other models it actually unlocks manual fan control. Signed-off-by: Kurt Borja Reviewed-by: Armin Wolf --- .../platform/x86/dell/alienware-wmi-wmax.c | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index e8fe16da036a..0d31156f43bb 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -30,8 +30,6 @@ #define AWCC_METHOD_THERMAL_CONTROL 0x15 #define AWCC_METHOD_GAME_SHIFT_STATUS 0x25 =20 -#define AWCC_THERMAL_MODE_GMODE 0xAB - #define AWCC_FAILURE_CODE 0xFFFFFFFF #define AWCC_FAILURE_CODE_2 0xFFFFFFFE #define AWCC_THERMAL_TABLE_MASK GENMASK(7, 4) @@ -174,6 +172,11 @@ enum AWCC_THERMAL_TABLES { AWCC_THERMAL_TABLE_USTT =3D 0xA, }; =20 +enum AWCC_SPECIAL_THERMAL_CODES { + AWCC_SPECIAL_PROFILE_CUSTOM =3D 0x00, + AWCC_SPECIAL_PROFILE_GMODE =3D 0xAB, +}; + enum awcc_thermal_profile { AWCC_PROFILE_USTT_BALANCED, AWCC_PROFILE_USTT_BALANCED_PERFORMANCE, @@ -576,9 +579,15 @@ static int awcc_platform_profile_get(struct device *de= v, if (ret < 0) return ret; =20 - if (out_data =3D=3D AWCC_THERMAL_MODE_GMODE) { + switch (out_data) { + case AWCC_SPECIAL_PROFILE_CUSTOM: + *profile =3D PLATFORM_PROFILE_CUSTOM; + return 0; + case AWCC_SPECIAL_PROFILE_GMODE: *profile =3D PLATFORM_PROFILE_PERFORMANCE; return 0; + default: + break; } =20 if (!is_awcc_thermal_profile_id(out_data)) @@ -666,9 +675,15 @@ static int awcc_platform_profile_probe(void *drvdata, = unsigned long *choices) if (bitmap_empty(choices, PLATFORM_PROFILE_LAST)) return -ENODEV; =20 + /* Every model supports the "custom" profile */ + priv->supported_profiles[PLATFORM_PROFILE_CUSTOM] =3D + AWCC_SPECIAL_PROFILE_CUSTOM; + + set_bit(PLATFORM_PROFILE_CUSTOM, choices); + if (awcc->gmode) { priv->supported_profiles[PLATFORM_PROFILE_PERFORMANCE] =3D - AWCC_THERMAL_MODE_GMODE; + AWCC_SPECIAL_PROFILE_GMODE; =20 set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); } --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (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 7025519F424; Sat, 8 Feb 2025 05:17:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991830; cv=none; b=AH3PXsIU1p3ixezgXcowHXfuC1ZkzTZAhjy1kJrdyWf1Hz11nVGJKtA//z+y1LUMt0wQ9HlxNAuiIMfYIORQum1O4ZZwhfhlUy1xTVrN+nFoRar8o3fQsNMOttA5YdgL4OoPRhfVJBq3UDVX2p85ElGyH/pvQzPJLc0P2wi3VXY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991830; c=relaxed/simple; bh=1Anp77FcN7bxOnMpEO+v5PROUi84UI4+cUCYiiJdw64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hyn48un0z3dkW+SBxJaQJCn4VfAweVWcTo2GCJe8X/J4DqRzf0gdw2KzTB2TlMDko++xj1fBVnJXSEHv59/naadagohEExzw6kP8cEM5DB5Zrq46wMaRwjS08ls8tX/ukzamdF0BeD6c7wckPHK9aEqtN5zxfeIhSSuEs9cFYoE= 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=mRiMC5Yd; arc=none smtp.client-ip=209.85.219.180 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="mRiMC5Yd" Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e589c258663so2932288276.1; Fri, 07 Feb 2025 21:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991827; x=1739596627; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TYJ506aWVCpMesdUlUZdBnyCzfpI5labEdaE/TF9xbw=; b=mRiMC5YdizYYvbWoS7cmoJJ0D66UK/CXeaq5DGzMpzs0h7Z2LfOQzEgkFrECmV+mnF pT2iPR7gC7Mc7abLCsh79tHsped46Amy2slL6SsdfDmdvgbdlLyUfMLj9pVbdzSYxm8a JbpYW9uonNWbcvJO7md2T4Skfo+iwMHnbK1/57XpOthczi01lDk2EnpQcEE1JYH2bt77 lp8k4iYE2vL4xvOfbvaDGynSghROowSar0wcqst1Ygcg41BVSta8xp37QFZKV8HSepCg KHi/Cj1hE92ZmA8uuCyF7c0tAnyhrwRoFO3yffoaBk9dHQOAuVJirbBm3DCLBEzS8J+N BYsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991827; x=1739596627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TYJ506aWVCpMesdUlUZdBnyCzfpI5labEdaE/TF9xbw=; b=n9vXVyWcrG4ONDhQM41dQdT5ndAUOmRdd38dRmbat175sX88VOyspkAv4ngXqVv+9d SLZQV36MbC4Spc8xr/FklTkSLsEd7he/Pf34PH7ADy83wwtBvJNOSWxotIalsYUurV1h h5ui5VZfbXGfCkBFbxF7gqvB3AnA5sU08MWDZJSlOJkQ9uMyhycWCacpF5+CDnnf5vka VXXCMje2QUBLtxxtMlXnH0XEAD+9yCwTdyaThwOzHaLIaB/ZE09Cd8f/bKoJAXj3jimX kNojQjamdeEaZQqE0Noe6wF+bPStPzeChvxSMKQsVHSRNZsxvo4oALkOkNAx1V5/1+Ko xhHA== X-Forwarded-Encrypted: i=1; AJvYcCUytafs0XAahBTrbhuGuD6awZ9jgipFbOOkl2O8beFpZpfTBWmtjHmGUrqyCTRkBastcjnYAxvwMKoA2XQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxQhSH4xFPtFP7rNwk7YUyDy3dB60LgUdYuYq6fspPqO+RfZp1t /Ing/Eue+I9TxW1Uz5k3nYO6S93iGKQ96IYZ66hCab0YVSV0ocFh X-Gm-Gg: ASbGncvyL6Hf7VXksaGoaR7B98BnK6eQupI8cgkzmmQw+00g9FB2lvHBTlnsJqQ16T4 Ma3h1zoLW82RDuD1Tt4xmaMh4CCP3N7Y/bIUTl66jdlsLEjFYfCGKCSPOL/nOhb2c2u+UxlW07S /Yl36v8JoHDPQZzYX52ehqiXSbznArX4ctRzAqYd6PF+JLIS5mFajv+B9Jhi4KTuKBKQVV9II7s 529c/cdI5UQl5TXiqlVYXaXULOfvAb0ncXxy2GvHVdU298FH6Gp6xJz4cgNk1rd8tuDhqTP8O53 /04Ad6V6qpU9sZtFoZnkNRU= X-Google-Smtp-Source: AGHT+IHTbBgxymXKR89/yBx9fqLWG3XQhHJ2DfMSVkyLPisTDv0BD9O1uzxW0Wo+qfnLZYdctR7WAQ== X-Received: by 2002:a05:6902:1b90:b0:e5a:e774:d238 with SMTP id 3f1490d57ef6-e5b4616c69dmr5400693276.2.1738991827389; Fri, 07 Feb 2025 21:17:07 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:17:06 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja , Guenter Roeck Subject: [PATCH 07/10] platform/x86: alienware-wmi-wmax: Add HWMON support Date: Sat, 8 Feb 2025 00:16:11 -0500 Message-ID: <20250208051614.10644-8-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All models with the "AWCC" WMAX device support monitoring fan speed and temperature sensors. Expose this feature through the HWMON interface. Sensor readings are cached for 1 second before refreshing them to mitigate the performance cost of calling WMI methods. Cc: Guenter Roeck Signed-off-by: Kurt Borja --- drivers/platform/x86/dell/Kconfig | 1 + .../platform/x86/dell/alienware-wmi-wmax.c | 341 ++++++++++++++++++ 2 files changed, 342 insertions(+) diff --git a/drivers/platform/x86/dell/Kconfig b/drivers/platform/x86/dell/= Kconfig index f8a0dffcaab7..85a57c01aaad 100644 --- a/drivers/platform/x86/dell/Kconfig +++ b/drivers/platform/x86/dell/Kconfig @@ -43,6 +43,7 @@ config ALIENWARE_WMI_WMAX bool "Alienware WMAX WMI device driver" default y depends on ALIENWARE_WMI + depends on HWMON select ACPI_PLATFORM_PROFILE help Alienware WMI driver with AlienFX LED, HDMI, amplifier, deep sleep and diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 0d31156f43bb..5f02da7ff25f 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -11,9 +11,13 @@ #include #include #include +#include +#include #include +#include #include #include +#include #include #include "alienware-wmi.h" =20 @@ -26,6 +30,7 @@ #define WMAX_METHOD_BRIGHTNESS 0x3 #define WMAX_METHOD_ZONE_CONTROL 0x4 =20 +#define AWCC_METHOD_GET_FAN_SENSORS 0x13 #define AWCC_METHOD_THERMAL_INFORMATION 0x14 #define AWCC_METHOD_THERMAL_CONTROL 0x15 #define AWCC_METHOD_GAME_SHIFT_STATUS 0x25 @@ -36,6 +41,10 @@ #define AWCC_THERMAL_MODE_MASK GENMASK(3, 0) #define AWCC_RESOURCE_ID_MASK GENMASK(7, 0) =20 +static bool force_hwmon; +module_param_unsafe(force_hwmon, bool, 0); +MODULE_PARM_DESC(force_hwmon, "Force probing for HWMON support without che= cking if the WMI backend is available"); + static bool force_platform_profile; module_param_unsafe(force_platform_profile, bool, 0); MODULE_PARM_DESC(force_platform_profile, "Forces auto-detecting thermal pr= ofiles without checking if WMI thermal backend is available"); @@ -45,16 +54,19 @@ module_param_unsafe(force_gmode, bool, 0); MODULE_PARM_DESC(force_gmode, "Forces G-Mode when performance profile is s= elected"); =20 struct awcc_quirks { + bool hwmon; bool pprof; bool gmode; }; =20 static struct awcc_quirks g_series_quirks =3D { + .hwmon =3D true, .pprof =3D true, .gmode =3D true, }; =20 static struct awcc_quirks generic_quirks =3D { + .hwmon =3D true, .pprof =3D true, .gmode =3D false, }; @@ -152,9 +164,17 @@ static const struct dmi_system_id awcc_dmi_table[] __i= nitconst =3D { }, }; =20 +enum AWCC_GET_FAN_SENSORS_OPERATIONS { + AWCC_OP_GET_TEMP_SENSOR_ID =3D 0x02, +}; + enum AWCC_THERMAL_INFORMATION_OPERATIONS { AWCC_OP_GET_SYSTEM_DESCRIPTION =3D 0x02, AWCC_OP_GET_RESOURCE_ID =3D 0x03, + AWCC_OP_GET_TEMPERATURE =3D 0x04, + AWCC_OP_GET_CURRENT_RPM =3D 0x05, + AWCC_OP_GET_MIN_RPM =3D 0x08, + AWCC_OP_GET_MAX_RPM =3D 0x09, AWCC_OP_GET_CURRENT_PROFILE =3D 0x0B, }; =20 @@ -177,6 +197,11 @@ enum AWCC_SPECIAL_THERMAL_CODES { AWCC_SPECIAL_PROFILE_GMODE =3D 0xAB, }; =20 +enum AWCC_TEMP_SENSOR_TYPES { + AWCC_TEMP_SENSOR_CPU =3D 0x01, + AWCC_TEMP_SENSOR_GPU =3D 0x06, +}; + enum awcc_thermal_profile { AWCC_PROFILE_USTT_BALANCED, AWCC_PROFILE_USTT_BALANCED_PERFORMANCE, @@ -213,6 +238,23 @@ struct wmax_u32_args { u8 arg3; } __packed; =20 +struct awcc_fan_channel_data { + u8 id; + u32 state; + u32 min_rpm; + u32 max_rpm; + u8 temp_sensor; + u64 timestamp; + struct mutex lock; /* protects state and timestamp */ +}; + +struct awcc_temp_channel_data { + u8 id; + u32 state; + u64 timestamp; + struct mutex lock; /* protects state and timestamp */ +}; + struct awcc_priv { struct wmi_device *wdev; union { @@ -228,6 +270,10 @@ struct awcc_priv { =20 struct device *ppdev; u8 supported_profiles[PLATFORM_PROFILE_LAST]; + + struct device *hwdev; + struct awcc_temp_channel_data *temp_data; + struct awcc_fan_channel_data *fan_data; }; =20 static const enum platform_profile_option awcc_mode_to_platform_profile[AW= CC_PROFILE_LAST] =3D { @@ -492,6 +538,18 @@ static int __awcc_wmi_command(struct wmi_device *wdev,= u32 method_id, return 0; } =20 +static inline int awcc_get_fan_sensors(struct wmi_device *wdev, u8 fan_id,= u32 *out) +{ + struct wmax_u32_args args =3D { + .operation =3D AWCC_OP_GET_TEMP_SENSOR_ID, + .arg1 =3D fan_id, + .arg2 =3D 0, + .arg3 =3D 0, + }; + + return __awcc_wmi_command(wdev, AWCC_METHOD_GET_FAN_SENSORS, &args, out); +} + static inline int awcc_thermal_information(struct wmi_device *wdev, u8 ope= ration, u8 arg, u32 *out) { @@ -562,6 +620,276 @@ static inline int awcc_op_get_resource_id(struct wmi_= device *wdev, u8 index, u32 return __awcc_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, &args, o= ut); } =20 +/* + * HWMON + * - Provides temperature and fan speed monitoring as well as manual fan + * control + */ +static int awcc_hwmon_update_temp(struct wmi_device *wdev, + struct awcc_temp_channel_data *data) +{ + u32 temp; + int ret; + + lockdep_assert_held(data->lock); + + if (time_is_after_jiffies64(data->timestamp + secs_to_jiffies(1))) + return 0; + + ret =3D awcc_thermal_information(wdev, AWCC_OP_GET_TEMPERATURE, data->id, + &temp); + if (ret) + return ret; + + data->state =3D temp * MILLIDEGREE_PER_DEGREE; + data->timestamp =3D get_jiffies_64(); + + return 0; +} + +static int awcc_hwmon_update_fan(struct wmi_device *wdev, + struct awcc_fan_channel_data *data) +{ + u32 rpm; + int ret; + + lockdep_assert_held(data->lock); + + if (time_is_after_jiffies64(data->timestamp + secs_to_jiffies(1))) + return 0; + + ret =3D awcc_thermal_information(wdev, AWCC_OP_GET_CURRENT_RPM, data->id, + &rpm); + if (ret) + return ret; + + data->state =3D rpm; + data->timestamp =3D get_jiffies_64(); + + return 0; +} + +static umode_t awcc_hwmon_is_visible(const void *drvdata, enum hwmon_senso= r_types type, + u32 attr, int channel) +{ + const struct awcc_priv *priv =3D drvdata; + + switch (type) { + case hwmon_temp: + if (channel < priv->temp_count) + return 0444; + + break; + case hwmon_fan: + if (channel < priv->fan_count) + return 0444; + + break; + default: + break; + } + + return 0; +} + +static int awcc_hwmon_read(struct device *dev, enum hwmon_sensor_types typ= e, + u32 attr, int channel, long *val) +{ + struct awcc_priv *priv =3D dev_get_drvdata(dev); + struct awcc_temp_channel_data *temp; + struct awcc_fan_channel_data *fan; + int ret; + + switch (type) { + case hwmon_temp: + temp =3D &priv->temp_data[channel]; + + switch (attr) { + case hwmon_temp_input: + mutex_lock(&temp->lock); + ret =3D awcc_hwmon_update_temp(priv->wdev, temp); + mutex_unlock(&temp->lock); + if (ret) + return ret; + + *val =3D temp->state; + break; + default: + return -EOPNOTSUPP; + } + + break; + case hwmon_fan: + fan =3D &priv->fan_data[channel]; + + switch (attr) { + case hwmon_fan_input: + mutex_lock(&fan->lock); + ret =3D awcc_hwmon_update_fan(priv->wdev, fan); + mutex_unlock(&fan->lock); + if (ret) + return ret; + + *val =3D fan->state; + break; + case hwmon_fan_min: + *val =3D fan->min_rpm; + break; + case hwmon_fan_max: + *val =3D fan->max_rpm; + break; + default: + return -EOPNOTSUPP; + } + + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static int awcc_hwmon_read_string(struct device *dev, enum hwmon_sensor_ty= pes type, + u32 attr, int channel, const char **str) +{ + struct awcc_priv *priv =3D dev_get_drvdata(dev); + u8 temp_id; + + switch (type) { + case hwmon_temp: + temp_id =3D priv->temp_data[channel].id; + + switch (temp_id) { + case AWCC_TEMP_SENSOR_CPU: + *str =3D "CPU"; + break; + case AWCC_TEMP_SENSOR_GPU: + *str =3D "GPU"; + break; + default: + *str =3D "Unknown"; + break; + } + + break; + case hwmon_fan: + temp_id =3D priv->fan_data[channel].temp_sensor; + + switch (temp_id) { + case AWCC_TEMP_SENSOR_CPU: + *str =3D "Processor Fan"; + break; + case AWCC_TEMP_SENSOR_GPU: + *str =3D "Video Fan"; + break; + default: + *str =3D "Unknown Fan"; + break; + } + + break; + default: + return -EOPNOTSUPP; + } + + return 0; +} + +static const struct hwmon_ops awcc_hwmon_ops =3D { + .is_visible =3D awcc_hwmon_is_visible, + .read =3D awcc_hwmon_read, + .read_string =3D awcc_hwmon_read_string, +}; + +static const struct hwmon_channel_info * const awcc_hwmon_info[] =3D { + HWMON_CHANNEL_INFO(temp, + HWMON_T_LABEL | HWMON_T_INPUT, + HWMON_T_LABEL | HWMON_T_INPUT, + HWMON_T_LABEL | HWMON_T_INPUT + ), + HWMON_CHANNEL_INFO(fan, + HWMON_F_LABEL | HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_MAX, + HWMON_F_LABEL | HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_MAX, + HWMON_F_LABEL | HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_MAX, + HWMON_F_LABEL | HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_MAX + ), + NULL +}; + +static const struct hwmon_chip_info awcc_hwmon_chip_info =3D { + .ops =3D &awcc_hwmon_ops, + .info =3D awcc_hwmon_info, +}; + +static int awcc_hwmon_init(struct wmi_device *wdev) +{ + struct awcc_priv *priv =3D dev_get_drvdata(&wdev->dev); + u32 id, temp_sensor, min_rpm, max_rpm; + int ret; + + priv->fan_data =3D devm_kcalloc(&wdev->dev, priv->fan_count, + sizeof(*priv->fan_data), GFP_KERNEL); + if (!priv->fan_data) + return -ENOMEM; + + priv->temp_data =3D devm_kcalloc(&wdev->dev, priv->temp_count, + sizeof(*priv->temp_data), GFP_KERNEL); + if (!priv->temp_data) + return -ENOMEM; + + for (u32 i =3D 0; i < priv->fan_count; i++) { + /* + * Fan IDs are listed first at offset 0 + */ + ret =3D awcc_op_get_resource_id(wdev, i, &id); + if (ret) + return ret; + + ret =3D awcc_thermal_information(wdev, AWCC_OP_GET_MIN_RPM, id, + &min_rpm); + if (ret) + return ret; + + ret =3D awcc_thermal_information(wdev, AWCC_OP_GET_MAX_RPM, id, + &max_rpm); + if (ret) + return ret; + + ret =3D awcc_get_fan_sensors(wdev, id, &temp_sensor); + if (ret) + return ret; + + priv->fan_data[i].id =3D FIELD_GET(AWCC_RESOURCE_ID_MASK, id); + priv->fan_data[i].min_rpm =3D min_rpm; + priv->fan_data[i].max_rpm =3D max_rpm; + priv->fan_data[i].temp_sensor =3D temp_sensor; + ret =3D devm_mutex_init(&wdev->dev, &priv->fan_data[i].lock); + if (ret) + return ret; + } + + for (u32 i =3D 0; i < priv->temp_count; i++) { + /* + * Temperature sensors IDs are listed after the fan IDs at + * offset `fan_count` + */ + ret =3D awcc_op_get_resource_id(wdev, i + priv->fan_count, &id); + if (ret) + return ret; + + priv->temp_data[i].id =3D FIELD_GET(AWCC_RESOURCE_ID_MASK, id); + ret =3D devm_mutex_init(&wdev->dev, &priv->temp_data[i].lock); + if (ret) + return ret; + } + + priv->hwdev =3D devm_hwmon_device_register_with_info( + &wdev->dev, "alienware_wmi", priv, &awcc_hwmon_chip_info, NULL); + + return PTR_ERR_OR_ZERO(priv->hwdev); +} + /* * Thermal Profile control * - Provides thermal profile control through the Platform Profile API @@ -734,6 +1062,12 @@ static int alienware_awcc_setup(struct wmi_device *wd= ev) priv->wdev =3D wdev; dev_set_drvdata(&wdev->dev, priv); =20 + if (awcc->hwmon) { + ret =3D awcc_hwmon_init(wdev); + if (ret) + return ret; + } + if (awcc->pprof) { ret =3D awcc_platform_profile_init(wdev); if (ret) @@ -814,6 +1148,13 @@ int __init alienware_wmax_wmi_init(void) if (id) awcc =3D id->driver_data; =20 + if (force_hwmon) { + if (!awcc) + awcc =3D &empty_quirks; + + awcc->hwmon =3D true; + } + if (force_platform_profile) { if (!awcc) awcc =3D &empty_quirks; --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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 72A9C1B6D0F; Sat, 8 Feb 2025 05:17:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991833; cv=none; b=rb+kvV+/PJRzh+XyoFazMI96Bl/BAp21DWOXsdPNiMgrwr+8Lh28OPR+cq6ydvlNrr77YcoOw2e4b/4fBsb0aMk6O35yZyJeUYiUm7FKlecSml8csORoWluHAIgsbQcwg7MGruX9+rZ5BsIGe+YBB5SYA1qwW8uccfn8DVxBMeM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991833; c=relaxed/simple; bh=Twen0jVCoMYxUM9BpY9R0VcejpmIG3T5HQXJkM8Rp/Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KWqbStbkDVivmq1I43qupFbMKPfI3+Pf5Kb5BR1/QvECzr4VbuCZckpHj6R21RE8rYyoPrdBNJSa58c0kOSdowcv5cbTdRVgVcVO3+0rwkYgu1j4NbCbMLEDxWVmh3hQIGVfYj1EQ+N/GI+caQaIROZ19MzCY7z7i2RoPV9khlY= 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=iShDXW2b; arc=none smtp.client-ip=209.85.219.171 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="iShDXW2b" Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e53c9035003so1999082276.2; Fri, 07 Feb 2025 21:17:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991829; x=1739596629; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kYttPlgEcN4Cf6Au1A4MigyPKR+OwvlvZlYPz13VZbc=; b=iShDXW2bjnfPd0u5FJnIkR9tG95OYRD8NLpIyQR9iOGHdPD/CQtv8rJ20dvV9/Ecle yA0ViMXYDwlIgca6BNts7MgZ20dIbC2Tewujcj8S4nAzjNFTL2NH1UYFVE4GVk92cFno bRar0h3PUKko8UE2sFNo6c28mbXMZ9jyVE0+kdDf9ly/URja2W9i3aic+HiWiQ8pf3E1 bulFpM1GzQyCi5wgE/1aqpcN3fzKJivIe2xYz4dg2Oe7+D36tzGyeslbrqGM13D54pKM NMv4o7r4HkI95roz0juNoukvlxbqvKhOP7JpV77jR9mWFACzr1ndtG0U+5kqlE6eZp7o JW9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991829; x=1739596629; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kYttPlgEcN4Cf6Au1A4MigyPKR+OwvlvZlYPz13VZbc=; b=is03rKK0zzbdjCuRMiSgV/iDjOWtYT/1otT30hHQ9gmZGKTC67dhz0JvW9jnVHp9Xa Qpv1JSHP0xcMTABKspMpTXwc6xGr6Wt/k/aDGlTFIONE07yBaldwDSWiY+IQoiJTx1wt IE15MUPSJPoMI4MW7txhL0AI/qwBmfoTK842ab4i7EHyNfORXCdCcuGBxwqSddz22esh MA7YCYmkBnZGwKeL4NHe4TvLSjUrv62q03gd5DQXqgQ1WrvojDy17t7q2E/bv+C43bgh Nd7wCNt5YXVahkK42WKQDRGbEiBVi1deLoZwAeE4wX4Rgmk9YH0VEW+zfKIHsUVuVmae Gx2w== X-Forwarded-Encrypted: i=1; AJvYcCXxq8L4DPfFiN+Ud3SNjBXdxJoyBelouR6oC99uvKGBnCCLmpNheo6ddUYVsVXjE+INeQp0Ne6fsvfRElE=@vger.kernel.org X-Gm-Message-State: AOJu0YxZNyq5YQDbBSXEnlHJ0zmIKfWgt/x/M/2UPEtWgQT71ynnP/Ko oVTUNh1bkiSVvSXcORNgLDWvAoK60/6gZx5i90nJ4l8ncS/QGbeeyoO37Q== X-Gm-Gg: ASbGncvOgcqmMJLTMVu/bzyQy92Y4xnAv+7ThPk8+zSU8KKo4PAwzC66aUdS0VzHa0B UiQ3LlmOmGJX1haWm3arje22pcB52Kjd48zuT/dLE9WCwEnn1MsnBOWJXgDTIIcxLhP7RRHMDw9 3y24XFlEFsSXhVOuS+JqPE4NstvZ33VIR3oPaIhuf5WaPFdBl2W4x+3oLAuWh6vEittbvARxSDE HU/5k+daCV2U+wbMynb2yj6CkIM27unhiquQi3opEJB5NbW1zLsTaFASeT9XZwCvwFblTbvaLXQ Z3g7Eh2sse2P3xOni41iing= X-Google-Smtp-Source: AGHT+IGfrdTfXOcobn8spbJ8oKTLLA/9qdZPw+dFY5zcizCfwfjRoZpktVFxLC6ZGM2sxEqwtVmWtg== X-Received: by 2002:a5b:c:0:b0:e5b:53ec:69e0 with SMTP id 3f1490d57ef6-e5b53ec6c32mr1879327276.40.1738991829396; Fri, 07 Feb 2025 21:17:09 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:17:09 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja , Guenter Roeck Subject: [PATCH 08/10] platform/x86: alienware-wmi-wmax: Add support for manual fan control Date: Sat, 8 Feb 2025 00:16:12 -0500 Message-ID: <20250208051614.10644-9-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" All models with the "AWCC" WMAX device support a way of manually controlling fans. The PWM duty cycle of a fan can't be controlled directly. Instead the AWCC interface let's us tune a PWM `boost` value, which has the following empirically discovered behavior over the PWM value: pwm =3D pwm_base + (pwm_boost / 255) * (pwm_max - pwm_base) Where the pwm_base is the locked PWM value controlled by the EC and pwm_boost is a value between 0 and 255. This pwm_boost knob is exposed as a standard `pwm` attribute. Cc: Guenter Roeck Signed-off-by: Kurt Borja --- .../platform/x86/dell/alienware-wmi-wmax.c | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 5f02da7ff25f..06d6f88ea54b 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -176,10 +177,12 @@ enum AWCC_THERMAL_INFORMATION_OPERATIONS { AWCC_OP_GET_MIN_RPM =3D 0x08, AWCC_OP_GET_MAX_RPM =3D 0x09, AWCC_OP_GET_CURRENT_PROFILE =3D 0x0B, + AWCC_OP_GET_FAN_BOOST =3D 0x0C, }; =20 enum AWCC_THERMAL_CONTROL_OPERATIONS { AWCC_OP_ACTIVATE_PROFILE =3D 0x01, + AWCC_OP_SET_FAN_BOOST =3D 0x02, }; =20 enum AWCC_GAME_SHIFT_STATUS_OPERATIONS { @@ -563,12 +566,13 @@ static inline int awcc_thermal_information(struct wmi= _device *wdev, u8 operation return __awcc_wmi_command(wdev, AWCC_METHOD_THERMAL_INFORMATION, &args, o= ut); } =20 -static inline int awcc_thermal_control(struct wmi_device *wdev, u8 profile) +static inline int awcc_thermal_control(struct wmi_device *wdev, u8 operati= on, + u8 arg1, u8 arg2) { struct wmax_u32_args args =3D { - .operation =3D AWCC_OP_ACTIVATE_PROFILE, - .arg1 =3D profile, - .arg2 =3D 0, + .operation =3D operation, + .arg1 =3D arg1, + .arg2 =3D arg2, .arg3 =3D 0, }; u32 out; @@ -684,6 +688,11 @@ static umode_t awcc_hwmon_is_visible(const void *drvda= ta, enum hwmon_sensor_type if (channel < priv->fan_count) return 0444; =20 + break; + case hwmon_pwm: + if (channel < priv->fan_count) + return 0644; + break; default: break; @@ -698,6 +707,7 @@ static int awcc_hwmon_read(struct device *dev, enum hwm= on_sensor_types type, struct awcc_priv *priv =3D dev_get_drvdata(dev); struct awcc_temp_channel_data *temp; struct awcc_fan_channel_data *fan; + u32 fan_boost; int ret; =20 switch (type) { @@ -742,6 +752,16 @@ static int awcc_hwmon_read(struct device *dev, enum hw= mon_sensor_types type, return -EOPNOTSUPP; } =20 + break; + case hwmon_pwm: + fan =3D &priv->fan_data[channel]; + + ret =3D awcc_thermal_information(priv->wdev, AWCC_OP_GET_FAN_BOOST, + fan->id, &fan_boost); + if (ret) + return ret; + + *val =3D fan_boost; break; default: return -EOPNOTSUPP; @@ -796,10 +816,27 @@ static int awcc_hwmon_read_string(struct device *dev,= enum hwmon_sensor_types ty return 0; } =20 + +static int awcc_hwmon_write(struct device *dev, enum hwmon_sensor_types ty= pe, + u32 attr, int channel, long val) +{ + struct awcc_priv *priv =3D dev_get_drvdata(dev); + u8 fan_id =3D priv->fan_data[channel].id; + + switch (type) { + case hwmon_pwm: + return awcc_thermal_control(priv->wdev, AWCC_OP_SET_FAN_BOOST, + fan_id, (u8)clamp_val(val, 0, 255)); + default: + return -EOPNOTSUPP; + } +} + static const struct hwmon_ops awcc_hwmon_ops =3D { .is_visible =3D awcc_hwmon_is_visible, .read =3D awcc_hwmon_read, .read_string =3D awcc_hwmon_read_string, + .write =3D awcc_hwmon_write, }; =20 static const struct hwmon_channel_info * const awcc_hwmon_info[] =3D { @@ -814,6 +851,12 @@ static const struct hwmon_channel_info * const awcc_hw= mon_info[] =3D { HWMON_F_LABEL | HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_MAX, HWMON_F_LABEL | HWMON_F_INPUT | HWMON_F_MIN | HWMON_F_MAX ), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT + ), NULL }; =20 @@ -954,8 +997,8 @@ static int awcc_platform_profile_set(struct device *dev, } } =20 - return awcc_thermal_control(priv->wdev, - priv->supported_profiles[profile]); + return awcc_thermal_control(priv->wdev, AWCC_OP_ACTIVATE_PROFILE, + priv->supported_profiles[profile], 0); } =20 static int awcc_platform_profile_probe(void *drvdata, unsigned long *choic= es) --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) (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 C42C61A38E3; Sat, 8 Feb 2025 05:17:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991834; cv=none; b=PgK5SIY99L6uHM/s3d2BYRF5FVyMui7SBppUg7oTynR/tXKmyySWCksMp2COELqh0Bkr5+lWCQeEwtJMjxa4H25PGcQf4EPiYgFhRbM7NOZixnuTMCTkylpIOifYKSrr4PLLvf8J+bX/l5Pgg5Nt1XXYotg1FDJ1ac4xLJx1Xz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991834; c=relaxed/simple; bh=6cgx9dWQkmB0bDgx/OJivmc3zhpAiNjIiuR80NuyyLs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LdmVZmElSCkbAyQDD3ZgyxBj+cKoNSwpZ5+SxoJYwqsV7yXwjCt0L4crQ7vPHVB5aB7PcQ/PGJDa7xTnuFI90BV2YcbIvMwe90DF4zm0Sj+zj5HH5EP457jB3qEh5q3D91X8T9c6N9SizMzWdcW7gzV6kjRJOa8JXL9FuWM2BpE= 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=L9D3w8JM; arc=none smtp.client-ip=209.85.219.181 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="L9D3w8JM" Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-e5b41ee3065so1876464276.2; Fri, 07 Feb 2025 21:17:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991832; x=1739596632; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Pl7ZtWZq/gaplGMaiHSUCh/i0QfQVL8MTha2vS8e2cA=; b=L9D3w8JMWnTKMyKB+a0QMWr+JqizRYDF5LeTAFUMl7tx7d8Pzpz7BJdPeNGJvyZa6h 1TVWrzOvLvXDuu6Pktj7elLjkv24f8QowAPwgsVH7MOWqdxOIsyWP0fSIWP6HwnXSJkB 1J790ZhBrj6hlXky66ivo9r5nXZa9qFa5ENoNE6BG8YuR7dUp6ayJm40KQq+9BOPeNIj No5NY+NPgMJsSL8ahSER92CD7A7ubDBhuJnfsB20YbiePJC28pZfyUrSUJcDxo66EQ8q Q4NlCNKhT6Sf7evPENBiNYxALu0ul4UxQ0IAoH+HMy3ik10+v94ML6EnhurPb6kBIiSy LiZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991832; x=1739596632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Pl7ZtWZq/gaplGMaiHSUCh/i0QfQVL8MTha2vS8e2cA=; b=vYUtG3FO3ltzU0DouBvjOFfFUsmsvqGuGMq/Fdhp8emlrLIwicPJvx5IqzE8ZaoCTT uc0dlWn4opNL8Si8m4YS7XGiNHhutr47V8bKzu+3zXUZlpejtrHVzLehcZAudKpiZsYS ezOibLFnxckDfDxnFp1vquM9n2TEQ+r5r/RhJza4Aayj41LwosY/RupPCl7DxU3tTkAl zHynZQt/blSZAaXS4SJeOiSsG0pIL0pwSbVuxMg6iWwiQ1z8THZeT3WPyjDsDKDrg6ea vMpdiz9wYLwfLTQPYgkTlB354QSr/6oF667jh+AKYW1CWWHCuBeFfF6qnaYIY6ti7FiP ehGg== X-Forwarded-Encrypted: i=1; AJvYcCXftKSzosR+6wg/ydDq/TkRyeKNo9yNSNzVjDiZSq7hNavMhGUtesRo48EdVLioAUScxbP+oVjDUyGdTAA=@vger.kernel.org X-Gm-Message-State: AOJu0YzhOYX2aDCq2GGtT+Jjvje69Hivo3704JgTdJ30adCT73RVKKyr xOOoI5/rPdKrgOCqnSwGziRdNsTNPOKhmIDdc1j6Y3Ntlfm4+SCd X-Gm-Gg: ASbGncvOj8J6uriD3vDQ3elCqcARGly8qmQRK1qtRSvBOiyyr6aclXHoU2dWFfnedBU h1xdvzArHp6pXP9n8ZushkKLwK8QZXItA8uO6HZaiXdcQOb7lv8Zm6dnZ8szYAMzAkMlFv2VZq1 iFmOs+3DeZ4w77EPEeQLOxgHIP32N5SdPjYl1V46JhMlh9PXGqEpk9nHHnmdC73AIvHAWB5yf3I 1xDpnZ/LLYMAk7n2egSeBuYP9f0xb5TN2hesiqpYo3cyAqi3YE50p0sAJ7QL1PmzA6shM7cuBdN xathoXVpcERT7MdK8BKieaA= X-Google-Smtp-Source: AGHT+IFDMQmh8Lyz8IkDl/MW45ahBUJiGj89ldN2sxztsCcvc8CJniJj/fN6MhgT9UaIT/WHRpR6zA== X-Received: by 2002:a05:6902:1706:b0:e58:a25d:5696 with SMTP id 3f1490d57ef6-e5b4629db4bmr5825694276.45.1738991831801; Fri, 07 Feb 2025 21:17:11 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:17:11 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 09/10] platform/x86: alienware-wmi-wmax: Add a DebugFS interface Date: Sat, 8 Feb 2025 00:16:13 -0500 Message-ID: <20250208051614.10644-10-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a debugfs interface which exposes thermal private data. Signed-off-by: Kurt Borja --- .../platform/x86/dell/alienware-wmi-wmax.c | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/drivers/platform/x86/dell/alienware-wmi-wmax.c b/drivers/platf= orm/x86/dell/alienware-wmi-wmax.c index 06d6f88ea54b..f20bd9a062a7 100644 --- a/drivers/platform/x86/dell/alienware-wmi-wmax.c +++ b/drivers/platform/x86/dell/alienware-wmi-wmax.c @@ -10,6 +10,7 @@ =20 #include #include +#include #include #include #include @@ -18,6 +19,7 @@ #include #include #include +#include #include #include #include "alienware-wmi.h" @@ -1078,6 +1080,94 @@ static int awcc_platform_profile_init(struct wmi_dev= ice *wdev) return PTR_ERR_OR_ZERO(priv->ppdev); } =20 +/* + * DebugFS + */ +static int awcc_debugfs_system_description_read(struct seq_file *seq, void= *data) +{ + struct device *dev =3D seq->private; + struct awcc_priv *priv =3D dev_get_drvdata(dev); + + seq_printf(seq, "0x%08x\n", priv->system_description); + + return 0; +} + +static int awcc_debugfs_hwmon_data_read(struct seq_file *seq, void *data) +{ + struct device *dev =3D seq->private; + struct awcc_priv *priv =3D dev_get_drvdata(dev); + struct awcc_fan_channel_data *fan_data; + struct awcc_temp_channel_data *temp_data; + + seq_printf(seq, "Number of fans: %u\n", priv->fan_count); + seq_printf(seq, "Number of temperature sensors: %u\n\n", priv->temp_count= ); + + for (u32 i =3D 0; i < priv->fan_count; i++) { + fan_data =3D &priv->fan_data[i]; + + seq_printf(seq, "Fan %u:\n", i); + seq_printf(seq, " ID: 0x%02x\n", fan_data->id); + seq_printf(seq, " Temperature sensor: 0x%02x\n", fan_data->temp_sensor); + } + + seq_puts(seq, "\n"); + + for (u32 i =3D 0; i < priv->temp_count; i++) { + temp_data =3D &priv->temp_data[i]; + + seq_printf(seq, "Temperature sensor %u:\n", i); + seq_printf(seq, " ID: 0x%02x\n", temp_data->id); + } + + return 0; +} + +static int awcc_debugfs_pprof_data_read(struct seq_file *seq, void *data) +{ + struct device *dev =3D seq->private; + struct awcc_priv *priv =3D dev_get_drvdata(dev); + + seq_printf(seq, "Number of thermal profiles: %u\n\n", priv->profile_count= ); + + for (u32 i =3D 0; i < PLATFORM_PROFILE_LAST; i++) { + if (!priv->supported_profiles[i]) + continue; + + seq_printf(seq, "Platform profile %u:\n", i); + seq_printf(seq, " ID: 0x%02x\n", priv->supported_profiles[i]); + } + + return 0; +} + +static void awcc_debugfs_remove(void *data) +{ + struct dentry *root =3D data; + + debugfs_remove(root); +} + +static void awcc_debugfs_init(struct wmi_device *wdev) +{ + struct dentry *root; + + root =3D debugfs_create_dir("alienware-wmi", NULL); + + debugfs_create_devm_seqfile(&wdev->dev, "system_description", root, + awcc_debugfs_system_description_read); + + if (awcc->hwmon) + debugfs_create_devm_seqfile(&wdev->dev, "hwmon_data", root, + awcc_debugfs_hwmon_data_read); + + if (awcc->pprof) + debugfs_create_devm_seqfile(&wdev->dev, "pprof_data", root, + awcc_debugfs_pprof_data_read); + + devm_add_action_or_reset(&wdev->dev, awcc_debugfs_remove, root); +} + static int alienware_awcc_setup(struct wmi_device *wdev) { struct awcc_priv *priv; @@ -1117,6 +1207,8 @@ static int alienware_awcc_setup(struct wmi_device *wd= ev) return ret; } =20 + awcc_debugfs_init(wdev); + return 0; } =20 --=20 2.48.1 From nobody Thu Dec 18 22:18:32 2025 Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (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 81DF61B85EB; Sat, 8 Feb 2025 05:17:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991839; cv=none; b=PmLCPgEJxUYFD7pU8z+LHBMq8lQDHd+yx0IJeP+WszXWKJmJyzTHVlHnVYEydffeHPmJsAItYYO3pIjz/Fqh5KtFf9ELB2Q3EQIiaoleqkvqEIDwCk0T5clyttt4OkdfKmF636elPMTYme6unx0TrEVc5GMHs3o+iHQVCuW1rhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738991839; c=relaxed/simple; bh=9muKqbJSUVdPeiRYIlVh42ZCZMbus+wplzyGdtdjqJE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EAMdcm1B80fGfKp+9JnA4lvmN4TsxRpgt2VOUc52UFAJcv1uq0529E9osr3JynIknT6uT+VaBZo9P7CVSQBCH+sanLhGgxwRxU7pmWIcMwZWvo/4O9ynMpqXCUSLElrJDt2KgW1xUYr1qWrQDhQNPgVsLNIAILoXHaXwvwPBfQ0= 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=ltBN49yi; arc=none smtp.client-ip=209.85.219.179 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="ltBN49yi" Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e5b3dbd6732so2008963276.1; Fri, 07 Feb 2025 21:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1738991834; x=1739596634; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qkAqC+Bw7h3b39jDNFlT+YMm6ypioK+dNekzyUVSK3M=; b=ltBN49yiXKBeQXpoEKcTbZRwJPh4Vmgx3wfeIr+82mCK/XWqv72z8wIQ65wvRAsy5z YJX/Bj01dnU+hQQ3eeOOwDr//OdVrLHXzvTYeEIXHTN57/CBHsOKdhK2TzkAyW7noUET zIN7/OBxXvpscU838gyltj3Yoy16uhVu1DHqMHzZpmdnyvB0bRWH2ew6WLsqcmlaqK+J CIFOi8WFFbR/Ci+M1awetJoT9A4s4zd/R+XBtTGJI3bX6mthsoVLmmBYf3RiINm3ZNai howr9ApgQhmQ7KDjQ3zXK/ftc0LYbzpZE4vi5Lvgeog3GgCU8ZCxyiVX60B5026BQqKb l4IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738991834; x=1739596634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qkAqC+Bw7h3b39jDNFlT+YMm6ypioK+dNekzyUVSK3M=; b=X3ShUdQ2AVfTtr1FcyG6JZVFdulY1pe3IXsW/+Z8bHrFVEV3qd26EHThq8QawFXMPn NyVwnafHbTTXKxq6nqahHjDZBk7PdniTTrEsnZjNjP+unlmaOjKI5cfLoafi1TPfQkQX mH8MJJhigq89Af9520QN/mwzsLdVzYmtZbaQvQMvTpnq6jjatkkm6RI1KZougNrVsUSc bHI5hf9rHXoRTWxJEC7VshVh15fnTyGgVImfHyhr82iVcokn1RzhRMx1fdk5ThP17g5e chfBWz4EX49/4GDcTkxzlXD0jsdJDsxqa5Vh0NU3rGd2C1Ns5q9UvOCky4muNzVmXkEN YY7w== X-Forwarded-Encrypted: i=1; AJvYcCVzRzb5Ndk/i51dbojeyEGJbFIulNAeGYRoM39gJQwGEkNngDMzu3oP0CnVoqmNTKcxcMxWJhjq2cr90hs=@vger.kernel.org X-Gm-Message-State: AOJu0YyjDNk6/7loHZnjooartFynrgHfR3YRDLZ1AnfsRPPaNWM6OEIL /2iDhgUfVrZmjGtStS1vfeqVjcwwFabNvwfkU0yt1C+mOPo5Tgiq X-Gm-Gg: ASbGnctgAr9WdFOB6TDRJDNSmmoCq4AguXR8KznprRGxXxNAtr6UscGhuDz8eipE7ov JaPWeNeozvSVf/KHTqmnGrGu8ObpIAZsJNqPoRZ9PUn4CfwuR3HDsNQRzeedRNGZkPC+JKzzSNO ujGlB6TjWFzcrurrzN/TSUJA0IaHra5g1QAq0MMXlB0exQwjUmJQK0W21KuqBJO1dTxY7asEsfz ZCIPV9c9PaF0E3ffGAGCxUP8f+2b70CyL9iT5ohwVQLcUZpv2qGbfKvAdJFCHDDy+Nvr39qU9Cz OS9qoGSTTBGfMrh9+Jdn6cY= X-Google-Smtp-Source: AGHT+IHfeN1FcG9blUNW736S0NrkeDownTGFrI3xHREXIUVZ6aYHy8VGwSLCIFft6vAEOlEa+b1wUg== X-Received: by 2002:a05:6902:a8f:b0:e5b:3de2:ce95 with SMTP id 3f1490d57ef6-e5b46170272mr5314485276.9.1738991834213; Fri, 07 Feb 2025 21:17:14 -0800 (PST) Received: from localhost.localdomain ([2800:bf0:82:3d2:4207:a956:ebad:2a64]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e5b3a1f00e0sm1207670276.2.2025.02.07.21.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Feb 2025 21:17:13 -0800 (PST) From: Kurt Borja To: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , "Armin Wolf" Cc: platform-driver-x86@vger.kernel.org, "Hans de Goede" , Dell.Client.Kernel@dell.com, linux-kernel@vger.kernel.org, Kurt Borja Subject: [PATCH 10/10] platform/x86: alienware-wmi: Improve and update documentation Date: Sat, 8 Feb 2025 00:16:14 -0500 Message-ID: <20250208051614.10644-11-kuurtb@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250208051614.10644-1-kuurtb@gmail.com> References: <20250208051614.10644-1-kuurtb@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use tables to describe method operations instead of using pseudo-code. Drop unknown method descriptions to avoid redundancy. Drop GPIO section as it is currently irrelevant to this driver. Update Thermal_Information method documentation. Add one more helpful developer to the kudos section. Signed-off-by: Kurt Borja --- Documentation/wmi/devices/alienware-wmi.rst | 390 ++++++-------------- 1 file changed, 122 insertions(+), 268 deletions(-) diff --git a/Documentation/wmi/devices/alienware-wmi.rst b/Documentation/wm= i/devices/alienware-wmi.rst index ddc5e561960e..2bb3abfd9cd7 100644 --- a/Documentation/wmi/devices/alienware-wmi.rst +++ b/Documentation/wmi/devices/alienware-wmi.rst @@ -11,7 +11,7 @@ The WMI device WMAX has been implemented for many Alienwa= re and Dell's G-Series models. Throughout these models, two implementations have been identified.= The first one, used by older systems, deals with HDMI, brightness, RGB, amplif= ier and deep sleep control. The second one used by newer systems deals primari= ly -with thermal, overclocking, and GPIO control. +with thermal control and overclocking. =20 It is suspected that the latter is used by Alienware Command Center (AWCC)= to manage manufacturer predefined thermal profiles. The alienware-wmi driver @@ -69,9 +69,6 @@ data using the `bmfdec `_= utility: [WmiMethodId(164), Implemented, read, write, Description("Tobii Camera = Power Off.")] void TobiiCameraPowerOff([out] uint32 argr); }; =20 -Some of these methods get quite intricate so we will describe them using -pseudo-code that vaguely resembles the original ASL code. - Methods not described in the following document have unknown behavior. =20 Argument Structure @@ -87,175 +84,136 @@ ID 0xA0, the argument you would pass to the method is= 0xA001. Thermal Methods =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -WMI method Thermal_Information([in] uint32 arg2, [out] uint32 argr) -------------------------------------------------------------------- - -:: - - if BYTE_0(arg2) =3D=3D 0x01: - argr =3D 1 - - if BYTE_0(arg2) =3D=3D 0x02: - argr =3D SYSTEM_DESCRIPTION - - if BYTE_0(arg2) =3D=3D 0x03: - if BYTE_1(arg2) =3D=3D 0x00: - argr =3D FAN_ID_0 - - if BYTE_1(arg2) =3D=3D 0x01: - argr =3D FAN_ID_1 - - if BYTE_1(arg2) =3D=3D 0x02: - argr =3D FAN_ID_2 - - if BYTE_1(arg2) =3D=3D 0x03: - argr =3D FAN_ID_3 - - if BYTE_1(arg2) =3D=3D 0x04: - argr =3D SENSOR_ID_CPU | 0x0100 - - if BYTE_1(arg2) =3D=3D 0x05: - argr =3D SENSOR_ID_GPU | 0x0100 - - if BYTE_1(arg2) =3D=3D 0x06: - argr =3D THERMAL_MODE_QUIET_ID - - if BYTE_1(arg2) =3D=3D 0x07: - argr =3D THERMAL_MODE_BALANCED_ID - - if BYTE_1(arg2) =3D=3D 0x08: - argr =3D THERMAL_MODE_BALANCED_PERFORMANCE_ID - - if BYTE_1(arg2) =3D=3D 0x09: - argr =3D THERMAL_MODE_PERFORMANCE_ID - - if BYTE_1(arg2) =3D=3D 0x0A: - argr =3D THERMAL_MODE_LOW_POWER_ID - - if BYTE_1(arg2) =3D=3D 0x0B: - argr =3D THERMAL_MODE_GMODE_ID - - else: - argr =3D 0xFFFFFFFF - - if BYTE_0(arg2) =3D=3D 0x04: - if is_valid_sensor(BYTE_1(arg2)): - argr =3D SENSOR_TEMP_C - else: - argr =3D 0xFFFFFFFF - - if BYTE_0(arg2) =3D=3D 0x05: - if is_valid_fan(BYTE_1(arg2)): - argr =3D FAN_RPM() - - if BYTE_0(arg2) =3D=3D 0x06: - skip - - if BYTE_0(arg2) =3D=3D 0x07: - argr =3D 0 - - If BYTE_0(arg2) =3D=3D 0x08: - if is_valid_fan(BYTE_1(arg2)): - argr =3D 0 - else: - argr =3D 0xFFFFFFFF - - if BYTE_0(arg2) =3D=3D 0x09: - if is_valid_fan(BYTE_1(arg2)): - argr =3D FAN_UNKNOWN_STAT_0() - - else: - argr =3D 0xFFFFFFFF - - if BYTE_0(arg2) =3D=3D 0x0A: - argr =3D THERMAL_MODE_BALANCED_ID - - if BYTE_0(arg2) =3D=3D 0x0B: - argr =3D CURRENT_THERMAL_MODE() - - if BYTE_0(arg2) =3D=3D 0x0C: - if is_valid_fan(BYTE_1(arg2)): - argr =3D FAN_UNKNOWN_STAT_1() - else: - argr =3D 0xFFFFFFFF - -Operation 0x02 returns a *system description* buffer with the following -structure: - -:: - - out[0] -> Number of fans - out[1] -> Number of sensors - out[2] -> 0x00 - out[3] -> Number of thermal modes +WMI method GetFanSensors([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------- =20 -Operation 0x03 list all available fan IDs, sensor IDs and thermal profile -codes in order, but different models may have different number of fans and -thermal profiles. These are the known ranges: ++--------------------+------------------------------------+---------------= -----+ +| Operation (Byte 0) | Description | Arguments = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| 0x01 | Get the number of fans for a given | - Byte 1: Fan = ID | +| | fan ID. | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x02 | Get the temperature sensor ID | - Byte 1: Fan = ID | +| | related to a fan sensor ID | = | ++--------------------+------------------------------------+---------------= -----+ =20 -* Fan IDs: from 2 up to 4 -* Sensor IDs: 2 -* Thermal profile codes: from 1 up to 7 +WMI method Thermal_Information([in] uint32 arg2, [out] uint32 argr) +------------------------------------------------------------------- =20 -In total BYTE_1(ARG2) may range from 0x5 up to 0xD depending on the model. ++--------------------+------------------------------------+---------------= -----+ +| Operation (Byte 0) | Description | Arguments = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| 0x01 | Unknown. | - None = | ++--------------------+------------------------------------+---------------= -----+ +| 0x02 | Get system description number with | - None = | +| | the following structure: | = | +| | | = | +| | - Byte 0: Number of fans | = | +| | - Byte 1: Number of temperature | = | +| | sensors | = | +| | - Byte 2: Unknown | = | +| | - Byte 3: Number of thermal | = | +| | profiles | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x03 | List an ID or resource at a given | - Byte 1: Inde= x | +| | index. Fan IDs, temperature IDs, | = | +| | unknown IDs and thermal profile | = | +| | IDs are listed in that exact | = | +| | order. | = | +| | | = | +| | Operation 0x02 is used to know | = | +| | which indexes map to which | = | +| | resources. | = | +| | | = | +| | **Returns:** ID at a given index | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x04 | Get the current temperature for a | - Byte 1: Sens= or | +| | given temperature sensor. | ID = | ++--------------------+------------------------------------+---------------= -----+ +| 0x05 | Get the current RPM for a given | - Byte 1: Fan = ID | +| | fan. | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x06 | Get fan speed percentage. (not | - Byte 1: Fan = ID | +| | implemented in every model) | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x07 | Unknown. | - Unknown = | ++--------------------+------------------------------------+---------------= -----+ +| 0x08 | Get minimum RPM for a given FAN | - Byte 1: Fan = ID | +| | ID. | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x09 | Get maximum RPM for a given FAN | - Byte 1: Fan = ID | +| | ID. | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x09 | Get maximum RPM for a given FAN | - Byte 1: Fan = ID | +| | ID. | = | ++--------------------+------------------------------------+---------------= -----+ +| 0x0A | Get balanced thermal profile ID. | - None = | ++--------------------+------------------------------------+---------------= -----+ +| 0x0B | Get current thermal profile ID. | - None = | ++--------------------+------------------------------------+---------------= -----+ +| 0x0C | Get current `boost` value for a | - Byte 1: Fan = ID | +| | given fan ID. | = | ++--------------------+------------------------------------+---------------= -----+ =20 WMI method Thermal_Control([in] uint32 arg2, [out] uint32 argr) --------------------------------------------------------------- =20 -:: - - if BYTE_0(arg2) =3D=3D 0x01: - if is_valid_thermal_profile(BYTE_1(arg2)): - SET_THERMAL_PROFILE(BYTE_1(arg2)) - argr =3D 0 - - if BYTE_0(arg2) =3D=3D 0x02: - if is_valid_fan(BYTE_1(arg2)): - SET_FAN_SPEED_MULTIPLIER(BYTE_2(arg2)) - argr =3D 0 - else: - argr =3D 0xFFFFFFFF - -.. note:: - While you can manually change the fan speed multiplier with this method, - Dell's BIOS tends to overwrite this changes anyway. ++--------------------+------------------------------------+---------------= -----+ +| Operation (Byte 0) | Description | Arguments = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| 0x01 | Activate a given thermal profile. | - Byte 1: Ther= mal | +| | | profile ID = | ++--------------------+------------------------------------+---------------= -----+ +| 0x02 | Set a `boost` value for a given | - Byte 1: Fan = ID | +| | fan ID. | - Byte 2: Boos= t | ++--------------------+------------------------------------+---------------= -----+ =20 These are the known thermal profile codes: =20 -:: - - CUSTOM 0x00 - - BALANCED_USTT 0xA0 - BALANCED_PERFORMANCE_USTT 0xA1 - COOL_USTT 0xA2 - QUIET_USTT 0xA3 - PERFORMANCE_USTT 0xA4 - LOW_POWER_USTT 0xA5 - - QUIET 0x96 - BALANCED 0x97 - BALANCED_PERFORMANCE 0x98 - PERFORMANCE 0x99 - - GMODE 0xAB - -Usually if a model doesn't support the first four profiles they will suppo= rt -the User Selectable Thermal Tables (USTT) profiles and vice-versa. - -GMODE replaces PERFORMANCE in G-Series laptops. ++------------------------------+----------+------+ +| Thermal Profile | Type | ID | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D+ +| Custom | Special | 0x00 | ++------------------------------+----------+------+ +| G-Mode | Special | 0xAB | ++------------------------------+----------+------+ +| Quiet | Legacy | 0x96 | ++------------------------------+----------+------+ +| Balanced | Legacy | 0x97 | ++------------------------------+----------+------+ +| Balanced Performance | Legacy | 0x98 | ++------------------------------+----------+------+ +| Performance | Legacy | 0x99 | ++------------------------------+----------+------+ +| Balanced | USTT | 0xA0 | ++------------------------------+----------+------+ +| Balanced Performance | USTT | 0xA1 | ++------------------------------+----------+------+ +| Cool | USTT | 0xA2 | ++------------------------------+----------+------+ +| Quiet | USTT | 0xA3 | ++------------------------------+----------+------+ +| Performance | USTT | 0xA4 | ++------------------------------+----------+------+ +| Low Power | USTT | 0xA5 | ++------------------------------+----------+------+ + +If a model supports the User Selectable Thermal Tables (USTT) profiles, it= will +not support the Legacy profiles and vice-versa. + +Every model supports the CUSTOM (0x00) thermal profile. GMODE replaces +PERFORMANCE in G-Series laptops. =20 WMI method GameShiftStatus([in] uint32 arg2, [out] uint32 argr) --------------------------------------------------------------- =20 -:: - - if BYTE_0(arg2) =3D=3D 0x1: - TOGGLE_GAME_SHIFT() - argr =3D GET_GAME_SHIFT_STATUS() - - if BYTE_0(arg2) =3D=3D 0x2: - argr =3D GET_GAME_SHIFT_STATUS() ++--------------------+------------------------------------+---------------= -----+ +| Operation (Byte 0) | Description | Arguments = | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D+ +| 0x01 | Toggle *Game Shift*. | - None = | ++--------------------+------------------------------------+---------------= -----+ +| 0x02 | Get *Game Shift* status. | - None = | ++--------------------+------------------------------------+---------------= -----+ =20 Game Shift Status does not change the fan speed profile but it could be so= me sort of CPU/GPU power profile. Benchmarks have not been done. @@ -267,131 +225,27 @@ Thermal_Information does not list it. G-key on Dell's G-Series laptops also changes Game Shift status, so both a= re directly related. =20 -WMI method GetFanSensors([in] uint32 arg2, [out] uint32 argr) -------------------------------------------------------------- - -:: - - if BYTE_0(arg2) =3D=3D 0x1: - if is_valid_fan(BYTE_1(arg2)): - argr =3D 1 - else: - argr =3D 0 - - if BYTE_0(arg2) =3D=3D 0x2: - if is_valid_fan(BYTE_1(arg2)): - if BYTE_2(arg2) =3D=3D 0: - argr =3D=3D SENSOR_ID - else - argr =3D=3D 0xFFFFFFFF - else: - argr =3D 0 - Overclocking Methods =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -.. warning:: - These methods have not been tested and are only partially reverse - engineered. - -WMI method Return_OverclockingReport([out] uint32 argr) -------------------------------------------------------- - -:: - - CSMI (0xE3, 0x99) - argr =3D 0 - -CSMI is an unknown operation. - -WMI method Set_OCUIBIOSControl([in] uint32 arg2, [out] uint32 argr) -------------------------------------------------------------------- - -:: - - CSMI (0xE3, 0x99) - argr =3D 0 - -CSMI is an unknown operation. - -WMI method Clear_OCFailSafeFlag([out] uint32 argr) --------------------------------------------------- - -:: - - CSMI (0xE3, 0x99) - argr =3D 0 - -CSMI is an unknown operation. - - WMI method MemoryOCControl([in] uint32 arg2, [out] uint32 argr) --------------------------------------------------------------- =20 AWCC supports memory overclocking, but this method is very intricate and h= as not been deciphered yet. =20 -GPIO methods -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -These methods are probably related to some kind of firmware update system, -through a GPIO device. - -.. warning:: - These methods have not been tested and are only partially reverse - engineered. - -WMI method FWUpdateGPIOtoggle([in] uint32 arg2, [out] uint32 argr) ------------------------------------------------------------------- - -:: - - if BYTE_0(arg2) =3D=3D 0: - if BYTE_1(arg2) =3D=3D 1: - SET_PIN_A_HIGH() - else: - SET_PIN_A_LOW() - - if BYTE_0(arg2) =3D=3D 1: - if BYTE_1(arg2) =3D=3D 1: - SET_PIN_B_HIGH() - - else: - SET_PIN_B_LOW() - - else: - argr =3D 1 - -WMI method ReadTotalofGPIOs([out] uint32 argr) ----------------------------------------------- - -:: - - argr =3D 0x02 - -WMI method ReadGPIOpPinStatus([in] uint32 arg2, [out] uint32 argr) ------------------------------------------------------------------- - -:: - - if BYTE_0(arg2) =3D=3D 0: - argr =3D PIN_A_STATUS - - if BYTE_0(arg2) =3D=3D 1: - argr =3D PIN_B_STATUS - Other information Methods =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D =20 WMI method ReadChassisColor([out] uint32 argr) ---------------------------------------------- =20 -:: - - argr =3D CHASSIS_COLOR_ID +Returns the chassis color internal ID. =20 Acknowledgements =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -Kudos to `AlexIII `_ for documenting -and testing available thermal profile codes. +Kudos to `AlexIII `_ and +`T-Troll `_ for documenting and +testing some of this device's functionality, making it possible to general= ize +this driver. --=20 2.48.1