2024-04-02 06:02:35

by Luke D. Jones

[permalink] [raw]
Subject: [PATCH v2 0/9] asus-wmi: add new features, clean up, fixes

My appologies for the rapid v2. I hadn't run checkpatch like I usually do and
when I did it showed some improvements.

This patch series touches quite a few things along with adding support for some
new features.

- Add support for mini-LED on 2024 ROG lpatops
- Add support for the gpu MUX WMI call on Vivobook laptops
- Add support for the POST boot sound on ROG laptops
- Add support for MCU power-save (ROG Ally only, saves more power on suspend)
- Store written values for ppt_* features
- Small formatting cleanup
- Small fixes to cleanup struct holes found with pahole

Obsoletes:
- https://lore.kernel.org/all/[email protected]/
- https://lore.kernel.org/all/[email protected]/
- https://lore.kernel.org/all/[email protected]/
- https://lore.kernel.org/all/[email protected]/
- https://lore.kernel.org/all/[email protected]/

Changelog:
- V1
- Mini-LED: use asus_wmi_get_devstate() and not asus_wmi_get_devstate_simple()
- Fix dates in Documentation/ABI/testing/sysfs-platform-asus-wmi
- Remove <name>_available bools and rely on devid for:
- gpu_mux
- mini_led
- kbd_rgb (TUF RGB LED)
- V2
- Fix formating on select if/else blocks shown by checkpatch.pl

Luke D. Jones (9):
platform/x86: asus-wmi: add support for 2024 ROG Mini-LED
platform/x86: asus-wmi: add support for Vivobook GPU MUX
platform/x86: asus-wmi: add support variant of TUF RGB
platform/x86: asus-wmi: support toggling POST sound
platform/x86: asus-wmi: store a min default for ppt options
platform/x86: asus-wmi: adjust formatting of ppt-<name>() functions
platform/x86: asus-wmi: ROG Ally increase wait time, allow MCU
powersave
platform/x86: asus-wmi: Add support for MCU powersave
platform/x86: asus-wmi: cleanup main struct to avoid some holes

.../ABI/testing/sysfs-platform-asus-wmi | 26 ++
drivers/platform/x86/asus-wmi.c | 393 ++++++++++++++----
include/linux/platform_data/x86/asus-wmi.h | 6 +
3 files changed, 338 insertions(+), 87 deletions(-)

--
2.44.0



2024-04-02 06:27:52

by Luke D. Jones

[permalink] [raw]
Subject: [PATCH v2 2/9] platform/x86: asus-wmi: add support for Vivobook GPU MUX

Add support for the Vivobook dgpu MUX available on the ASUS Viviobook
and some of the other ranges (Zen).

This MUX functions exactly the same as the existing ROG MUX support so
the existing functionality now detects which MUX is available and uses
that for control.

