platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable
cover platform/x86: asus-armoury: Add dgpu_power_state and check in dgpu_disable
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.
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(-)
Signature · 1 line
2.55.0
PATCH 1/3 platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define
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.
--- include/linux/platform_data/x86/asus-wmi.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/platform_data/x86/asus-wmi.h +2 -1
@@ -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
Signature · 1 line
2.55.0
PATCH 2/3 platform/x86: asus-armoury: Add dgpu_power_state attribute
In reply to Marco ScardoviAdd 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).
--- drivers/platform/x86/asus-armoury.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/x86/asus-armoury.c +3 -0
@@ -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 },
Signature · 1 line
2.55.0
PATCH 3/3 platform/x86: asus-armoury: Prevent disabling dGPU when in use
In reply to Marco ScardoviCheck 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.
--- drivers/platform/x86/asus-armoury.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/platform/x86/asus-armoury.c +19 -7
@@ -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 ; + } } }
Signature · 1 line
2.55.0
Ilpo Järvinen
maintainerQuoted 8 lines · 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 ---
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/3] platform/x86: asus-wmi: Add ASUS_WMI_DEVID_DGPU_POWER_STATE define
commit: b39c54c59e4e9afaac37d0370b776660ba86cbae
[2/3] platform/x86: asus-armoury: Add dgpu_power_state attribute
commit: bf6e7e433e83924bf7e96514e7afb50b43723022
[3/3] platform/x86: asus-armoury: Prevent disabling dGPU when in use
commit: b3f06a74fea6f1ddec192dfece8e52053d0b6c57--
i.