From: "Luke D. Jones" <luke@ljones.dev>
To: hdegoede@redhat.com
Cc: ilpo.jarvinen@linux.intel.com, corentin.chary@gmail.com,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, "Luke D. Jones" <luke@ljones.dev>
Subject: [PATCH 9/9] platform/x86: asus-wmi: add setting dGPU TGP
Date: Tue, 28 May 2024 13:36:26 +1200 [thread overview]
Message-ID: <20240528013626.14066-10-luke@ljones.dev> (raw)
In-Reply-To: <20240528013626.14066-1-luke@ljones.dev>
The dGPU TGP can be set on a few ROG laptops. This gnerally needs some
extra userspace inference to find the base and limit:
- Find max-tgp from nvidia-smi
- Find max-boost from nv_dynamic_boost_max (asus_wmi)
- (max-tgp - max-boost - initial TGP) = base TGP
- (max-tgp - max-boost - base TGP) = max additional TGP
On some laptops the dgpu_base_tgp may return 0, in which case the base
TGP must be derived as above.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
.../ABI/testing/sysfs-platform-asus-wmi | 19 +++++++++++++++++++
drivers/platform/x86/asus-wmi.c | 9 +++++++++
include/linux/platform_data/x86/asus-wmi.h | 3 +++
3 files changed, 31 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-platform-asus-wmi b/Documentation/ABI/testing/sysfs-platform-asus-wmi
index d221a3bc1a81..46df3452c9da 100644
--- a/Documentation/ABI/testing/sysfs-platform-asus-wmi
+++ b/Documentation/ABI/testing/sysfs-platform-asus-wmi
@@ -253,3 +253,22 @@ Contact: "Luke Jones" <luke@ljones.dev>
Description:
Set the maximum available system memory for the APU.
* Min=0, Max=8
+
+What: /sys/devices/platform/<platform>/dgpu_tgp
+Date: Jun 2024
+KernelVersion: 6.11
+Contact: "Luke Jones" <luke@ljones.dev>
+Description:
+ Read and set the extra TGP applied to the dGPU. This is applied on
+ top of the dgpu_base_tgp.
+
+ If the dGPU maximum power including boost is 175 then we can calculate:
+ 175 - 25 (dynamic boost) - 70 (initial dgpu_tgp) = 80 (dgpu_base_tgp).
+ For NVIDIA dGPU the max power can be found with nvidia-smi.
+
+What: /sys/devices/platform/<platform>/dgpu_base_tgp
+Date: Jun 2024
+KernelVersion: 6.11
+Contact: "Luke Jones" <luke@ljones.dev>
+Description:
+ Read the absolute base TGP of the dGPU.
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 4b5fbae8c563..4d291429e7a1 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -123,6 +123,7 @@ module_param(fnlock_default, bool, 0444);
#define NVIDIA_BOOST_MAX 25
#define NVIDIA_TEMP_MIN 75
#define NVIDIA_TEMP_MAX 87
+#define NVIDIA_GPU_POWER_MAX 70
#define ASUS_SCREENPAD_BRIGHT_MIN 20
#define ASUS_SCREENPAD_BRIGHT_MAX 255
@@ -797,6 +798,8 @@ WMI_ATTR_SIMPLE_RO(egpu_connected, ASUS_WMI_DEVID_EGPU_CONNECTED);
WMI_ATTR_SIMPLE_RW(panel_od, 0, 1, ASUS_WMI_DEVID_PANEL_OD);
WMI_ATTR_SIMPLE_RW(boot_sound, 0, 1, ASUS_WMI_DEVID_BOOT_SOUND);
WMI_ATTR_SIMPLE_RO(charge_mode, ASUS_WMI_DEVID_CHARGE_MODE);
+WMI_ATTR_SIMPLE_RO(dgpu_base_tgp, ASUS_WMI_DEVID_DGPU_BASE_TGP);
+WMI_ATTR_SIMPLE_RW(dgpu_tgp, 0, NVIDIA_GPU_POWER_MAX, ASUS_WMI_DEVID_DGPU_SET_TGP);
static ssize_t panel_fhd_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
@@ -4204,6 +4207,8 @@ static struct attribute *platform_attributes[] = {
&dev_attr_boot_sound.attr,
&dev_attr_panel_od.attr,
&dev_attr_panel_fhd.attr,
+ &dev_attr_dgpu_base_tgp.attr,
+ &dev_attr_dgpu_tgp.attr,
&dev_attr_cores_enabled.attr,
&dev_attr_cores_max.attr,
&dev_attr_apu_mem.attr,
@@ -4280,6 +4285,10 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
devid = ASUS_WMI_DEVID_PANEL_OD;
else if (attr == &dev_attr_panel_fhd.attr)
devid = ASUS_WMI_DEVID_PANEL_FHD;
+ else if (attr == &dev_attr_dgpu_base_tgp.attr)
+ devid = ASUS_WMI_DEVID_DGPU_BASE_TGP;
+ else if (attr == &dev_attr_dgpu_tgp.attr)
+ ok = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU_SET_TGP);
else if (attr == &dev_attr_cores_enabled.attr
|| attr == &dev_attr_cores_max.attr)
ok = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CORES_SET);
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index efe608861e55..71833bd60f27 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -135,6 +135,9 @@
/* dgpu on/off */
#define ASUS_WMI_DEVID_DGPU 0x00090020
+#define ASUS_WMI_DEVID_DGPU_BASE_TGP 0x00120099
+#define ASUS_WMI_DEVID_DGPU_SET_TGP 0x00120098
+
/* gpu mux switch, 0 = dGPU, 1 = Optimus */
#define ASUS_WMI_DEVID_GPU_MUX 0x00090016
#define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026
--
2.45.1
prev parent reply other threads:[~2024-05-28 1:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 1:36 [PATCH 0/9] platform-x86-asus-wmi: multiple fixes, improvements, features Luke D. Jones
2024-05-28 1:36 ` [PATCH 1/9] platform/x86: asus-wmi: add debug print in more key places Luke D. Jones
2024-05-28 1:36 ` [PATCH 2/9] platform/x86: asus-wmi: don't fail if platform_profile already registered Luke D. Jones
2024-05-28 1:36 ` [PATCH 3/9] platform/x86: asus-wmi: add macros and expose min/max sysfs for ppt tunables Luke D. Jones
2024-05-28 8:50 ` Ilpo Järvinen
2024-06-04 5:14 ` kernel test robot
2024-05-28 1:36 ` [PATCH 4/9] platform/x86: asus-wmi: reduce code duplication with macros Luke D. Jones
2024-05-28 8:55 ` Ilpo Järvinen
2024-05-28 9:03 ` Ilpo Järvinen
2024-05-28 1:36 ` [PATCH 5/9] platform/x86: asus-wmi: use WMI_SIMPLE_SHOW in more places Luke D. Jones
2024-05-28 9:06 ` Ilpo Järvinen
2024-05-28 1:36 ` [PATCH 6/9] platform/x86: asus-wmi: add panel-fhd functionality Luke D. Jones
2024-05-28 9:18 ` Ilpo Järvinen
2024-05-28 1:36 ` [PATCH 7/9] platform/x86: asus-wmi: add enable/disable CPU cores Luke D. Jones
2024-05-28 9:27 ` Ilpo Järvinen
2024-05-28 21:37 ` Luke Jones
2024-05-28 1:36 ` [PATCH 8/9] platform/x86: asus-wmi: add apu_mem setting Luke D. Jones
2024-05-28 2:19 ` Limonciello, Mario
2024-05-28 2:40 ` Luke Jones
2024-05-28 13:27 ` Mario Limonciello
2024-05-28 21:04 ` Luke Jones
2024-05-28 21:16 ` Mario Limonciello
2024-05-28 21:34 ` Luke Jones
2024-05-28 21:36 ` Mario Limonciello
2024-05-28 21:37 ` Mario Limonciello
2024-05-28 1:36 ` Luke D. Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240528013626.14066-10-luke@ljones.dev \
--to=luke@ljones.dev \
--cc=corentin.chary@gmail.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®