Signed-off-by: Luke D. Jones <[email protected]>
---
drivers/platform/x86/asus-wmi.c | 22 +++++++++++++---------
include/linux/platform_data/x86/asus-wmi.h | 1 +
2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 2330f02ff76f..797531300138 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -259,7 +259,7 @@ struct asus_wmi {
bool egpu_enable_available;
bool egpu_connect_available;
bool dgpu_disable_available;
- bool gpu_mux_mode_available;
+ u32 gpu_mux_dev;

/* Tunables provided by ASUS for gaming laptops */
bool ppt_pl2_sppt_available;
@@ -682,8 +682,8 @@ static ssize_t dgpu_disable_store(struct device *dev,
if (disable > 1)
return -EINVAL;

- if (asus->gpu_mux_mode_available) {
- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
+ if (asus->gpu_mux_dev) {
+ result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev);
if (result < 0)
/* An error here may signal greater failure of GPU handling */
return result;
@@ -748,8 +748,8 @@ static ssize_t egpu_enable_store(struct device *dev,
return err;
}

- if (asus->gpu_mux_mode_available) {
- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
+ if (asus->gpu_mux_dev) {
+ result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev);
if (result < 0) {
/* An error here may signal greater failure of GPU handling */
pr_warn("Failed to get gpu mux status: %d\n", result);
@@ -802,7 +802,7 @@ static ssize_t gpu_mux_mode_show(struct device *dev,
struct asus_wmi *asus = dev_get_drvdata(dev);
int result;

- result = asus_wmi_get_devstate_simple(asus, ASUS_WMI_DEVID_GPU_MUX);
+ result = asus_wmi_get_devstate_simple(asus, asus->gpu_mux_dev);
if (result < 0)
return result;

@@ -848,7 +848,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev,
}
}

- err = asus_wmi_set_devstate(ASUS_WMI_DEVID_GPU_MUX, optimus, &result);
+ err = asus_wmi_set_devstate(asus->gpu_mux_dev, optimus, &result);
if (err) {
dev_err(dev, "Failed to set GPU MUX mode: %d\n", err);
return err;
@@ -4221,7 +4221,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_dgpu_disable.attr)
ok = asus->dgpu_disable_available;
else if (attr == &dev_attr_gpu_mux_mode.attr)
- ok = asus->gpu_mux_mode_available;
+ ok = asus->gpu_mux_dev != 0;
else if (attr == &dev_attr_fan_boost_mode.attr)
ok = asus->fan_boost_mode_available;
else if (attr == &dev_attr_throttle_thermal_policy.attr)
@@ -4487,7 +4487,6 @@ static int asus_wmi_add(struct platform_device *pdev)
asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU);
asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED);
asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU);
- asus->gpu_mux_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX);
asus->kbd_rgb_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_MODE);
asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE);
asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT);
@@ -4506,6 +4505,11 @@ static int asus_wmi_add(struct platform_device *pdev)
else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE2))
asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE2;

+ if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX))
+ asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX;
+ else if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_GPU_MUX_VIVO))
+ asus->gpu_mux_dev = ASUS_WMI_DEVID_GPU_MUX_VIVO;
+
err = fan_boost_mode_check_present(asus);
if (err)
goto fail_fan_boost_mode;
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 9cadce10ad9a..b48b024dd844 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -128,6 +128,7 @@

/* gpu mux switch, 0 = dGPU, 1 = Optimus */
#define ASUS_WMI_DEVID_GPU_MUX 0x00090016
+#define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026

/* TUF laptop RGB modes/colours */
#define ASUS_WMI_DEVID_TUF_RGB_MODE 0x00100056
--
2.44.0


2024-04-02 06:32:30

by Luke D. Jones

[permalink] [raw]
Subject: [PATCH v2 5/9] platform/x86: asus-wmi: store a min default for ppt options

Laptops with any of the ppt or nv tunables default to the minimum setting
on boot so we can safely assume a stored value is correct.

This patch adds storing of those values in the local struct, and enables
reading of those values back. To prevent creating a series of byte holes
in the struct the "<name>_available" bool is removed and
`asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_<name>` directly.

Signed-off-by: Luke D. Jones <[email protected]>
---
drivers/platform/x86/asus-wmi.c | 127 +++++++++++++++++++++++++-------
1 file changed, 99 insertions(+), 28 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index b795f9c1941f..c80afa385532 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -262,13 +262,13 @@ struct asus_wmi {
u32 gpu_mux_dev;

/* Tunables provided by ASUS for gaming laptops */
- bool ppt_pl2_sppt_available;
- bool ppt_pl1_spl_available;
- bool ppt_apu_sppt_available;
- bool ppt_plat_sppt_available;
- bool ppt_fppt_available;
- bool nv_dyn_boost_available;
- bool nv_temp_tgt_available;
+ u32 ppt_pl2_sppt;
+ u32 ppt_pl1_spl;
+ u32 ppt_apu_sppt;
+ u32 ppt_platform_sppt;
+ u32 ppt_fppt;
+ u32 nv_dynamic_boost;
+ u32 nv_temp_target;

u32 kbd_rgb_dev;
bool kbd_rgb_state_available;
@@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev,
return -EIO;
}

+ asus->ppt_pl2_sppt = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt");

return count;
}
-static DEVICE_ATTR_WO(ppt_pl2_sppt);
+
+static ssize_t ppt_pl2_sppt_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt);
+}
+static DEVICE_ATTR_RW(ppt_pl2_sppt);

