platform/x86: asus-armoury: fix mini-LED mode get/set on MODE2 devices
PATCH 1/1 platform/x86: asus-armoury: fix mini-LED mode get/set on MODE2 devices
The mini-LED current_value attribute does not work on devices that use ASUS_WMI_DEVID_MINI_LED_MODE2 (2024 and newer models).
Reading is broken: mini_led_mode_current_value_show() fetches the mode from the device but then decodes a literal 0 instead of the value it just read:
mode = FIELD_GET(ASUS_MINI_LED_MODE_MASK, 0);
So mode is always 0, and the attribute always reports the same thing regardless of the real hardware state.
Writing is broken too. The number a user writes is an index; the value the firmware actually wants is looked up from that index in mini_led_mode_map[]. mini_led_mode_current_value_store() skips that lookup and passes the raw index straight to armoury_attr_uint_store(). On 2024 devices the firmware numbers its modes differently from the index, so some writes are rejected with -EINVAL and the rest send the wrong mode to the hardware.
Fix both paths: decode the value actually read from the device when reading, and look up the firmware value before sending it when writing. Older (MODE1) devices were unaffected because there the index and the firmware value are the same.
--- drivers/platform/x86/asus-armoury.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/platform/x86/asus-armoury.c +12 -4
@@ -370,7 +370,7 @@ static ssize_t mini_led_mode_current_value_show(struct kobject *kobj,if (err)return err; - mode =FIELD_GET (ASUS_MINI_LED_MODE_MASK ,0 ); + mode =FIELD_GET (ASUS_MINI_LED_MODE_MASK , mode);for (i =0 ; i < mini_led_mode_map_size; i++)if (mode == mini_led_mode_map[i])
@@ -386,6 +386,7 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj, {u32 *mini_led_mode_map;size_t mini_led_mode_map_size; +char mapped_value[12 ];u32 mode;int err;
@@ -414,9 +415,16 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj,return -ENODEV ; } -return armoury_attr_uint_store (kobj, attr, buf, count, -0 , mini_led_mode_map[mode], -NULL , asus_armoury.mini_led_dev_id); +/* +* armoury_attr_uint_store() parses and sends the value from the +* passed buffer; hand it the mapped firmware value so the device +* receives the translated mode instead of the raw index. +*/ +snprintf (mapped_value,sizeof (mapped_value),"%u" , mini_led_mode_map[mode]); + +return armoury_attr_uint_store (kobj, attr, mapped_value, count,0 , + mini_led_mode_map[mode],NULL , + asus_armoury.mini_led_dev_id); } static ssize_t mini_led_mode_possible_values_show(struct kobject *kobj,
Signature · 1 line
2.54.0
Quoted 20 lines · Ahmed Yaseen
The mini-LED
current_valueattribute does not work on devices that useASUS_WMI_DEVID_MINI_LED_MODE2(2024 and newer models).Reading is broken:
mini_led_mode_current_value_show()fetches the mode from the device but then decodes a literal 0 instead of the value it just read:mode = FIELD_GET(ASUS_MINI_LED_MODE_MASK, 0);So mode is always 0, and the attribute always reports the same thing regardless of the real hardware state.
Writing is broken too. The number a user writes is an index; the value the firmware actually wants is looked up from that index in mini_led_mode_map[].
mini_led_mode_current_value_store()skips that lookup and passes the raw index straight toarmoury_attr_uint_store(). On 2024 devices the firmware numbers its modes differently from the index, so some writes are rejected with-EINVALand the rest send the wrong mode to the hardware.
Quoted 4 lines
Fix both paths: decode the value actually read from the device when reading, and look up the firmware value before sending it when writing. Older (MODE1) devices were unaffected because there the index and the firmware value are the same.
Thank for finding and fixing this!
Quoted 47 lines
Fixes f99eb098090e ("platform/x86: asus-armoury: move existing tunings to asus-armoury module")Signed-off-by Ahmed Yaseen <[email protected]>--- drivers/platform/x86/asus-armoury.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)drivers/platform/x86/asus-armoury.c +12
-4@@ -370,7 +370,7 @@ static ssize_t mini_led_mode_current_value_show(struct kobject *kobj,if (err)return err; - mode =FIELD_GET (ASUS_MINI_LED_MODE_MASK ,0 ); + mode =FIELD_GET (ASUS_MINI_LED_MODE_MASK , mode);for (i =0 ; i < mini_led_mode_map_size; i++)if (mode == mini_led_mode_map[i])@@ -386,6 +386,7 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj, {u32 *mini_led_mode_map;size_t mini_led_mode_map_size; +char mapped_value[12 ];u32 mode;int err;@@ -414,9 +415,16 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj,return -ENODEV ; } -return armoury_attr_uint_store (kobj, attr, buf, count, -0 , mini_led_mode_map[mode], -NULL , asus_armoury.mini_led_dev_id); +/* +* armoury_attr_uint_store() parses and sends the value from the +* passed buffer; hand it the mapped firmware value so the device +* receives the translated mode instead of the raw index. +*/ +snprintf (mapped_value,sizeof (mapped_value),"%u" , mini_led_mode_map[mode]); + +return armoury_attr_uint_store (kobj, attr, mapped_value, count,0 , + mini_led_mode_map[mode],NULL , + asus_armoury.mini_led_dev_id); } static ssize_t mini_led_mode_possible_values_show(struct kobject *kobj,
Ilpo Järvinen
maintainerQuoted 8 lines · Ahmed Yaseen
The mini-LED
current_valueattribute does not work on devices that useASUS_WMI_DEVID_MINI_LED_MODE2(2024 and newer models).Reading is broken:
mini_led_mode_current_value_show()fetches the mode from the device but then decodes a literal 0 instead of the value it just read:[...]
Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/1] platform/x86: asus-armoury: fix mini-LED mode get/set on MODE2 devices
commit: d2d2e7c8fb37b27301ee5c8343b2f7037efc6ea6
--
i.
Denis Benato
maintainerThis has no business being here. I used *.patch to send and missed this. Apologies!
Quoted 74 lines · Denis Benato
From: Ahmed Yaseen <[email protected]>
The mini-LED
current_valueattribute does not work on devices that useASUS_WMI_DEVID_MINI_LED_MODE2(2024 and newer models).Reading is broken:
mini_led_mode_current_value_show()fetches the mode from the device but then decodes a literal 0 instead of the value it just read:mode = FIELD_GET(ASUS_MINI_LED_MODE_MASK, 0);So mode is always 0, and the attribute always reports the same thing regardless of the real hardware state.
Writing is broken too. The number a user writes is an index; the value the firmware actually wants is looked up from that index in mini_led_mode_map[].
mini_led_mode_current_value_store()skips that lookup and passes the raw index straight toarmoury_attr_uint_store(). On 2024 devices the firmware numbers its modes differently from the index, so some writes are rejected with-EINVALand the rest send the wrong mode to the hardware.Fix both paths: decode the value actually read from the device when reading, and look up the firmware value before sending it when writing. Older (MODE1) devices were unaffected because there the index and the firmware value are the same.
Fixes f99eb098090e ("platform/x86: asus-armoury: move existing tunings to asus-armoury module")Signed-off-by Ahmed Yaseen <[email protected]>--- drivers/platform/x86/asus-armoury.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)drivers/platform/x86/asus-armoury.c +12
-4@@ -370,7 +370,7 @@ static ssize_t mini_led_mode_current_value_show(struct kobject *kobj,if (err)return err; - mode =FIELD_GET (ASUS_MINI_LED_MODE_MASK ,0 ); + mode =FIELD_GET (ASUS_MINI_LED_MODE_MASK , mode);for (i =0 ; i < mini_led_mode_map_size; i++)if (mode == mini_led_mode_map[i])@@ -386,6 +386,7 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj, {u32 *mini_led_mode_map;size_t mini_led_mode_map_size; +char mapped_value[12 ];u32 mode;int err;@@ -414,9 +415,16 @@ static ssize_t mini_led_mode_current_value_store(struct kobject *kobj,return -ENODEV ; } -return armoury_attr_uint_store (kobj, attr, buf, count, -0 , mini_led_mode_map[mode], -NULL , asus_armoury.mini_led_dev_id); +/* +* armoury_attr_uint_store() parses and sends the value from the +* passed buffer; hand it the mapped firmware value so the device +* receives the translated mode instead of the raw index. +*/ +snprintf (mapped_value,sizeof (mapped_value),"%u" , mini_led_mode_map[mode]); + +return armoury_attr_uint_store (kobj, attr, mapped_value, count,0 , + mini_led_mode_map[mode],NULL , + asus_armoury.mini_led_dev_id); } static ssize_t mini_led_mode_possible_values_show(struct kobject *kobj,
Denis Benato
maintainercover platform/x86: asus-armoury: more ppt data
Hi all,
This patch series adds support for three more ASUS models to the asus-armoury driver:
the GA402NJ, GA403UM, and FX608JPR.
Cheers!
Denis Benato (3):
platform/x86: asus-armoury: add support for GA402NJ platform/x86: asus-armoury: add support for GA403UM platform/x86: asus-armoury: add support for FX608JPR
drivers/platform/x86/asus-armoury.h | 92 +++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
Signature · 1 line
2.47.3
Denis Benato
maintainerPATCH 1/3 platform/x86: asus-armoury: add support for GA402NJ
Add TDP data for laptop model GA402NJ.
--- drivers/platform/x86/asus-armoury.h | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/platform/x86/asus-armoury.h +32 -0
@@ -950,6 +950,38 @@ static const struct dmi_system_id power_limits[] = { .dc_data = NULL, }, }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GA402NJ"), + }, + .driver_data = &(struct power_data ) { + .ac_data = &(struct power_limits ) { + .ppt_pl1_spl_min =15 , + .ppt_pl1_spl_def =35 , + .ppt_pl1_spl_max =80 , + .ppt_pl2_sppt_min =25 , + .ppt_pl2_sppt_def =65 , + .ppt_pl2_sppt_max =80 , + .ppt_pl3_fppt_min =35 , + .ppt_pl3_fppt_max =80 , + .nv_temp_target_min =75 , + .nv_temp_target_max =87 , + .nv_dynamic_boost_min =5 , + .nv_dynamic_boost_def =10 , + .nv_dynamic_boost_max =15 , + }, + .dc_data = &(struct power_limits ) { + .ppt_pl1_spl_min =15 , + .ppt_pl1_spl_max =35 , + .ppt_pl2_sppt_min =25 , + .ppt_pl2_sppt_max =35 , + .ppt_pl3_fppt_min =35 , + .ppt_pl3_fppt_max =65 , + .nv_temp_target_min =75 , + .nv_temp_target_max =87 , + }, + }, + }, { .matches = {// This model is full AMD. No Nvidia dGPU.
Signature · 1 line
2.47.3
Denis Benato
maintainerPATCH 2/3 platform/x86: asus-armoury: add support for GA403UM
In reply to Denis BenatoAdd TDP data for laptop model GA403UM.
--- drivers/platform/x86/asus-armoury.h | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/platform/x86/asus-armoury.h +32 -0
@@ -1065,6 +1065,38 @@ static const struct dmi_system_id power_limits[] = { .requires_fan_curve = true, }, }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "GA403UM"), + }, + .driver_data = &(struct power_data ) { + .ac_data = &(struct power_limits ) { + .ppt_pl1_spl_min =15 , + .ppt_pl1_spl_max =80 , + .ppt_pl2_sppt_min =25 , + .ppt_pl2_sppt_max =80 , + .ppt_pl3_fppt_min =35 , + .ppt_pl3_fppt_max =80 , + .nv_dynamic_boost_min =0 , + .nv_dynamic_boost_max =15 , + .nv_temp_target_min =75 , + .nv_temp_target_max =87 , + .nv_tgp_min =55 , + .nv_tgp_max =85 , + }, + .dc_data = &(struct power_limits ) { + .ppt_pl1_spl_min =15 , + .ppt_pl1_spl_max =35 , + .ppt_pl2_sppt_min =25 , + .ppt_pl2_sppt_max =35 , + .ppt_pl3_fppt_min =35 , + .ppt_pl3_fppt_max =65 , + .nv_temp_target_min =75 , + .nv_temp_target_max =87 , + }, + .requires_fan_curve = true, + }, + }, { .matches = { DMI_MATCH(DMI_BOARD_NAME, "GA403UV"),
Signature · 1 line
2.47.3
Denis Benato
maintainerPATCH 3/3 platform/x86: asus-armoury: add support for FX608JPR
In reply to Denis BenatoAdd TDP data for laptop model FX608JPR.
--- drivers/platform/x86/asus-armoury.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/platform/x86/asus-armoury.h +28 -0
@@ -909,6 +909,34 @@ static const struct dmi_system_id power_limits[] = { .requires_fan_curve = true, }, }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "FX608JPR"), + }, + .driver_data = &(struct power_data ) { + .ac_data = &(struct power_limits ) { + .ppt_pl1_spl_min =28 , + .ppt_pl1_spl_max =100 , + .ppt_pl2_sppt_min =28 , + .ppt_pl2_sppt_max =135 , + .nv_dynamic_boost_min =10 , + .nv_dynamic_boost_max =15 , + .nv_temp_target_min =75 , + .nv_temp_target_max =87 , + .nv_tgp_min =55 , + .nv_tgp_max =100 , + }, + .dc_data = &(struct power_limits ) { + .ppt_pl1_spl_min =25 , + .ppt_pl1_spl_max =53 , + .ppt_pl2_sppt_min =25 , + .ppt_pl2_sppt_max =65 , + .nv_temp_target_min =75 , + .nv_temp_target_max =87 , + }, + .requires_fan_curve = true, + }, + }, { .matches = { DMI_MATCH(DMI_BOARD_NAME, "FX607VU"),
Signature · 1 line
2.47.3
Ilpo Järvinen
maintainerRe: [PATCH 3/3] platform/x86: asus-armoury: add support for FX608JPR
Quoted 12 lines · Denis Benato
Add TDP data for laptop model FX608JPR.
Signed-off-by Denis Benato <[email protected]>--- drivers/platform/x86/asus-armoury.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/platform/x86/asus-armoury.h +0
-0
drivers/platform/x86/asus-armoury.h static const struct dmi_system_id power_limits[] = { · line 917
Quoted 9 lines
drivers/platform/x86/asus-armoury.h +3
-0@@ -909,6 +909,34 @@ static const struct dmi_system_id power_limits[] = { .requires_fan_curve = true, }, }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "FX608JPR"), .matches = { DMI_MATCH(DMI_BOARD_NAME, "FX607VU"),
Shouldn't FX608JPR come after FX607VU?
You might have to violate the strict alphanumeric order in some cases where the name is a strict subset of the other as the first matching one is picked from the array. But for other cases, keeping things in order will be easier.
Signature · 1 line
i.
Re: [PATCH 3/3] platform/x86: asus-armoury: add support for FX608JPR
Quoted 9 lines · Ilpo Järvinen
Quoted 7 lines · Denis Benato
Add TDP data for laptop model FX608JPR.
Signed-off-by Denis Benato <[email protected]>--- drivers/platform/x86/asus-armoury.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
Quoted 14 lines
drivers/platform/x86/asus-armoury.h static const struct dmi_system_id power_limits[] = { · line 916
Quoted 13 lines
drivers/platform/x86/asus-armoury.h +3
-0@@ -909,6 +909,34 @@ static const struct dmi_system_id power_limits[] = { .requires_fan_curve = true, }, }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "FX608JPR"), .matches = { DMI_MATCH(DMI_BOARD_NAME, "FX607VU"),Shouldn't FX608JPR come after FX607VU?
Yes, absolutely.
Quoted 5 lines
You might have to violate the strict alphanumeric order in some cases where the name is a strict subset of the other as the first matching one is picked from the array. But for other cases, keeping things in order will be easier.
Fully agree. Will send v2 shortly.