diff --git a/patches/0001-cachyos-base-all.patch b/patches/0001-cachyos-base-all.patch index 1134836..c67163d 100644 --- a/patches/0001-cachyos-base-all.patch +++ b/patches/0001-cachyos-base-all.patch @@ -1,9 +1,9 @@ -From 1138281a324639ba9ab730e82ab976c2ac80b24c Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:48:51 +0800 +From e54439b481ba3c4095c75d8f7e49a48deb3dd13b Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:37:58 +0100 Subject: [PATCH 1/9] amd-pstate -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- drivers/cpufreq/amd-pstate-trace.h | 46 ++++---- drivers/cpufreq/amd-pstate.c | 162 +++++++++++++---------------- @@ -687,14 +687,14 @@ index c49aea8c1025..b61a261ee45b 100644 } while (sg != sd->groups); -- -2.48.1 +2.48.0.rc1 -From 22e026f1d3db4c42b3187ce5db2bc9d79f11c131 Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:48:58 +0800 +From 75770c34b5a7fe78408e13760b242c8da62a2b5a Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:38:12 +0100 Subject: [PATCH 2/9] amd-tlb-broadcast -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- arch/x86/Kconfig | 2 +- arch/x86/Kconfig.cpu | 5 + @@ -2020,14 +2020,14 @@ index 3ae84c3b8e6d..dc1c1057f26e 100644 /* -- -2.48.1 +2.48.0.rc1 -From bb53b6f3a6bce80dfd97efc1bc956f8591063d50 Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:49:33 +0800 +From c7f34a05480caed20a4490edeea8b598b947d159 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:38:23 +0100 Subject: [PATCH 3/9] asus -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- .../ABI/testing/sysfs-platform-asus-wmi | 17 + .../display/dc/dml2/dml2_translation_helper.c | 2 +- @@ -2039,12 +2039,11 @@ Signed-off-by: Eric Naim drivers/hid/hid-ids.h | 1 + drivers/platform/x86/Kconfig | 21 + drivers/platform/x86/Makefile | 1 + - drivers/platform/x86/asus-armoury.c | 1153 +++++++++ - drivers/platform/x86/asus-armoury.h | 1231 +++++++++ - drivers/platform/x86/asus-wmi.c | 381 ++- - drivers/platform/x86/asus-wmi.h | 33 + - include/linux/platform_data/x86/asus-wmi.h | 24 + - 15 files changed, 5436 insertions(+), 113 deletions(-) + drivers/platform/x86/asus-armoury.c | 1075 ++++++++ + drivers/platform/x86/asus-armoury.h | 1183 +++++++++ + drivers/platform/x86/asus-wmi.c | 273 +- + include/linux/platform_data/x86/asus-wmi.h | 28 + + 14 files changed, 5210 insertions(+), 76 deletions(-) create mode 100644 drivers/hid/hid-asus-ally.c create mode 100644 drivers/hid/hid-asus-ally.h create mode 100644 drivers/platform/x86/asus-armoury.c @@ -2237,7 +2236,7 @@ index 482b096eea28..7aba738d9355 100644 obj-$(CONFIG_HID_BETOP_FF) += hid-betopff.o diff --git a/drivers/hid/hid-asus-ally.c b/drivers/hid/hid-asus-ally.c new file mode 100644 -index 000000000000..c10121ebcbb8 +index 000000000000..7ffe0ae0d7aa --- /dev/null +++ b/drivers/hid/hid-asus-ally.c @@ -0,0 +1,2256 @@ @@ -2650,6 +2649,7 @@ index 000000000000..c10121ebcbb8 + struct ally_gamepad_cfg *gamepad_cfg; + struct ally_rgb_dev *led_rgb_dev; + struct ally_rgb_data led_rgb_data; ++ uint mcu_version; +} drvdata; + +static void reverse_bytes_in_pairs(u8 *buf, size_t size) { @@ -3523,6 +3523,13 @@ index 000000000000..c10121ebcbb8 + +DEVICE_ATTR_RW(gamepad_mode); + ++static ssize_t mcu_version_show(struct device *dev, struct device_attribute *attr, char *buf) ++{ ++ return sysfs_emit(buf, "%d\n", drvdata.mcu_version); ++} ++ ++DEVICE_ATTR_RO(mcu_version); ++ +/* ROOT LEVEL ATTRS *******************************************************************************/ +static struct attribute *gamepad_device_attrs[] = { + &dev_attr_btn_mapping_reset.attr, @@ -3530,6 +3537,7 @@ index 000000000000..c10121ebcbb8 + &dev_attr_gamepad_apply_all.attr, + &dev_attr_gamepad_vibration_intensity.attr, + &dev_attr_gamepad_vibration_intensity_index.attr, ++ &dev_attr_mcu_version.attr, + NULL +}; + @@ -4272,11 +4280,10 @@ index 000000000000..c10121ebcbb8 +static void mcu_maybe_warn_version(struct hid_device *hdev, int idProduct) +{ + int min_version, version; -+ struct asus_wmi *asus; -+ struct device *dev; + + min_version = ROG_ALLY_X_MIN_MCU; + version = mcu_request_version(hdev); ++ drvdata.mcu_version = version; + if (version) { + switch (idProduct) { + case USB_DEVICE_ID_ASUSTEK_ROG_NKEY_ALLY: @@ -4290,19 +4297,11 @@ index 000000000000..c10121ebcbb8 + + hid_info(hdev, "Ally device MCU version: %d\n", version); + if (version < min_version) { ++ set_ally_mcu_hack_available(false); + hid_warn(hdev, + "The MCU version must be %d or greater\n" + "Please update your MCU with official ASUS firmware release\n", + min_version); -+ /* Get the asus platform device */ -+ dev = bus_find_device_by_name(&platform_bus_type, NULL, "asus-nb-wmi"); -+ if (dev) { -+ asus = dev_get_drvdata(dev); -+ /* Do not show the powersave attribute if MCU version too low */ -+ if (asus) -+ asus->mcu_powersave_available = false; -+ put_device(dev); -+ } + } +} + @@ -5026,10 +5025,10 @@ index e1b142947067..fe3e7e7dede8 100644 obj-$(CONFIG_ASUS_TF103C_DOCK) += asus-tf103c-dock.o diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c new file mode 100644 -index 000000000000..7f968469a9e9 +index 000000000000..5768997ea2d3 --- /dev/null +++ b/drivers/platform/x86/asus-armoury.c -@@ -0,0 +1,1153 @@ +@@ -0,0 +1,1075 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Asus Armoury (WMI) attributes driver. This driver uses the fw_attributes @@ -5041,7 +5040,6 @@ index 000000000000..7f968469a9e9 + * Copyright(C) 2024 Luke Jones + */ + -+#include "asus-wmi.h" +#include "linux/cleanup.h" +#include +#include @@ -5092,7 +5090,40 @@ index 000000000000..7f968469a9e9 +#define CPU_PERF_CORE_COUNT_MIN 4 +#define CPU_POWR_CORE_COUNT_MIN 0 + -+static struct asus_wmi_armoury_interface wmi_armoury_interface; ++/* Tunables provided by ASUS for gaming laptops */ ++struct cpu_cores { ++ u32 cur_perf_cores; ++ u32 min_perf_cores; ++ u32 max_perf_cores; ++ u32 cur_power_cores; ++ u32 min_power_cores; ++ u32 max_power_cores; ++}; ++ ++struct rog_tunables { ++ const struct power_data *tuning_limits; ++ u32 ppt_pl1_spl; // cpu ++ u32 ppt_pl2_sppt; // cpu ++ u32 ppt_pl3_fppt; // cpu ++ u32 ppt_apu_sppt; // plat ++ u32 ppt_platform_sppt; // plat ++ ++ u32 nv_dynamic_boost; ++ u32 nv_temp_target; ++ u32 nv_tgp; ++}; ++ ++struct asus_armoury_priv { ++ struct device *fw_attr_dev; ++ struct kset *fw_attr_kset; ++ ++ struct cpu_cores *cpu_cores; ++ struct rog_tunables *rog_tunables; ++ u32 mini_led_dev_id; ++ u32 gpu_mux_dev_id; ++ ++ struct mutex mutex; ++}; + +static struct asus_armoury_priv asus_armoury = { + .mutex = __MUTEX_INITIALIZER(asus_armoury.mutex) @@ -5110,7 +5141,6 @@ index 000000000000..7f968469a9e9 + const struct attribute_group *attr_group; + u32 wmi_devid; +}; -+static const struct asus_attr_group armoury_attr_groups[]; + +static bool asus_wmi_is_present(u32 dev_id) +{ @@ -5214,26 +5244,6 @@ index 000000000000..7f968469a9e9 + return count; +} + -+ssize_t attr_uint_cache(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, -+ size_t count, u32 min, u32 max, u32 *store_value) -+{ -+ u32 value; -+ int err; -+ -+ err = kstrtouint(buf, 10, &value); -+ if (err) -+ return err; -+ -+ if (value < min || value > max) -+ return -EINVAL; -+ -+ if (store_value != NULL) -+ *store_value = value; -+ sysfs_notify(kobj, NULL, attr->attr.name); -+ -+ return count; -+} -+ +/* Mini-LED mode **************************************************************/ +static ssize_t mini_led_mode_current_value_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) @@ -5765,79 +5775,6 @@ index 000000000000..7f968469a9e9 +ATTR_GROUP_CORES_RW(cores_efficiency, "cores_efficiency", + "Set the max available efficiency cores"); + -+static ssize_t ppt_enabled_current_value_show(struct kobject *kobj, -+ struct kobj_attribute *attr, -+ char *buf) -+{ -+ bool enabled = false; -+ -+ if (wmi_armoury_interface.wmi_driver) -+ enabled = asus_wmi_get_fan_curves_enabled(0); -+ -+ return sysfs_emit(buf, "%d\n", enabled); -+} -+ -+static ssize_t ppt_enabled_current_value_store(struct kobject *kobj, -+ struct kobj_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = wmi_armoury_interface.wmi_driver; -+ const char *name; -+ u32 wmi_dev, set; -+ bool value; -+ int err, i; -+ -+ if (!asus) { -+ pr_debug("%s: wmi_driver is NULL\n", __func__); -+ return -ENODEV; -+ } -+ -+ err = kstrtobool(buf, &value); -+ if (err) -+ return err; -+ -+ /* Set enabled state */ -+ err = asus_wmi_set_fan_curves_enabled(asus, value); -+ if (err) -+ return err; -+ -+ for (i = 0; i < 21; i++) { -+ name = armoury_attr_groups[i].attr_group->name; -+ wmi_dev = armoury_attr_groups[i].wmi_devid; -+ -+ if (!asus_wmi_is_present(wmi_dev)) -+ continue; -+ -+ if (!strcmp(name, "ppt_pl1_spl")) -+ set = asus_armoury.rog_tunables->ppt_pl1_spl; -+ if (!strcmp(name, "ppt_pl2_sppt")) -+ set = asus_armoury.rog_tunables->ppt_pl2_sppt; -+ if (!strcmp(name, "ppt_pl3_fppt")) -+ set = asus_armoury.rog_tunables->ppt_pl3_fppt; -+ if (!strcmp(name, "ppt_apu_sppt")) -+ set = asus_armoury.rog_tunables->ppt_apu_sppt; -+ if (!strcmp(name, "ppt_apu_sppt")) -+ set = asus_armoury.rog_tunables->ppt_apu_sppt; -+ if (!strcmp(name, "nv_dynamic_boost")) -+ set = asus_armoury.rog_tunables->nv_dynamic_boost; -+ if (!strcmp(name, "nv_temp_target")) -+ set = asus_armoury.rog_tunables->nv_temp_target; -+ // if (!strcmp(name, "nv_base_tgp")) -+ // set = asus_armoury.rog_tunables->nv_base_tgp; -+ // if (!strcmp(name, "dgpu_tgp")) -+ // set = asus_armoury.rog_tunables->dgpu_tgp; -+ err = armoury_wmi_set_devstate(attr, value, wmi_dev); -+ if (err) -+ return err; -+ } -+ -+ notify_fan_curves_changed(); -+ return count; -+} -+ -+ATTR_GROUP_BOOL_CUSTOM(ppt_enabled, "ppt_enabled", -+ "Enable PPT tuning and custom fan curves"); -+ +/* Simple attribute creation */ +ATTR_GROUP_ROG_TUNABLE(ppt_pl1_spl, "ppt_pl1_spl", ASUS_WMI_DEVID_PPT_PL1_SPL, + "Set the CPU slow package limit"); @@ -5897,8 +5834,6 @@ index 000000000000..7f968469a9e9 + { &mcu_powersave_attr_group, ASUS_WMI_DEVID_MCU_POWERSAVE }, + { &panel_od_attr_group, ASUS_WMI_DEVID_PANEL_OD }, + { &panel_hd_mode_attr_group, ASUS_WMI_DEVID_PANEL_HD }, -+ -+ { &ppt_enabled_attr_group, ASUS_WMI_DEVID_CPU_FAN_CTRL }, +}; + +static int asus_fw_attr_add(void) @@ -5973,7 +5908,7 @@ index 000000000000..7f968469a9e9 + !strcmp(name, "ppt_pl3_fppt") || !strcmp(name, "ppt_apu_sppt") || + !strcmp(name, "ppt_platform_sppt") || !strcmp(name, "nv_dynamic_boost") || + !strcmp(name, "nv_temp_target") || !strcmp(name, "nv_base_tgp") || -+ !strcmp(name, "dgpu_tgp") || !strcmp(name, "ppt_enabled")) ++ !strcmp(name, "dgpu_tgp")) + { + should_create = false; + if (asus_armoury.rog_tunables && asus_armoury.rog_tunables->tuning_limits && @@ -5989,9 +5924,7 @@ index 000000000000..7f968469a9e9 + (!strcmp(name, "nv_dynamic_boost") && limits->nv_dynamic_boost_max) || + (!strcmp(name, "nv_temp_target") && limits->nv_temp_target_max) || + (!strcmp(name, "nv_base_tgp") && limits->nv_tgp_max) || -+ (!strcmp(name, "dgpu_tgp") && limits->nv_tgp_max) || -+ (!strcmp(name, "ppt_enabled") && -+ asus_armoury.rog_tunables->tuning_limits->requires_fan_curve)); ++ (!strcmp(name, "dgpu_tgp") && limits->nv_tgp_max)); + + /* Log error so users can report upstream */ + if (!should_create) @@ -6108,7 +6041,6 @@ index 000000000000..7f968469a9e9 +static int __init asus_fw_init(void) +{ + char *wmi_uid; -+ bool tuning; + int err; + + wmi_uid = wmi_get_acpi_device_uid(ASUS_WMI_MGMT_GUID); @@ -6140,8 +6072,7 @@ index 000000000000..7f968469a9e9 + if (!asus_armoury.rog_tunables) + return -ENOMEM; + /* Init logs warn/error and the driver should still be usable if init fails */ -+ tuning = init_rog_tunables(asus_armoury.rog_tunables); -+ if (!tuning) { ++ if (!init_rog_tunables(asus_armoury.rog_tunables)) { + kfree(asus_armoury.rog_tunables); + pr_err("Could not initialise PPT tunable control %d\n", err); + } @@ -6151,14 +6082,6 @@ index 000000000000..7f968469a9e9 + if (err) + return err; + -+ if (tuning) { -+ wmi_armoury_interface.armoury_fw_attr_dev = asus_armoury.fw_attr_dev; -+ wmi_armoury_interface.ppt_enabled_attr = &attr_ppt_enabled_current_value; -+ err = asus_wmi_register_armoury_interface(&wmi_armoury_interface); -+ if (err) -+ return err; -+ } -+ + return 0; +} + @@ -6170,8 +6093,6 @@ index 000000000000..7f968469a9e9 + kset_unregister(asus_armoury.fw_attr_kset); + device_destroy(&firmware_attributes_class, MKDEV(0, 0)); + -+ asus_wmi_unregister_armoury_interface(&wmi_armoury_interface); -+ + mutex_unlock(&asus_armoury.mutex); +} + @@ -6185,10 +6106,10 @@ index 000000000000..7f968469a9e9 +MODULE_ALIAS("wmi:" ASUS_NB_WMI_EVENT_GUID); diff --git a/drivers/platform/x86/asus-armoury.h b/drivers/platform/x86/asus-armoury.h new file mode 100644 -index 000000000000..a44265788103 +index 000000000000..735521585327 --- /dev/null +++ b/drivers/platform/x86/asus-armoury.h -@@ -0,0 +1,1231 @@ +@@ -0,0 +1,1183 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Definitions for kernel modules using asus-armoury driver @@ -6205,44 +6126,6 @@ index 000000000000..a44265788103 + +#define DRIVER_NAME "asus-armoury" + -+/* Tunables provided by ASUS for gaming laptops */ -+struct cpu_cores { -+ u32 cur_perf_cores; -+ u32 min_perf_cores; -+ u32 max_perf_cores; -+ u32 cur_power_cores; -+ u32 min_power_cores; -+ u32 max_power_cores; -+}; -+ -+struct rog_tunables { -+ const struct power_data *tuning_limits; -+ u32 ppt_pl1_spl; // cpu -+ u32 ppt_pl2_sppt; // cpu -+ u32 ppt_pl3_fppt; // cpu -+ u32 ppt_apu_sppt; // plat -+ u32 ppt_platform_sppt; // plat -+ -+ u32 nv_dynamic_boost; -+ u32 nv_temp_target; -+ u32 nv_tgp; -+}; -+ -+struct asus_armoury_priv { -+ struct device *fw_attr_dev; -+ struct kset *fw_attr_kset; -+ -+ struct cpu_cores *cpu_cores; -+ struct rog_tunables *rog_tunables; -+ u32 mini_led_dev_id; -+ u32 gpu_mux_dev_id; -+ -+ struct mutex mutex; -+}; -+ -+static ssize_t attr_uint_cache(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, -+ size_t count, u32 min, u32 max, u32 *store_value); -+ +static ssize_t attr_uint_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count, u32 min, u32 max, + u32 *store_value, u32 wmi_dev); @@ -6470,35 +6353,25 @@ index 000000000000..a44265788103 + const char *buf, size_t count) \ + { \ + const struct power_limits *limits; \ -+ int err; \ + limits = power_supply_is_system_supplied() ? \ -+ asus_armoury.rog_tunables->tuning_limits->ac_data : \ -+ asus_armoury.rog_tunables->tuning_limits->dc_data; \ ++ asus_armoury.rog_tunables->tuning_limits->ac_data : \ ++ asus_armoury.rog_tunables->tuning_limits->dc_data; \ + if (!limits) \ + return -ENODEV; \ -+ if (!asus_wmi_get_fan_curves_enabled(0)) { \ -+ err = attr_uint_cache(kobj, attr, buf, count, \ -+ limits->_attr##_min, \ -+ limits->_attr##_max, \ -+ &asus_armoury.rog_tunables->_attr); \ -+ if (err) \ -+ return err; \ -+ return count; \ -+ } \ -+ return attr_uint_store(kobj, attr, buf, count, \ ++ return attr_uint_store(kobj, attr, buf, count, \ + limits->_attr##_min, \ + limits->_attr##_max, \ -+ &asus_armoury.rog_tunables->_attr, \ -+ _wmi); \ ++ &asus_armoury.rog_tunables->_attr, \ ++ _wmi); \ + } \ -+ static ssize_t _attr##_current_value_show( \ ++ static ssize_t _attr##_current_value_show( \ + struct kobject *kobj, struct kobj_attribute *attr, \ + char *buf) \ + { \ -+ return sysfs_emit(buf, "%u\n", \ -+ asus_armoury.rog_tunables->_attr); \ ++ return sysfs_emit(buf, "%u\n", \ ++ asus_armoury.rog_tunables->_attr); \ + } \ -+ static struct kobj_attribute attr_##_attr##_current_value = \ ++ static struct kobj_attribute attr_##_attr##_current_value = \ + __ASUS_ATTR_RW(_attr, current_value) + +#define ATTR_GROUP_ROG_TUNABLE(_attrname, _fsname, _wmi, _dispname) \ @@ -7421,7 +7294,7 @@ index 000000000000..a44265788103 + +#endif /* _ASUS_ARMOURY_H_ */ diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index 38ef778e8c19..6bcc8974d525 100644 +index 38ef778e8c19..deb73593d952 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -55,8 +55,6 @@ module_param(fnlock_default, bool, 0444); @@ -7442,28 +7315,32 @@ index 38ef778e8c19..6bcc8974d525 100644 #define WMI_EVENT_MASK 0xFFFF #define FAN_CURVE_POINTS 8 -@@ -142,11 +138,6 @@ module_param(fnlock_default, bool, 0444); +@@ -142,16 +138,20 @@ module_param(fnlock_default, bool, 0444); #define ASUS_MINI_LED_2024_STRONG 0x01 #define ASUS_MINI_LED_2024_OFF 0x02 -/* Controls the power state of the USB0 hub on ROG Ally which input is on */ --#define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE" + #define ASUS_USB0_PWR_EC0_CSEE "\\_SB.PCI0.SBRG.EC0.CSEE" -/* 300ms so far seems to produce a reliable result on AC and battery */ -#define ASUS_USB0_PWR_EC0_CSEE_WAIT 1500 -- ++/* ++ * The period required to wait after screen off/on/s2idle.check in MS. ++ * Time here greatly impacts the wake behaviour. Used in suspend/wake. ++ */ ++#define ASUS_USB0_PWR_EC0_CSEE_WAIT 600 ++#define ASUS_USB0_PWR_EC0_CSEE_OFF 0xB7 ++#define ASUS_USB0_PWR_EC0_CSEE_ON 0xB8 + static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; static int throttle_thermal_policy_write(struct asus_wmi *); -@@ -238,6 +229,8 @@ struct fan_curve_data { - u8 percents[FAN_CURVE_POINTS]; - }; -+static struct asus_wmi_armoury_interface wmi_armoury_interface; -+ - struct asus_wmi { - int dsts_id; - int spec; -@@ -274,9 +267,6 @@ struct asus_wmi { +-static const struct dmi_system_id asus_ally_mcu_quirk[] = { ++static const struct dmi_system_id asus_rog_ally_device[] = { + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "RC71L"), +@@ -274,9 +274,6 @@ struct asus_wmi { u32 tablet_switch_dev_id; bool tablet_switch_inverted; @@ -7473,10 +7350,22 @@ index 38ef778e8c19..6bcc8974d525 100644 enum fan_type fan_type; enum fan_type gpu_fan_type; enum fan_type mid_fan_type; -@@ -335,6 +325,15 @@ struct asus_wmi { +@@ -335,6 +332,27 @@ struct asus_wmi { struct asus_wmi_driver *driver; }; ++static bool ally_mcu_usb_plug; ++ ++/* ++ * The HID driver needs to check MCU version and set this to false if the MCU FW ++ * version is >= the minimum requirements. New FW do not need the hacks. ++ */ ++void set_ally_mcu_hack_available(bool enabled) ++{ ++ ally_mcu_usb_plug = enabled; ++} ++EXPORT_SYMBOL_NS_GPL(set_ally_mcu_hack_available, "ASUS_WMI"); ++ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) +static void asus_wmi_show_deprecated(void) +{ @@ -7489,7 +7378,7 @@ index 38ef778e8c19..6bcc8974d525 100644 /* WMI ************************************************************************/ static int asus_wmi_evaluate_method3(u32 method_id, -@@ -385,7 +384,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) +@@ -385,7 +403,7 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) { return asus_wmi_evaluate_method3(method_id, arg0, arg1, 0, retval); } @@ -7498,37 +7387,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static int asus_wmi_evaluate_method5(u32 method_id, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval) -@@ -406,10 +405,10 @@ static int asus_wmi_evaluate_method5(u32 method_id, - status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id, - &input, &output); - -- pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", -+ pr_warn("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x\n", - __func__, method_id, arg0, arg1, arg2, arg3, arg4); - if (ACPI_FAILURE(status)) { -- pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n", -+ pr_warn("%s, (0x%08x), arg 0x%08x failed: %d\n", - __func__, method_id, arg0, -EIO); - return -EIO; - } -@@ -418,14 +417,14 @@ static int asus_wmi_evaluate_method5(u32 method_id, - if (obj && obj->type == ACPI_TYPE_INTEGER) - tmp = (u32) obj->integer.value; - -- pr_debug("Result: %x\n", tmp); -+ pr_warn("Result: %x\n", tmp); - if (retval) - *retval = tmp; - - kfree(obj); - - if (tmp == ASUS_WMI_UNSUPPORTED_METHOD) { -- pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n", -+ pr_warn("%s, (0x%08x), arg 0x%08x failed: %d\n", - __func__, method_id, arg0, -ENODEV); - return -ENODEV; - } -@@ -549,12 +548,50 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) +@@ -549,12 +567,50 @@ static int asus_wmi_get_devstate(struct asus_wmi *asus, u32 dev_id, u32 *retval) return 0; } @@ -7581,7 +7440,7 @@ index 38ef778e8c19..6bcc8974d525 100644 /* Helper for special devices with magic return codes */ static int asus_wmi_get_devstate_bits(struct asus_wmi *asus, -@@ -687,6 +724,7 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus) +@@ -687,6 +743,7 @@ static void asus_wmi_tablet_mode_get_state(struct asus_wmi *asus) } /* Charging mode, 1=Barrel, 2=USB ******************************************/ @@ -7589,7 +7448,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t charge_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -697,12 +735,16 @@ static ssize_t charge_mode_show(struct device *dev, +@@ -697,12 +754,16 @@ static ssize_t charge_mode_show(struct device *dev, if (result < 0) return result; @@ -7606,7 +7465,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t dgpu_disable_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -713,6 +755,8 @@ static ssize_t dgpu_disable_show(struct device *dev, +@@ -713,6 +774,8 @@ static ssize_t dgpu_disable_show(struct device *dev, if (result < 0) return result; @@ -7615,7 +7474,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -766,8 +810,10 @@ static ssize_t dgpu_disable_store(struct device *dev, +@@ -766,8 +829,10 @@ static ssize_t dgpu_disable_store(struct device *dev, return count; } static DEVICE_ATTR_RW(dgpu_disable); @@ -7626,7 +7485,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t egpu_enable_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -778,6 +824,8 @@ static ssize_t egpu_enable_show(struct device *dev, +@@ -778,6 +843,8 @@ static ssize_t egpu_enable_show(struct device *dev, if (result < 0) return result; @@ -7635,7 +7494,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -834,8 +882,10 @@ static ssize_t egpu_enable_store(struct device *dev, +@@ -834,8 +901,10 @@ static ssize_t egpu_enable_store(struct device *dev, return count; } static DEVICE_ATTR_RW(egpu_enable); @@ -7646,7 +7505,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t egpu_connected_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -846,12 +896,16 @@ static ssize_t egpu_connected_show(struct device *dev, +@@ -846,12 +915,16 @@ static ssize_t egpu_connected_show(struct device *dev, if (result < 0) return result; @@ -7663,7 +7522,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t gpu_mux_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -862,6 +916,8 @@ static ssize_t gpu_mux_mode_show(struct device *dev, +@@ -862,6 +935,8 @@ static ssize_t gpu_mux_mode_show(struct device *dev, if (result < 0) return result; @@ -7672,7 +7531,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -920,6 +976,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, +@@ -920,6 +995,7 @@ static ssize_t gpu_mux_mode_store(struct device *dev, return count; } static DEVICE_ATTR_RW(gpu_mux_mode); @@ -7680,7 +7539,7 @@ index 38ef778e8c19..6bcc8974d525 100644 /* TUF Laptop Keyboard RGB Modes **********************************************/ static ssize_t kbd_rgb_mode_store(struct device *dev, -@@ -1043,6 +1100,7 @@ static const struct attribute_group *kbd_rgb_mode_groups[] = { +@@ -1043,6 +1119,7 @@ static const struct attribute_group *kbd_rgb_mode_groups[] = { }; /* Tunable: PPT: Intel=PL1, AMD=SPPT *****************************************/ @@ -7688,7 +7547,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t ppt_pl2_sppt_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) -@@ -1081,6 +1139,8 @@ static ssize_t ppt_pl2_sppt_show(struct device *dev, +@@ -1081,6 +1158,8 @@ static ssize_t ppt_pl2_sppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7697,7 +7556,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%u\n", asus->ppt_pl2_sppt); } static DEVICE_ATTR_RW(ppt_pl2_sppt); -@@ -1123,6 +1183,8 @@ static ssize_t ppt_pl1_spl_show(struct device *dev, +@@ -1123,6 +1202,8 @@ static ssize_t ppt_pl1_spl_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7706,7 +7565,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%u\n", asus->ppt_pl1_spl); } static DEVICE_ATTR_RW(ppt_pl1_spl); -@@ -1166,6 +1228,8 @@ static ssize_t ppt_fppt_show(struct device *dev, +@@ -1166,6 +1247,8 @@ static ssize_t ppt_fppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7715,7 +7574,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%u\n", asus->ppt_fppt); } static DEVICE_ATTR_RW(ppt_fppt); -@@ -1209,6 +1273,8 @@ static ssize_t ppt_apu_sppt_show(struct device *dev, +@@ -1209,6 +1292,8 @@ static ssize_t ppt_apu_sppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7724,7 +7583,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%u\n", asus->ppt_apu_sppt); } static DEVICE_ATTR_RW(ppt_apu_sppt); -@@ -1252,6 +1318,8 @@ static ssize_t ppt_platform_sppt_show(struct device *dev, +@@ -1252,6 +1337,8 @@ static ssize_t ppt_platform_sppt_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7733,7 +7592,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%u\n", asus->ppt_platform_sppt); } static DEVICE_ATTR_RW(ppt_platform_sppt); -@@ -1295,6 +1363,8 @@ static ssize_t nv_dynamic_boost_show(struct device *dev, +@@ -1295,6 +1382,8 @@ static ssize_t nv_dynamic_boost_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7742,7 +7601,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%u\n", asus->nv_dynamic_boost); } static DEVICE_ATTR_RW(nv_dynamic_boost); -@@ -1338,11 +1408,15 @@ static ssize_t nv_temp_target_show(struct device *dev, +@@ -1338,11 +1427,15 @@ static ssize_t nv_temp_target_show(struct device *dev, { struct asus_wmi *asus = dev_get_drvdata(dev); @@ -7758,7 +7617,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t mcu_powersave_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -1353,6 +1427,8 @@ static ssize_t mcu_powersave_show(struct device *dev, +@@ -1353,6 +1446,8 @@ static ssize_t mcu_powersave_show(struct device *dev, if (result < 0) return result; @@ -7767,7 +7626,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -1388,6 +1464,7 @@ static ssize_t mcu_powersave_store(struct device *dev, +@@ -1388,6 +1483,7 @@ static ssize_t mcu_powersave_store(struct device *dev, return count; } static DEVICE_ATTR_RW(mcu_powersave); @@ -7775,7 +7634,7 @@ index 38ef778e8c19..6bcc8974d525 100644 /* Battery ********************************************************************/ -@@ -2261,6 +2338,7 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) +@@ -2261,6 +2357,7 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus) } /* Panel Overdrive ************************************************************/ @@ -7783,7 +7642,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t panel_od_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -2271,6 +2349,8 @@ static ssize_t panel_od_show(struct device *dev, +@@ -2271,6 +2368,8 @@ static ssize_t panel_od_show(struct device *dev, if (result < 0) return result; @@ -7792,7 +7651,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -2307,9 +2387,10 @@ static ssize_t panel_od_store(struct device *dev, +@@ -2307,9 +2406,10 @@ static ssize_t panel_od_store(struct device *dev, return count; } static DEVICE_ATTR_RW(panel_od); @@ -7804,7 +7663,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t boot_sound_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -2320,6 +2401,8 @@ static ssize_t boot_sound_show(struct device *dev, +@@ -2320,6 +2420,8 @@ static ssize_t boot_sound_show(struct device *dev, if (result < 0) return result; @@ -7813,7 +7672,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", result); } -@@ -2355,8 +2438,10 @@ static ssize_t boot_sound_store(struct device *dev, +@@ -2355,8 +2457,10 @@ static ssize_t boot_sound_store(struct device *dev, return count; } static DEVICE_ATTR_RW(boot_sound); @@ -7824,7 +7683,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t mini_led_mode_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -2387,6 +2472,8 @@ static ssize_t mini_led_mode_show(struct device *dev, +@@ -2387,6 +2491,8 @@ static ssize_t mini_led_mode_show(struct device *dev, } } @@ -7833,7 +7692,7 @@ index 38ef778e8c19..6bcc8974d525 100644 return sysfs_emit(buf, "%d\n", value); } -@@ -2457,10 +2544,13 @@ static ssize_t available_mini_led_mode_show(struct device *dev, +@@ -2457,10 +2563,13 @@ static ssize_t available_mini_led_mode_show(struct device *dev, return sysfs_emit(buf, "0 1 2\n"); } @@ -7847,203 +7706,7 @@ index 38ef778e8c19..6bcc8974d525 100644 /* Quirks *********************************************************************/ -@@ -2982,6 +3072,72 @@ static struct attribute *hwmon_attributes[] = { - NULL - }; - -+int asus_wmi_register_armoury_interface(struct asus_wmi_armoury_interface *armoury_interface) -+{ -+ if (!armoury_interface->armoury_fw_attr_dev) -+ return -EINVAL; -+ -+ if (!armoury_interface->ppt_enabled_attr) -+ return -EINVAL; -+ -+ if (!wmi_armoury_interface.wmi_driver) -+ return -EINVAL; -+ -+ if (!wmi_armoury_interface.fan_curves_enabled_attr) -+ return -EINVAL; -+ -+ wmi_armoury_interface.armoury_fw_attr_dev = armoury_interface->armoury_fw_attr_dev; -+ wmi_armoury_interface.ppt_enabled_attr = armoury_interface->ppt_enabled_attr; -+ armoury_interface->wmi_driver = wmi_armoury_interface.wmi_driver; -+ armoury_interface->fan_curves_enabled_attr = wmi_armoury_interface.fan_curves_enabled_attr; -+ -+ return 0; -+} -+EXPORT_SYMBOL_NS_GPL(asus_wmi_register_armoury_interface, "ASUS_WMI"); -+ -+void asus_wmi_unregister_armoury_interface(struct asus_wmi_armoury_interface *armoury_interface) -+{ -+ wmi_armoury_interface.armoury_fw_attr_dev = NULL; -+ wmi_armoury_interface.ppt_enabled_attr = NULL; -+ armoury_interface->wmi_driver = NULL; -+ armoury_interface->fan_curves_enabled_attr = NULL; -+} -+EXPORT_SYMBOL_NS_GPL(asus_wmi_unregister_armoury_interface, "ASUS_WMI"); -+ -+bool asus_wmi_get_fan_curves_enabled(uint fan) -+{ -+ if (!wmi_armoury_interface.wmi_driver) -+ pr_debug("%s: wmi_driver is NULL\n", __func__); -+ -+ if (!wmi_armoury_interface.wmi_driver) -+ return false; -+ -+ return wmi_armoury_interface.wmi_driver->custom_fan_curves[fan].enabled; -+} -+EXPORT_SYMBOL_NS_GPL(asus_wmi_get_fan_curves_enabled, "ASUS_WMI"); -+ -+/* Notification helpers */ -+void notify_fan_curves_changed(void) -+{ -+ struct device *dev; -+ if (!interface_is_ready(&wmi_armoury_interface)) -+ return; -+ -+ /* Notify both attributes */ -+ if (wmi_armoury_interface.fan_curves_enabled_attr) { -+ dev = &wmi_armoury_interface.wmi_driver->platform_device->dev; -+ sysfs_notify(&dev->kobj, NULL, -+ wmi_armoury_interface.fan_curves_enabled_attr->attr.name); -+ } -+ -+ if (wmi_armoury_interface.ppt_enabled_attr) { -+ dev = wmi_armoury_interface.armoury_fw_attr_dev; -+ sysfs_notify(&dev->kobj, NULL, -+ wmi_armoury_interface.ppt_enabled_attr->attr.name); -+ } -+} -+EXPORT_SYMBOL_NS_GPL(notify_fan_curves_changed, "ASUS_WMI"); -+ - static umode_t asus_hwmon_sysfs_is_visible(struct kobject *kobj, - struct attribute *attr, int idx) - { -@@ -3367,6 +3523,52 @@ static ssize_t fan_curve_store(struct device *dev, - return count; - } - -+int asus_wmi_set_fan_curves_enabled(struct asus_wmi *asus, bool enabled) -+{ -+ int err; -+ -+ /* Set enabled state for all available fan curves */ -+ if (asus->cpu_fan_curve_available) -+ asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled = enabled; -+ if (asus->gpu_fan_curve_available) -+ asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled = enabled; -+ if (asus->mid_fan_curve_available) -+ asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled = enabled; -+ -+ if (enabled) { -+ if (asus->cpu_fan_curve_available) { -+ err = fan_curve_write(asus, &asus->custom_fan_curves[FAN_CURVE_DEV_CPU]); -+ if (err) -+ return err; -+ } -+ if (asus->gpu_fan_curve_available) { -+ err = fan_curve_write(asus, &asus->custom_fan_curves[FAN_CURVE_DEV_GPU]); -+ if (err) -+ return err; -+ } -+ if (asus->mid_fan_curve_available) { -+ /* -+ * Some laptops error with ASUS_WMI_UNSUPPORTED_METHOD -+ * even though it works due to bugged bios acpi -+ */ -+ fan_curve_write(asus, &asus->custom_fan_curves[FAN_CURVE_DEV_MID]); -+ } -+ } else { -+ if (asus->throttle_thermal_policy_dev) { -+ err = throttle_thermal_policy_write(asus); -+ if (err) -+ return err; -+ } else { -+ err = asus_fan_set_auto(asus); -+ if (err) -+ return err; -+ } -+ } -+ -+ return 0; -+} -+EXPORT_SYMBOL_NS_GPL(asus_wmi_set_fan_curves_enabled, "ASUS_WMI"); -+ - static ssize_t fan_curve_enable_show(struct device *dev, - struct device_attribute *attr, char *buf) - { -@@ -3398,10 +3600,10 @@ static ssize_t fan_curve_enable_store(struct device *dev, - - switch (value) { - case 1: -- data->enabled = true; -+ err = asus_wmi_set_fan_curves_enabled(asus, true); - break; - case 2: -- data->enabled = false; -+ err = asus_wmi_set_fan_curves_enabled(asus, false); - break; - /* - * Auto + reset the fan curve data to defaults. Make it an explicit -@@ -3411,40 +3613,17 @@ static ssize_t fan_curve_enable_store(struct device *dev, - err = fan_curve_get_factory_default(asus, data->device_id); - if (err) - return err; -- data->enabled = false; -+ err = asus_wmi_set_fan_curves_enabled(asus, false); - break; - default: - return -EINVAL; - } - -- if (data->enabled) { -- err = fan_curve_write(asus, data); -- if (err) -- return err; -- } else { -- /* -- * For machines with throttle this is the only way to reset fans -- * to default mode of operation (does not erase curve data). -- */ -- if (asus->throttle_thermal_policy_dev) { -- err = throttle_thermal_policy_write(asus); -- if (err) -- return err; -- /* Similar is true for laptops with this fan */ -- } else if (asus->fan_type == FAN_TYPE_SPEC83) { -- err = asus_fan_set_auto(asus); -- if (err) -- return err; -- } else { -- /* Safeguard against fautly ACPI tables */ -- err = fan_curve_get_factory_default(asus, data->device_id); -- if (err) -- return err; -- err = fan_curve_write(asus, data); -- if (err) -- return err; -- } -- } -+ if (err) -+ return err; -+ -+ notify_fan_curves_changed(); -+ - return count; - } - -@@ -3690,6 +3869,9 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus) - return PTR_ERR(hwmon); - } - -+ wmi_armoury_interface.wmi_driver = asus; -+ wmi_armoury_interface.fan_curves_enabled_attr = &dev_attr_pwm1_enable; -+ - return 0; - } - -@@ -3748,6 +3930,7 @@ static int throttle_thermal_policy_set_default(struct asus_wmi *asus) +@@ -3748,6 +3857,7 @@ static int throttle_thermal_policy_set_default(struct asus_wmi *asus) return throttle_thermal_policy_write(asus); } @@ -8051,7 +7714,7 @@ index 38ef778e8c19..6bcc8974d525 100644 static ssize_t throttle_thermal_policy_show(struct device *dev, struct device_attribute *attr, char *buf) { -@@ -3791,6 +3974,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, +@@ -3791,6 +3901,7 @@ static ssize_t throttle_thermal_policy_store(struct device *dev, * Throttle thermal policy: 0 - default, 1 - overboost, 2 - silent */ static DEVICE_ATTR_RW(throttle_thermal_policy); @@ -8059,7 +7722,7 @@ index 38ef778e8c19..6bcc8974d525 100644 /* Platform profile ***********************************************************/ static int asus_wmi_platform_profile_get(struct device *dev, -@@ -3810,7 +3994,7 @@ static int asus_wmi_platform_profile_get(struct device *dev, +@@ -3810,7 +3921,7 @@ static int asus_wmi_platform_profile_get(struct device *dev, *profile = PLATFORM_PROFILE_PERFORMANCE; break; case ASUS_THROTTLE_THERMAL_POLICY_SILENT: @@ -8068,7 +7731,7 @@ index 38ef778e8c19..6bcc8974d525 100644 break; default: return -EINVAL; -@@ -3834,7 +4018,7 @@ static int asus_wmi_platform_profile_set(struct device *dev, +@@ -3834,7 +3945,7 @@ static int asus_wmi_platform_profile_set(struct device *dev, case PLATFORM_PROFILE_BALANCED: tp = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT; break; @@ -8077,7 +7740,7 @@ index 38ef778e8c19..6bcc8974d525 100644 tp = ASUS_THROTTLE_THERMAL_POLICY_SILENT; break; default: -@@ -3847,7 +4031,7 @@ static int asus_wmi_platform_profile_set(struct device *dev, +@@ -3847,7 +3958,7 @@ static int asus_wmi_platform_profile_set(struct device *dev, static int asus_wmi_platform_profile_probe(void *drvdata, unsigned long *choices) { @@ -8086,7 +7749,7 @@ index 38ef778e8c19..6bcc8974d525 100644 set_bit(PLATFORM_PROFILE_BALANCED, choices); set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); -@@ -4392,27 +4576,29 @@ static struct attribute *platform_attributes[] = { +@@ -4392,27 +4503,29 @@ static struct attribute *platform_attributes[] = { &dev_attr_camera.attr, &dev_attr_cardr.attr, &dev_attr_touchpad.attr, @@ -8134,7 +7797,7 @@ index 38ef778e8c19..6bcc8974d525 100644 NULL }; -@@ -4434,7 +4620,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, +@@ -4434,7 +4547,11 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, devid = ASUS_WMI_DEVID_LID_RESUME; else if (attr == &dev_attr_als_enable.attr) devid = ASUS_WMI_DEVID_ALS_ENABLE; @@ -8147,7 +7810,7 @@ index 38ef778e8c19..6bcc8974d525 100644 devid = ASUS_WMI_DEVID_CHARGE_MODE; else if (attr == &dev_attr_egpu_enable.attr) ok = asus->egpu_enable_available; -@@ -4472,6 +4662,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, +@@ -4472,6 +4589,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, ok = asus->mini_led_dev_id != 0; else if (attr == &dev_attr_available_mini_led_mode.attr) ok = asus->mini_led_dev_id != 0; @@ -8155,15 +7818,27 @@ index 38ef778e8c19..6bcc8974d525 100644 if (devid != -1) { ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); -@@ -4712,6 +4903,7 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -4711,7 +4829,19 @@ static int asus_wmi_add(struct platform_device *pdev) + if (err) goto fail_platform; ++ ally_mcu_usb_plug = acpi_has_method(NULL, ASUS_USB0_PWR_EC0_CSEE) ++ && dmi_check_system(asus_rog_ally_device); ++ if (ally_mcu_usb_plug && dmi_match(DMI_BOARD_NAME, "RC71")) { ++ /* ++ * These steps ensure the device is in a valid good state, this is ++ * especially important for the Ally 1 after a reboot. ++ */ ++ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ASUS_USB0_PWR_EC0_CSEE_ON); ++ msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); ++ } ++ /* ensure defaults for tunables */ +#if IS_ENABLED(CONFIG_ASUS_WMI_DEPRECATED_ATTRS) asus->ppt_pl2_sppt = 5; asus->ppt_pl1_spl = 5; asus->ppt_apu_sppt = 5; -@@ -4723,8 +4915,6 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -4723,8 +4853,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->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); @@ -8172,7 +7847,7 @@ index 38ef778e8c19..6bcc8974d525 100644 if (asus_wmi_dev_is_present(asus, ASUS_WMI_DEVID_MINI_LED_MODE)) asus->mini_led_dev_id = ASUS_WMI_DEVID_MINI_LED_MODE; -@@ -4735,17 +4925,18 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -4735,17 +4863,18 @@ static int asus_wmi_add(struct platform_device *pdev) 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; @@ -8196,7 +7871,7 @@ index 38ef778e8c19..6bcc8974d525 100644 err = fan_boost_mode_check_present(asus); if (err) goto fail_fan_boost_mode; -@@ -4910,34 +5101,6 @@ static int asus_hotk_resume(struct device *device) +@@ -4910,34 +5039,6 @@ static int asus_hotk_resume(struct device *device) return 0; } @@ -8231,59 +7906,61 @@ index 38ef778e8c19..6bcc8974d525 100644 static int asus_hotk_restore(struct device *device) { struct asus_wmi *asus = dev_get_drvdata(device); -@@ -4982,8 +5145,6 @@ static const struct dev_pm_ops asus_pm_ops = { +@@ -4978,11 +5079,32 @@ static int asus_hotk_restore(struct device *device) + return 0; + } + ++static void asus_ally_s2idle_restore(void) ++{ ++ if (ally_mcu_usb_plug) { ++ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ASUS_USB0_PWR_EC0_CSEE_ON); ++ msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); ++ } ++} ++ ++static int asus_hotk_prepare(struct device *device) ++{ ++ if (ally_mcu_usb_plug) { ++ acpi_execute_simple_method(NULL, ASUS_USB0_PWR_EC0_CSEE, ASUS_USB0_PWR_EC0_CSEE_OFF); ++ msleep(ASUS_USB0_PWR_EC0_CSEE_WAIT); ++ } ++ return 0; ++} ++ ++/* Use only for Ally devices due to the wake_on_ac */ ++static struct acpi_s2idle_dev_ops asus_ally_s2idle_dev_ops = { ++ .restore = asus_ally_s2idle_restore, ++}; ++ + static const struct dev_pm_ops asus_pm_ops = { .thaw = asus_hotk_thaw, .restore = asus_hotk_restore, .resume = asus_hotk_resume, - .resume_early = asus_hotk_resume_early, -- .prepare = asus_hotk_prepare, + .prepare = asus_hotk_prepare, }; - /* Registration ***************************************************************/ -diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h -index 018dfde4025e..e7e566acbca6 100644 ---- a/drivers/platform/x86/asus-wmi.h -+++ b/drivers/platform/x86/asus-wmi.h -@@ -85,4 +85,37 @@ struct asus_wmi_driver { - int asus_wmi_register_driver(struct asus_wmi_driver *driver); - void asus_wmi_unregister_driver(struct asus_wmi_driver *driver); +@@ -5010,6 +5132,10 @@ static int asus_wmi_probe(struct platform_device *pdev) + return ret; + } ++ ret = acpi_register_lps0_dev(&asus_ally_s2idle_dev_ops); ++ if (ret) ++ pr_warn("failed to register LPS0 sleep handler in asus-wmi\n"); + -+/* asus_armoury and asus_wmi need a copy each, with members filled on register */ -+struct asus_wmi_armoury_interface { -+ /* Driver instances */ -+ struct asus_wmi *wmi_driver; -+ /* Required so asus_wmi can notify the related attribute */ -+ struct device *armoury_fw_attr_dev; -+ -+ /* Attribute references for cross-notification */ -+ struct device_attribute *fan_curves_enabled_attr; /* From asus_wmi */ -+ struct kobj_attribute *ppt_enabled_attr; /* From asus_armoury */ -+}; -+ -+int asus_wmi_register_armoury_interface(struct asus_wmi_armoury_interface *armoury_interface); -+void asus_wmi_unregister_armoury_interface(struct asus_wmi_armoury_interface *armoury_interface); -+ -+/* Helper to check if interface is ready */ -+static inline bool interface_is_ready(struct asus_wmi_armoury_interface *wmi_armoury_interface) -+{ -+ if (!wmi_armoury_interface->wmi_driver) -+ pr_debug("%s: wmi_driver is NULL\n", __func__); -+ if (!wmi_armoury_interface->armoury_fw_attr_dev) -+ pr_debug("%s: armoury_fw_attr_dev is NULL\n", __func__); -+ return wmi_armoury_interface->wmi_driver && -+ wmi_armoury_interface->armoury_fw_attr_dev; -+} -+ -+void notify_fan_curves_changed(void); -+ -+bool asus_wmi_get_fan_curves_enabled(uint fan); -+ -+int asus_wmi_set_fan_curves_enabled(struct asus_wmi *asus, bool enabled); -+ - #endif /* !_ASUS_WMI_H_ */ + return asus_wmi_add(pdev); + } + +@@ -5042,6 +5168,7 @@ EXPORT_SYMBOL_GPL(asus_wmi_register_driver); + + void asus_wmi_unregister_driver(struct asus_wmi_driver *driver) + { ++ acpi_unregister_lps0_dev(&asus_ally_s2idle_dev_ops); + platform_device_unregister(driver->platform_device); + platform_driver_unregister(&driver->platform_driver); + used = false; diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h -index 783e2a336861..761bb228bcfb 100644 +index 783e2a336861..8e90d2221706 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -6,6 +6,9 @@ @@ -8321,14 +7998,18 @@ index 783e2a336861..761bb228bcfb 100644 /* gpu mux switch, 0 = dGPU, 1 = Optimus */ #define ASUS_WMI_DEVID_GPU_MUX 0x00090016 #define ASUS_WMI_DEVID_GPU_MUX_VIVO 0x00090026 -@@ -158,8 +172,18 @@ +@@ -158,8 +172,22 @@ #define ASUS_WMI_DSTS_LIGHTBAR_MASK 0x0000000F #if IS_REACHABLE(CONFIG_ASUS_WMI) ++void set_ally_mcu_hack_available(bool enabled); +int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval); +int asus_wmi_set_devstate(u32 dev_id, u32 ctrl_param, u32 *retval); int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval); #else ++static inline void set_ally_mcu_hack_available(bool enabled) { ++ return -ENODEV; ++} +static inline int asus_wmi_get_devstate_dsts(u32 dev_id, u32 *retval) +{ + return -ENODEV; @@ -8341,14 +8022,14 @@ index 783e2a336861..761bb228bcfb 100644 u32 *retval) { -- -2.48.1 +2.48.0.rc1 -From b6629e2e27b6bc7d6006500dde841c45d1d178de Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:49:45 +0800 +From 0e78cf1e12886a0caa4716ee5910bc26ab79bb76 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:38:33 +0100 Subject: [PATCH 4/9] bbr3 -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- include/linux/tcp.h | 4 +- include/net/inet_connection_sock.h | 4 +- @@ -11727,14 +11408,14 @@ index b412ed88ccd9..d70f8b742b21 100644 event = icsk->icsk_pending; -- -2.48.1 +2.48.0.rc1 -From 37e983bd3a048828771d1a9379c93b619cdda084 Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:49:54 +0800 +From 4f54c7ee952b2e76ff763f418c10fd45d7217ab5 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:38:45 +0100 Subject: [PATCH 5/9] cachy -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- .../admin-guide/kernel-parameters.txt | 12 + Makefile | 8 + @@ -19482,14 +19163,14 @@ index e4decfb270fa..38bff2d8a740 100644 release_sock(sk); if (reqsk_queue_empty(&icsk->icsk_accept_queue)) -- -2.48.1 +2.48.0.rc1 -From 43f08216a28bacd58ccb54d9a61e8164fc55b5be Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:50:03 +0800 +From 5b49b5dab4f2c5414c319cbee2dd69b557e227b5 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:39:01 +0100 Subject: [PATCH 6/9] crypto -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- MAINTAINERS | 1 + arch/x86/Kconfig | 2 +- @@ -21956,14 +21637,14 @@ index 000000000000..608714ba451e + else: + raise ValueError(f'Unknown consts_type: {consts_type}') -- -2.48.1 +2.48.0.rc1 -From a75ceb8efcdcc1085525ab31747a2b4849b6d0e4 Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:50:13 +0800 +From 4fed6c2b7cc05227a22467987b343973598bc788 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:39:13 +0100 Subject: [PATCH 7/9] fixes -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- arch/Kconfig | 4 ++-- drivers/gpu/drm/drm_edid.c | 47 +++++++++++++++++++++++++++++++++++--- @@ -22135,14 +21816,14 @@ index 753dbc4f8198..096c4eeaab57 100644 warned = true; } -- -2.48.1 +2.48.0.rc1 -From 9ff3ff1b55e44c71811787bd933721a2472bdb65 Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:50:19 +0800 +From 294f60c1d926a717f8a40fe35deb0029421f3d12 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 17:49:15 +0100 Subject: [PATCH 8/9] mm -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- include/linux/pid.h | 7 +- kernel/exit.c | 36 +++++++---- @@ -22754,14 +22435,14 @@ index 49f3a75046f6..6eb7cf1cccce 100644 ret = (total_len - iov_iter_count(iter)) ? : ret; -- -2.48.1 +2.48.0.rc1 -From aa5f9f2f21fefea3cb480c4a319b211031cd51f6 Mon Sep 17 00:00:00 2001 -From: Eric Naim -Date: Mon, 10 Feb 2025 09:50:37 +0800 +From 320b966f565cf8d1b06b66af3110911c9690cce5 Mon Sep 17 00:00:00 2001 +From: Peter Jung +Date: Mon, 10 Feb 2025 16:39:48 +0100 Subject: [PATCH 9/9] zstd -Signed-off-by: Eric Naim +Signed-off-by: Peter Jung --- include/linux/zstd.h | 2 +- include/linux/zstd_errors.h | 23 +- @@ -41406,4 +41087,5 @@ index 469fc3059be0..0ae819f0c927 100644 EXPORT_SYMBOL(zstd_reset_dstream); -- -2.48.1 +2.48.0.rc1 +