/* Tunable: PPT, Intel=PL1, AMD=SPL ******************************************/
static ssize_t ppt_pl1_spl_store(struct device *dev,
@@ -1054,11 +1064,20 @@ static ssize_t ppt_pl1_spl_store(struct device *dev,
return -EIO;
}

+ asus->ppt_pl1_spl = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl1_spl");

return count;
}
-static DEVICE_ATTR_WO(ppt_pl1_spl);
+static ssize_t ppt_pl1_spl_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->ppt_pl1_spl);
+}
+static DEVICE_ATTR_RW(ppt_pl1_spl);

/* Tunable: PPT APU FPPT ******************************************************/
static ssize_t ppt_fppt_store(struct device *dev,
@@ -1088,11 +1107,21 @@ static ssize_t ppt_fppt_store(struct device *dev,
return -EIO;
}

+ asus->ppt_fppt = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_fpu_sppt");

return count;
}
-static DEVICE_ATTR_WO(ppt_fppt);
+
+static ssize_t ppt_fppt_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->ppt_fppt);
+}
+static DEVICE_ATTR_RW(ppt_fppt);

/* Tunable: PPT APU SPPT *****************************************************/
static ssize_t ppt_apu_sppt_store(struct device *dev,
@@ -1122,11 +1151,21 @@ static ssize_t ppt_apu_sppt_store(struct device *dev,
return -EIO;
}

+ asus->ppt_apu_sppt = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_apu_sppt");

return count;
}
-static DEVICE_ATTR_WO(ppt_apu_sppt);
+
+static ssize_t ppt_apu_sppt_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->ppt_apu_sppt);
+}
+static DEVICE_ATTR_RW(ppt_apu_sppt);

/* Tunable: PPT platform SPPT ************************************************/
static ssize_t ppt_platform_sppt_store(struct device *dev,
@@ -1156,11 +1195,21 @@ static ssize_t ppt_platform_sppt_store(struct device *dev,
return -EIO;
}

+ asus->ppt_platform_sppt = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_platform_sppt");

return count;
}
-static DEVICE_ATTR_WO(ppt_platform_sppt);
+
+static ssize_t ppt_platform_sppt_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->ppt_platform_sppt);
+}
+static DEVICE_ATTR_RW(ppt_platform_sppt);

/* Tunable: NVIDIA dynamic boost *********************************************/
static ssize_t nv_dynamic_boost_store(struct device *dev,
@@ -1190,11 +1239,21 @@ static ssize_t nv_dynamic_boost_store(struct device *dev,
return -EIO;
}

+ asus->nv_dynamic_boost = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_dynamic_boost");

return count;
}
-static DEVICE_ATTR_WO(nv_dynamic_boost);
+
+static ssize_t nv_dynamic_boost_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->nv_dynamic_boost);
+}
+static DEVICE_ATTR_RW(nv_dynamic_boost);

/* Tunable: NVIDIA temperature target ****************************************/
static ssize_t nv_temp_target_store(struct device *dev,
@@ -1224,11 +1283,21 @@ static ssize_t nv_temp_target_store(struct device *dev,
return -EIO;
}

+ asus->nv_temp_target = value;
sysfs_notify(&asus->platform_device->dev.kobj, NULL, "nv_temp_target");

return count;
}
-static DEVICE_ATTR_WO(nv_temp_target);
+
+static ssize_t nv_temp_target_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
+
+ return sysfs_emit(buf, "%d\n", asus->nv_temp_target);
+}
+static DEVICE_ATTR_RW(nv_temp_target);

/* Battery ********************************************************************/

