All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable
@ 2026-08-05 18:28 Marco Scardovi
  2026-08-05 18:28 ` [PATCH 1/3] platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define Marco Scardovi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marco Scardovi @ 2026-08-05 18:28 UTC (permalink / raw)
  To: Corentin Chary, Luke D . Jones, Denis Benato, Hans de Goede,
	Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Marco Scardovi

This patch series adds support for WMI device ID 0x00120097
(ASUS_WMI_DEVID_DGPU_POWER_STATE) to query the power state level of the
discrete GPU (dGPU) on ASUS ROG laptops, and uses it to prevent disabling
the dGPU while it is in active use.

--- Background & How it Works ---

Modern ASUS ROG firmware provides WMI device ID 0x00120097 in the ACPI DSTS
evaluation method:

If ((IIA0 == 0x00120097))
{
  Return (0x00010000)
}

When queried, DSTS returns:
  - Bit 16 (0x00010000): Presence bit (set when supported by ACPI).
  - Bit 0  (0x00000001): Power state status:
      * 0: D3 cold (off / suspended)
      * 1: D0 (active / powered on)

--- Patch Series Summary ---

- Patch 1/3: Defines ASUS_WMI_DEVID_DGPU_POWER_STATE (0x00120097) in
  include/linux/platform_data/x86/asus-wmi.h.
- Patch 2/3: Registers the read-only sysfs attribute 'dgpu_power_state' in
  drivers/platform/x86/asus-armoury.c under firmware_attributes class.
- Patch 3/3: Consolidates dgpu_disable checks under a single 'if (disable)'
  block and returns -EBUSY if an attempt is made to disable the dGPU while active.

--- Testing ---

Verified on ASUS ROG G614PR hardware:
- Reading 'current_value' returns 0 when the dGPU is suspended in D3 cold,
  and 1 when active in D0.
- Attempting to disable the dGPU while in use returns -EBUSY.

Suggested-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Marco Scardovi <scardracs@disroot.org>

Marco Scardovi (3):
  platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define
  platform/x86: asus-armoury: Add dgpu_power_state attribute
  platform/x86: asus-armoury: Prevent disabling dGPU when in use

 drivers/platform/x86/asus-armoury.c        | 29 ++++++++++++++++------
 include/linux/platform_data/x86/asus-wmi.h |  3 ++-
 2 files changed, 24 insertions(+), 8 deletions(-)

-- 
2.55.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define
  2026-08-05 18:28 [PATCH 0/3] platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable Marco Scardovi
@ 2026-08-05 18:28 ` Marco Scardovi
  2026-08-05 18:28 ` [PATCH 2/3] platform/x86: asus-armoury: Add dgpu_power_state attribute Marco Scardovi
  2026-08-05 18:28 ` [PATCH 3/3] platform/x86: asus-armoury: Prevent disabling dGPU when in use Marco Scardovi
  2 siblings, 0 replies; 4+ messages in thread
From: Marco Scardovi @ 2026-08-05 18:28 UTC (permalink / raw)
  To: Corentin Chary, Luke D . Jones, Denis Benato, Hans de Goede,
	Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Marco Scardovi

Add WMI device ID 0x00120097 (ASUS_WMI_DEVID_DGPU_POWER_STATE) to the
asus-wmi platform header. This device ID is used on ASUS ROG laptops to
query the discrete GPU (dGPU) power state level.

Suggested-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Marco Scardovi <scardracs@disroot.org>
---
 include/linux/platform_data/x86/asus-wmi.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index b5ed8c83ace1..289be6ac7335 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -140,8 +140,9 @@
 
 #define ASUS_WMI_DEVID_APU_MEM		0x000600C1
 
-#define ASUS_WMI_DEVID_DGPU_BASE_TGP	0x00120099
+#define ASUS_WMI_DEVID_DGPU_POWER_STATE	0x00120097
 #define ASUS_WMI_DEVID_DGPU_SET_TGP	0x00120098
+#define ASUS_WMI_DEVID_DGPU_BASE_TGP	0x00120099
 
 /* gpu mux switch, 0 = dGPU, 1 = Optimus */
 #define ASUS_WMI_DEVID_GPU_MUX		0x00090016