@@ -4277,19 +4346,19 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_throttle_thermal_policy.attr)
ok = asus->throttle_thermal_policy_available;
else if (attr == &dev_attr_ppt_pl2_sppt.attr)
- ok = asus->ppt_pl2_sppt_available;
+ devid = ASUS_WMI_DEVID_PPT_PL2_SPPT;
else if (attr == &dev_attr_ppt_pl1_spl.attr)
- ok = asus->ppt_pl1_spl_available;
+ devid = ASUS_WMI_DEVID_PPT_PL1_SPL;
else if (attr == &dev_attr_ppt_fppt.attr)
- ok = asus->ppt_fppt_available;
+ devid = ASUS_WMI_DEVID_PPT_FPPT;
else if (attr == &dev_attr_ppt_apu_sppt.attr)
- ok = asus->ppt_apu_sppt_available;
+ devid = ASUS_WMI_DEVID_PPT_APU_SPPT;
else if (attr == &dev_attr_ppt_platform_sppt.attr)
- ok = asus->ppt_plat_sppt_available;
+ devid = ASUS_WMI_DEVID_PPT_PLAT_SPPT;
else if (attr == &dev_attr_nv_dynamic_boost.attr)
- ok = asus->nv_dyn_boost_available;
+ devid = ASUS_WMI_DEVID_NV_DYN_BOOST;
else if (attr == &dev_attr_nv_temp_target.attr)
- ok = asus->nv_temp_tgt_available;
+ devid = ASUS_WMI_DEVID_NV_THERM_TARGET;
else if (attr == &dev_attr_boot_sound.attr)
devid = ASUS_WMI_DEVID_BOOT_SOUND;
else if (attr == &dev_attr_panel_od.attr)
@@ -4535,18 +4604,20 @@ static int asus_wmi_add(struct platform_device *pdev)
if (err)
goto fail_platform;

+ /* ensure defaults for tunables */
+ asus->ppt_pl2_sppt = 5;
+ asus->ppt_pl1_spl = 5;
+ asus->ppt_apu_sppt = 5;
+ asus->ppt_platform_sppt = 5;
+ asus->ppt_fppt = 5;
+ asus->nv_dynamic_boost = 5;
+ asus->nv_temp_target = 75;
+
asus->charge_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CHARGE_MODE);
asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU);
asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED);
asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU);
asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE);
- asus->ppt_pl2_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL2_SPPT);
- asus->ppt_pl1_spl_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PL1_SPL);
- asus->ppt_fppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_FPPT);
- asus->ppt_apu_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_APU_SPPT);
- asus->ppt_plat_sppt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PPT_PLAT_SPPT);
- asus->nv_dyn_boost_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_DYN_BOOST);
- asus->nv_temp_tgt_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_NV_THERM_TARGET);
asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);
asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
&& dmi_match(DMI_BOARD_NAME, "RC71L");
--
2.44.0


2024-04-02 06:44:45

by Luke D. Jones

[permalink] [raw]
Subject: [PATCH v2 9/9] platform/x86: asus-wmi: cleanup main struct to avoid some holes

Reorganises some attr-available calls to remove a few unrequired
booleans in the main driver struct which combined with some
reorganisation prevents a series of large holes seen with pahole.

Signed-off-by: Luke D. Jones <[email protected]>
---
drivers/platform/x86/asus-wmi.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index cf872eed0986..c8a8ddaeff29 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -243,6 +243,9 @@ struct asus_wmi {
u32 tablet_switch_dev_id;
bool tablet_switch_inverted;

+ /* The ROG Ally device requires the MCU USB device be disconnected before suspend */
+ bool ally_mcu_usb_switch;
+
enum fan_type fan_type;
enum fan_type gpu_fan_type;
enum fan_type mid_fan_type;
@@ -255,9 +258,7 @@ struct asus_wmi {
u8 fan_boost_mode_mask;
u8 fan_boost_mode;

- bool charge_mode_available;
bool egpu_enable_available;
- bool egpu_connect_available;
bool dgpu_disable_available;
u32 gpu_mux_dev;

@@ -298,9 +299,6 @@ struct asus_wmi {

bool fnlock_locked;

- /* The ROG Ally device requires the MCU USB device be disconnected before suspend */
- bool ally_mcu_usb_switch;
-
struct asus_wmi_debug debug;

struct asus_wmi_driver *driver;
@@ -4373,11 +4371,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_als_enable.attr)
devid = ASUS_WMI_DEVID_ALS_ENABLE;
else if (attr == &dev_attr_charge_mode.attr)
- ok = asus->charge_mode_available;
+ devid = ASUS_WMI_DEVID_CHARGE_MODE;
else if (attr == &dev_attr_egpu_enable.attr)
ok = asus->egpu_enable_available;
else if (attr == &dev_attr_egpu_connected.attr)
- ok = asus->egpu_connect_available;
+ devid = ASUS_WMI_DEVID_EGPU_CONNECTED;
else if (attr == &dev_attr_dgpu_disable.attr)
ok = asus->dgpu_disable_available;
else if (attr == &dev_attr_gpu_mux_mode.attr)
@@ -4405,7 +4403,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_boot_sound.attr)
devid = ASUS_WMI_DEVID_BOOT_SOUND;
else if (attr == &dev_attr_panel_od.attr)
- ok = asus->panel_overdrive_available;
+ devid = ASUS_WMI_DEVID_PANEL_OD;
else if (attr == &dev_attr_mini_led_mode.attr)
ok = asus->mini_led_dev_id != 0;
else if (attr == &dev_attr_available_mini_led_mode.attr)
@@ -4656,12 +4654,9 @@ static int asus_wmi_add(struct platform_device *pdev)
asus->nv_dynamic_boost = 5;
asus->nv_temp_target = 75;

- asus->charge_mode_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_CHARGE_MODE);
asus->egpu_enable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU);
- asus->egpu_connect_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_EGPU_CONNECTED);
asus->dgpu_disable_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_DGPU);
asus->kbd_rgb_state_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_TUF_RGB_STATE);
- asus->panel_overdrive_available = asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_PANEL_OD);
asus->ally_mcu_usb_switch = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE)
&& dmi_match(DMI_BOARD_NAME, "RC71L");

--
2.44.0


2024-04-02 08:27:20

by Luke D. Jones

[permalink] [raw]
Subject: [PATCH v2 6/9] platform/x86: asus-wmi: adjust formatting of ppt-<name>() functions

Shift the call to dev_get_drvdata() up to top of the function block
in all of the ppt_<name>() functions as part of a minor cleanup.

Signed-off-by: Luke D. Jones <[email protected]>
---
drivers/platform/x86/asus-wmi.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index c80afa385532..1743ff1eb0ac 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -997,11 +997,10 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
@@ -1041,11 +1040,10 @@ static ssize_t ppt_pl1_spl_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
@@ -1084,11 +1082,10 @@ static ssize_t ppt_fppt_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
@@ -1128,11 +1125,10 @@ static ssize_t ppt_apu_sppt_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
@@ -1172,11 +1168,10 @@ static ssize_t ppt_platform_sppt_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
@@ -1216,11 +1211,10 @@ static ssize_t nv_dynamic_boost_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
@@ -1260,11 +1254,10 @@ static ssize_t nv_temp_target_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
+ struct asus_wmi *asus = dev_get_drvdata(dev);
int result, err;
u32 value;

- struct asus_wmi *asus = dev_get_drvdata(dev);
-
result = kstrtou32(buf, 10, &value);
if (result)
return result;
--
2.44.0


2024-04-02 10:44:35

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v2 2/9] platform/x86: asus-wmi: add support for Vivobook GPU MUX

On Tue, 2 Apr 2024, Luke D. Jones wrote:

> Add support for the Vivobook dgpu MUX available on the ASUS Viviobook
> and some of the other ranges (Zen).
>
> This MUX functions exactly the same as the existing ROG MUX support so
> the existing functionality now detects which MUX is available and uses
> that for control.
>
> Signed-off-by: Luke D. Jones <[email protected]>

Reviewed-by: Ilpo J?rvinen <[email protected]>

--
i.

2024-04-02 10:50:04

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v2 5/9] platform/x86: asus-wmi: store a min default for ppt options

On Tue, 2 Apr 2024, Luke D. Jones wrote:

> Laptops with any of the ppt or nv tunables default to the minimum setting
> on boot so we can safely assume a stored value is correct.
>
> This patch adds storing of those values in the local struct, and enables
> reading of those values back. To prevent creating a series of byte holes
> in the struct the "<name>_available" bool is removed and
> `asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_<name>` directly.
>
> Signed-off-by: Luke D. Jones <[email protected]>
> ---
> drivers/platform/x86/asus-wmi.c | 127 +++++++++++++++++++++++++-------
> 1 file changed, 99 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index b795f9c1941f..c80afa385532 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -262,13 +262,13 @@ struct asus_wmi {
> u32 gpu_mux_dev;
>
> /* Tunables provided by ASUS for gaming laptops */
> - bool ppt_pl2_sppt_available;
> - bool ppt_pl1_spl_available;
> - bool ppt_apu_sppt_available;
> - bool ppt_plat_sppt_available;
> - bool ppt_fppt_available;
> - bool nv_dyn_boost_available;
> - bool nv_temp_tgt_available;
> + u32 ppt_pl2_sppt;
> + u32 ppt_pl1_spl;
> + u32 ppt_apu_sppt;
> + u32 ppt_platform_sppt;
> + u32 ppt_fppt;
> + u32 nv_dynamic_boost;
> + u32 nv_temp_target;
>
> u32 kbd_rgb_dev;
> bool kbd_rgb_state_available;
> @@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device *dev,
> return -EIO;
> }
>
> + asus->ppt_pl2_sppt = value;
> sysfs_notify(&asus->platform_device->dev.kobj, NULL, "ppt_pl2_sppt");
>
> return count;
> }
> -static DEVICE_ATTR_WO(ppt_pl2_sppt);
> +
> +static ssize_t ppt_pl2_sppt_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct asus_wmi *asus = dev_get_drvdata(dev);
> +
> + return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt);