-- 
2.55.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] platform/x86: asus-armoury: Add dgpu_power_state attribute
  2026-08-05 18:28 [PATCH 0/3] platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable Marco Scardovi
  2026-08-05 18:28 ` [PATCH 1/3] platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define Marco Scardovi
@ 2026-08-05 18:28 ` Marco Scardovi
  2026-08-05 18:28 ` [PATCH 3/3] platform/x86: asus-armoury: Prevent disabling dGPU when in use Marco Scardovi
  2 siblings, 0 replies; 4+ messages in thread
From: Marco Scardovi @ 2026-08-05 18:28 UTC (permalink / raw)
  To: Corentin Chary, Luke D . Jones, Denis Benato, Hans de Goede,
	Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Marco Scardovi

Add support for WMI device ID 0x00120097 (ASUS_WMI_DEVID_DGPU_POWER_STATE)
in the asus-armoury driver. This exposes a read-only sysfs attribute
'dgpu_power_state' under the firmware_attributes class to query the
discrete GPU power state (0: D3 cold, 1: D0 active).

Suggested-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Marco Scardovi <scardracs@disroot.org>
---
 drivers/platform/x86/asus-armoury.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c
index 93d9665717af..f745924af8a8 100644
--- a/drivers/platform/x86/asus-armoury.c
+++ b/drivers/platform/x86/asus-armoury.c
@@ -786,6 +786,8 @@ ASUS_ATTR_GROUP_BOOL_RW(screen_auto_brightness, "screen_auto_brightness",
 			"Set the panel brightness to Off<0> or On<1>");
 ASUS_ATTR_GROUP_BOOL_RO(egpu_connected, "egpu_connected", ASUS_WMI_DEVID_EGPU_CONNECTED,
 			"Show the eGPU connection status");
+ASUS_ATTR_GROUP_BOOL_RO(dgpu_power_state, "dgpu_power_state", ASUS_WMI_DEVID_DGPU_POWER_STATE,
+			"Show the dGPU power state (0: D3 cold, 1: D0 active)");
 ASUS_ATTR_GROUP_ROG_TUNABLE(ppt_pl1_spl, ATTR_PPT_PL1_SPL, ASUS_WMI_DEVID_PPT_PL1_SPL,
 			    "Set the CPU slow package limit");
 ASUS_ATTR_GROUP_ROG_TUNABLE(ppt_pl2_sppt, ATTR_PPT_PL2_SPPT, ASUS_WMI_DEVID_PPT_PL2_SPPT,
@@ -810,6 +812,7 @@ static const struct asus_attr_group armoury_attr_groups[] = {
 	{ &egpu_connected_attr_group, ASUS_WMI_DEVID_EGPU_CONNECTED },
 	{ &egpu_enable_attr_group, ASUS_WMI_DEVID_EGPU },
 	{ &dgpu_disable_attr_group, ASUS_WMI_DEVID_DGPU },
+	{ &dgpu_power_state_attr_group, ASUS_WMI_DEVID_DGPU_POWER_STATE },
 	{ &apu_mem_attr_group, ASUS_WMI_DEVID_APU_MEM },
 
 	{ &ppt_pl1_spl_attr_group, ASUS_WMI_DEVID_PPT_PL1_SPL },
-- 
2.55.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] platform/x86: asus-armoury: Prevent disabling dGPU when in use
  2026-08-05 18:28 [PATCH 0/3] platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable Marco Scardovi
  2026-08-05 18:28 ` [PATCH 1/3] platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define Marco Scardovi
  2026-08-05 18:28 ` [PATCH 2/3] platform/x86: asus-armoury: Add dgpu_power_state attribute Marco Scardovi
@ 2026-08-05 18:28 ` Marco Scardovi
  2 siblings, 0 replies; 4+ messages in thread
From: Marco Scardovi @ 2026-08-05 18:28 UTC (permalink / raw)
  To: Corentin Chary, Luke D . Jones, Denis Benato, Hans de Goede,
	Ilpo Järvinen
  Cc: platform-driver-x86, linux-kernel, Marco Scardovi

Check ASUS_WMI_DEVID_DGPU_POWER_STATE before attempting to disable the
discrete GPU in dgpu_disable_current_value_store(). Return -EBUSY if the
dGPU is currently active and in use.

Fixes: f99eb098090e ("platform/x86: asus-armoury: move existing tunings to asus-armoury module")
Suggested-by: Denis Benato <denis.benato@linux.dev>
Signed-off-by: Marco Scardovi <scardracs@disroot.org>
---
 drivers/platform/x86/asus-armoury.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c
index f745924af8a8..2d5ca75bc727 100644
--- a/drivers/platform/x86/asus-armoury.c
+++ b/drivers/platform/x86/asus-armoury.c
@@ -515,13 +515,25 @@ static ssize_t dgpu_disable_current_value_store(struct kobject *kobj,
 	if (err)
 		return err;
 
-	if (asus_armoury.gpu_mux_dev_id) {
-		err = armoury_get_devstate(NULL, &result, asus_armoury.gpu_mux_dev_id);
-		if (err)
-			return err;
-		if (!result && disable) {
-			pr_warn("Cannot disable dGPU when the MUX is in dGPU mode\n");
-			return -EBUSY;
+	if (disable) {
+		if (asus_armoury.gpu_mux_dev_id) {
+			err = armoury_get_devstate(NULL, &result, asus_armoury.gpu_mux_dev_id);
+			if (err)
+				return err;
+			if (!result) {
+				pr_warn("Cannot disable dGPU when the MUX is in dGPU mode\n");
+				return -EBUSY;
+			}
+		}
+
+		if (armoury_has_devstate(ASUS_WMI_DEVID_DGPU_POWER_STATE)) {
+			err = armoury_get_devstate(NULL, &result, ASUS_WMI_DEVID_DGPU_POWER_STATE);
+			if (err)
+				return err;
+			if (result) {
+				pr_warn("Cannot disable dGPU when it is in use\n");
+				return -EBUSY;
+			}
 		}
 	}
 
-- 
2.55.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-05 18:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05 18:28 [PATCH 0/3] platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable Marco Scardovi
2026-08-05 18:28 ` [PATCH 1/3] platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define Marco Scardovi
2026-08-05 18:28 ` [PATCH 2/3] platform/x86: asus-armoury: Add dgpu_power_state attribute Marco Scardovi
2026-08-05 18:28 ` [PATCH 3/3] platform/x86: asus-armoury: Prevent disabling dGPU when in use Marco Scardovi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.