Use %u for u32 values. This applies to all sysfs_emits in this patch.

--
i.


2024-04-02 13:05:05

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v2 9/9] platform/x86: asus-wmi: cleanup main struct to avoid some holes

On Tue, 2 Apr 2024, Luke D. Jones wrote:

> Reorganises some attr-available calls to remove a few unrequired
> booleans in the main driver struct which combined with some
> reorganisation prevents a series of large holes seen with pahole.
>
> Signed-off-by: Luke D. Jones <[email protected]>

Reviewed-by: Ilpo J?rvinen <[email protected]>

--
i.

2024-04-02 14:38:57

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v2 6/9] platform/x86: asus-wmi: adjust formatting of ppt-<name>() functions

On Tue, 2 Apr 2024, Luke D. Jones wrote:

> Shift the call to dev_get_drvdata() up to top of the function block
> in all of the ppt_<name>() functions as part of a minor cleanup.
>
> Signed-off-by: Luke D. Jones <[email protected]>

Thanks for doing this,

Reviewed-by: Ilpo J?rvinen <[email protected]>

--
i.

2024-04-03 00:10:14

by Luke D. Jones

[permalink] [raw]
Subject: Re: [PATCH v2 5/9] platform/x86: asus-wmi: store a min default for ppt options

On Tuesday, 2 April 2024 11:49:50 PM NZDT Ilpo Järvinen wrote:
> On Tue, 2 Apr 2024, Luke D. Jones wrote:
> > Laptops with any of the ppt or nv tunables default to the minimum setting
> > on boot so we can safely assume a stored value is correct.
> >
> > This patch adds storing of those values in the local struct, and enables
> > reading of those values back. To prevent creating a series of byte holes
> > in the struct the "<name>_available" bool is removed and
> > `asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_<name>` directly.
> >
> > Signed-off-by: Luke D. Jones <[email protected]>
> > ---
> >
> > drivers/platform/x86/asus-wmi.c | 127 +++++++++++++++++++++++++-------
> > 1 file changed, 99 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/platform/x86/asus-wmi.c
> > b/drivers/platform/x86/asus-wmi.c index b795f9c1941f..c80afa385532 100644
> > --- a/drivers/platform/x86/asus-wmi.c
> > +++ b/drivers/platform/x86/asus-wmi.c
> > @@ -262,13 +262,13 @@ struct asus_wmi {
> >
> > u32 gpu_mux_dev;
> >
> > /* Tunables provided by ASUS for gaming laptops */
> >
> > - bool ppt_pl2_sppt_available;
> > - bool ppt_pl1_spl_available;
> > - bool ppt_apu_sppt_available;
> > - bool ppt_plat_sppt_available;
> > - bool ppt_fppt_available;
> > - bool nv_dyn_boost_available;
> > - bool nv_temp_tgt_available;
> > + u32 ppt_pl2_sppt;
> > + u32 ppt_pl1_spl;
> > + u32 ppt_apu_sppt;
> > + u32 ppt_platform_sppt;
> > + u32 ppt_fppt;
> > + u32 nv_dynamic_boost;
> > + u32 nv_temp_target;
> >
> > u32 kbd_rgb_dev;
> > bool kbd_rgb_state_available;
> >
> > @@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device
> > *dev,>
> > return -EIO;
> >
> > }
> >
> > + asus->ppt_pl2_sppt = value;
> >
> > sysfs_notify(&asus->platform_device->dev.kobj, NULL,
"ppt_pl2_sppt");
> >
> > return count;
> >
> > }
> >
> > -static DEVICE_ATTR_WO(ppt_pl2_sppt);
> > +
> > +static ssize_t ppt_pl2_sppt_show(struct device *dev,
> > + struct device_attribute
*attr,
> > + char *buf)
> > +{
> > + struct asus_wmi *asus = dev_get_drvdata(dev);
> > +
> > + return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt);
>
> Use %u for u32 values. This applies to all sysfs_emits in this patch.

Thought checkpatch or the compiler would catch that. Done.

I've added your reviewed tag due to the simplicity of the change requested. I
hope this was okay.





2024-04-03 12:24:34

by Ilpo Järvinen

[permalink] [raw]
Subject: Re: [PATCH v2 5/9] platform/x86: asus-wmi: store a min default for ppt options

On Wed, 3 Apr 2024, Luke Jones wrote:

> On Tuesday, 2 April 2024 11:49:50 PM NZDT Ilpo Järvinen wrote:
> > On Tue, 2 Apr 2024, Luke D. Jones wrote:
> > > Laptops with any of the ppt or nv tunables default to the minimum setting
> > > on boot so we can safely assume a stored value is correct.
> > >
> > > This patch adds storing of those values in the local struct, and enables
> > > reading of those values back. To prevent creating a series of byte holes
> > > in the struct the "<name>_available" bool is removed and
> > > `asus_sysfs_is_visible()` uses the `ASUS_WMI_DEVID_<name>` directly.
> > >
> > > Signed-off-by: Luke D. Jones <[email protected]>
> > > ---
> > >
> > > drivers/platform/x86/asus-wmi.c | 127 +++++++++++++++++++++++++-------
> > > 1 file changed, 99 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/drivers/platform/x86/asus-wmi.c
> > > b/drivers/platform/x86/asus-wmi.c index b795f9c1941f..c80afa385532 100644
> > > --- a/drivers/platform/x86/asus-wmi.c
> > > +++ b/drivers/platform/x86/asus-wmi.c
> > > @@ -262,13 +262,13 @@ struct asus_wmi {
> > >
> > > u32 gpu_mux_dev;
> > >
> > > /* Tunables provided by ASUS for gaming laptops */
> > >
> > > - bool ppt_pl2_sppt_available;
> > > - bool ppt_pl1_spl_available;
> > > - bool ppt_apu_sppt_available;
> > > - bool ppt_plat_sppt_available;
> > > - bool ppt_fppt_available;
> > > - bool nv_dyn_boost_available;
> > > - bool nv_temp_tgt_available;
> > > + u32 ppt_pl2_sppt;
> > > + u32 ppt_pl1_spl;
> > > + u32 ppt_apu_sppt;
> > > + u32 ppt_platform_sppt;
> > > + u32 ppt_fppt;
> > > + u32 nv_dynamic_boost;
> > > + u32 nv_temp_target;
> > >
> > > u32 kbd_rgb_dev;
> > > bool kbd_rgb_state_available;
> > >
> > > @@ -1020,11 +1020,21 @@ static ssize_t ppt_pl2_sppt_store(struct device
> > > *dev,>
> > > return -EIO;
> > >
> > > }
> > >
> > > + asus->ppt_pl2_sppt = value;
> > >
> > > sysfs_notify(&asus->platform_device->dev.kobj, NULL,
> "ppt_pl2_sppt");
> > >
> > > return count;
> > >
> > > }
> > >
> > > -static DEVICE_ATTR_WO(ppt_pl2_sppt);
> > > +
> > > +static ssize_t ppt_pl2_sppt_show(struct device *dev,
> > > + struct device_attribute
> *attr,
> > > + char *buf)
> > > +{
> > > + struct asus_wmi *asus = dev_get_drvdata(dev);
> > > +
> > > + return sysfs_emit(buf, "%d\n", asus->ppt_pl2_sppt);
> >
> > Use %u for u32 values. This applies to all sysfs_emits in this patch.
>
> Thought checkpatch or the compiler would catch that. Done.
>
> I've added your reviewed tag due to the simplicity of the change requested. I
> hope this was okay.

Hi,

Please don't add Reviewed-by tags automatically in the future. Its
meaning is not that the person has looked the patch.

--
i.