aboutsummarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO94
-rw-r--r--.gitignore9
-rw-r--r--0101-asus-wmi-Add-panel-overdrive-functionality.patch166
-rw-r--r--0102-asus-wmi-Add-dgpu-disable-method.patch182
-rw-r--r--0103-asus-wmi-Add-egpu-enable-method.patch169
-rw-r--r--1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch128
-rw-r--r--1-2-mt76-mt7915-send-EAPOL-frames-at-lowest-rate.patch127
-rw-r--r--2-2-mt76-mt7921-send-EAPOL-frames-at-lowest-rate.patch131
-rw-r--r--8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch41
-rw-r--r--8014-mt76-mt7921-Add-mt7922-support.patch221
-rw-r--r--9001-v5.14.1-s0ix-patch-2021-09-03.patch766
-rw-r--r--9002-amd-pmc-delay-test.patch44
-rw-r--r--HID-asus-Prevent-Claymore-sending-suspend-event.patch73
-rw-r--r--HID-asus-Reduce-object-size-by-consolidating-calls.patch190
-rw-r--r--PKGBUILD434
-rw-r--r--README.md97
-rw-r--r--acpi-battery-Always-read-fresh-battery-state-on-update.patch38
-rwxr-xr-xchoose-gcc-optimization.sh139
-rw-r--r--hwmon-k10temp-support-Zen3-APUs.patch37
-rw-r--r--mt76-mt7921-enable-VO-tx-aggregation.patch134
-rw-r--r--mt76-mt7921-fix-dma-hang-in-rmmod.patch149
-rw-r--r--mt76-mt7921-fix-firmware-usage-of-RA-info-using-legacy-rates.patch166
-rw-r--r--mt76-mt7921-fix-the-inconsistent-state-between-bind-and-unbind.patch139
-rw-r--r--mt76-mt7921-report-HE-MU-radiotap.patch282
-rw-r--r--myconfig117
-rw-r--r--sphinx-workaround.patch19
-rw-r--r--v2-mt76-mt7921-fix-kernel-warning-from-cfg80211_calculate_bitrate.patch194
-rw-r--r--v5-asus-wmi-Add-support-for-platform_profile.patch239
-rw-r--r--v9-asus-wmi-Add-support-for-custom-fan-curves.patch790
-rw-r--r--x86-ACPI-State-Optimize-C3-entry-on-AMD-CPUs.patch58
30 files changed, 5373 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..acc511a864a0
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,94 @@
+pkgbase = linux-xanmod-rog
+ pkgdesc = Linux Xanmod
+ pkgver = 5.14.1.xanpre0
+ pkgrel = 1
+ url = http://www.xanmod.org/
+ arch = x86_64
+ license = GPL2
+ makedepends = bc
+ makedepends = kmod
+ makedepends = libelf
+ makedepends = pahole
+ makedepends = cpio
+ makedepends = perl
+ makedepends = tar
+ makedepends = xz
+ makedepends = zstd
+ makedepends = gcc>=11.0
+ options = !strip
+ source = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.tar.xz
+ source = https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.tar.sign
+ source = https://github.com/xanmod/linux/releases/download/5.14.0-xanmod1/patch-5.14.0-xanmod1.xz
+ source = choose-gcc-optimization.sh
+ source = sphinx-workaround.patch
+ source = https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.14.1.xz
+ source = x86-ACPI-State-Optimize-C3-entry-on-AMD-CPUs.patch
+ source = acpi-battery-Always-read-fresh-battery-state-on-update.patch
+ source = hwmon-k10temp-support-Zen3-APUs.patch
+ source = 0101-asus-wmi-Add-panel-overdrive-functionality.patch
+ source = 0102-asus-wmi-Add-dgpu-disable-method.patch
+ source = 0103-asus-wmi-Add-egpu-enable-method.patch
+ source = HID-asus-Prevent-Claymore-sending-suspend-event.patch
+ source = HID-asus-Reduce-object-size-by-consolidating-calls.patch
+ source = v5-asus-wmi-Add-support-for-platform_profile.patch
+ source = v9-asus-wmi-Add-support-for-custom-fan-curves.patch
+ source = 8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch
+ source = 8014-mt76-mt7921-Add-mt7922-support.patch
+ source = 1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch
+ source = 1-2-mt76-mt7915-send-EAPOL-frames-at-lowest-rate.patch
+ source = 2-2-mt76-mt7921-send-EAPOL-frames-at-lowest-rate.patch
+ source = mt76-mt7921-enable-VO-tx-aggregation.patch
+ source = mt76-mt7921-fix-dma-hang-in-rmmod.patch
+ source = mt76-mt7921-fix-firmware-usage-of-RA-info-using-legacy-rates.patch
+ source = mt76-mt7921-fix-the-inconsistent-state-between-bind-and-unbind.patch
+ source = mt76-mt7921-report-HE-MU-radiotap.patch
+ source = v2-mt76-mt7921-fix-kernel-warning-from-cfg80211_calculate_bitrate.patch
+ source = 9001-v5.14.1-s0ix-patch-2021-09-03.patch
+ source = 9002-amd-pmc-delay-test.patch
+ validpgpkeys = ABAF11C65A2970B130ABE3C479BE3E4300411886
+ validpgpkeys = 647F28654894E3BD457199BE38DBBDC86092693E
+ sha256sums = 7e068b5e0d26a62b10e5320b25dce57588cbbc6f781c090442138c9c9c3271b2
+ sha256sums = SKIP
+ sha256sums = b8e693326d8daf6d91e7dfb81ebdef88edc9d7ded6ad12907b2c7a0551e802ab
+ sha256sums = 1ac18cad2578df4a70f9346f7c6fccbb62f042a0ee0594817fdef9f2704904ee
+ sha256sums = 52fc0fcd806f34e774e36570b2a739dbdf337f7ff679b1c1139bee54d03301eb
+ sha256sums = 96c0bbe43e508f56277a3f03386cc01538bad013bcfaf0384475a01deaf244d7
+ sha256sums = 923230ed8367e28adfdeed75d3cdba9eec6b781818c37f6f3d3eb64101d2e716
+ sha256sums = f7a4bf6293912bfc4a20743e58a5a266be8c4dbe3c1862d196d3a3b45f2f7c90
+ sha256sums = de8c9747637768c4356c06aa65c3f157c526aa420f21fdd5edd0ed06f720a62e
+ sha256sums = 1ab75535772c63567384eb2ac74753e4d5db2f3317cb265aedf6151b9f18c6c2
+ sha256sums = 8cc771f37ee08ad5796e6db64f180c1415a5f6e03eb3045272dade30ca754b53
+ sha256sums = f3461e7cc759fd4cef2ec5c4fa15b80fa6d37e16008db223f77ed88a65aa938e
+ sha256sums = ec317cc2c2c8c1186c4f553fdd010adc013c37600a499802473653fd8e7564df
+ sha256sums = 544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4
+ sha256sums = 4ef12029ea73ca924b6397e1de4911e84d9e77ddaccdab1ef579823d848524e8
+ sha256sums = 3f1ea86d64cf1258385250641a907f00cdf60ad4ae17d2d43b6dcf279b26eff5
+ sha256sums = 2163cb2e394a013042a40cd3b00dae788603284b20d71e262995366c5534e480
+ sha256sums = a01cf700d79b983807e2285be1b30df6e02db6adfd9c9027fe2dfa8ca5a74bc9
+ sha256sums = ea1d552f8fe6907e4fbd374842a655a9a64529e021c45d8459a0595c739e5cc6
+ sha256sums = 051769c129e0e3a5b516b8799712e1a39dd36216d77879b33b416c8e0fd67d7a
+ sha256sums = fa96d4e690f3e0b51075be06fe47fe5b6d94b10835767c13416701690e842e4b
+ sha256sums = 3ed940a006bc1846daac9ca1194bcbffc0b7b71266d0527b7508f2263cdba9d6
+ sha256sums = 1687b5d7cefdcdbe9f0152d0b38e204229ce75994b1ba5f9fee5eff65580e6a2
+ sha256sums = 16c30e45665f8be034b25d3a21a9ed4cba025dd38293b77aaa12426892091adb
+ sha256sums = 5b7a106d371fcf880920967d7e36728f1bcc0368eaa7bf75ebf67a4ddb93c6d5
+ sha256sums = aa5bb422421cb7e1340d8f07b5471995bbc3c7dd7cf91db76ab1dbe7efc2777a
+ sha256sums = 5e66b5a6a775ad42489dfd0f6057b69dae696a5ec8be428da329f68c1265764a
+ sha256sums = 3d6d1e6374688c5f1abbc40b15c03c62f695e9d04d790556c57f8ec5d0d6a3f9
+ sha256sums = d8dd84c26a44af618c6d1b68723e3bf0f8f50165af04fe090256afb0f931713e
+
+pkgname = linux-xanmod-rog
+ pkgdesc = The Linux kernel and modules with Xanmod and ASUS ROG laptop patches (Zephyrus G14, G15, etc)
+ depends = coreutils
+ depends = kmod
+ depends = initramfs
+ optdepends = crda: to set the correct wireless channels of your country
+ optdepends = linux-firmware: firmware images needed for some devices
+ provides = linux-xanmod-g14
+ conflicts = linux-xanmod-g14
+
+pkgname = linux-xanmod-rog-headers
+ pkgdesc = Headers and scripts for building modules for the Linux Xanmod kernel
+ depends = pahole
+ provides = linux-xanmod-g14-headers
+ conflicts = linux-xanmod-g14-headers
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..df25090fd770
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+src-cache/
+src-cache
+src/
+pkg/
+patches/
+buildlog*
+*log
+*.pkg.tar.*
+*.sig
diff --git a/0101-asus-wmi-Add-panel-overdrive-functionality.patch b/0101-asus-wmi-Add-panel-overdrive-functionality.patch
new file mode 100644
index 000000000000..9ee246ce3398
--- /dev/null
+++ b/0101-asus-wmi-Add-panel-overdrive-functionality.patch
@@ -0,0 +1,166 @@
+From 4fb0353bff3b881de7709b114d4607a0988c3420 Mon Sep 17 00:00:00 2001
+From: "Luke D. Jones" <luke@ljones.dev>
+Date: Sat, 17 Jul 2021 20:13:21 +1200
+Subject: [PATCH 101/103] asus-wmi: Add panel overdrive functionality
+
+Some ASUS ROG laptops have the ability to drive the display panel
+a higher rate to eliminate or reduce ghosting.
+
+Signed-off-by: Luke D. Jones <luke@ljones.dev>
+---
+ drivers/platform/x86/asus-wmi.c | 91 ++++++++++++++++++++++
+ include/linux/platform_data/x86/asus-wmi.h | 1 +
+ 2 files changed, 92 insertions(+)
+
+diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
+index ebaeb7bb80f5..cd881443bc2f 100644
+--- a/drivers/platform/x86/asus-wmi.c
++++ b/drivers/platform/x86/asus-wmi.c
+@@ -216,6 +216,9 @@ struct asus_wmi {
+ // The RSOC controls the maximum charging percentage.
+ bool battery_rsoc_available;
+
++ bool panel_overdrive_available;
++ bool panel_overdrive;
++
+ struct hotplug_slot hotplug_slot;
+ struct mutex hotplug_lock;
+ struct mutex wmi_lock;
+@@ -1221,6 +1224,86 @@ static int asus_wmi_rfkill_init(struct asus_wmi *asus)
+ return result;
+ }
+
++/* Panel Overdrive ************************************************************/
++static int panel_od_check_present(struct asus_wmi *asus)
++{
++ u32 result;
++ int err;
++
++ asus->panel_overdrive_available = false;
++
++ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_PANEL_OD, &result);
++ if (err) {
++ if (err == -ENODEV)
++ return 0;
++ return err;
++ }
++
++ if (result & ASUS_WMI_DSTS_PRESENCE_BIT) {
++ asus->panel_overdrive_available = true;
++ asus->panel_overdrive = result & ASUS_WMI_DSTS_STATUS_BIT;
++ }
++
++ return 0;
++}
++
++static int panel_od_write(struct asus_wmi *asus)
++{
++ int err;
++ u8 value;
++ u32 retval;
++
++ value = asus->panel_overdrive;
++
++ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_PANEL_OD, value, &retval);
++
++ if (err) {
++ pr_warn("Failed to set panel overdrive: %d\n", err);
++ return err;
++ }
++
++ if (retval > 1 || retval < 0) {
++ pr_warn("Failed to set panel overdrive (retval): 0x%x\n", retval);
++ return -EIO;
++ }
++
++ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "panel_od");
++
++ return 0;
++}
++
++static ssize_t panel_od_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ bool mode = asus->panel_overdrive;
++
++ return sysfs_emit(buf, "%d\n", mode);
++}
++
++static ssize_t panel_od_store(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ int result;
++ bool overdrive;
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++
++ result = kstrtobool(buf, &overdrive);
++ if (result == -EINVAL)
++ return result;
++
++ asus->panel_overdrive = overdrive;
++ result = panel_od_write(asus);
++
++ if (result != 0)
++ return result;
++
++ return count;
++}
++
++static DEVICE_ATTR_RW(panel_od);
++
+ /* Quirks *********************************************************************/
+
+ static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
+@@ -2332,6 +2415,7 @@ static struct attribute *platform_attributes[] = {
+ &dev_attr_als_enable.attr,
+ &dev_attr_fan_boost_mode.attr,
+ &dev_attr_throttle_thermal_policy.attr,
++ &dev_attr_panel_od.attr,
+ NULL
+ };
+
+@@ -2357,6 +2441,8 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
+ ok = asus->fan_boost_mode_available;
+ else if (attr == &dev_attr_throttle_thermal_policy.attr)
+ ok = asus->throttle_thermal_policy_available;
++ else if (attr == &dev_attr_panel_od.attr)
++ ok = asus->panel_overdrive_available;
+
+ if (devid != -1)
+ ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
+@@ -2622,6 +2708,10 @@ static int asus_wmi_add(struct platform_device *pdev)
+ else
+ throttle_thermal_policy_set_default(asus);
+
++ err = panel_od_check_present(asus);
++ if (err)
++ goto fail_panel_od;
++
+ err = asus_wmi_sysfs_init(asus->platform_device);
+ if (err)
+ goto fail_sysfs;
+@@ -2709,6 +2799,7 @@ static int asus_wmi_add(struct platform_device *pdev)
+ fail_throttle_thermal_policy:
+ fail_fan_boost_mode:
+ fail_platform:
++fail_panel_od:
+ kfree(asus);
+ return err;
+ }
+diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
+index 2f274cf52805..428aea701c7b 100644
+--- a/include/linux/platform_data/x86/asus-wmi.h
++++ b/include/linux/platform_data/x86/asus-wmi.h
+@@ -61,6 +61,7 @@
+ #define ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY 0x00120075
+
+ /* Misc */
++#define ASUS_WMI_DEVID_PANEL_OD 0x00050019
+ #define ASUS_WMI_DEVID_CAMERA 0x00060013
+ #define ASUS_WMI_DEVID_LID_FLIP 0x00060062
+
+--
+2.32.0
+
diff --git a/0102-asus-wmi-Add-dgpu-disable-method.patch b/0102-asus-wmi-Add-dgpu-disable-method.patch
new file mode 100644
index 000000000000..415590fd6094
--- /dev/null
+++ b/0102-asus-wmi-Add-dgpu-disable-method.patch
@@ -0,0 +1,182 @@
+From de08016c5ef567c853dcf2ff8d9c9b352af253b6 Mon Sep 17 00:00:00 2001
+From: "Luke D. Jones" <luke@ljones.dev>
+Date: Sat, 17 Jul 2021 20:13:22 +1200
+Subject: [PATCH 102/103] asus-wmi: Add dgpu disable method
+
+In Windows the ASUS Armory Crate program can enable or disable the
+dGPU via a WMI call. This functions much the same as various Linux
+methods in software where the dGPU is removed from the device tree.
+
+However the WMI call saves the state of dGPU (enabled or not) and
+this then changes the dGPU visibility in Linux with no way for
+Linux users to re-enable it. We expose the WMI method so users can
+see and change the dGPU ACPI state.
+
+Signed-off-by: Luke D. Jones <luke@ljones.dev>
+---
+ drivers/platform/x86/asus-wmi.c | 99 ++++++++++++++++++++++
+ include/linux/platform_data/x86/asus-wmi.h | 3 +
+ 2 files changed, 102 insertions(+)
+
+diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
+index cd881443bc2f..02762a60d27a 100644
+--- a/drivers/platform/x86/asus-wmi.c
++++ b/drivers/platform/x86/asus-wmi.c
+@@ -210,6 +210,9 @@ struct asus_wmi {
+ u8 fan_boost_mode_mask;
+ u8 fan_boost_mode;
+
++ bool dgpu_disable_available;
++ bool dgpu_disable;
++
+ bool throttle_thermal_policy_available;
+ u8 throttle_thermal_policy_mode;
+
+@@ -427,6 +430,94 @@ static void lid_flip_tablet_mode_get_state(struct asus_wmi *asus)
+ }
+ }
+
++/* dGPU ********************************************************************/
++static int dgpu_disable_check_present(struct asus_wmi *asus)
++{
++ u32 result;
++ int err;
++
++ asus->dgpu_disable_available = false;
++
++ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_DGPU, &result);
++ if (err) {
++ if (err == -ENODEV)
++ return 0;
++ return err;
++ }
++
++ if (result & ASUS_WMI_DSTS_PRESENCE_BIT) {
++ asus->dgpu_disable_available = true;
++ asus->dgpu_disable = result & ASUS_WMI_DSTS_STATUS_BIT;
++ }
++
++ return 0;
++}
++
++static int dgpu_disable_write(struct asus_wmi *asus)
++{
++ int err;
++ u8 value;
++ u32 retval;
++
++ value = asus->dgpu_disable;
++
++ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_DGPU, value, &retval);
++
++ if (err) {
++ pr_warn("Failed to set dgpu disable: %d\n", err);
++ return err;
++ }
++
++ if (retval > 1 || retval < 0) {
++ pr_warn("Failed to set dgpu disable (retval): 0x%x\n", retval);
++ return -EIO;
++ }
++
++ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "dgpu_disable");
++
++ return 0;
++}
++
++static ssize_t dgpu_disable_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ bool mode = asus->dgpu_disable;
++
++ return sysfs_emit(buf, "%d\n", mode);
++}
++
++static ssize_t dgpu_disable_store(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ int result;
++ bool disable;
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++
++ result = kstrtobool(buf, &disable);
++ if (result == -EINVAL)
++ return result;
++
++ asus->dgpu_disable = disable;
++ /*
++ * The ACPI call used does not save the mode unless the call is run twice.
++ * Once to disable, then once to check status and save - this is two code
++ * paths in the method in the ACPI dumps.
++ */
++ result = dgpu_disable_write(asus);
++ if (result != 0)
++ return result;
++
++ result = dgpu_disable_write(asus);
++ if (result != 0)
++ return result;
++
++ return count;
++}
++
++static DEVICE_ATTR_RW(dgpu_disable);
++
+ /* Battery ********************************************************************/
+
+ /* The battery maximum charging percentage */
+@@ -2411,6 +2502,7 @@ static struct attribute *platform_attributes[] = {
+ &dev_attr_camera.attr,
+ &dev_attr_cardr.attr,
+ &dev_attr_touchpad.attr,
++ &dev_attr_dgpu_disable.attr,
+ &dev_attr_lid_resume.attr,
+ &dev_attr_als_enable.attr,
+ &dev_attr_fan_boost_mode.attr,
+@@ -2437,6 +2529,8 @@ 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;
++ else if (attr == &dev_attr_dgpu_disable.attr)
++ ok = asus->dgpu_disable_available;
+ else if (attr == &dev_attr_fan_boost_mode.attr)
+ ok = asus->fan_boost_mode_available;
+ else if (attr == &dev_attr_throttle_thermal_policy.attr)
+@@ -2698,6 +2792,10 @@ static int asus_wmi_add(struct platform_device *pdev)
+ if (err)
+ goto fail_platform;
+
++ err = dgpu_disable_check_present(asus);
++ if (err)
++ goto fail_dgpu_disable;
++
+ err = fan_boost_mode_check_present(asus);
+ if (err)
+ goto fail_fan_boost_mode;
+@@ -2798,6 +2896,7 @@ static int asus_wmi_add(struct platform_device *pdev)
+ fail_sysfs:
+ fail_throttle_thermal_policy:
+ fail_fan_boost_mode:
++fail_dgpu_disable:
+ fail_platform:
+ fail_panel_od:
+ kfree(asus);
+diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
+index 428aea701c7b..a528f9d0e4b7 100644
+--- a/include/linux/platform_data/x86/asus-wmi.h
++++ b/include/linux/platform_data/x86/asus-wmi.h
+@@ -90,6 +90,9 @@
+ /* Keyboard dock */
+ #define ASUS_WMI_DEVID_KBD_DOCK 0x00120063
+
++/* dgpu on/off */
++#define ASUS_WMI_DEVID_DGPU 0x00090020
++
+ /* DSTS masks */
+ #define ASUS_WMI_DSTS_STATUS_BIT 0x00000001
+ #define ASUS_WMI_DSTS_UNKNOWN_BIT 0x00000002
+--
+2.32.0
+
diff --git a/0103-asus-wmi-Add-egpu-enable-method.patch b/0103-asus-wmi-Add-egpu-enable-method.patch
new file mode 100644
index 000000000000..13804605dc37
--- /dev/null
+++ b/0103-asus-wmi-Add-egpu-enable-method.patch
@@ -0,0 +1,169 @@
+From 49872973ce89a5778cd57094eb2eebba530b1244 Mon Sep 17 00:00:00 2001
+From: "Luke D. Jones" <luke@ljones.dev>
+Date: Sat, 17 Jul 2021 20:13:23 +1200
+Subject: [PATCH 103/103] asus-wmi: Add egpu enable method
+
+The X13 Flow laptops can utilise an external GPU. This requires
+toggling an ACPI method which will first disable the internal
+dGPU, and then enable the eGPU.
+
+Signed-off-by: Luke D. Jones <luke@ljones.dev>
+---
+ drivers/platform/x86/asus-wmi.c | 91 ++++++++++++++++++++++
+ include/linux/platform_data/x86/asus-wmi.h | 3 +
+ 2 files changed, 94 insertions(+)
+
+diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
+index 02762a60d27a..ee5d8656641e 100644
+--- a/drivers/platform/x86/asus-wmi.c
++++ b/drivers/platform/x86/asus-wmi.c
+@@ -210,6 +210,9 @@ struct asus_wmi {
+ u8 fan_boost_mode_mask;
+ u8 fan_boost_mode;
+
++ bool egpu_enable_available; // 0 = enable
++ bool egpu_enable;
++
+ bool dgpu_disable_available;
+ bool dgpu_disable;
+
+@@ -430,6 +433,86 @@ static void lid_flip_tablet_mode_get_state(struct asus_wmi *asus)
+ }
+ }
+
++/* eGPU ********************************************************************/
++static int egpu_enable_check_present(struct asus_wmi *asus)
++{
++ u32 result;
++ int err;
++
++ asus->egpu_enable_available = false;
++
++ err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_EGPU, &result);
++ if (err) {
++ if (err == -ENODEV)
++ return 0;
++ return err;
++ }
++
++ if (result & ASUS_WMI_DSTS_PRESENCE_BIT) {
++ asus->egpu_enable_available = true;
++ asus->egpu_enable = result & ASUS_WMI_DSTS_STATUS_BIT;
++ }
++
++ return 0;
++}
++
++static int egpu_enable_write(struct asus_wmi *asus)
++{
++ int err;
++ u8 value;
++ u32 retval;
++
++ value = asus->egpu_enable;
++
++ err = asus_wmi_set_devstate(ASUS_WMI_DEVID_EGPU, value, &retval);
++
++ if (err) {
++ pr_warn("Failed to set egpu disable: %d\n", err);
++ return err;
++ }
++
++ if (retval > 1 || retval < 0) {
++ pr_warn("Failed to set egpu disable (retval): 0x%x\n", retval);
++ return -EIO;
++ }
++
++ sysfs_notify(&asus->platform_device->dev.kobj, NULL, "egpu_enable");
++
++ return 0;
++}
++
++static ssize_t egpu_enable_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ bool mode = asus->egpu_enable;
++
++ return sysfs_emit(buf, "%d\n", mode);
++}
++
++static ssize_t egpu_enable_store(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ int result;
++ bool disable;
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++
++ result = kstrtobool(buf, &disable);
++ if (result == -EINVAL)
++ return result;
++
++ asus->egpu_enable = disable;
++
++ result = egpu_enable_write(asus);
++ if (result != 0)
++ return result;
++
++ return count;
++}
++
++static DEVICE_ATTR_RW(egpu_enable);
++
+ /* dGPU ********************************************************************/
+ static int dgpu_disable_check_present(struct asus_wmi *asus)
+ {
+@@ -2502,6 +2585,7 @@ static struct attribute *platform_attributes[] = {
+ &dev_attr_camera.attr,
+ &dev_attr_cardr.attr,
+ &dev_attr_touchpad.attr,
++ &dev_attr_egpu_enable.attr,
+ &dev_attr_dgpu_disable.attr,
+ &dev_attr_lid_resume.attr,
+ &dev_attr_als_enable.attr,
+@@ -2529,6 +2613,8 @@ 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;
++ else if (attr == &dev_attr_egpu_enable.attr)
++ ok = asus->egpu_enable_available;
+ else if (attr == &dev_attr_dgpu_disable.attr)
+ ok = asus->dgpu_disable_available;
+ else if (attr == &dev_attr_fan_boost_mode.attr)
+@@ -2792,6 +2878,10 @@ static int asus_wmi_add(struct platform_device *pdev)
+ if (err)
+ goto fail_platform;
+
++ err = egpu_enable_check_present(asus);
++ if (err)
++ goto fail_egpu_enable;
++
+ err = dgpu_disable_check_present(asus);
+ if (err)
+ goto fail_dgpu_disable;
+@@ -2896,6 +2986,7 @@ static int asus_wmi_add(struct platform_device *pdev)
+ fail_sysfs:
+ fail_throttle_thermal_policy:
+ fail_fan_boost_mode:
++fail_egpu_enable:
+ fail_dgpu_disable:
+ fail_platform:
+ fail_panel_od:
+diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
+index a528f9d0e4b7..17dc5cb6f3f2 100644
+--- a/include/linux/platform_data/x86/asus-wmi.h
++++ b/include/linux/platform_data/x86/asus-wmi.h
+@@ -90,6 +90,9 @@
+ /* Keyboard dock */
+ #define ASUS_WMI_DEVID_KBD_DOCK 0x00120063
+
++/* dgpu on/off */
++#define ASUS_WMI_DEVID_EGPU 0x00090019
++
+ /* dgpu on/off */
+ #define ASUS_WMI_DEVID_DGPU 0x00090020
+
+--
+2.32.0
+
diff --git a/1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch b/1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch
new file mode 100644
index 000000000000..06369ca10afe
--- /dev/null
+++ b/1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch
@@ -0,0 +1,128 @@
+From patchwork Mon Aug 2 12:59:41 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Mark-YW.Chen@mediatek.com
+X-Patchwork-Id: 12413935
+Return-Path:
+ <SRS0=Q+Xe=MZ=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id 5A6DFC432BE
+ for <linux-mediatek@archiver.kernel.org>;
+ Mon, 2 Aug 2021 13:00:23 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id 298C160F4B
+ for <linux-mediatek@archiver.kernel.org>;
+ Mon, 2 Aug 2021 13:00:23 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 298C160F4B
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=5WBIaI20Ea+oX4Ih8ajsU0sFBZxuscG3dPFM3dwGfxY=; b=B3V2CHxzEjXum4
+ lkau/WH9tfSMULGcO8l9dc5RBBbU2MIho2Tj0V+Wy19iN4JKZjOuBgR5V1mnC0eVMr/Ep2YFNWzfV
+ 9kDULl/BOKn+e0DbC0pfNqEYXkEFCyYebgKRrFpd4bb51SnlKiTpE7AOfzUzPTk7A/+elHUV9ZdzW
+ SxaGX9bDciPb5N3rWNqZtq+8sbqX6TE7/zqcjYey6AEClN+4qm5T7np8IfrGMiTd+Q1+K/SYG36NT
+ 6rPgaP7L0fYOnkqDS7QtNdl3/oD94O2TONEDEFyVXyOBoqNZzzjFg6YorBLjfC9HDYv83WgzCGMbJ
+ BA8nirCcJvae7hHJwhwQ==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mAXY9-00GHfL-D8; Mon, 02 Aug 2021 13:00:09 +0000
+Received: from mailgw02.mediatek.com ([216.200.240.185])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mAXY6-00GHeT-W3
+ for linux-mediatek@lists.infradead.org; Mon, 02 Aug 2021 13:00:08 +0000
+X-UUID: a7e3f44da49743f19b1f98e3b1e28255-20210802
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=XAcS2wryvL3iE8Bi6rTANLOzPfI+GSwKuIrwIOWmJuA=;
+ b=SgzOboJwiVleHJqLoYlk+IsrrgY1svu5wa6U6VfgImlkxwYOwhtPYqmerx7rp0pftVszE76vAIOBiM4m++E5mxShdqxmItmAp0Dg5XccXmwz6mD9USZM+DuVOcTlxvdHR7VYpaJwt4XvgpJPE9VX4uAoe/OrpzBuKPm49c2ekWs=;
+X-UUID: a7e3f44da49743f19b1f98e3b1e28255-20210802
+Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by
+ mailgw02.mediatek.com
+ (envelope-from <mark-yw.chen@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 1188650374; Mon, 02 Aug 2021 06:00:04 -0700
+Received: from MTKMBS02N2.mediatek.inc (172.21.101.101) by
+ MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Mon, 2 Aug 2021 06:00:02 -0700
+Received: from mtkcas07.mediatek.inc (172.21.101.84) by
+ mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Mon, 2 Aug 2021 20:59:43 +0800
+Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Mon, 2 Aug 2021 20:59:43 +0800
+From: <mark-yw.chen@mediatek.com>
+To: <marcel@holtmann.org>, <johan.hedberg@gmail.com>
+CC: <chris.lu@mediatek.com>, <will-cy.lee@mediatek.com>,
+ <sean.wang@mediatek.com>, <linux-bluetooth@vger.kernel.org>,
+ <linux-mediatek@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
+ <michaelfsun@google.com>, <shawnku@google.com>, <jemele@google.com>,
+ <apusaka@google.com>, mark-yw.chen <mark-yw.chen@mediatek.com>
+Subject: [PATCH 1/1] Bluetooth: btusb: Enable MSFT extension for Mediatek Chip
+ (MT7921)
+Date: Mon, 2 Aug 2021 20:59:41 +0800
+Message-ID: <20210802125941.29078-1-mark-yw.chen@mediatek.com>
+X-Mailer: git-send-email 2.18.0
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210802_060007_065317_DD61498C
+X-CRM114-Status: UNSURE ( 8.00 )
+X-CRM114-Notice: Please train this message.
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: "mark-yw.chen" <mark-yw.chen@mediatek.com>
+
+The Mdiatek MT7921(7961) support MSFT HCI extensions, we are using
+0xFD30 for VsMsftOpCode.
+
+Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
+---
+ drivers/bluetooth/btusb.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
+index fec798dadd99..b1a05bb9f4bf 100644
+--- a/drivers/bluetooth/btusb.c
++++ b/drivers/bluetooth/btusb.c
+@@ -3775,6 +3775,8 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
+ bt_dev_err(hdev, "Failed to send wmt func ctrl (%d)", err);
+ return err;
+ }
++
++ hci_set_msft_opcode(hdev, 0xFD30);
+ goto done;
+ default:
+ bt_dev_err(hdev, "Unsupported hardware variant (%08x)",
diff --git a/1-2-mt76-mt7915-send-EAPOL-frames-at-lowest-rate.patch b/1-2-mt76-mt7915-send-EAPOL-frames-at-lowest-rate.patch
new file mode 100644
index 000000000000..b7d1c939371d
--- /dev/null
+++ b/1-2-mt76-mt7915-send-EAPOL-frames-at-lowest-rate.patch
@@ -0,0 +1,127 @@
+From patchwork Sat Jul 17 05:05:48 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Ryder Lee <ryder.lee@mediatek.com>
+X-Patchwork-Id: 12383197
+Return-Path:
+ <SRS0=8BsG=MJ=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id E0A29C636CA
+ for <linux-mediatek@archiver.kernel.org>;
+ Sat, 17 Jul 2021 05:06:30 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id AA9E7610D1
+ for <linux-mediatek@archiver.kernel.org>;
+ Sat, 17 Jul 2021 05:06:30 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA9E7610D1
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none
+ smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=rjomw0wp1+A4VMUfXKgPRtakm5irGEo3QqwVRGLvUP8=; b=oe+vB2X8hjnZN7
+ Or599HTQ/UoSBTiNbiIR/7I8RQ3WqieT4u1A0h8WoW6zcPG/oV5tHQcq8Ggcog2c4/z5JDsPV8u/f
+ E5Aa0ewIp0Nh4tyFmKstqdxGB+EFESRegu509Yz0VKWivUALEQdB/KMVgKRkHFnIKBVyaCEf39QbQ
+ 3tByFhM+ou3kVMdx3dozOoYsL97I0UZl1SasmAO9nUiso4kNpB2ritVD9/kabEtspFM548cDTCgz8
+ 0BgrmsnAiQ2ZLUZGOHB6DIY2jik4OgQU+/tdNXCJm0WEP0jpb/QOgQSybU6jUAdPpG8bAKEePHjFj
+ ILlbUyrs13tFQG3rBi3g==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1m4cWn-0060Mu-VH; Sat, 17 Jul 2021 05:06:18 +0000
+Received: from mailgw02.mediatek.com ([216.200.240.185])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1m4cWk-0060JL-B6
+ for linux-mediatek@lists.infradead.org; Sat, 17 Jul 2021 05:06:15 +0000
+X-UUID: 987eb99dbefa46a3b60ec8747a637a6b-20210716
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=ipgE+yUVdOZXFRIMYzExOPN9eG6bKAxGCH9sHXZiejY=;
+ b=bml/Wb1gbVRaRkF+bBvysBqmMJrIgd/7Am8PiMq1E7WryXnwML9g82hf7sthXTtcyJ+p/R5cxCFn2Z/zN8fwCIi8Wvpu4KtNkY8XXYxbCIsZd0vQjHFy5YsuwQrR1ka/r3RtM+YJhvl4aryDWe+Za0Qg5h/3qNhVj7zYXebiF7A=;
+X-UUID: 987eb99dbefa46a3b60ec8747a637a6b-20210716
+Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by
+ mailgw02.mediatek.com
+ (envelope-from <ryder.lee@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 360980783; Fri, 16 Jul 2021 22:06:07 -0700
+Received: from MTKMBS02N1.mediatek.inc (172.21.101.77) by
+ MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Fri, 16 Jul 2021 22:06:05 -0700
+Received: from mtkcas07.mediatek.inc (172.21.101.84) by
+ mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Sat, 17 Jul 2021 13:05:51 +0800
+Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Sat, 17 Jul 2021 13:05:52 +0800
+From: Ryder Lee <ryder.lee@mediatek.com>
+To: Felix Fietkau <nbd@nbd.name>
+CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>, Shayne Chen
+ <shayne.chen@mediatek.com>, Evelyn Tsai <evelyn.tsai@mediatek.com>, Sean Wang
+ <sean.wang@mediatek.com>, <linux-wireless@vger.kernel.org>,
+ <linux-mediatek@lists.infradead.org>, Ryder Lee <ryder.lee@mediatek.com>
+Subject: [PATCH 1/2] mt76: mt7915: send EAPOL frames at lowest rate
+Date: Sat, 17 Jul 2021 13:05:48 +0800
+Message-ID:
+ <aea4d98082bea79c7e116fc56d2b0e0c1442deae.1626498075.git.ryder.lee@mediatek.com>
+X-Mailer: git-send-email 2.18.0
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210716_220614_445118_09B765EF
+X-CRM114-Status: UNSURE ( 7.01 )
+X-CRM114-Notice: Please train this message.
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+The firmware rate control may choose the high rate for EAPOL frames,
+so checking IEEE80211_TX_CTL_USE_MINRATE to use the lowest TX rate.
+
+Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
+---
+ drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+index 2462704094b0..d47dd0f96bdb 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7915/mac.c
+@@ -869,7 +869,8 @@ mt7915_mac_write_txwi_80211(struct mt7915_dev *dev, __le32 *txwi,
+ txwi[3] &= ~cpu_to_le32(MT_TXD3_PROTECT_FRAME);
+ }
+
+- if (!ieee80211_is_data(fc) || multicast)
++ if (!ieee80211_is_data(fc) || multicast ||
++ info->flags & IEEE80211_TX_CTL_USE_MINRATE)
+ val |= MT_TXD2_FIX_RATE;
+
+ txwi[2] |= cpu_to_le32(val);
diff --git a/2-2-mt76-mt7921-send-EAPOL-frames-at-lowest-rate.patch b/2-2-mt76-mt7921-send-EAPOL-frames-at-lowest-rate.patch
new file mode 100644
index 000000000000..8cad4029fe85
--- /dev/null
+++ b/2-2-mt76-mt7921-send-EAPOL-frames-at-lowest-rate.patch
@@ -0,0 +1,131 @@
+From patchwork Sat Jul 17 05:05:49 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Ryder Lee <ryder.lee@mediatek.com>
+X-Patchwork-Id: 12383195
+Return-Path:
+ <SRS0=8BsG=MJ=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id B5302C636C9
+ for <linux-mediatek@archiver.kernel.org>;
+ Sat, 17 Jul 2021 05:06:16 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id 64BED61164
+ for <linux-mediatek@archiver.kernel.org>;
+ Sat, 17 Jul 2021 05:06:16 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 64BED61164
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none
+ smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:
+ Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description:
+ Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
+ List-Owner; bh=XYt5as2V75Ot/pCMe0BQkBlua3GxCfpt9rHvOA+go5w=; b=DBNscgMvxMI7d1
+ qo/PP9jjVhWfndggeJH93f6tLYvb2coTT21qdLr7/WgN7q0iZaFebNaY2YJFXdciwTnWTryyr20m4
+ zojp8rpHlNx4KBH6SIooigj1lMP5wo1WvfwlXlGq+ziEfItVWc8n/gkWlwwxmILHjAnqp3J6RL357
+ 8fYNZNhTEYjpszGZV4A48oOuADZ2Cfu5e2JV8R3HgNJT5gRR6t84kuZZcS3/+Ul1ETTYbLlSQs7CK
+ MocRSCovAxmwekQEC10lFfvm6S/Apcva/nKy+QVbMNv2VlJho+xlRVpyaJMnNZ+L+F37axONXIVAs
+ RcCgUcIX83TaSYfEFROg==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1m4cWZ-0060HS-4n; Sat, 17 Jul 2021 05:06:03 +0000
+Received: from mailgw01.mediatek.com ([216.200.240.184])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1m4cWV-0060Fr-Jh
+ for linux-mediatek@lists.infradead.org; Sat, 17 Jul 2021 05:06:01 +0000
+X-UUID: 195cad4f32c74550923ecf6771d9e2ca-20210716
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From;
+ bh=e3sRdoFT02nVhSGkHEUZXS/w1QWkJVlllXBc00Doke0=;
+ b=WyOxCx9VMa1VCnEzCP6lfKl9HZnwW792i17YQ52EWLqAvw/UTGHJgP5qjsbEg1bpQFt5b6Lceya7ucAzN4bK74vFqCiIqNEcVfzUTtcQaBvs23cfKZvb7n1Oh0K/APp56JV5Ai2k/x8fY8+Ud+zAS2QOxoFgD6OSHTV64K5yjak=;
+X-UUID: 195cad4f32c74550923ecf6771d9e2ca-20210716
+Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by
+ mailgw01.mediatek.com
+ (envelope-from <ryder.lee@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 1788141652; Fri, 16 Jul 2021 22:05:56 -0700
+Received: from mtkmbs05n2.mediatek.inc (172.21.101.140) by
+ MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Fri, 16 Jul 2021 22:05:54 -0700
+Received: from mtkcas07.mediatek.inc (172.21.101.84) by
+ mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Sat, 17 Jul 2021 13:05:53 +0800
+Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Sat, 17 Jul 2021 13:05:53 +0800
+From: Ryder Lee <ryder.lee@mediatek.com>
+To: Felix Fietkau <nbd@nbd.name>
+CC: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>, Shayne Chen
+ <shayne.chen@mediatek.com>, Evelyn Tsai <evelyn.tsai@mediatek.com>, Sean Wang
+ <sean.wang@mediatek.com>, <linux-wireless@vger.kernel.org>,
+ <linux-mediatek@lists.infradead.org>, Ryder Lee <ryder.lee@mediatek.com>
+Subject: [PATCH 2/2] mt76: mt7921: send EAPOL frames at lowest rate
+Date: Sat, 17 Jul 2021 13:05:49 +0800
+Message-ID:
+ <089a52032471c2f058e0837582b21f6e9b039fba.1626498075.git.ryder.lee@mediatek.com>
+X-Mailer: git-send-email 2.18.0
+In-Reply-To:
+ <aea4d98082bea79c7e116fc56d2b0e0c1442deae.1626498075.git.ryder.lee@mediatek.com>
+References:
+ <aea4d98082bea79c7e116fc56d2b0e0c1442deae.1626498075.git.ryder.lee@mediatek.com>
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210716_220559_709174_3852E090
+X-CRM114-Status: UNSURE ( 7.24 )
+X-CRM114-Notice: Please train this message.
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+The firmware rate control may choose the high rate for EAPOL frames,
+so checking IEEE80211_TX_CTL_USE_MINRATE to use the lowest TX rate.
+
+Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
+---
+ drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+index 7fe2e3a50428..eb0d98c8d5d8 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+@@ -702,7 +702,8 @@ mt7921_mac_write_txwi_80211(struct mt7921_dev *dev, __le32 *txwi,
+ txwi[3] &= ~cpu_to_le32(MT_TXD3_PROTECT_FRAME);
+ }
+
+- if (!ieee80211_is_data(fc) || multicast)
++ if (!ieee80211_is_data(fc) || multicast ||
++ info->flags & IEEE80211_TX_CTL_USE_MINRATE)
+ val |= MT_TXD2_FIX_RATE;
+
+ txwi[2] |= cpu_to_le32(val);
diff --git a/8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch b/8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch
new file mode 100644
index 000000000000..e3c25ccae6f9
--- /dev/null
+++ b/8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch
@@ -0,0 +1,41 @@
+From 8c7b55f401ae8cf172fd9766178ef20cda322e42 Mon Sep 17 00:00:00 2001
+From: Deren Wu <deren.wu@mediatek.com>
+Date: Wed, 14 Jul 2021 23:50:52 +0800
+Subject: [PATCH 8013/8014] mt76: mt7921: Fix out of order process by invalid
+ event pkt
+
+The acceptable event report should inlcude original CMD-ID. Otherwise,
+drop unexpected result from fw.
+
+Fixes: 1c099ab44727c ("mt76: mt7921: add MCU support")
+Signed-off-by: Jimmy Hu <Jimmy.Hu@mediatek.com>
+Signed-off-by: Deren Wu <deren.wu@mediatek.com>
+---
+ drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+index f7459ad2a073..bc8e3327a49f 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+@@ -157,6 +157,7 @@ mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ struct sk_buff *skb, int seq)
+ {
+ struct mt7921_mcu_rxd *rxd;
++ int mcu_cmd = cmd & MCU_CMD_MASK;
+ int ret = 0;
+
+ if (!skb) {
+@@ -194,6 +195,9 @@ mt7921_mcu_parse_response(struct mt76_dev *mdev, int cmd,
+ skb_pull(skb, sizeof(*rxd));
+ event = (struct mt7921_mcu_uni_event *)skb->data;
+ ret = le32_to_cpu(event->status);
++ /* skip invalid event */
++ if (mcu_cmd != event->cid)
++ ret = -EAGAIN;
+ break;
+ }
+ case MCU_CMD_REG_READ: {
+--
+2.32.0
+
diff --git a/8014-mt76-mt7921-Add-mt7922-support.patch b/8014-mt76-mt7921-Add-mt7922-support.patch
new file mode 100644
index 000000000000..d11143822c5f
--- /dev/null
+++ b/8014-mt76-mt7921-Add-mt7922-support.patch
@@ -0,0 +1,221 @@
+From ad4ffe33fd9d517ef27e213c6bd9d11675658fe2 Mon Sep 17 00:00:00 2001
+From: Deren Wu <deren.wu@mediatek.com>
+Date: Fri, 16 Jul 2021 01:34:19 +0800
+Subject: [PATCH 8014/8014] mt76: mt7921: Add mt7922 support
+
+Add new chip mt7922 in mt7921 module with following items
+1. new chip ID / fw bin name
+2. is_mt7922()
+ check chip type for different fw files
+3. mt7921_get_data_mode()
+ check security type of fw (backward compatible)
+
+Co-developed-by: Jimmy Hu <Jimmy.Hu@mediatek.com>
+Signed-off-by: Jimmy Hu <Jimmy.Hu@mediatek.com>
+Signed-off-by: Deren Wu <deren.wu@mediatek.com>
+---
+ .../net/wireless/mediatek/mt76/mt76_connac.h | 7 +-
+ .../wireless/mediatek/mt76/mt7921/eeprom.c | 1 +
+ .../net/wireless/mediatek/mt76/mt7921/mcu.c | 71 +++++++++++++++++--
+ .../wireless/mediatek/mt76/mt7921/mt7921.h | 3 +
+ .../net/wireless/mediatek/mt76/mt7921/pci.c | 3 +
+ 5 files changed, 80 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac.h b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
+index 6c889b90fd12..f6e7671fc3be 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76_connac.h
++++ b/drivers/net/wireless/mediatek/mt76/mt76_connac.h
+@@ -82,9 +82,14 @@ struct mt76_connac_coredump {
+
+ extern const struct wiphy_wowlan_support mt76_connac_wowlan_support;
+
++static inline bool is_mt7922(struct mt76_dev *dev)
++{
++ return mt76_chip(dev) == 0x7922;
++}
++
+ static inline bool is_mt7921(struct mt76_dev *dev)
+ {
+- return mt76_chip(dev) == 0x7961;
++ return mt76_chip(dev) == 0x7961 || is_mt7922(dev);
+ }
+
+ static inline bool is_mt7663(struct mt76_dev *dev)
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7921/eeprom.c
+index 691d14a1a7bf..4d0a4aeac6bf 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/eeprom.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/eeprom.c
+@@ -36,6 +36,7 @@ static int mt7921_check_eeprom(struct mt7921_dev *dev)
+ val = get_unaligned_le16(eeprom);
+
+ switch (val) {
++ case 0x7922:
+ case 0x7961:
+ return 0;
+ default:
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+index bc8e3327a49f..798ddfde205a 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+@@ -82,9 +82,17 @@ struct mt7921_fw_region {
+ #define FW_START_OVERRIDE BIT(0)
+ #define FW_START_WORKING_PDA_CR4 BIT(2)
+
++#define PATCH_SEC_NOT_SUPPORT GENMASK(31, 0)
+ #define PATCH_SEC_TYPE_MASK GENMASK(15, 0)
+ #define PATCH_SEC_TYPE_INFO 0x2
+
++#define PATCH_SEC_ENC_TYPE_MASK GENMASK(31, 24)
++#define PATCH_SEC_ENC_TYPE_PLAIN 0x00
++#define PATCH_SEC_ENC_TYPE_AES 0x01
++#define PATCH_SEC_ENC_TYPE_SCRAMBLE 0x02
++#define PATCH_SEC_ENC_SCRAMBLE_INFO_MASK GENMASK(15, 0)
++#define PATCH_SEC_ENC_AES_KEY_MASK GENMASK(7, 0)
++
+ #define to_wcid_lo(id) FIELD_GET(GENMASK(7, 0), (u16)id)
+ #define to_wcid_hi(id) FIELD_GET(GENMASK(9, 8), (u16)id)
+
+@@ -722,6 +730,46 @@ static int mt7921_driver_own(struct mt7921_dev *dev)
+ return 0;
+ }
+
++static u32 mt7921_get_data_mode(struct mt7921_dev *dev, u32 info)
++{
++ u32 mode = DL_MODE_NEED_RSP;
++
++ if (info == PATCH_SEC_NOT_SUPPORT)
++ return mode;
++
++ switch (FIELD_GET(PATCH_SEC_ENC_TYPE_MASK, info)) {
++ case PATCH_SEC_ENC_TYPE_PLAIN:
++ break;
++ case PATCH_SEC_ENC_TYPE_AES:
++ mode |= DL_MODE_ENCRYPT;
++ mode |= FIELD_PREP(DL_MODE_KEY_IDX,
++ (info & PATCH_SEC_ENC_AES_KEY_MASK)) & DL_MODE_KEY_IDX;
++ mode |= DL_MODE_RESET_SEC_IV;
++ break;
++ case PATCH_SEC_ENC_TYPE_SCRAMBLE:
++ mode |= DL_MODE_ENCRYPT;
++ mode |= DL_CONFIG_ENCRY_MODE_SEL;
++ mode |= DL_MODE_RESET_SEC_IV;
++ break;
++ default:
++ dev_err(dev->mt76.dev, "Encryption type not support!\n");
++ }
++
++ return mode;
++}
++
++static char *mt7921_patch_name(struct mt7921_dev *dev)
++{
++ char *ret;
++
++ if (is_mt7922(&dev->mt76))
++ ret = MT7922_ROM_PATCH;
++ else
++ ret = MT7921_ROM_PATCH;
++
++ return ret;
++}
++
+ static int mt7921_load_patch(struct mt7921_dev *dev)
+ {
+ const struct mt7921_patch_hdr *hdr;
+@@ -739,7 +787,7 @@ static int mt7921_load_patch(struct mt7921_dev *dev)
+ return -EAGAIN;
+ }
+
+- ret = request_firmware(&fw, MT7921_ROM_PATCH, dev->mt76.dev);
++ ret = request_firmware(&fw, mt7921_patch_name(dev), dev->mt76.dev);
+ if (ret)
+ goto out;
+
+@@ -757,7 +805,8 @@ static int mt7921_load_patch(struct mt7921_dev *dev)
+ for (i = 0; i < be32_to_cpu(hdr->desc.n_region); i++) {
+ struct mt7921_patch_sec *sec;
+ const u8 *dl;
+- u32 len, addr;
++ u32 len, addr, mode;
++ u32 sec_info = 0;
+
+ sec = (struct mt7921_patch_sec *)(fw->data + sizeof(*hdr) +
+ i * sizeof(*sec));
+@@ -770,9 +819,11 @@ static int mt7921_load_patch(struct mt7921_dev *dev)
+ addr = be32_to_cpu(sec->info.addr);
+ len = be32_to_cpu(sec->info.len);
+ dl = fw->data + be32_to_cpu(sec->offs);
++ sec_info = be32_to_cpu(sec->info.sec_key_idx);
++ mode = mt7921_get_data_mode(dev, sec_info);
+
+ ret = mt76_connac_mcu_init_download(&dev->mt76, addr, len,
+- DL_MODE_NEED_RSP);
++ mode);
+ if (ret) {
+ dev_err(dev->mt76.dev, "Download request failed\n");
+ goto out;
+@@ -869,13 +920,25 @@ mt7921_mcu_send_ram_firmware(struct mt7921_dev *dev,
+ return mt76_connac_mcu_start_firmware(&dev->mt76, override, option);
+ }
+
++static char *mt7921_ram_name(struct mt7921_dev *dev)
++{
++ char *ret;
++
++ if (is_mt7922(&dev->mt76))
++ ret = MT7922_FIRMWARE_WM;
++ else
++ ret = MT7921_FIRMWARE_WM;
++
++ return ret;
++}
++
+ static int mt7921_load_ram(struct mt7921_dev *dev)
+ {
+ const struct mt7921_fw_trailer *hdr;
+ const struct firmware *fw;
+ int ret;
+
+- ret = request_firmware(&fw, MT7921_FIRMWARE_WM, dev->mt76.dev);
++ ret = request_firmware(&fw, mt7921_ram_name(dev), dev->mt76.dev);
+ if (ret)
+ return ret;
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+index 59862ea4951c..d8e616229e9f 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h
+@@ -33,6 +33,9 @@
+ #define MT7921_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7961_1.bin"
+ #define MT7921_ROM_PATCH "mediatek/WIFI_MT7961_patch_mcu_1_2_hdr.bin"
+
++#define MT7922_FIRMWARE_WM "mediatek/WIFI_RAM_CODE_MT7922_1.bin"
++#define MT7922_ROM_PATCH "mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin"
++
+ #define MT7921_EEPROM_SIZE 3584
+ #define MT7921_TOKEN_SIZE 8192
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+index fa02d934f0bf..684d0568a92a 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/pci.c
+@@ -14,6 +14,7 @@
+
+ static const struct pci_device_id mt7921_pci_device_table[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7961) },
++ { PCI_DEVICE(PCI_VENDOR_ID_MEDIATEK, 0x7922) },
+ { },
+ };
+
+@@ -317,6 +318,8 @@ module_pci_driver(mt7921_pci_driver);
+ MODULE_DEVICE_TABLE(pci, mt7921_pci_device_table);
+ MODULE_FIRMWARE(MT7921_FIRMWARE_WM);
+ MODULE_FIRMWARE(MT7921_ROM_PATCH);
++MODULE_FIRMWARE(MT7922_FIRMWARE_WM);
++MODULE_FIRMWARE(MT7922_ROM_PATCH);
+ MODULE_AUTHOR("Sean Wang <sean.wang@mediatek.com>");
+ MODULE_AUTHOR("Lorenzo Bianconi <lorenzo@kernel.org>");
+ MODULE_LICENSE("Dual BSD/GPL");
+--
+2.32.0
+
diff --git a/9001-v5.14.1-s0ix-patch-2021-09-03.patch b/9001-v5.14.1-s0ix-patch-2021-09-03.patch
new file mode 100644
index 000000000000..21d22c496a3a
--- /dev/null
+++ b/9001-v5.14.1-s0ix-patch-2021-09-03.patch
@@ -0,0 +1,766 @@
+From 20d622ad8d682cdfa8d2db3aac2e2940fb6b7f37 Mon Sep 17 00:00:00 2001
+From: Scott B <arglebargle@arglebargle.dev>
+Date: Fri, 3 Sep 2021 06:18:48 -0700
+Subject: [PATCH] v5.14.1 s0ix patch 2021-09-03
+
+Squashed commit of the following:
+
+commit 59a128d473a903fc256ca20b05a83aedae570fef
+Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+Date: Tue Aug 31 17:36:12 2021 +0530
+
+ pinctrl: amd: Add irq field data
+
+ pinctrl_amd use gpiochip_get_data() to get their local state containers
+ back from the gpiochip passed as amd_gpio chip data.
+
+ Hence added irq field data to get directly using amd_gpio chip data.
+
+ Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+
+commit d48c21c63803949bb4655e93b0fb064d56db5682
+Author: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+Date: Tue Aug 31 17:36:13 2021 +0530
+
+ pinctrl: amd: Handle wake-up interrupt
+
+ Enable/disable power management wakeup mode, which is disabled by
+ default. enable_irq_wake enables wakes the system from sleep.
+
+ Hence added enable/disable irq_wake to handle wake-up interrupt.
+
+ Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
+
+commit 2219e4d484f61a7234a1744fe7f44255850264fb
+Author: Mario Limonciello <mario.limonciello@amd.com>
+Date: Tue Aug 31 11:36:19 2021 -0500
+
+ ACPI: PM: s2idle: Run both AMD and Microsoft methods if both are supported
+
+ It was reported that on "HP ENVY x360" that power LED does not come back
+ on, certain keys like brightness controls do not work, and the fan never
+ spins up, even under load.
+
+ In analysis of the SSDT it's clear that the Microsoft UUID doesn't provide
+ functional support, but rather the AMD UUID should be supporting this
+ system.
+
+ Because this is a gap in the expected logic, confirmation with internal
+ team is that AMD uPEP *does* run even when Microsoft UUID present, but
+ most OEM systems have adopted value of "0x3" for supported functions and
+ hence nothing runs.
+
+ Henceforth add support for running both Microsoft and AMD methods. This
+ approach will also allow the same logic on Intel systems if desired at a
+ future time as well by pulling the evaluation of
+ `lps0_dsm_func_mask_microsoft` out of the if block for
+ `acpi_s2idle_vendor_amd`.
+
+ BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1691
+ Reported-by: Maxwell Beck <max@ryt.one>
+ Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
+
+commit 290e605b95a082a6cef455fcb89e263271db9ee5
+Author: Scott B <28817345+foundObjects@users.noreply.github.com>
+Date: Wed Jul 21 18:10:28 2021 -0700
+
+ amd-pmc smu register dump for diagnostics
+
+ patch this per Mario's request:
+ https://gitlab.freedesktop.org/drm/amd/-/issues/1629#note_1000332
+
+commit 69a3e85d633dbdac57017feb9a059b97c8937034
+Author: Scott B <28817345+foundObjects@users.noreply.github.com>
+Date: Tue Jul 20 23:33:01 2021 -0700
+
+ drm/amd/pm: Add information about SMU12 firmware version
+
+ hacky manual import of: https://lists.freedesktop.org/archives/amd-gfx/2021-July/066835.html
+
+ This information is useful for root causing issues with S0ix.
+
+ Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
+
+commit 24c0c263a463b39c74216a640873fd2060d82156
+Author: Scott B <28817345+foundObjects@users.noreply.github.com>
+Date: Tue Jul 20 23:31:31 2021 -0700
+
+ drm/amd/pm: Add information about SMU11 firmware version
+
+ hacky manual import of: https://lists.freedesktop.org/archives/amd-gfx/2021-July/066834.html
+
+ This information is useful for root causing issues with S0ix.
+
+ Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
+
+commit 1406ea8541b9148c692abd0b97de373df3db413f
+Author: Guchun Chen <guchun.chen@amd.com>
+Date: Thu Jul 22 17:20:21 2021 +0800
+
+ drm/amdgpu: fix build error
+
+ drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c: In function 'smu_cmn_send_msg_without_waiting':
+ drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.c:259:15: error: 'struct amdgpu_device' has no member named 'in_pci_err_recovery'
+ if (smu->adev->in_pci_err_recovery)
+ ^~
+ CC [M] drivers/staging/rtl8192u/ieee80211/ieee80211_tx.o
+ scripts/Makefile.build:272: recipe for target 'drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.o' failed
+ make[7]: *** [drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu_cmn.o] Error 1
+ scripts/Makefile.build:515: recipe for target 'drivers/gpu/drm/amd/amdgpu' failed
+ make[6]: *** [drivers/gpu/drm/amd/amdgpu] Error 2
+ make[6]: *** Waiting for unfinished jobs....
+
+ Fixes: e070ba49f3a7 drm/amd/pm: Fix a bug communicating with the SMU (v5)
+ Signed-off-by: Guchun Chen <guchun.chen@amd.com>
+ Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
+
+commit ec7f3b175ad85caf3289506ae95b27ddb106416e
+Author: Luben Tuikov <luben.tuikov@amd.com>
+Date: Fri Jul 9 23:33:11 2021 -0400
+
+ drm/amd/pm: Fix a bug communicating with the SMU (v5)
+
+ This fixes a bug which if we probe a non-existing
+ I2C device, and the SMU returns 0xFF, from then on
+ we can never communicate with the SMU, because the
+ code before this patch reads and interprets 0xFF
+ as a terminal error, and thus we never write 0
+ into register 90 to clear the status (and
+ subsequently send a new command to the SMU.)
+
+ It is not an error that the SMU returns status
+ 0xFF. This means that the SMU executed the last
+ command successfully (execution status), but the
+ command result is an error of some sort (execution
+ result), depending on what the command was.
+
+ When doing a status check of the SMU, before we
+ send a new command, the only status which
+ precludes us from sending a new command is 0--the
+ SMU hasn't finished executing a previous command,
+ and 0xFC--the SMU is busy.
+
+ This bug was seen as the following line in the
+ kernel log,
+
+ amdgpu: Msg issuing pre-check failed(0xff) and SMU may be not in the right state!
+
+ when subsequent SMU commands, not necessarily
+ related to I2C, were sent to the SMU.
+
+ This patch fixes this bug.
+
+ v2: Add a comment to the description of
+ __smu_cmn_poll_stat() to explain why we're NOT
+ defining the SMU FW return codes as macros, but
+ are instead hard-coding them. Such a change, can
+ be followed up by a subsequent patch.
+
+ v3: The changes are,
+ a) Add comments to break labels in
+ __smu_cmn_reg2errno().
+
+ b) When an unknown/unspecified/undefined result is
+ returned back from the SMU, map that to
+ -EREMOTEIO, to distinguish failure at the SMU
+ FW.
+
+ c) Add kernel-doc to
+ smu_cmn_send_msg_without_waiting(),
+ smu_cmn_wait_for_response(),
+ smu_cmn_send_smc_msg_with_param().
+
+ d) In smu_cmn_send_smc_msg_with_param(), since we
+ wait for completion of the command, if the
+ result of the completion is
+ undefined/unknown/unspecified, we print that to
+ the kernel log.
+
+ v4: a) Add macros as requested, though redundant, to
+ be removed when SMU consolidates for all
+ ASICs--see comment in code.
+ b) Get out if the SMU code is unknown.
+
+ v5: Rename the macro names.
+
+ Cc: Alex Deucher <Alexander.Deucher@amd.com>
+ Cc: Evan Quan <evan.quan@amd.com>
+ Cc: Lijo Lazar <Lijo.Lazar@amd.com>
+ Fixes: fcb1fe9c9e0031 ("drm/amd/powerplay: pre-check the SMU state before issuing message")
+ Signed-off-by: Luben Tuikov <luben.tuikov@amd.com>
+ Reviewed-by: Alex Deucher <Alexander.Deucher@amd.com>
+---
+ drivers/acpi/x86/s2idle.c | 67 ++--
+ .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 3 +
+ .../gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c | 3 +
+ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c | 290 +++++++++++++++---
+ drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h | 3 +-
+ drivers/pinctrl/pinctrl-amd.c | 19 +-
+ drivers/pinctrl/pinctrl-amd.h | 1 +
+ drivers/platform/x86/amd-pmc.c | 1 +
+ 8 files changed, 306 insertions(+), 81 deletions(-)
+
+diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c
+index 3a308461246a..7d1976e5dd8b 100644
+--- a/drivers/acpi/x86/s2idle.c
++++ b/drivers/acpi/x86/s2idle.c
+@@ -449,25 +449,30 @@ int acpi_s2idle_prepare_late(void)
+ if (pm_debug_messages_on)
+ lpi_check_constraints();
+
+- if (lps0_dsm_func_mask_microsoft > 0) {
++ /* screen off */
++ if (lps0_dsm_func_mask > 0)
++ acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
++ ACPI_LPS0_SCREEN_OFF_AMD :
++ ACPI_LPS0_SCREEN_OFF,
++ lps0_dsm_func_mask, lps0_dsm_guid);
++
++ if (lps0_dsm_func_mask_microsoft > 0)
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF,
+ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
++
++ /* lps0 entry */
++ if (lps0_dsm_func_mask > 0)
++ acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
++ ACPI_LPS0_ENTRY_AMD :
++ ACPI_LPS0_ENTRY,
++ lps0_dsm_func_mask, lps0_dsm_guid);
++ if (lps0_dsm_func_mask_microsoft > 0) {
++ acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
++ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
++ /* modern standby entry */
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_ENTRY,
+ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
+- lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
+- } else if (acpi_s2idle_vendor_amd()) {
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF_AMD,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- } else {
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+ }
+-
+ return 0;
+ }
+
+@@ -476,24 +481,30 @@ void acpi_s2idle_restore_early(void)
+ if (!lps0_device_handle || sleep_no_lps0)
+ return;
+
+- if (lps0_dsm_func_mask_microsoft > 0) {
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
+- lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
++ /* mdoern standby exit */
++ if (lps0_dsm_func_mask_microsoft > 0)
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT,
+ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
++
++ /* lps0 exit */
++ if (lps0_dsm_func_mask > 0)
++ acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
++ ACPI_LPS0_EXIT_AMD :
++ ACPI_LPS0_EXIT,
++ lps0_dsm_func_mask, lps0_dsm_guid);
++ if (lps0_dsm_func_mask_microsoft > 0)
++ acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
++ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
++
++ /* screen on */
++ if (lps0_dsm_func_mask_microsoft > 0)
+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON,
+ lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
+- } else if (acpi_s2idle_vendor_amd()) {
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT_AMD,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON_AMD,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- } else {
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON,
+- lps0_dsm_func_mask, lps0_dsm_guid);
+- }
++ if (lps0_dsm_func_mask > 0)
++ acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
++ ACPI_LPS0_SCREEN_ON_AMD :
++ ACPI_LPS0_SCREEN_ON,
++ lps0_dsm_func_mask, lps0_dsm_guid);
+ }
+
+ static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = {
+diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+index 0a5d46ac9ccd..626d7c2bdf66 100644
+--- a/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
++++ b/drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c
+@@ -272,6 +272,9 @@ int smu_v11_0_check_fw_version(struct smu_context *smu)
+ break;
+ }
+
++ dev_info(smu->adev->dev, "smu fw reported version = 0x%08x (%d.%d.%d)\n",
++ smu_version, smu_major, smu_minor, smu_debug);
++
+ /*
+ * 1. if_version mismatch is not critical as our fw is designed
+ * to be backward compatible.
+diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c b/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c
+index d60b8c5e8715..00ebc381a605 100644
+--- a/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c
++++ b/drivers/gpu/drm/amd/pm/swsmu/smu12/smu_v12_0.c
+@@ -88,6 +88,9 @@ int smu_v12_0_check_fw_version(struct smu_context *smu)
+ if (smu->is_apu)
+ adev->pm.fw_version = smu_version;
+
++ dev_info(smu->adev->dev, "smu fw reported version = 0x%08x (%d.%d.%d)\n",
++ smu_version, smu_major, smu_minor, smu_debug);
++
+ /*
+ * 1. if_version mismatch is not critical as our fw is designed
+ * to be backward compatible.
+diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
+index e802f9a95f08..a0e2111eb783 100644
+--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
++++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c
+@@ -55,7 +55,7 @@
+
+ #undef __SMU_DUMMY_MAP
+ #define __SMU_DUMMY_MAP(type) #type
+-static const char* __smu_message_names[] = {
++static const char * const __smu_message_names[] = {
+ SMU_MESSAGE_TYPES
+ };
+
+@@ -76,55 +76,258 @@ static void smu_cmn_read_arg(struct smu_context *smu,
+ *arg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82);
+ }
+
+-int smu_cmn_wait_for_response(struct smu_context *smu)
++/* Redefine the SMU error codes here.
++ *
++ * Note that these definitions are redundant and should be removed
++ * when the SMU has exported a unified header file containing these
++ * macros, which header file we can just include and use the SMU's
++ * macros. At the moment, these error codes are defined by the SMU
++ * per-ASIC unfortunately, yet we're a one driver for all ASICs.
++ */
++#define SMU_RESP_NONE 0
++#define SMU_RESP_OK 1
++#define SMU_RESP_CMD_FAIL 0xFF
++#define SMU_RESP_CMD_UNKNOWN 0xFE
++#define SMU_RESP_CMD_BAD_PREREQ 0xFD
++#define SMU_RESP_BUSY_OTHER 0xFC
++#define SMU_RESP_DEBUG_END 0xFB
++
++/**
++ * __smu_cmn_poll_stat -- poll for a status from the SMU
++ * smu: a pointer to SMU context
++ *
++ * Returns the status of the SMU, which could be,
++ * 0, the SMU is busy with your previous command;
++ * 1, execution status: success, execution result: success;
++ * 0xFF, execution status: success, execution result: failure;
++ * 0xFE, unknown command;
++ * 0xFD, valid command, but bad (command) prerequisites;
++ * 0xFC, the command was rejected as the SMU is busy;
++ * 0xFB, "SMC_Result_DebugDataDumpEnd".
++ *
++ * The values here are not defined by macros, because I'd rather we
++ * include a single header file which defines them, which is
++ * maintained by the SMU FW team, so that we're impervious to firmware
++ * changes. At the moment those values are defined in various header
++ * files, one for each ASIC, yet here we're a single ASIC-agnostic
++ * interface. Such a change can be followed-up by a subsequent patch.
++ */
++static u32 __smu_cmn_poll_stat(struct smu_context *smu)
+ {
+ struct amdgpu_device *adev = smu->adev;
+- uint32_t cur_value, i, timeout = adev->usec_timeout * 20;
++ int timeout = adev->usec_timeout * 20;
++ u32 reg;
+
+- for (i = 0; i < timeout; i++) {
+- cur_value = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
+- if ((cur_value & MP1_C2PMSG_90__CONTENT_MASK) != 0)
+- return cur_value;
++ for ( ; timeout > 0; timeout--) {
++ reg = RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
++ if ((reg & MP1_C2PMSG_90__CONTENT_MASK) != 0)
++ break;
+
+ udelay(1);
+ }
+
+- /* timeout means wrong logic */
+- if (i == timeout)
+- return -ETIME;
+-
+- return RREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90);
++ return reg;
+ }
+
+-int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
+- uint16_t msg, uint32_t param)
++static void __smu_cmn_reg_print_error(struct smu_context *smu,
++ u32 reg_c2pmsg_90,
++ int msg_index,
++ u32 param,
++ enum smu_message_type msg)
+ {
+ struct amdgpu_device *adev = smu->adev;
+- int ret;
++ const char *message = smu_get_message_name(smu, msg);
+
+- ret = smu_cmn_wait_for_response(smu);
+- if (ret != 0x1) {
+- dev_err(adev->dev, "Msg issuing pre-check failed(0x%x) and "
+- "SMU may be not in the right state!\n", ret);
+- if (ret != -ETIME)
+- ret = -EIO;
+- return ret;
++ switch (reg_c2pmsg_90) {
++ case SMU_RESP_NONE:
++ dev_err_ratelimited(adev->dev,
++ "SMU: I'm not done with your previous command!");
++ break;
++ case SMU_RESP_OK:
++ /* The SMU executed the command. It completed with a
++ * successful result.
++ */
++ break;
++ case SMU_RESP_CMD_FAIL:
++ /* The SMU executed the command. It completed with an
++ * unsuccessful result.
++ */
++ break;
++ case SMU_RESP_CMD_UNKNOWN:
++ dev_err_ratelimited(adev->dev,
++ "SMU: unknown command: index:%d param:0x%08X message:%s",
++ msg_index, param, message);
++ break;
++ case SMU_RESP_CMD_BAD_PREREQ:
++ dev_err_ratelimited(adev->dev,
++ "SMU: valid command, bad prerequisites: index:%d param:0x%08X message:%s",
++ msg_index, param, message);
++ break;
++ case SMU_RESP_BUSY_OTHER:
++ dev_err_ratelimited(adev->dev,
++ "SMU: I'm very busy for your command: index:%d param:0x%08X message:%s",
++ msg_index, param, message);
++ break;
++ case SMU_RESP_DEBUG_END:
++ dev_err_ratelimited(adev->dev,
++ "SMU: I'm debugging!");
++ break;
++ default:
++ dev_err_ratelimited(adev->dev,
++ "SMU: response:0x%08X for index:%d param:0x%08X message:%s?",
++ reg_c2pmsg_90, msg_index, param, message);
++ break;
+ }
++}
++
++static int __smu_cmn_reg2errno(struct smu_context *smu, u32 reg_c2pmsg_90)
++{
++ int res;
++
++ switch (reg_c2pmsg_90) {
++ case SMU_RESP_NONE:
++ /* The SMU is busy--still executing your command.
++ */
++ res = -ETIME;
++ break;
++ case SMU_RESP_OK:
++ res = 0;
++ break;
++ case SMU_RESP_CMD_FAIL:
++ /* Command completed successfully, but the command
++ * status was failure.
++ */
++ res = -EIO;
++ break;
++ case SMU_RESP_CMD_UNKNOWN:
++ /* Unknown command--ignored by the SMU.
++ */
++ res = -EOPNOTSUPP;
++ break;
++ case SMU_RESP_CMD_BAD_PREREQ:
++ /* Valid command--bad prerequisites.
++ */
++ res = -EINVAL;
++ break;
++ case SMU_RESP_BUSY_OTHER:
++ /* The SMU is busy with other commands. The client
++ * should retry in 10 us.
++ */
++ res = -EBUSY;
++ break;
++ default:
++ /* Unknown or debug response from the SMU.
++ */
++ res = -EREMOTEIO;
++ break;
++ }
++
++ return res;
++}
++
++static void __smu_cmn_send_msg(struct smu_context *smu,
++ u16 msg,
++ u32 param)
++{
++ struct amdgpu_device *adev = smu->adev;
+
+ WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_90, 0);
+ WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_82, param);
+ WREG32_SOC15(MP1, 0, mmMP1_SMN_C2PMSG_66, msg);
+-
+- return 0;
+ }
+
++/**
++ * smu_cmn_send_msg_without_waiting -- send the message; don't wait for status
++ * @smu: pointer to an SMU context
++ * @msg_index: message index
++ * @param: message parameter to send to the SMU
++ *
++ * Send a message to the SMU with the parameter passed. Do not wait
++ * for status/result of the message, thus the "without_waiting".
++ *
++ * Return 0 on success, -errno on error if we weren't able to _send_
++ * the message for some reason. See __smu_cmn_reg2errno() for details
++ * of the -errno.
++ */
++int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
++ uint16_t msg_index,
++ uint32_t param)
++{
++ u32 reg;
++ int res;
++
++ if (smu->adev->no_hw_access)
++ return 0;
++
++ mutex_lock(&smu->message_lock);
++ reg = __smu_cmn_poll_stat(smu);
++ res = __smu_cmn_reg2errno(smu, reg);
++ if (reg == SMU_RESP_NONE ||
++ reg == SMU_RESP_BUSY_OTHER ||
++ res == -EREMOTEIO)
++ goto Out;
++ __smu_cmn_send_msg(smu, msg_index, param);
++ res = 0;
++Out:
++ mutex_unlock(&smu->message_lock);
++ return res;
++}
++
++/**
++ * smu_cmn_wait_for_response -- wait for response from the SMU
++ * @smu: pointer to an SMU context
++ *
++ * Wait for status from the SMU.
++ *
++ * Return 0 on success, -errno on error, indicating the execution
++ * status and result of the message being waited for. See
++ * __smu_cmn_reg2errno() for details of the -errno.
++ */
++int smu_cmn_wait_for_response(struct smu_context *smu)
++{
++ u32 reg;
++
++ reg = __smu_cmn_poll_stat(smu);
++ return __smu_cmn_reg2errno(smu, reg);
++}
++
++/**
++ * smu_cmn_send_smc_msg_with_param -- send a message with parameter
++ * @smu: pointer to an SMU context
++ * @msg: message to send
++ * @param: parameter to send to the SMU
++ * @read_arg: pointer to u32 to return a value from the SMU back
++ * to the caller
++ *
++ * Send the message @msg with parameter @param to the SMU, wait for
++ * completion of the command, and return back a value from the SMU in
++ * @read_arg pointer.
++ *
++ * Return 0 on success, -errno on error, if we weren't able to send
++ * the message or if the message completed with some kind of
++ * error. See __smu_cmn_reg2errno() for details of the -errno.
++ *
++ * If we weren't able to send the message to the SMU, we also print
++ * the error to the standard log.
++ *
++ * Command completion status is printed only if the -errno is
++ * -EREMOTEIO, indicating that the SMU returned back an
++ * undefined/unknown/unspecified result. All other cases are
++ * well-defined, not printed, but instead given back to the client to
++ * decide what further to do.
++ *
++ * The return value, @read_arg is read back regardless, to give back
++ * more information to the client, which on error would most likely be
++ * @param, but we can't assume that. This also eliminates more
++ * conditionals.
++ */
+ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
+ enum smu_message_type msg,
+ uint32_t param,
+ uint32_t *read_arg)
+ {
+- struct amdgpu_device *adev = smu->adev;
+- int ret = 0, index = 0;
++ int res, index;
++ u32 reg;
+
+ if (smu->adev->no_hw_access)
+ return 0;
+@@ -136,31 +339,24 @@ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
+ return index == -EACCES ? 0 : index;
+
+ mutex_lock(&smu->message_lock);
+- ret = smu_cmn_send_msg_without_waiting(smu, (uint16_t)index, param);
+- if (ret)
+- goto out;
+-
+- ret = smu_cmn_wait_for_response(smu);
+- if (ret != 0x1) {
+- if (ret == -ETIME) {
+- dev_err(adev->dev, "message: %15s (%d) \tparam: 0x%08x is timeout (no response)\n",
+- smu_get_message_name(smu, msg), index, param);
+- } else {
+- dev_err(adev->dev, "failed send message: %15s (%d) \tparam: 0x%08x response %#x\n",
+- smu_get_message_name(smu, msg), index, param,
+- ret);
+- ret = -EIO;
+- }
+- goto out;
++ reg = __smu_cmn_poll_stat(smu);
++ res = __smu_cmn_reg2errno(smu, reg);
++ if (reg == SMU_RESP_NONE ||
++ reg == SMU_RESP_BUSY_OTHER ||
++ res == -EREMOTEIO) {
++ __smu_cmn_reg_print_error(smu, reg, index, param, msg);
++ goto Out;
+ }
+-
++ __smu_cmn_send_msg(smu, (uint16_t) index, param);
++ reg = __smu_cmn_poll_stat(smu);
++ res = __smu_cmn_reg2errno(smu, reg);
++ if (res == -EREMOTEIO)
++ __smu_cmn_reg_print_error(smu, reg, index, param, msg);
+ if (read_arg)
+ smu_cmn_read_arg(smu, read_arg);
+-
+- ret = 0; /* 0 as driver return value */
+-out:
++Out:
+ mutex_unlock(&smu->message_lock);
+- return ret;
++ return res;
+ }
+
+ int smu_cmn_send_smc_msg(struct smu_context *smu,
+diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
+index 9add5f16ff56..16993daa2ae0 100644
+--- a/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
++++ b/drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h
+@@ -27,7 +27,8 @@
+
+ #if defined(SWSMU_CODE_LAYER_L2) || defined(SWSMU_CODE_LAYER_L3) || defined(SWSMU_CODE_LAYER_L4)
+ int smu_cmn_send_msg_without_waiting(struct smu_context *smu,
+- uint16_t msg, uint32_t param);
++ uint16_t msg_index,
++ uint32_t param);
+ int smu_cmn_send_smc_msg_with_param(struct smu_context *smu,
+ enum smu_message_type msg,
+ uint32_t param,
+diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
+index 5b764740b829..d19974aceb2e 100644
+--- a/drivers/pinctrl/pinctrl-amd.c
++++ b/drivers/pinctrl/pinctrl-amd.c
+@@ -445,6 +445,7 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ struct amd_gpio *gpio_dev = gpiochip_get_data(gc);
+ u32 wake_mask = BIT(WAKE_CNTRL_OFF_S0I3) | BIT(WAKE_CNTRL_OFF_S3);
++ int err;
+
+ raw_spin_lock_irqsave(&gpio_dev->lock, flags);
+ pin_reg = readl(gpio_dev->base + (d->hwirq)*4);
+@@ -457,6 +458,15 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
+ writel(pin_reg, gpio_dev->base + (d->hwirq)*4);
+ raw_spin_unlock_irqrestore(&gpio_dev->lock, flags);
+
++ if (on)
++ err = enable_irq_wake(gpio_dev->irq);
++ else
++ err = disable_irq_wake(gpio_dev->irq);
++
++ if (err)
++ dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n",
++ on ? "enable" : "disable");
++
+ return 0;
+ }
+
+@@ -904,7 +914,6 @@ static struct pinctrl_desc amd_pinctrl_desc = {
+ static int amd_gpio_probe(struct platform_device *pdev)
+ {
+ int ret = 0;
+- int irq_base;
+ struct resource *res;
+ struct amd_gpio *gpio_dev;
+ struct gpio_irq_chip *girq;
+@@ -927,9 +936,9 @@ static int amd_gpio_probe(struct platform_device *pdev)
+ if (!gpio_dev->base)
+ return -ENOMEM;
+
+- irq_base = platform_get_irq(pdev, 0);
+- if (irq_base < 0)
+- return irq_base;
++ gpio_dev->irq = platform_get_irq(pdev, 0);
++ if (gpio_dev->irq < 0)
++ return gpio_dev->irq;
+
+ #ifdef CONFIG_PM_SLEEP
+ gpio_dev->saved_regs = devm_kcalloc(&pdev->dev, amd_pinctrl_desc.npins,
+@@ -989,7 +998,7 @@ static int amd_gpio_probe(struct platform_device *pdev)
+ goto out2;
+ }
+
+- ret = devm_request_irq(&pdev->dev, irq_base, amd_gpio_irq_handler,
++ ret = devm_request_irq(&pdev->dev, gpio_dev->irq, amd_gpio_irq_handler,
+ IRQF_SHARED, KBUILD_MODNAME, gpio_dev);
+ if (ret)
+ goto out2;
+diff --git a/drivers/pinctrl/pinctrl-amd.h b/drivers/pinctrl/pinctrl-amd.h
+index 95e763424042..1d4317073654 100644
+--- a/drivers/pinctrl/pinctrl-amd.h
++++ b/drivers/pinctrl/pinctrl-amd.h
+@@ -98,6 +98,7 @@ struct amd_gpio {
+ struct resource *res;
+ struct platform_device *pdev;
+ u32 *saved_regs;
++ int irq;
+ };
+
+ /* KERNCZ configuration*/
+diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c
+index 3481479a2942..52a88c9bc0ab 100644
+--- a/drivers/platform/x86/amd-pmc.c
++++ b/drivers/platform/x86/amd-pmc.c
+@@ -270,6 +270,7 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set, u32 *data, u8 msg
+ u32 val;
+
+ mutex_lock(&dev->lock);
++ amd_pmc_dump_registers(dev);
+ /* Wait until we get a valid response */
+ rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
+ val, val != 0, PMC_MSG_DELAY_MIN_US,
+--
+2.33.0
+
diff --git a/9002-amd-pmc-delay-test.patch b/9002-amd-pmc-delay-test.patch
new file mode 100644
index 000000000000..5c1d59cc0ddf
--- /dev/null
+++ b/9002-amd-pmc-delay-test.patch
@@ -0,0 +1,44 @@
+From 47e5da763d58a3b6657e2a716130a470e1deee2f Mon Sep 17 00:00:00 2001
+From: Scott B <28817345+foundObjects@users.noreply.github.com>
+Date: Wed, 25 Aug 2021 07:35:52 -0700
+Subject: [PATCH] amd-pmc delay test
+
+---
+ drivers/platform/x86/amd-pmc.c | 8 +++++++-
+ 1 file changed, 7 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c
+index 52a88c9bc0ab..336303e963c5 100644
+--- a/drivers/platform/x86/amd-pmc.c
++++ b/drivers/platform/x86/amd-pmc.c
+@@ -71,7 +71,7 @@
+ #define AMD_CPU_ID_YC 0x14B5
+
+ #define PMC_MSG_DELAY_MIN_US 100
+-#define RESPONSE_REGISTER_LOOP_MAX 200
++#define RESPONSE_REGISTER_LOOP_MAX 2000
+
+ #define SOC_SUBSYSTEM_IP_MAX 12
+ #define DELAY_MIN_US 2000
+@@ -283,12 +283,18 @@ static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set, u32 *data, u8 msg
+ /* Write zero to response register */
+ amd_pmc_reg_write(dev, AMD_PMC_REGISTER_RESPONSE, 0);
+
++ udelay(500);
++
+ /* Write argument into response register */
+ amd_pmc_reg_write(dev, AMD_PMC_REGISTER_ARGUMENT, set);
+
++ udelay(500);
++
+ /* Write message ID to message ID register */
+ amd_pmc_reg_write(dev, AMD_PMC_REGISTER_MESSAGE, msg);
+
++ udelay(500);
++
+ /* Wait until we get a valid response */
+ rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
+ val, val != 0, PMC_MSG_DELAY_MIN_US,
+--
+2.33.0
+
diff --git a/HID-asus-Prevent-Claymore-sending-suspend-event.patch b/HID-asus-Prevent-Claymore-sending-suspend-event.patch
new file mode 100644
index 000000000000..c72d5ce0e0a7
--- /dev/null
+++ b/HID-asus-Prevent-Claymore-sending-suspend-event.patch
@@ -0,0 +1,73 @@
+From patchwork Sat Aug 7 02:49:21 2021
+From: "Luke D. Jones" <luke@ljones.dev>
+To: linux-input@vger.kernel.org
+Cc: linux-kernel@vger.kernel.org, jikos@kernel.org,
+ benjamin.tissoires@redhat.com, "Luke D. Jones" <luke@ljones.dev>
+Subject: [PATCH] HID: asus: Prevent Claymore sending suspend event
+Date: Sat, 7 Aug 2021 14:49:21 +1200
+Message-Id: <20210807024921.26479-1-luke@ljones.dev>
+List-ID: <linux-input.vger.kernel.org>
+X-Mailing-List: linux-input@vger.kernel.org
+
+Prevent the ASUS Claymore keyboard from sending a suspend event
+when the device sleeps itself. The suspend event causes a system
+suspend if uncaught.
+
+Signed off by: Luke D Jones <luke@ljones.dev>
+---
+ drivers/hid/hid-asus.c | 15 +++++++++++++++
+ drivers/hid/hid-ids.h | 1 +
+ 2 files changed, 16 insertions(+)
+
+diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
+index fca8fc78a78a..9de0129fc3d4 100644
+--- a/drivers/hid/hid-asus.c
++++ b/drivers/hid/hid-asus.c
+@@ -82,6 +82,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
+ #define QUIRK_T90CHI BIT(9)
+ #define QUIRK_MEDION_E1239T BIT(10)
+ #define QUIRK_ROG_NKEY_KEYBOARD BIT(11)
++#define QUIRK_ROG_CLAYMORE_II_KEYBOARD BIT(12)
+
+ #define I2C_KEYBOARD_QUIRKS (QUIRK_FIX_NOTEBOOK_REPORT | \
+ QUIRK_NO_INIT_REPORTS | \
+@@ -366,6 +367,17 @@ static int asus_raw_event(struct hid_device *hdev,
+
+ }
+
++ if (drvdata->quirks & QUIRK_ROG_CLAYMORE_II_KEYBOARD) {
++ /*
++ * CLAYMORE II keyboard sends this packet when it goes to sleep
++ * this causes the whole system to go into suspend.
++ */
++
++ if(size == 2 && data[0] == 0x02 && data[1] == 0x00) {
++ return -1;
++ }
++ }
++
+ return 0;
+ }
+
+@@ -1228,6 +1240,9 @@ static const struct hid_device_id asus_devices[] = {
+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
+ USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2),
+ QUIRK_USE_KBD_BACKLIGHT | QUIRK_ROG_NKEY_KEYBOARD },
++ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
++ USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD),
++ QUIRK_ROG_CLAYMORE_II_KEYBOARD },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK,
+ USB_DEVICE_ID_ASUSTEK_T100TA_KEYBOARD),
+ QUIRK_T100_KEYBOARD | QUIRK_NO_CONSUMER_USAGES },
+diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
+index b84a0a11e05b..c5d5e6f269a0 100644
+--- a/drivers/hid/hid-ids.h
++++ b/drivers/hid/hid-ids.h
+@@ -197,6 +197,7 @@
+ #define USB_DEVICE_ID_ASUSTEK_ROG_KEYBOARD3 0x1822
+ #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD 0x1866
+ #define USB_DEVICE_ID_ASUSTEK_ROG_NKEY_KEYBOARD2 0x19b6
++#define USB_DEVICE_ID_ASUSTEK_ROG_CLAYMORE_II_KEYBOARD 0x196b
+ #define USB_DEVICE_ID_ASUSTEK_FX503VD_KEYBOARD 0x1869
+
+ #define USB_VENDOR_ID_ATEN 0x0557
diff --git a/HID-asus-Reduce-object-size-by-consolidating-calls.patch b/HID-asus-Reduce-object-size-by-consolidating-calls.patch
new file mode 100644
index 000000000000..761b6bcae9ef
--- /dev/null
+++ b/HID-asus-Reduce-object-size-by-consolidating-calls.patch
@@ -0,0 +1,190 @@
+From patchwork Sat May 29 16:29:48 2021
+Message-ID: <56767df55117cc5834b0021ba2c056272e686804.camel@perches.com>
+Subject: [PATCH] HID: asus: Reduce object size by consolidating calls
+From: Joe Perches <joe@perches.com>
+To: Jiri Kosina <jikos@kernel.org>,
+ Benjamin Tissoires <benjamin.tissoires@redhat.com>
+Cc: linux-input <linux-input@vger.kernel.org>,
+ LKML <linux-kernel@vger.kernel.org>
+Date: Sat, 29 May 2021 09:29:48 -0700
+List-ID: <linux-input.vger.kernel.org>
+X-Mailing-List: linux-input@vger.kernel.org
+
+Add intermediating lookup functions to avoid repetitive calls.
+
+Reduces object size ~4kb (x86-64 defconfig w/ hid-asus)
+
+$ size drivers/hid/hid-asus.o*
+ text data bss dec hex filename
+ 10442 468 0 10910 2a9e drivers/hid/hid-asus.o.bew
+ 14523 468 0 14991 3a8f drivers/hid/hid-asus.o.old
+
+Miscellanea:
+
+o Remove now unused asus_map_kay_clear macro
+
+Signed-off-by: Joe Perches <joe@perches.com>
+---
+
+untested, no hardware
+
+ drivers/hid/hid-asus.c | 128 ++++++++++++++++++++++++-------------------------
+ 1 file changed, 64 insertions(+), 64 deletions(-)
+
+diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
+index fca8fc78a78a3..5b78e6c3bb5d9 100644
+--- a/drivers/hid/hid-asus.c
++++ b/drivers/hid/hid-asus.c
+@@ -811,8 +811,58 @@ static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
+ return 0;
+ }
+
+-#define asus_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, \
+- max, EV_KEY, (c))
++static int asus_map_use_to_btn(int use)
++{
++ switch (use) {
++ case 0x10: return KEY_BRIGHTNESSDOWN;
++ case 0x20: return KEY_BRIGHTNESSUP;
++ case 0x35: return KEY_DISPLAY_OFF;
++ case 0x6c: return KEY_SLEEP;
++ case 0x7c: return KEY_MICMUTE;
++ case 0x82: return KEY_CAMERA;
++ case 0x88: return KEY_RFKILL;
++ case 0xb5: return KEY_CALC;
++ case 0xc4: return KEY_KBDILLUMUP;
++ case 0xc5: return KEY_KBDILLUMDOWN;
++ case 0x6b: return KEY_F21; /* ASUS touchpad toggle */
++ case 0x38: return KEY_PROG1; /* ROG key */
++ case 0xba: return KEY_PROG2; /* Fn+C ASUS Splendid */
++ case 0x5c: return KEY_PROG3; /* Fn+Space Power4Gear Hybrid */
++ case 0x99: return KEY_PROG4; /* Fn+F5 "fan" symbol on FX503VD */
++ /* for N-Key keyboard */
++ case 0xae: return KEY_PROG4; /* Fn+F5 "fan" symbol */
++ case 0x92: return KEY_CALC; /* Fn+Ret "Calc" symbol */
++ case 0xb2: return KEY_PROG2; /* Fn+Left Aura mode previous */
++ case 0xb3: return KEY_PROG3; /* Fn+Right Aura mode next */
++ }
++
++ return 0;
++}
++
++static int ms_map_use_to_btn(int use)
++{
++ switch (use) {
++ case 0xff01: return BTN_1;
++ case 0xff02: return BTN_2;
++ case 0xff03: return BTN_3;
++ case 0xff04: return BTN_4;
++ case 0xff05: return BTN_5;
++ case 0xff06: return BTN_6;
++ case 0xff07: return BTN_7;
++ case 0xff08: return BTN_8;
++ case 0xff09: return BTN_9;
++ case 0xff0a: return BTN_A;
++ case 0xff0b: return BTN_B;
++ case 0x00f1: return KEY_WLAN;
++ case 0x00f2: return KEY_BRIGHTNESSDOWN;
++ case 0x00f3: return KEY_BRIGHTNESSUP;
++ case 0x00f4: return KEY_DISPLAY_OFF;
++ case 0x00f7: return KEY_CAMERA;
++ case 0x00f8: return KEY_PROG1;
++ }
++
++ return 0;
++}
+ static int asus_input_mapping(struct hid_device *hdev,
+ struct hid_input *hi, struct hid_field *field,
+ struct hid_usage *usage, unsigned long **bit,
+@@ -842,50 +892,16 @@ static int asus_input_mapping(struct hid_device *hdev,
+
+ /* ASUS-specific keyboard hotkeys and led backlight */
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_ASUSVENDOR) {
+- switch (usage->hid & HID_USAGE) {
+- case 0x10: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
+- case 0x20: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
+- case 0x35: asus_map_key_clear(KEY_DISPLAY_OFF); break;
+- case 0x6c: asus_map_key_clear(KEY_SLEEP); break;
+- case 0x7c: asus_map_key_clear(KEY_MICMUTE); break;
+- case 0x82: asus_map_key_clear(KEY_CAMERA); break;
+- case 0x88: asus_map_key_clear(KEY_RFKILL); break;
+- case 0xb5: asus_map_key_clear(KEY_CALC); break;
+- case 0xc4: asus_map_key_clear(KEY_KBDILLUMUP); break;
+- case 0xc5: asus_map_key_clear(KEY_KBDILLUMDOWN); break;
+-
+- /* ASUS touchpad toggle */
+- case 0x6b: asus_map_key_clear(KEY_F21); break;
+-
+- /* ROG key */
+- case 0x38: asus_map_key_clear(KEY_PROG1); break;
+-
+- /* Fn+C ASUS Splendid */
+- case 0xba: asus_map_key_clear(KEY_PROG2); break;
++ int btn = asus_map_use_to_btn(usage->hid & HID_USAGE);
+
+- /* Fn+Space Power4Gear Hybrid */
+- case 0x5c: asus_map_key_clear(KEY_PROG3); break;
+-
+- /* Fn+F5 "fan" symbol on FX503VD */
+- case 0x99: asus_map_key_clear(KEY_PROG4); break;
+-
+- /* Fn+F5 "fan" symbol on N-Key keyboard */
+- case 0xae: asus_map_key_clear(KEY_PROG4); break;
+-
+- /* Fn+Ret "Calc" symbol on N-Key keyboard */
+- case 0x92: asus_map_key_clear(KEY_CALC); break;
+-
+- /* Fn+Left Aura mode previous on N-Key keyboard */
+- case 0xb2: asus_map_key_clear(KEY_PROG2); break;
+-
+- /* Fn+Right Aura mode next on N-Key keyboard */
+- case 0xb3: asus_map_key_clear(KEY_PROG3); break;
+-
+- default:
+- /* ASUS lazily declares 256 usages, ignore the rest,
+- * as some make the keyboard appear as a pointer device. */
++ /*
++ * ASUS lazily declares 256 usages, ignore the rest,
++ * as some make the keyboard appear as a pointer device.
++ */
++ if (!btn)
+ return -1;
+- }
++
++ hid_map_usage_clear(hi, usage, bit, max, EV_KEY, btn);
+
+ /*
+ * Check and enable backlight only on devices with UsagePage ==
+@@ -901,28 +917,12 @@ static int asus_input_mapping(struct hid_device *hdev,
+ }
+
+ if ((usage->hid & HID_USAGE_PAGE) == HID_UP_MSVENDOR) {
+- switch (usage->hid & HID_USAGE) {
+- case 0xff01: asus_map_key_clear(BTN_1); break;
+- case 0xff02: asus_map_key_clear(BTN_2); break;
+- case 0xff03: asus_map_key_clear(BTN_3); break;
+- case 0xff04: asus_map_key_clear(BTN_4); break;
+- case 0xff05: asus_map_key_clear(BTN_5); break;
+- case 0xff06: asus_map_key_clear(BTN_6); break;
+- case 0xff07: asus_map_key_clear(BTN_7); break;
+- case 0xff08: asus_map_key_clear(BTN_8); break;
+- case 0xff09: asus_map_key_clear(BTN_9); break;
+- case 0xff0a: asus_map_key_clear(BTN_A); break;
+- case 0xff0b: asus_map_key_clear(BTN_B); break;
+- case 0x00f1: asus_map_key_clear(KEY_WLAN); break;
+- case 0x00f2: asus_map_key_clear(KEY_BRIGHTNESSDOWN); break;
+- case 0x00f3: asus_map_key_clear(KEY_BRIGHTNESSUP); break;
+- case 0x00f4: asus_map_key_clear(KEY_DISPLAY_OFF); break;
+- case 0x00f7: asus_map_key_clear(KEY_CAMERA); break;
+- case 0x00f8: asus_map_key_clear(KEY_PROG1); break;
+- default:
++ int btn = ms_map_use_to_btn(usage->hid & HID_USAGE);
++
++ if (!btn)
+ return 0;
+- }
+
++ hid_map_usage_clear(hi, usage, bit, max, EV_KEY, btn);
+ set_bit(EV_REP, hi->input->evbit);
+ return 1;
+ }
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..e0fce949a973
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,434 @@
+# Maintainer: Arglebargle < arglebargle at arglebargle dot dev>
+# Contributor: Joan Figueras <ffigue at gmail dot com>
+# Contributor: Torge Matthies <openglfreak at googlemail dot com>
+# Contributor: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
+# Contributor: Yoshi2889 <rick.2889 at gmail dot com>
+# Contributor: Tobias Powalowski <tpowa@archlinux.org>
+# Contributor: Thomas Baechler <thomas@archlinux.org>
+
+# shellcheck disable=SC2034,SC2164
+
+##
+## Xanmod-ROG options:
+##
+## Ultra Kernel Samepage Merging, enable this to perform fast in-use memory deduplication
+## See: https://github.com/dolohow/uksm
+##
+## build with 'env use_uksm=foo makepkg ...' to include UKSM patch
+##
+## NOTE: Don't enable UKSM and LRU_GEN together at runtime, they are incompatible and will crash
+## If UKSM is enabled during build LRU_GEN will be disabled by default in the kernel config
+## You can still switch between them at runtime but do *not* attempt to use both.
+##
+if [[ -v use_uksm ]]; then
+ use_uksm=y
+fi
+
+##
+## The following variables can be customized at build time. Use env or export to change at your wish
+##
+## Example: env _microarchitecture=99 use_numa=n use_tracers=n use_pds=n makepkg -sc
+##
+## Look inside 'choose-gcc-optimization.sh' to choose your microarchitecture
+## Valid numbers between: 0 to 99
+## Default is: 0 => generic
+## Good option if your package is for one machine: 98 (Intel native) or 99 (AMD native)
+if [ -z ${_microarchitecture+x} ]; then
+ _microarchitecture=93
+fi
+
+## Disable NUMA since most users do not have multiple processors. Breaks CUDA/NvEnc.
+## Archlinux and Xanmod enable it by default.
+## Set variable "use_numa" to: n to disable (possibly increase performance)
+## y to enable (stock default)
+if [ -z ${use_numa+x} ]; then
+ use_numa=y
+fi
+
+## For performance you can disable FUNCTION_TRACER/GRAPH_TRACER. Limits debugging and analyzing of the kernel.
+## Stock Archlinux and Xanmod have this enabled.
+## Set variable "use_tracers" to: n to disable (possibly increase performance)
+## y to enable (stock default)
+if [ -z ${use_tracers+x} ]; then
+ use_tracers=y
+fi
+
+## Choose between GCC and CLANG config (default is GCC)
+if [ -z ${_compiler+x} ]; then
+ _compiler=gcc
+fi
+
+# Compile ONLY used modules to VASTLY reduce the number of modules built
+# and the build time.
+#
+# To keep track of which modules are needed for your specific system/hardware,
+# give module_db script a try: https://aur.archlinux.org/packages/modprobed-db
+# This PKGBUILD read the database kept if it exists
+#
+# More at this wiki page ---> https://wiki.archlinux.org/index.php/Modprobed-db
+if [ -z "${_localmodcfg}" ]; then
+ _localmodcfg=n
+fi
+
+# Tweak kernel options prior to a build via nconfig
+_makenconfig=
+
+### IMPORTANT: Do no edit below this line unless you know what you're doing
+
+pkgbase=linux-xanmod-rog
+xanmod=5.14.0-xanmod1
+#pkgver=${xanmod//-/.}
+pkgver=5.14.1.xanpre0 # NOTE: start 4th position with 'xan...', we rely on parsing for '.xan...' later
+pkgrel=1
+pkgdesc='Linux Xanmod'
+url="http://www.xanmod.org/"
+arch=(x86_64)
+license=(GPL2)
+makedepends=(
+ bc kmod libelf pahole cpio perl tar xz zstd
+ "gcc>=11.0"
+)
+if [ "${_compiler}" = "clang" ]; then
+ makedepends+=(clang llvm lld python)
+fi
+options=('!strip')
+_major=$(echo $xanmod | cut -d'.' -f1,2)
+_patchver=$(echo $pkgver | cut -d'.' -f3)
+_branch="$(echo $xanmod | cut -d'.' -f1).x"
+_localversion=$(echo $pkgver | cut -d'.' -f4)
+
+source=("https://cdn.kernel.org/pub/linux/kernel/v${_branch}/linux-${_major}.tar."{xz,sign}
+ "https://github.com/xanmod/linux/releases/download/${xanmod}/patch-${xanmod}.xz"
+ "choose-gcc-optimization.sh"
+ "sphinx-workaround.patch"
+
+ # incremental kernel.org patch ahead of official Xanmod release
+ #"https://cdn.kernel.org/pub/linux/kernel/v5.x/incr/patch-5.13.13-14.xz"
+ "https://cdn.kernel.org/pub/linux/kernel/v5.x/patch-5.14.1.xz"
+
+ # don't drop shared caches on C3 state transitions
+ "x86-ACPI-State-Optimize-C3-entry-on-AMD-CPUs.patch"
+
+ # patch from Chromium developers; more accurately report battery state changes
+ "acpi-battery-Always-read-fresh-battery-state-on-update.patch"
+
+ # k10temp support for Zen3 APUs
+ #"x86-amd_nb-Add-AMD-family-19h-model-50h-PCI-ids.patch" # included in 5.14
+ "hwmon-k10temp-support-Zen3-APUs.patch"
+
+ # ASUS ROG enablement
+ "0101-asus-wmi-Add-panel-overdrive-functionality.patch"
+ "0102-asus-wmi-Add-dgpu-disable-method.patch"
+ "0103-asus-wmi-Add-egpu-enable-method.patch"
+ #"0006-HID-asus-Remove-check-for-same-LED-brightness-on-set.patch"
+ #"0007-ALSA-hda-realtek-Fix-speakers-not-working-on-Asus-Fl.patch"
+ "HID-asus-Prevent-Claymore-sending-suspend-event.patch"
+ "HID-asus-Reduce-object-size-by-consolidating-calls.patch"
+ "v5-asus-wmi-Add-support-for-platform_profile.patch"
+ "v9-asus-wmi-Add-support-for-custom-fan-curves.patch"
+
+ # mediatek mt7921 bt/wifi patches
+ #"8010-Bluetooth-btusb-Fixed-too-many-in-token-issue-for-Me.patch"
+ #"8011-Bluetooth-btusb-Add-support-for-Lite-On-Mediatek-Chi.patch"
+ #"8012-mt76-mt7921-continue-to-probe-driver-when-fw-already.patch"
+ "8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch"
+ "8014-mt76-mt7921-Add-mt7922-support.patch"
+ "1-1-Bluetooth-btusb-Enable-MSFT-extension-for-Mediatek-Chip-MT7921.patch"
+ "1-2-mt76-mt7915-send-EAPOL-frames-at-lowest-rate.patch"
+ "2-2-mt76-mt7921-send-EAPOL-frames-at-lowest-rate.patch"
+ "mt76-mt7921-enable-VO-tx-aggregation.patch"
+ "mt76-mt7921-fix-dma-hang-in-rmmod.patch"
+ "mt76-mt7921-fix-firmware-usage-of-RA-info-using-legacy-rates.patch"
+ "mt76-mt7921-fix-the-inconsistent-state-between-bind-and-unbind.patch"
+ "mt76-mt7921-report-HE-MU-radiotap.patch"
+ "v2-mt76-mt7921-fix-kernel-warning-from-cfg80211_calculate_bitrate.patch"
+
+ # squashed s0ix enablement
+ "9001-v5.14.1-s0ix-patch-2021-09-03.patch"
+ # delay hack adding micro delays during resume, drastically improves SMU stability
+ "9002-amd-pmc-delay-test.patch"
+ )
+validpgpkeys=(
+ 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linux Torvalds
+ '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman
+)
+
+sha256sums=('7e068b5e0d26a62b10e5320b25dce57588cbbc6f781c090442138c9c9c3271b2'
+ 'SKIP'
+ 'b8e693326d8daf6d91e7dfb81ebdef88edc9d7ded6ad12907b2c7a0551e802ab'
+ '1ac18cad2578df4a70f9346f7c6fccbb62f042a0ee0594817fdef9f2704904ee'
+ '52fc0fcd806f34e774e36570b2a739dbdf337f7ff679b1c1139bee54d03301eb'
+ '96c0bbe43e508f56277a3f03386cc01538bad013bcfaf0384475a01deaf244d7'
+ '923230ed8367e28adfdeed75d3cdba9eec6b781818c37f6f3d3eb64101d2e716'
+ 'f7a4bf6293912bfc4a20743e58a5a266be8c4dbe3c1862d196d3a3b45f2f7c90'
+ 'de8c9747637768c4356c06aa65c3f157c526aa420f21fdd5edd0ed06f720a62e'
+ '1ab75535772c63567384eb2ac74753e4d5db2f3317cb265aedf6151b9f18c6c2'
+ '8cc771f37ee08ad5796e6db64f180c1415a5f6e03eb3045272dade30ca754b53'
+ 'f3461e7cc759fd4cef2ec5c4fa15b80fa6d37e16008db223f77ed88a65aa938e'
+ 'ec317cc2c2c8c1186c4f553fdd010adc013c37600a499802473653fd8e7564df'
+ '544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4'
+ '4ef12029ea73ca924b6397e1de4911e84d9e77ddaccdab1ef579823d848524e8'
+ '3f1ea86d64cf1258385250641a907f00cdf60ad4ae17d2d43b6dcf279b26eff5'
+ '2163cb2e394a013042a40cd3b00dae788603284b20d71e262995366c5534e480'
+ 'a01cf700d79b983807e2285be1b30df6e02db6adfd9c9027fe2dfa8ca5a74bc9'
+ 'ea1d552f8fe6907e4fbd374842a655a9a64529e021c45d8459a0595c739e5cc6'
+ '051769c129e0e3a5b516b8799712e1a39dd36216d77879b33b416c8e0fd67d7a'
+ 'fa96d4e690f3e0b51075be06fe47fe5b6d94b10835767c13416701690e842e4b'
+ '3ed940a006bc1846daac9ca1194bcbffc0b7b71266d0527b7508f2263cdba9d6'
+ '1687b5d7cefdcdbe9f0152d0b38e204229ce75994b1ba5f9fee5eff65580e6a2'
+ '16c30e45665f8be034b25d3a21a9ed4cba025dd38293b77aaa12426892091adb'
+ '5b7a106d371fcf880920967d7e36728f1bcc0368eaa7bf75ebf67a4ddb93c6d5'
+ 'aa5bb422421cb7e1340d8f07b5471995bbc3c7dd7cf91db76ab1dbe7efc2777a'
+ '5e66b5a6a775ad42489dfd0f6057b69dae696a5ec8be428da329f68c1265764a'
+ '3d6d1e6374688c5f1abbc40b15c03c62f695e9d04d790556c57f8ec5d0d6a3f9'
+ 'd8dd84c26a44af618c6d1b68723e3bf0f8f50165af04fe090256afb0f931713e')
+
+# apply UKSM patch; TODO: note to self: don't forget to update the sum here during major version changes
+#
+_uksm_patch="https://raw.githubusercontent.com/dolohow/uksm/master/v5.x/uksm-${_major}.patch"
+if [[ -v use_uksm ]]; then
+ source+=("${_uksm_patch##*/}::${_uksm_patch}")
+ sha256sums+=('d38e2ee1f43bd6ca18845c80f5e68c0e597db01780004ff47607dd605e9aa086')
+fi
+
+export KBUILD_BUILD_HOST=${KBUILD_BUILD_HOST:-archlinux}
+export KBUILD_BUILD_USER=${KBUILD_BUILD_USER:-"$pkgbase"}
+export KBUILD_BUILD_TIMESTAMP=${KBUILD_BUILD_TIMESTAMP:-$(date -Ru${SOURCE_DATE_EPOCH:+d @$SOURCE_DATE_EPOCH})}
+
+# shellcheck disable=SC2154,SC2155
+prepare() {
+ cd "linux-${_major}"
+
+ # Apply Xanmod patch
+ msg2 "Applying Xanmod patch..."
+ patch -Np1 -i "../patch-${xanmod}"
+
+ # WARN: mangle Makefile versions here if needed so patches apply cleanly
+
+ # Monkey patch: apply kernel.org patches when mainline is slightly ahead of Xanmod official
+ patch -Np1 -i ../patch-5.14.1
+
+ # Archlinux patches
+ local src
+ for src in "${source[@]}"; do
+ src="${src%%::*}"
+ src="${src##*/}"
+ [[ "$src" =~ .*(patch|diff)$ ]] || continue
+ msg2 "Applying patch $src..."
+ patch -Np1 < "../$src"
+ done
+
+ # WARN: mangle Makefile versions if needed before calling setlocalversion
+
+ msg2 "Setting version..."
+ scripts/setlocalversion --save-scmversion
+ echo "-$pkgrel" > localversion.99-pkgrel
+ echo "${pkgbase#linux-xanmod}" > localversion.20-pkgname
+
+ # Monkey patch: rewrite Xanmod release to $_localversion (eg: xanpre0) if we're applying a point release on top of Xanmod
+ if [[ ${xanmod%-xanmod?} != "${pkgver%%\.xan*}" ]]; then
+ msg2 "(Monkey)ing with kernel, rewriting localversion xanmod to $_localversion ..."
+ sed -Ei "s/xanmod[0-9]+/${_localversion}/" localversion
+ fi
+
+ # Applying configuration
+ cp -vf CONFIGS/xanmod/${_compiler}/config .config
+ # enable LTO_CLANG_THIN
+ if [ "${_compiler}" = "clang" ]; then
+ scripts/config --disable LTO_CLANG_FULL
+ scripts/config --enable LTO_CLANG_THIN
+ _LLVM=1
+ fi
+
+ # User set. See at the top of this file
+ if [ "$use_tracers" = "n" ]; then
+ msg2 "Disabling FUNCTION_TRACER/GRAPH_TRACER only if we are not compiling with clang..."
+ if [ "${_compiler}" = "gcc" ]; then
+ scripts/config --disable CONFIG_FUNCTION_TRACER \
+ --disable CONFIG_STACK_TRACER
+ fi
+ fi
+
+ if [ "$use_numa" = "n" ]; then
+ msg2 "Disabling NUMA..."
+ scripts/config --disable CONFIG_NUMA
+ fi
+
+ # This is intended for the people that want to build this package with their own config
+ # Put the file "myconfig" at the package folder (this will take preference) or "${XDG_CONFIG_HOME}/linux-xanmod/myconfig"
+ # If we detect partial file with scripts/config commands, we execute as a script
+ # If not, it's a full config, will be replaced
+ for _myconfig in "${startdir}/myconfig" "${HOME}/.config/linux-xanmod/myconfig" "${XDG_CONFIG_HOME}/linux-xanmod/myconfig" ; do
+ # if file exists and size > 0 bytes
+ if [ -s "${_myconfig}" ]; then
+ if grep -q 'scripts/config' "${_myconfig}"; then
+ # myconfig is a partial file. Executing as a script
+ msg2 "Applying myconfig..."
+ bash -x "${_myconfig}"
+ else
+ # myconfig is a full config file. Replacing default .config
+ msg2 "Using user CUSTOM config..."
+ cp -f "${_myconfig}" .config
+ fi
+ echo
+ break
+ fi
+ done
+
+ ## disable lru_gen by default if UKSM is selected for the build; these crash if used together, see README
+ if [[ -v use_uksm ]]; then
+ msg2 "UKSM selected, disabling LRU_GEN by default"
+ set -x
+ scripts/config --disable CONFIG_LRU_GEN_ENABLED
+ { set +x; } >& /dev/null
+ fi
+
+ ### Optionally load needed modules for the make localmodconfig
+ # See https://aur.archlinux.org/packages/modprobed-db
+ if [ "$_localmodcfg" = "y" ]; then
+ if [ -f "$HOME/.config/modprobed.db" ]; then
+ msg2 "Running Steven Rostedt's make localmodconfig now"
+ make LLVM=$_LLVM LLVM_IAS=$_LLVM LSMOD="$HOME/.config/modprobed.db" localmodconfig
+ else
+ msg2 "No modprobed.db data found"
+ exit
+ fi
+ fi
+
+ make LLVM=$_LLVM LLVM_IAS=$_LLVM olddefconfig
+
+ # let user choose microarchitecture optimization target; NOTE: must run *after* make olddefconfig so any new uarch macros exist
+ sh "${srcdir}/choose-gcc-optimization.sh" $_microarchitecture
+
+ make -s kernelrelease > version
+ msg2 "Prepared %s version %s" "$pkgbase" "$(<version)"
+
+ [[ -z "$_makenconfig" ]] || make LLVM=$_LLVM LLVM_IAS=$_LLVM nconfig
+
+ # save configuration for later reuse or inspection
+ cat .config > "${SRCDEST}/config.last"
+}
+
+build() {
+ cd "linux-${_major}"
+ make LLVM=$_LLVM LLVM_IAS=$_LLVM all
+}
+
+# shellcheck disable=SC2154,SC2155
+_package() {
+ pkgdesc="The Linux kernel and modules with Xanmod and ASUS ROG laptop patches (Zephyrus G14, G15, etc)"
+ depends=(coreutils kmod initramfs)
+ optdepends=('crda: to set the correct wireless channels of your country'
+ 'linux-firmware: firmware images needed for some devices')
+ provides+=(linux-xanmod-g14)
+ conflicts+=(linux-xanmod-g14)
+
+ cd "linux-${_major}"
+ local kernver="$(<version)"
+ local modulesdir="$pkgdir/usr/lib/modules/$kernver"
+
+ msg2 "Installing boot image..."
+ # systemd expects to find the kernel here to allow hibernation
+ # https://github.com/systemd/systemd/commit/edda44605f06a41fb86b7ab8128dcf99161d2344
+ install -Dm644 "$(make -s image_name)" "$modulesdir/vmlinuz"
+
+ # Used by mkinitcpio to name the kernel
+ echo "$pkgbase" | install -Dm644 /dev/stdin "$modulesdir/pkgbase"
+
+ msg2 "Installing modules..."
+ make INSTALL_MOD_PATH="$pkgdir/usr" INSTALL_MOD_STRIP=1 modules_install
+
+ # remove build and source links
+ rm "$modulesdir"/{source,build}
+}
+
+# shellcheck disable=SC2154,SC2155
+_package-headers() {
+ pkgdesc="Headers and scripts for building modules for the $pkgdesc kernel"
+ depends=(pahole)
+ provides+=(linux-xanmod-g14-headers)
+ conflicts+=(linux-xanmod-g14-headers)
+
+ cd "linux-${_major}"
+ local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
+
+ msg2 "Installing build files..."
+ install -Dt "$builddir" -m644 .config Makefile Module.symvers System.map \
+ localversion.* version vmlinux
+ install -Dt "$builddir/kernel" -m644 kernel/Makefile
+ install -Dt "$builddir/arch/x86" -m644 arch/x86/Makefile
+ cp -t "$builddir" -a scripts
+
+ # add objtool for external module building and enabled VALIDATION_STACK option
+ install -Dt "$builddir/tools/objtool" tools/objtool/objtool
+
+ # add xfs and shmem for aufs building
+ mkdir -p "$builddir"/{fs/xfs,mm}
+
+ msg2 "Installing headers..."
+ cp -t "$builddir" -a include
+ cp -t "$builddir/arch/x86" -a arch/x86/include
+ install -Dt "$builddir/arch/x86/kernel" -m644 arch/x86/kernel/asm-offsets.s
+
+ install -Dt "$builddir/drivers/md" -m644 drivers/md/*.h
+ install -Dt "$builddir/net/mac80211" -m644 net/mac80211/*.h
+
+ # http://bugs.archlinux.org/task/13146
+ install -Dt "$builddir/drivers/media/i2c" -m644 drivers/media/i2c/msp3400-driver.h
+
+ # http://bugs.archlinux.org/task/20402
+ install -Dt "$builddir/drivers/media/usb/dvb-usb" -m644 drivers/media/usb/dvb-usb/*.h
+ install -Dt "$builddir/drivers/media/dvb-frontends" -m644 drivers/media/dvb-frontends/*.h
+ install -Dt "$builddir/drivers/media/tuners" -m644 drivers/media/tuners/*.h
+
+ msg2 "Installing KConfig files..."
+ find . -name 'Kconfig*' -exec install -Dm644 {} "$builddir/{}" \;
+
+ msg2 "Removing unneeded architectures..."
+ local arch
+ for arch in "$builddir"/arch/*/; do
+ [[ $arch = */x86/ ]] && continue
+ echo "Removing $(basename "$arch")"
+ rm -r "$arch"
+ done
+
+ msg2 "Removing documentation..."
+ rm -r "$builddir/Documentation"
+
+ msg2 "Removing broken symlinks..."
+ find -L "$builddir" -type l -printf 'Removing %P\n' -delete
+
+ msg2 "Removing loose objects..."
+ find "$builddir" -type f -name '*.o' -printf 'Removing %P\n' -delete
+
+ msg2 "Stripping build tools..."
+ local file
+ while read -rd '' file; do
+ case "$(file -bi "$file")" in
+ application/x-sharedlib\;*) # Libraries (.so)
+ strip -v "$STRIP_SHARED" "$file" ;;
+ application/x-archive\;*) # Libraries (.a)
+ strip -v "$STRIP_STATIC" "$file" ;;
+ application/x-executable\;*) # Binaries
+ strip -v "$STRIP_BINARIES" "$file" ;;
+ application/x-pie-executable\;*) # Relocatable binaries
+ strip -v "$STRIP_SHARED" "$file" ;;
+ esac
+ done < <(find "$builddir" -type f -perm -u+x ! -name vmlinux -print0)
+
+ msg2 "Stripping vmlinux..."
+ strip -v "$STRIP_STATIC" "$builddir/vmlinux"
+ msg2 "Adding symlink..."
+ mkdir -p "$pkgdir/usr/src"
+ ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
+}
+
+pkgname=("${pkgbase}" "${pkgbase}-headers")
+for _p in "${pkgname[@]}"; do
+ eval "package_$_p() {
+ $(declare -f "_package${_p#$pkgbase}")
+ _package${_p#$pkgbase}
+ }"
+done
+
+# vim:set ts=8 sts=2 sw=2 et:
diff --git a/README.md b/README.md
new file mode 100644
index 000000000000..e9bc7dde3781
--- /dev/null
+++ b/README.md
@@ -0,0 +1,97 @@
+
+Arch linux `linux-xanmod` derived kernel with hardware enablement patches for ASUS ROG laptops and ACPI backports from mainline enabling s0ix power states
+
+**Suspend is currently unstable, this is a known upstream issue that I'm working with an AMD developer to resolve. All available patches to help stabilize suspend are currently in this kernel, we're waiting on upstream to finish writing patches to fix this. It mostly works but for now expect resume to crash periodically.**
+
+Up to date information on suspend can be found in the '#suspend-issues' channel on the asus-linux discord: https://discord.gg/qUUm9cWW
+
+More information about s0ix enablement status can be found here:
+ - https://gitlab.freedesktop.org/drm/amd/-/issues/1629
+ - https://gitlab.freedesktop.org/drm/amd/-/issues/1652
+ - https://gitlab.freedesktop.org/drm/amd/-/issues/1230
+
+Notes:
+
+ - Xanmod builds with the performance governor as the default; this is great for performance but doesn't clock down as readily. Since this kernel package is mainly targeted at ROG laptop users I've switched the build config to default to the schedutil governor at boot time. I strongly suggest making a couple of bash aliases to make switching modes/governors easier; this allows you to easily boost performance or conserve battery power as needed.
+
+ * `alias goboost='set -x; asusctl profile boost -t true -f boost; sudo cpupower frequency-set -g performance >&/dev/null; { set +x; } >&/dev/null'`
+ * `alias gonormal='set -x; asusctl profile normal -t true -f normal; sudo cpupower frequency-set -g schedutil >&/dev/null; { set +x; } >&/dev/null'`
+ * `alias gosilent='set -x; asusctl profile silent -t false -f silent; sudo cpupower frequency-set -g schedutil >&/dev/null; { set +x; } >&/dev/null'`
+
+ * To switch performance profiles during a kernel build you'd run something like: `goboost; makepkg -Ccsr; gonormal`
+
+ - UKSM can be enabled by building with `use_uksm=y makepkg ...` to perform fast deduplication on in-use memory.
+
+ * WARNING: Don't enable UKSM *and* the multigenerational LRU together at runtime, this will cause crashes.
+ The PKGBUILD disables lru_gen by default when UKSM is included in the build, switching both on at runtime will crash the system rather quickly.
+
+ - Use the included `myconfig` script fragment to make minor changes to the kernel configuration during build.
+
+ - We now build for the `x86-64-v3` target by default; this supports Haswell era and newer CPUs and should be ~10% more performant than a generic `x86_64` build while maintaining wide compatibility. This supports all recent ROG laptops, including Intel machines.
+ - Package now requires GCC >= 11 to support the new default build target.
+ - Suggested architecture build targets:
+
+ * `_microarchitecture=14 makepkg ...` Zen2 optimization (AMD 4000 series CPUs, 2020 AMD ROG laptops)
+ * `_microarchitecture=15 makepkg ...` Zen3 optimizationa (most AMD 5000 series CPUs, 2021 AMD ROG laptops)
+ * `_microarchitecture=38 makepkg ...` Skylake optimization (Use this for [Comet Lake](https://wiki.gentoo.org/wiki/Safe_CFLAGS#Skylake.2C_Kaby_Lake.2C_Kaby_Lake_R.2C_Coffee_Lake.2C_Comet_Lake))
+ * `_microarchitecture=92 makepkg ...` x86-64-v2 for compatibility with older (2008 era) machines
+ * `_microarchitecture=93 makepkg ...` x86-64-v3 (this is the default, most machines from 2013/2014 and newer are compatible)
+ * `_microarchitecture=98 makepkg ...` Intel -march=native
+ * `_microarchitecture=99 makepkg ...` AMD -march=native
+
+ - GA503QR has an ACPI table BIOS bug in version 410 and below that prevents the machine from putting the second drive to sleep and breaks the suspend code path.
+ Errors related to StorageD3Enable issues will look like the following in `dmesg` or the system journal:
+ ```log
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: I/O 460 QID 3 timeout, aborting
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: I/O 461 QID 3 timeout, aborting
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: I/O 462 QID 3 timeout, aborting
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: I/O 463 QID 3 timeout, aborting
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: I/O 0 QID 0 timeout, reset controller
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: Abort status: 0x371
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: Abort status: 0x371
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: Abort status: 0x371
+ Jun 19 18:56:26 arch-zephyrus kernel: nvme nvme0: Abort status: 0x371
+ ```
+ See this project on github for a short how-to on fixing this yourself while you wait for ASUS to publish a fixed BIOS:
+ https://github.com/foundObjects/GA503QR-StorageD3Enable-DSDT-Patch
+
+ If you're experiencing this yourself *please* go make a vendor support ticket with ASUS and ask them to fix their BIOS.
+
+ - GA401QM may be having other ACPI/firmware related suspend/wake issues
+
+ - If you're experiencing errors like the following during resume/wake please visit the gitlab links below.
+ ```log
+ [16305.645129] amdgpu 0000:04:00.0: amdgpu: failed to write reg 28b4 wait reg 28c6
+ [16318.651117] amdgpu 0000:04:00.0: amdgpu: failed to write reg 1a6f4 wait reg 1a706
+ [16327.200382] [drm] PCIE GART of 1024M enabled (table at 0x000000F400900000).
+ [16327.200439] amdgpu 0000:04:00.0: amdgpu: SMU is resuming...
+ [16329.682185] amdgpu 0000:04:00.0: amdgpu: message: SetDriverDramAddrHigh (26) param: 0x000000f4 is timeout (no response)
+ [16329.682191] amdgpu 0000:04:00.0: amdgpu: Failed to SetDriverDramAddr!
+ [16329.682193] amdgpu 0000:04:00.0: amdgpu: Failed to setup smc hw!
+ [16329.682195] [drm:amdgpu_device_ip_resume_phase2 [amdgpu]] *ERROR* resume of IP block <smu> failed -62
+ [16329.682461] amdgpu 0000:04:00.0: amdgpu: amdgpu_device_ip_resume failed (-62).
+ [16329.682463] PM: dpm_run_callback(): pci_pm_resume+0x0/0xe0 returns -62
+ [16329.682478] amdgpu 0000:04:00.0: PM: failed to resume async: error -62
+ [16329.685538] PM: resume of devices complete after 37180.901 msecs
+ [16329.685960] PM: resume devices took 37.182 seconds
+ ```
+ see:
+ - https://gitlab.freedesktop.org/drm/amd/-/issues/1629
+ - https://gitlab.freedesktop.org/drm/amd/-/issues/1652
+
+
+Changes:
+
+ - 5.13.2-1: some early s0ix code has been merged into the stable tree, regenerated the s0ix support patch to include all s0ix related commits to date
+ - 5.13.1-3: new ACPI s0ix suport patch
+ - 5.13.1-2: squashed all s0ix commits through 2021-06-29 into a single patch
+ - 5.13.0-1: moved all config customizations into a `myconfig` script fragment, edit this before build to make config changes
+ - 5.12.13-2: hotfix: revert a couple of drm/amdgpu commits that snuck into stable that cause suspend failures with the new s0ix code
+ - 5.12.12-2: added 'Quirk PCI d3hot delay for AMD xhci' patch per GitLab discussion
+ - 5.12.12-2: added the 5.14 ACPI s0ix suspend patchset from upstream, suspend is mostly stable with some caveats: there seem to be a few machines with firmware issues that are still causing problems:
+ - ~~Since 5.12.7 Suspend has been unstable on 2021 (Cezanne) machines, we're still looking for a solution as the patches we were using up until that point have become an unreliable fix. If this is an issue for you either disable suspend in `/etc/systemd/sleep.conf` or stay with 5.12.6 until a solution is found. You can find more information about the issue by tracking the kernel [bug report](https://gitlab.freedesktop.org/drm/amd/-/issues/1230#note_947255) or help investigate the issue with us [on Discord](https://discord.gg/JW7yywZn). This affects all 2020/2021 Ryzen laptops, not just ASUS machines.~~
+ - ~~5.12.9-2: Big upstream suspend-related patch set update; this is mostly hidden from git history here because we're pulling patches out of the asus-linux fedora kernel repo during package build~~
+ - ~~5.12.8-2: Updated upstream suspend patches~~
+ - 5.12.8: Added Flow x13 audio patch
+ - Added support for new GCC-11 microarchitecture feature targets, see [`choose-gcc-optimization.sh`](choose-gcc-optimization.sh) or [`PKGBUILD`](PKGBUILD) for details.
+
diff --git a/acpi-battery-Always-read-fresh-battery-state-on-update.patch b/acpi-battery-Always-read-fresh-battery-state-on-update.patch
new file mode 100644
index 000000000000..04c52a5eab02
--- /dev/null
+++ b/acpi-battery-Always-read-fresh-battery-state-on-update.patch
@@ -0,0 +1,38 @@
+From patchwork Thu Jun 4 19:56:58 2020
+From: Mathew King <mathewk@chromium.org>
+To: linux-kernel@vger.kernel.org
+Cc: Mathew King <mathewk@chromium.org>,
+ "Rafael J. Wysocki" <rjw@rjwysocki.net>,
+ Len Brown <lenb@kernel.org>, linux-acpi@vger.kernel.org
+Subject: [PATCH] acpi: battery: Always read fresh battery state on update
+Date: Thu, 4 Jun 2020 13:56:58 -0600
+Message-Id: <20200604195658.66201-1-mathewk@chromium.org>
+List-ID: <linux-acpi.vger.kernel.org>
+X-Mailing-List: linux-acpi@vger.kernel.org
+
+When the ACPI battery receives a notification event it should always
+read the battery state fresh from the ACPI device and not use the cached
+state. Currently the cached state stays valid and the new state may not
+be read when a notification occurs. This can lead to a udev event
+showing that the battery has changed but the sysfs state will still have
+the cached state values. This change invalidates the update time forcing
+the state to be updated before notifying the power_supply subsystem of
+the change.
+
+Signed-off-by: Mathew King <mathewk@chromium.org>
+---
+ drivers/acpi/battery.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
+index 366c389175d8..ab7fa4879fbe 100644
+--- a/drivers/acpi/battery.c
++++ b/drivers/acpi/battery.c
+@@ -981,6 +981,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume)
+ acpi_battery_init_alarm(battery);
+ }
+
++ battery->update_time = 0;
+ result = acpi_battery_get_state(battery);
+ if (result)
+ return result;
diff --git a/choose-gcc-optimization.sh b/choose-gcc-optimization.sh
new file mode 100755
index 000000000000..f10eec54b81d
--- /dev/null
+++ b/choose-gcc-optimization.sh
@@ -0,0 +1,139 @@
+#!/usr/bin/env bash
+
+. /usr/share/makepkg/util/message.sh
+colorize
+
+Detect_CPU=$(gcc -c -Q -march=native --help=target | grep march | awk '{print $2}' | head -1)
+
+msg "Detected CPU architecture: $Detect_CPU"
+
+cat << EOF
+
+ Available CPU microarchitectures:
+
+ 1) AMD K6/K6-II/K6-III
+ 2) AMD Athlon/Duron/K7
+ 3) AMD Opteron/Athlon64/Hammer/K8
+ 4) AMD Opteron/Athlon64/Hammer/K8 with SSE3
+ 5) AMD 61xx/7x50/PhenomX3/X4/II/K10
+ 6) AMD Family 10h (Barcelona)
+ 7) AMD Family 14h (Bobcat)
+ 8) AMD Family 16h (Jaguar)
+ 9) AMD Family 15h (Bulldozer)
+ 10) AMD Family 15h (Piledriver)
+ 11) AMD Family 15h (Steamroller)
+ 12) AMD Family 15h (Excavator)
+ 13) AMD Family 17h (Zen)
+ 14) AMD Family 17h (Zen 2)
+ 15) AMD Family 19h Zen 3 processors (Zen 3)
+ 16) Transmeta Crusoe
+ 17) Transmeta Efficeon
+ 18) IDT Winchip C6
+ 19) Winchip-2/Winchip-2A/Winchip-3
+ 20) AMD Elan
+ 21) Geode GX1 (Cyrix MediaGX)
+ 22) AMD Geode GX and LX
+ 23) Cyrix III or C3
+ 24) VIA C3 "Nehemiah"
+ 25) VIA C7
+ 26) Intel Pentium 4, Pentium D and older Nocona/Dempsey Xeon CPUs with Intel 64bit
+ 27) Intel Atom
+ 28) Intel Core 2 and newer Core 2 Xeons (Xeon 51xx and 53xx)
+ 29) Intel 1st Gen Core i3/i5/i7-family (Nehalem)
+ 30) Intel 1.5 Gen Core i3/i5/i7-family (Westmere)
+ 31) Intel Silvermont
+ 32) Intel Goldmont (Apollo Lake and Denverton)
+ 33) Intel Goldmont Plus (Gemini Lake)
+ 34) Intel 2nd Gen Core i3/i5/i7-family (Sandybridge)
+ 35) Intel 3rd Gen Core i3/i5/i7-family (Ivybridge)
+ 36) Intel 4th Gen Core i3/i5/i7-family (Haswell)
+ 37) Intel 5th Gen Core i3/i5/i7-family (Broadwell)
+ 38) Intel 6th Gen Core i3/i5/i7-family (Skylake)
+ 39) Intel 6th Gen Core i7/i9-family (Skylake X)
+ 40) Intel 8th Gen Core i3/i5/i7-family (Cannon Lake)
+ 41) Intel 8th Gen Core i7/i9-family (Ice Lake)
+ 42) Xeon processors in the Cascade Lake family
+ 43) Intel Xeon (Cooper Lake)
+ 44) Intel 3rd Gen 10nm++ i3/i5/i7/i9-family (Tiger Lake)
+ 45) Intel Sapphire Rapids
+ 46) Intel Rocket Lake
+ 47) Intel Alder Lake
+
+ 92) Generic-x86-64-v2 (Nehalem and newer)
+ 93) Generic-x86-64-v3 (Haswell and newer)
+ 94) Generic-x86-64-v4 (AVX512 CPUs)
+
+ 98) Intel-Native optimizations autodetected by GCC
+ 99) AMD-Native optimizations autodetected by GCC
+
+ 0) Generic (default)
+
+EOF
+
+sleep 1
+answer=$1
+
+case $answer in
+ 1) Microarchitecture=CONFIG_MK6 ;;
+ 2) Microarchitecture=CONFIG_MK7 ;;
+ 3) Microarchitecture=CONFIG_MK8 ;;
+ 4) Microarchitecture=CONFIG_MK8SSE3 ;;
+ 5) Microarchitecture=CONFIG_MK10 ;;
+ 6) Microarchitecture=CONFIG_MBARCELONA ;;
+ 7) Microarchitecture=CONFIG_MBOBCAT ;;
+ 8) Microarchitecture=CONFIG_MJAGUAR ;;
+ 9) Microarchitecture=CONFIG_MBULLDOZER ;;
+ 10) Microarchitecture=CONFIG_MPILEDRIVER ;;
+ 11) Microarchitecture=CONFIG_MSTEAMROLLER ;;
+ 12) Microarchitecture=CONFIG_MEXCAVATOR ;;
+ 13) Microarchitecture=CONFIG_MZEN ;;
+ 14) Microarchitecture=CONFIG_MZEN2 ;;
+ 15) Microarchitecture=CONFIG_MZEN3 ;;
+ 16) Microarchitecture=CONFIG_MCRUSOE ;;
+ 17) Microarchitecture=CONFIG_MEFFICEON ;;
+ 18) Microarchitecture=CONFIG_MWINCHIPC6 ;;
+ 19) Microarchitecture=CONFIG_MWINCHIP3D ;;
+ 20) Microarchitecture=CONFIG_MELAN ;;
+ 21) Microarchitecture=CONFIG_MGEODEGX1 ;;
+ 22) Microarchitecture=CONFIG_MGEODE_LX ;;
+ 23) Microarchitecture=CONFIG_MCYRIXIII ;;
+ 24) Microarchitecture=CONFIG_MVIAC3_2 ;;
+ 25) Microarchitecture=CONFIG_MVIAC7 ;;
+ 26) Microarchitecture=CONFIG_MPSC ;;
+ 27) Microarchitecture=CONFIG_MATOM ;;
+ 28) Microarchitecture=CONFIG_MCORE2 ;;
+ 29) Microarchitecture=CONFIG_MNEHALEM ;;
+ 30) Microarchitecture=CONFIG_MWESTMERE ;;
+ 31) Microarchitecture=CONFIG_MSILVERMONT ;;
+ 32) Microarchitecture=CONFIG_MGOLDMONT ;;
+ 33) Microarchitecture=CONFIG_MGOLDMONTPLUS ;;
+ 34) Microarchitecture=CONFIG_MSANDYBRIDGE ;;
+ 35) Microarchitecture=CONFIG_MIVYBRIDGE ;;
+ 36) Microarchitecture=CONFIG_MHASWELL ;;
+ 37) Microarchitecture=CONFIG_MBROADWELL ;;
+ 38) Microarchitecture=CONFIG_MSKYLAKE ;;
+ 39) Microarchitecture=CONFIG_MSKYLAKEX ;;
+ 40) Microarchitecture=CONFIG_MCANNONLAKE ;;
+ 41) Microarchitecture=CONFIG_MICELAKE ;;
+ 42) Microarchitecture=CONFIG_MCASCADELAKE ;;
+ 43) Microarchitecture=CONFIG_MCOOPERLAKE ;;
+ 44) Microarchitecture=CONFIG_MTIGERLAKE ;;
+ 45) Microarchitecture=CONFIG_MSAPPHIRERAPIDS ;;
+ 46) Microarchitecture=CONFIG_MROCKETLAKE ;;
+ 47) Microarchitecture=CONFIG_MALDERLAKE ;;
+ 92) Microarchitecture=CONFIG_GENERIC_CPU2 ;;
+ 93) Microarchitecture=CONFIG_GENERIC_CPU3 ;;
+ 94) Microarchitecture=CONFIG_GENERIC_CPU4 ;;
+ 98) Microarchitecture=CONFIG_MNATIVE_INTEL ;;
+ 99) Microarchitecture=CONFIG_MNATIVE_AMD ;;
+ *) default=CONFIG_GENERIC_CPU ;;
+esac
+
+warning "According to PKGBUILD variable _microarchitecture, your choice is $answer"
+msg "Building this package for microarchitecture: $Microarchitecture$default"
+sleep 5
+
+sed -e 's|^CONFIG_GENERIC_CPU=y|# CONFIG_GENERIC_CPU is not set|g' -i .config
+sed -e "s|^# $Microarchitecture is not set|$Microarchitecture=y|g" -i .config
+
+echo
diff --git a/hwmon-k10temp-support-Zen3-APUs.patch b/hwmon-k10temp-support-Zen3-APUs.patch
new file mode 100644
index 000000000000..9f117f8f4365
--- /dev/null
+++ b/hwmon-k10temp-support-Zen3-APUs.patch
@@ -0,0 +1,37 @@
+From 02c6edd4b1a07f24b187a550d413a07260eb696d Mon Sep 17 00:00:00 2001
+From: David Bartley <andareed@gmail.com>
+Date: Sun, 16 May 2021 23:41:31 -0700
+Subject: hwmon: (k10temp) support Zen3 APUs
+
+Add support for Zen3 Ryzen APU.
+
+Signed-off-by: David Bartley <andareed@gmail.com>
+Link: https://lore.kernel.org/r/20210517064131.4369-1-andareed@gmail.com
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+---
+ drivers/hwmon/k10temp.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/drivers/hwmon/k10temp.c b/drivers/hwmon/k10temp.c
+index 5ff3669c2b608..fe3d92152e359 100644
+--- a/drivers/hwmon/k10temp.c
++++ b/drivers/hwmon/k10temp.c
+@@ -450,6 +450,7 @@ static int k10temp_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+ switch (boot_cpu_data.x86_model) {
+ case 0x0 ... 0x1: /* Zen3 SP3/TR */
+ case 0x21: /* Zen3 Ryzen Desktop */
++ case 0x50: /* Zen3 Ryzen APU */
+ k10temp_get_ccd_support(pdev, data, 8);
+ break;
+ }
+@@ -491,6 +492,7 @@ static const struct pci_device_id k10temp_id_table[] = {
+ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M60H_DF_F3) },
+ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_17H_M70H_DF_F3) },
+ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_19H_DF_F3) },
++ { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_19H_M50H_DF_F3) },
+ { PCI_VDEVICE(HYGON, PCI_DEVICE_ID_AMD_17H_DF_F3) },
+ {}
+ };
+--
+cgit 1.2.3-1.el7
+
diff --git a/mt76-mt7921-enable-VO-tx-aggregation.patch b/mt76-mt7921-enable-VO-tx-aggregation.patch
new file mode 100644
index 000000000000..673e065f5db4
--- /dev/null
+++ b/mt76-mt7921-enable-VO-tx-aggregation.patch
@@ -0,0 +1,134 @@
+From patchwork Wed Aug 4 10:11:53 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Deren Wu <Deren.Wu@mediatek.com>
+X-Patchwork-Id: 12418525
+Return-Path:
+ <SRS0=9YCi=M3=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id 5A394C4338F
+ for <linux-mediatek@archiver.kernel.org>;
+ Wed, 4 Aug 2021 10:15:35 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id E6C8460F0F
+ for <linux-mediatek@archiver.kernel.org>;
+ Wed, 4 Aug 2021 10:15:34 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E6C8460F0F
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=J2vdeU1xYOyXH3pQhLrO1WTFRsm6Z0YBd+RKdFMf6o4=; b=l+CsA3SZrS4S99
+ HveSpFDVX2jdzVYTVC2xKJ3VqT8K50d1WjQmMCe1zW6i/r9Dg3r24cQcoKuAqo4FInroVadRLy0Au
+ NF6XGutFDlMbNDBNRAIAAs5ShrA7sM56LNCfL6rQRHkPvUaVWZHzxSc2gugdmcZccYMyHc31wMusM
+ /S+wyC6AbzjFFoWDBn0so9X6R8Th0WOFt4vTdxjeiyABxBoH3BIXnkTjjqWHphqjNt6M4VjKBpsTg
+ MA0o0IS2egibAL6NXHxzpUlApdOlfz2gGhNwbFYtIGFWRPAQndPKI+usQfr3Swc5+Y808wJAmXC1F
+ J2IEBIZpiwFiJN+MejHQ==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mBDvk-005fXD-Aa; Wed, 04 Aug 2021 10:15:20 +0000
+Received: from mailgw02.mediatek.com ([216.200.240.185])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mBDuh-005f96-JP
+ for linux-mediatek@lists.infradead.org; Wed, 04 Aug 2021 10:14:18 +0000
+X-UUID: f6bd8be5d3804b55ae77ba67b7c91454-20210804
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=cNVXAqIvhnRa0S4zGQOEgoluwx+gw1GCEQF9pIZ4Mc0=;
+ b=q0hV572OArsQ9ZWQqMm0oEk3NfH1f9uaZjjf40I/s2WSRg8xL4QT9nlJUYEsQgr3EErdJzbz+wo17ZSWYrMWYH7bk0laCibshDbFg1f4+Gz59SGx0KT/T9cUBUQu7QkfpbNPAeBHm94WugSn862LDjIIIiUPLraIAdy0J/nNOZU=;
+X-UUID: f6bd8be5d3804b55ae77ba67b7c91454-20210804
+Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw02.mediatek.com
+ (envelope-from <deren.wu@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 1604006015; Wed, 04 Aug 2021 03:14:04 -0700
+Received: from mtkmbs05n1.mediatek.inc (172.21.101.15) by
+ MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Wed, 4 Aug 2021 03:14:02 -0700
+Received: from MTKCAS06.mediatek.inc (172.21.101.30) by
+ mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Wed, 4 Aug 2021 18:14:01 +0800
+Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Wed, 4 Aug 2021 18:14:00 +0800
+From: Deren Wu <Deren.Wu@mediatek.com>
+To: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi
+ <lorenzo.bianconi@redhat.com>
+CC: Sean Wang <sean.wang@mediatek.com>, Soul Huang <Soul.Huang@mediatek.com>,
+ YN Chen <YN.Chen@mediatek.com>, Leon Yen <Leon.Yen@mediatek.com>, "Eric-SY
+ Chang" <Eric-SY.Chang@mediatek.com>, Deren Wu <Deren.Wu@mediatek.com>,
+ KM Lin <km.lin@mediatek.com>, Robin Chiu <robin.chiu@mediatek.com>, CH Yeh
+ <ch.yeh@mediatek.com>, Posh Sun <posh.sun@mediatek.com>, Eric Liang
+ <Eric.Liang@mediatek.com>, Stella Chang <Stella.Chang@mediatek.com>,
+ <jemele@google.com>, <yenlinlai@google.com>, linux-wireless
+ <linux-wireless@vger.kernel.org>, linux-mediatek
+ <linux-mediatek@lists.infradead.org>, Deren Wu <deren.wu@mediatek.com>
+Subject: [PATCH] mt76: mt7921: enable VO tx aggregation
+Date: Wed, 4 Aug 2021 18:11:53 +0800
+Message-ID:
+ <0747f9249b2d7902f9cb514861342a9940d49e0d.1628071231.git.deren.wu@mediatek.com>
+X-Mailer: git-send-email 2.18.0
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210804_031417_105246_29C78169
+X-CRM114-Status: UNSURE ( 8.82 )
+X-CRM114-Notice: Please train this message.
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: Deren Wu <deren.wu@mediatek.com>
+
+From: YN Chen <YN.Chen@mediatek.com>
+
+Avoid throughput drop in VO streaming, enable TX BA by default.
+
+Signed-off-by: Deren Wu <deren.wu@mediatek.com>
+Signed-off-by: YN Chen <YN.Chen@mediatek.com>
+---
+ drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+index 296e0f7a1d14..1be1e07ae786 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+@@ -913,8 +913,6 @@ mt7921_tx_check_aggr(struct ieee80211_sta *sta, __le32 *txwi)
+ return;
+
+ tid = FIELD_GET(MT_TXD1_TID, le32_to_cpu(txwi[1]));
+- if (tid >= 6) /* skip VO queue */
+- return;
+
+ val = le32_to_cpu(txwi[2]);
+ fc = FIELD_GET(MT_TXD2_FRAME_TYPE, val) << 2 |
diff --git a/mt76-mt7921-fix-dma-hang-in-rmmod.patch b/mt76-mt7921-fix-dma-hang-in-rmmod.patch
new file mode 100644
index 000000000000..18b752475857
--- /dev/null
+++ b/mt76-mt7921-fix-dma-hang-in-rmmod.patch
@@ -0,0 +1,149 @@
+From patchwork Tue Jul 27 09:47:09 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Deren Wu <Deren.Wu@mediatek.com>
+X-Patchwork-Id: 12402229
+Return-Path:
+ <SRS0=KH1D=MT=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id A47D3C4338F
+ for <linux-mediatek@archiver.kernel.org>;
+ Tue, 27 Jul 2021 09:47:46 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id 7712861266
+ for <linux-mediatek@archiver.kernel.org>;
+ Tue, 27 Jul 2021 09:47:46 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7712861266
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=lreWGuYXofvP1dH0UcR0WqE0Cf53Kf+pOO2Hd0Xn8Hg=; b=wVMLs2vR2iWhCu
+ WvOnZKqsNCIXa4lUCWyTOTLrXtdAbJ2H5dkAjsvS0kg3BsLBiY2OIVC1MRfINIGXs+oOh/WZ4N00Q
+ eO0q2p5h8HqdgZkfkD+bcu59+CiZppy4U385OV0gqRvHZbyea9suhVFaJjYwwgtlkSYs5sv+r+ASF
+ CqLXBWAda2B+CEuwdjta3V/OEzCdRLrD/FUbwj2AeeQt9tnkU26t7vtc2jc4VNBVqVwx6Rhev7KY3
+ LsD6/p8FaNeBMbnbzHHEc0TEbdrMGhcIjDMUUKoWv8xEWQ1Tah3WAFZhkKuG2yZtmwhMzyF/37AdP
+ hXkHVztyZxvYIcGHArjg==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1m8JgU-00EFZA-Fh; Tue, 27 Jul 2021 09:47:34 +0000
+Received: from mailgw02.mediatek.com ([216.200.240.185])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1m8JgQ-00EFXZ-LA
+ for linux-mediatek@lists.infradead.org; Tue, 27 Jul 2021 09:47:32 +0000
+X-UUID: 0b6325a6b6af4029a4224783562d589b-20210727
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=DxtlOEHn9gAoacNB/3OvRRjbpFs0dQtXZpVe2OCVxl8=;
+ b=sGCyMUYQ3aGYggUm5f4OAlg9KYaLJQUUCfniEXjd9EPTOfxGOg7yRWJpzkUStSGhFzogo7XC1TvulhlaG0ffES/Mu8vky17loHw2yYW5Wf5S+1zuG2VQeabRONdcznm6QlXR32yupucDOEHLOG7LqX+Cv/uz+opkOJcEw2yXMPM=;
+X-UUID: 0b6325a6b6af4029a4224783562d589b-20210727
+Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw02.mediatek.com
+ (envelope-from <deren.wu@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 1048548800; Tue, 27 Jul 2021 02:47:25 -0700
+Received: from MTKMBS02N1.mediatek.inc (172.21.101.77) by
+ MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Tue, 27 Jul 2021 02:47:23 -0700
+Received: from MTKCAS06.mediatek.inc (172.21.101.30) by
+ mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Tue, 27 Jul 2021 17:47:15 +0800
+Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Tue, 27 Jul 2021 17:47:15 +0800
+From: Deren Wu <Deren.Wu@mediatek.com>
+To: Felix Fietkau <nbd@nbd.name>, Lorenzo Bianconi
+ <lorenzo.bianconi@redhat.com>
+CC: Sean Wang <sean.wang@mediatek.com>, Soul Huang <Soul.Huang@mediatek.com>,
+ YN Chen <YN.Chen@mediatek.com>, Leon Yen <Leon.Yen@mediatek.com>, "Eric-SY
+ Chang" <Eric-SY.Chang@mediatek.com>, Deren Wu <Deren.Wu@mediatek.com>,
+ KM Lin <km.lin@mediatek.com>, Robin Chiu <robin.chiu@mediatek.com>, CH Yeh
+ <ch.yeh@mediatek.com>, Posh Sun <posh.sun@mediatek.com>, Eric Liang
+ <Eric.Liang@mediatek.com>, Stella Chang <Stella.Chang@mediatek.com>, Jimmy Hu
+ <Jimmy.Hu@mediatek.com>, <jemele@google.com>, <yenlinlai@google.com>,
+ linux-wireless <linux-wireless@vger.kernel.org>, linux-mediatek
+ <linux-mediatek@lists.infradead.org>, Deren Wu <deren.wu@mediatek.com>
+Subject: [PATCH] mt76: mt7921: fix dma hang in rmmod
+Date: Tue, 27 Jul 2021 17:47:09 +0800
+Message-ID:
+ <0e68058a8c7c4948b9ad6b80d23a03726aecf4c2.1627378293.git.deren.wu@mediatek.com>
+X-Mailer: git-send-email 2.18.0
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210727_024730_744527_D1D814B2
+X-CRM114-Status: UNSURE ( 9.16 )
+X-CRM114-Notice: Please train this message.
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: Deren Wu <deren.wu@mediatek.com>
+
+The dma would be broken after rmmod flow. There are two different
+cases causing this issue.
+1. dma access without privilege.
+2. hw access sequence borken by another context.
+
+This patch handle both cases to avoid hw crash.
+
+Fixes: 2b9ea5a8cf1bd ("mt76: mt7921: add mt7921_dma_cleanup in mt7921_unregister_device")
+Signed-off-by: Deren Wu <deren.wu@mediatek.com>
+---
+ drivers/net/wireless/mediatek/mt76/mt7921/init.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+index 49725caca7ed..1f37e64b6038 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+@@ -266,10 +266,20 @@ int mt7921_register_device(struct mt7921_dev *dev)
+
+ void mt7921_unregister_device(struct mt7921_dev *dev)
+ {
++ int i;
++ struct mt76_connac_pm *pm = &dev->pm;
++
+ mt76_unregister_device(&dev->mt76);
++ mt76_for_each_q_rx(&dev->mt76, i)
++ napi_disable(&dev->mt76.napi[i]);
++ cancel_delayed_work_sync(&pm->ps_work);
++ cancel_work_sync(&pm->wake_work);
++
+ mt7921_tx_token_put(dev);
++ mt7921_mcu_drv_pmctrl(dev);
+ mt7921_dma_cleanup(dev);
+ mt7921_mcu_exit(dev);
++ mt7921_mcu_fw_pmctrl(dev);
+
+ tasklet_disable(&dev->irq_tasklet);
+ mt76_free_device(&dev->mt76);
diff --git a/mt76-mt7921-fix-firmware-usage-of-RA-info-using-legacy-rates.patch b/mt76-mt7921-fix-firmware-usage-of-RA-info-using-legacy-rates.patch
new file mode 100644
index 000000000000..28d88f7ef886
--- /dev/null
+++ b/mt76-mt7921-fix-firmware-usage-of-RA-info-using-legacy-rates.patch
@@ -0,0 +1,166 @@
+From patchwork Wed Aug 11 05:58:24 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Sean Wang <sean.wang@mediatek.com>
+X-Patchwork-Id: 12430087
+Return-Path:
+ <SRS0=F7c8=NC=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no
+ version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id BF140C4338F
+ for <linux-mediatek@archiver.kernel.org>;
+ Wed, 11 Aug 2021 05:58:51 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id 6EA8660F22
+ for <linux-mediatek@archiver.kernel.org>;
+ Wed, 11 Aug 2021 05:58:51 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6EA8660F22
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=zqwCf1wF0+ErPNhtjRbCj4B3OiJi2vKeWaIY3rcWyzM=; b=Pn1raIF1Y7itg2
+ 5Hh2mOVpGC3EzT5iKl0dqTPXq/F1JDSkbTYTlg/E1fsw/xrQ/Vj6N+mZ+i9Rq45ItAA/+WjwmEoc3
+ p/E6cH3KZ/LuIM2r+dg7U0CWhuXQV3EdR81hvsYmAcd1NZsGM/6LYsmNXY278TMI2KJwy3Isdb2gg
+ KEWVRtn3Wl9PVaSE1IMdLBQi8ZWOQtiYzOrROLLlANJTGKCdp+Wp+b+HyEMPmefawiA9eP9e7UHIi
+ qX4mtT3g/Va9w4Omr/r5ZvWE3jjBKAKlzXJNJQD8guBDB21clU2outwgUKBEthwxi21IDQtoIrHhR
+ 1SCu5xO+zENxRMb9hNQA==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mDhGC-005g7t-9M; Wed, 11 Aug 2021 05:58:40 +0000
+Received: from mailgw01.mediatek.com ([216.200.240.184])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mDhG5-005g5e-Pb
+ for linux-mediatek@lists.infradead.org; Wed, 11 Aug 2021 05:58:39 +0000
+X-UUID: 36cbea32a76241348b9f64a456d1d50b-20210810
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=BFFbKW23QDVEO7rPg7xuD9YWpv13ZtrEV8dbFDolRdc=;
+ b=mLOzjopiB9MbhA2W4c8ZamQV95jHEfb02jvUUjmH7Db6MNtPgR0jvGbyVc/lBv09cJa84p46pNVOFgagqURCRW2f8WvsWnjgHBtTjAMwzDDL2Ntd/Nc+eIToaHG0DS/rFwrsiMvL7lv2WXVIIt6TXFhPIhM+aZ5Iec7UIBu7vxE=;
+X-UUID: 36cbea32a76241348b9f64a456d1d50b-20210810
+Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com
+ (envelope-from <sean.wang@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 361943851; Tue, 10 Aug 2021 22:58:28 -0700
+Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by
+ MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Tue, 10 Aug 2021 22:58:27 -0700
+Received: from MTKCAS06.mediatek.inc (172.21.101.30) by
+ mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Wed, 11 Aug 2021 13:58:25 +0800
+Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Wed, 11 Aug 2021 13:58:25 +0800
+From: <sean.wang@mediatek.com>
+To: <nbd@nbd.name>, <lorenzo.bianconi@redhat.com>
+CC: <sean.wang@mediatek.com>, <Soul.Huang@mediatek.com>,
+ <YN.Chen@mediatek.com>, <Leon.Yen@mediatek.com>,
+ <Eric-SY.Chang@mediatek.com>, <Deren.Wu@mediatek.com>, <km.lin@mediatek.com>,
+ <robin.chiu@mediatek.com>, <ch.yeh@mediatek.com>, <posh.sun@mediatek.com>,
+ <Eric.Liang@mediatek.com>, <Stella.Chang@mediatek.com>, <jemele@google.com>,
+ <yenlinlai@google.com>, <linux-wireless@vger.kernel.org>,
+ <linux-mediatek@lists.infradead.org>
+Subject: [PATCH] mt76: mt7921: fix firmware usage of RA info using legacy
+ rates
+Date: Wed, 11 Aug 2021 13:58:24 +0800
+Message-ID:
+ <4be4378630c93ae32a4db8bc3e0871c7b15150a6.1628661185.git.objelf@gmail.com>
+X-Mailer: git-send-email 1.7.9.5
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210810_225835_290471_E1D27441
+X-CRM114-Status: GOOD ( 12.83 )
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: Sean Wang <sean.wang@mediatek.com>
+
+According to the firmware usage, OFDM rates should fill out bit 6 - 13
+while CCK rates should fill out bit 0 - 3 in legacy field of RA info to
+make the rate adaption runs propertly. Otherwise, a unicast frame might be
+picking up the unsupported rate to send out.
+
+Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
+Reported-by: Joshua Emele <jemele@chromium.org>
+Co-developed-by: YN Chen <YN.Chen@mediatek.com>
+Signed-off-by: YN Chen <YN.Chen@mediatek.com>
+Signed-off-by: Sean Wang <sean.wang@mediatek.com>
+---
+ drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c | 11 ++++++++++-
+ drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h | 2 ++
+ 2 files changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+index a2555dc0f003..27e45f4fc05f 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c
+@@ -719,6 +719,7 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
+ struct sta_rec_state *state;
+ struct sta_rec_phy *phy;
+ struct tlv *tlv;
++ u16 supp_rates;
+
+ /* starec ht */
+ if (sta->ht_cap.ht_supported) {
+@@ -767,7 +768,15 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb,
+
+ tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_RA, sizeof(*ra_info));
+ ra_info = (struct sta_rec_ra_info *)tlv;
+- ra_info->legacy = cpu_to_le16((u16)sta->supp_rates[band]);
++
++ supp_rates = sta->supp_rates[band];
++ if (band == NL80211_BAND_2GHZ)
++ supp_rates = FIELD_PREP(RA_LEGACY_OFDM, supp_rates >> 4) |
++ FIELD_PREP(RA_LEGACY_CCK, supp_rates & 0xf);
++ else
++ supp_rates = FIELD_PREP(RA_LEGACY_OFDM, supp_rates);
++
++ ra_info->legacy = cpu_to_le16(supp_rates);
+
+ if (sta->ht_cap.ht_supported)
+ memcpy(ra_info->rx_mcs_bitmask, sta->ht_cap.mcs.rx_mask,
+diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+index ab77289c0541..9dfdf7625844 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
++++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
+@@ -124,6 +124,8 @@ struct sta_rec_state {
+ u8 rsv[1];
+ } __packed;
+
++#define RA_LEGACY_OFDM GENMASK(13, 6)
++#define RA_LEGACY_CCK GENMASK(3, 0)
+ #define HT_MCS_MASK_NUM 10
+ struct sta_rec_ra_info {
+ __le16 tag;
diff --git a/mt76-mt7921-fix-the-inconsistent-state-between-bind-and-unbind.patch b/mt76-mt7921-fix-the-inconsistent-state-between-bind-and-unbind.patch
new file mode 100644
index 000000000000..fc4a59b76a74
--- /dev/null
+++ b/mt76-mt7921-fix-the-inconsistent-state-between-bind-and-unbind.patch
@@ -0,0 +1,139 @@
+From patchwork Mon Aug 23 02:26:51 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Sean Wang <sean.wang@mediatek.com>
+X-Patchwork-Id: 12451819
+Return-Path:
+ <SRS0=it3p=NO=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id 01111C4338F
+ for <linux-mediatek@archiver.kernel.org>;
+ Mon, 23 Aug 2021 02:27:23 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id B53A461361
+ for <linux-mediatek@archiver.kernel.org>;
+ Mon, 23 Aug 2021 02:27:22 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B53A461361
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=hTPARlexnTrmX4k4i5ctcWwoDVkLg9MQHHpMgUIBRRw=; b=zYMvjY8/550AJm
+ Pxk+jm34UaLMEIkioPNFo5ubxlUnggp6cL2zSA0irE2d2HPqypYkNGG7LxwgSWkkKJMjCD4FIfbd6
+ Zic8aFX7og0rl9yzwNeg7QeEVC57fat744k5os3nLXJ1ZFgKuGf8x6xb/MkX64hNHi9Lf/9WQQkl5
+ +NS/4Cgr6Qos0Sj0mSarfhc2tNsEK5ZvSr1Aoc7zHyc6dseuQesG06gTJRfOjDn02RqCGl6Bj+hlQ
+ 2kN3X4ACC5KIpxxBrsqonPrZDl7CJKbCuhlci88iFtack/OyhUkZj6iYKrsl9EaetZ7vYEXk4HdWj
+ HwHI1PQt/pjyww5v4uCA==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mHzg3-00FChW-Qr; Mon, 23 Aug 2021 02:27:07 +0000
+Received: from mailgw01.mediatek.com ([216.200.240.184])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mHzfz-00FCgj-I5
+ for linux-mediatek@lists.infradead.org; Mon, 23 Aug 2021 02:27:07 +0000
+X-UUID: aef938ea2bc34f6695fcc527f366760a-20210822
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=q89acb8ctpCqH7/PdsfVg1HDy9o+OgGBP2spYzVdU8U=;
+ b=KA+7nMVSpnHnPfzccOZoz6koMz2HQ+7NXWwaFmj2ZXVgSS1Q8XpubAQ0Tx3pJP/BSFs3kRQwFG6hy8dIRjsaLSA/5/xWXwGPuNJDZJmc/PlaXUyPjAlHXK+83lHnZ20rszwAKryICFKz7UEtvDjNm93eG+g3/xfhGOOMFA4AZ3g=;
+X-UUID: aef938ea2bc34f6695fcc527f366760a-20210822
+Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com
+ (envelope-from <sean.wang@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 408158283; Sun, 22 Aug 2021 19:26:55 -0700
+Received: from mtkmbs05n1.mediatek.inc (172.21.101.15) by
+ MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Sun, 22 Aug 2021 19:26:54 -0700
+Received: from mtkcas07.mediatek.inc (172.21.101.84) by
+ mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Mon, 23 Aug 2021 10:26:52 +0800
+Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas07.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Mon, 23 Aug 2021 10:26:52 +0800
+From: <sean.wang@mediatek.com>
+To: <nbd@nbd.name>, <lorenzo.bianconi@redhat.com>
+CC: <sean.wang@mediatek.com>, <Soul.Huang@mediatek.com>,
+ <YN.Chen@mediatek.com>, <Leon.Yen@mediatek.com>,
+ <Eric-SY.Chang@mediatek.com>, <Deren.Wu@mediatek.com>, <km.lin@mediatek.com>,
+ <robin.chiu@mediatek.com>, <ch.yeh@mediatek.com>, <posh.sun@mediatek.com>,
+ <Eric.Liang@mediatek.com>, <Stella.Chang@mediatek.com>, <jemele@google.com>,
+ <linux-wireless@vger.kernel.org>, <linux-mediatek@lists.infradead.org>
+Subject: [PATCH] mt76: mt7921: fix the inconsistent state between bind and
+ unbind
+Date: Mon, 23 Aug 2021 10:26:51 +0800
+Message-ID:
+ <9c71befbdf8a97f72f4538c39a71041ccffbaf83.1629685207.git.objelf@gmail.com>
+X-Mailer: git-send-email 1.7.9.5
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210822_192703_670236_8A0AF262
+X-CRM114-Status: GOOD ( 10.69 )
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: Sean Wang <sean.wang@mediatek.com>
+
+We shouldn't put back the device into fw own state after wifi reset at
+driver unbind stage to fix the following error because that is not the
+consistent state the current driver bind stage expects.
+
+localhost ~ # echo 0000:01:00.0 > /sys/bus/pci/drivers/mt7921e/unbind
+localhost ~ # echo 0000:01:00.0 > /sys/bus/pci/drivers/mt7921e/bind
+...
+[ 481.172969] mt7921e 0000:01:00.0: ASIC revision: feed0000
+[ 482.133547] mt7921e: probe of 0000:01:00.0 failed with error -110
+-bash: echo: write error: No such device
+
+Fixes: c1af184ba830 ("mt76: mt7921: fix dma hang in rmmod")
+Co-developed-by: YN Chen <YN.Chen@mediatek.com>
+Signed-off-by: YN Chen <YN.Chen@mediatek.com>
+Signed-off-by: Sean Wang <sean.wang@mediatek.com>
+Tested-by: Chen-Yu Tsai <wenst@chromium.org>
+---
+ drivers/net/wireless/mediatek/mt76/mt7921/init.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/init.c b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+index 1f37e64b6038..3e84ef8f5358 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/init.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/init.c
+@@ -279,7 +279,6 @@ void mt7921_unregister_device(struct mt7921_dev *dev)
+ mt7921_mcu_drv_pmctrl(dev);
+ mt7921_dma_cleanup(dev);
+ mt7921_mcu_exit(dev);
+- mt7921_mcu_fw_pmctrl(dev);
+
+ tasklet_disable(&dev->irq_tasklet);
+ mt76_free_device(&dev->mt76);
diff --git a/mt76-mt7921-report-HE-MU-radiotap.patch b/mt76-mt7921-report-HE-MU-radiotap.patch
new file mode 100644
index 000000000000..1841ea9cbc6c
--- /dev/null
+++ b/mt76-mt7921-report-HE-MU-radiotap.patch
@@ -0,0 +1,282 @@
+From patchwork Thu Aug 12 22:48:24 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Sean Wang <sean.wang@mediatek.com>
+X-Patchwork-Id: 12434387
+Return-Path:
+ <SRS0=QG8e=ND=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable
+ autolearn_force=no version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id B9F9FC4338F
+ for <linux-mediatek@archiver.kernel.org>;
+ Thu, 12 Aug 2021 22:50:57 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id 641AF60EB2
+ for <linux-mediatek@archiver.kernel.org>;
+ Thu, 12 Aug 2021 22:50:57 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 641AF60EB2
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=o31t1sz7ri5gg1b8FBW3Y8YfzjnIG2g2RNKYxEWqHAA=; b=Iu6E+cVXfz1/br
+ DNB8DQbdW4Y/cYarIbrPSHKQEGj8/axPW3YUH6MTzftVA8MXuTu70546ycD7vlpWrAHB0gykGZ/oh
+ +Q/mIYcA6oL3eR3lhaUE+BqV/9gdecLX+7s5HDOrFxUQXp/k0ZDCyHFsJ7YuKqdHe9fKq2Z95iTwP
+ M40Uz5lMpQbQC8ikfA2dVOcpu2DLTbr/9h8NK7QZJ6+ehaKtyDSUgI/WKMGnrJ3/22skq9sjGbPig
+ ivVHULv20/Y4JnItDsTftzX/uihwSPA2+J8hsKPN0y0MnokbAMctBJj+9dLiH3gN4DmpUjnxcy8xq
+ SsC6YITjVkwVvZTMdK4w==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mEJX7-00BSLR-2D; Thu, 12 Aug 2021 22:50:41 +0000
+Received: from mailgw02.mediatek.com ([216.200.240.185])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mEJX1-00BSKl-GU
+ for linux-mediatek@lists.infradead.org; Thu, 12 Aug 2021 22:50:39 +0000
+X-UUID: 87c68b25d0f04cfebf6ad6b0098e0838-20210812
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=SAqiFUJYFOdkzo58g5kpsAbyBjkiFKdnepXt8D3LyH8=;
+ b=jTNVnj6boxMkxz3EdtOSospVveDNk4rVnkQESnmd6wAnUlwV3kOnEzsBp8rdwIzmdiEb6hM64pmwgYY6kcGveEsFLczsf/f893jYp3OmARPwTfluIkTc8clIA/WeAVMkrYgxN7EXNVsq8wyfrIqJosEzdLg7+OGxJg/Ca0GnxDE=;
+X-UUID: 87c68b25d0f04cfebf6ad6b0098e0838-20210812
+Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by
+ mailgw02.mediatek.com
+ (envelope-from <sean.wang@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 1691799735; Thu, 12 Aug 2021 15:50:27 -0700
+Received: from mtkmbs05n1.mediatek.inc (172.21.101.15) by
+ MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Thu, 12 Aug 2021 15:48:27 -0700
+Received: from MTKCAS06.mediatek.inc (172.21.101.30) by
+ mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Fri, 13 Aug 2021 06:48:25 +0800
+Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Fri, 13 Aug 2021 06:48:26 +0800
+From: <sean.wang@mediatek.com>
+To: <nbd@nbd.name>, <lorenzo.bianconi@redhat.com>
+CC: <sean.wang@mediatek.com>, <Soul.Huang@mediatek.com>,
+ <YN.Chen@mediatek.com>, <Leon.Yen@mediatek.com>,
+ <Eric-SY.Chang@mediatek.com>, <Deren.Wu@mediatek.com>, <km.lin@mediatek.com>,
+ <robin.chiu@mediatek.com>, <ch.yeh@mediatek.com>, <posh.sun@mediatek.com>,
+ <Eric.Liang@mediatek.com>, <Stella.Chang@mediatek.com>, <jemele@google.com>,
+ <yenlinlai@google.com>, <linux-wireless@vger.kernel.org>,
+ <linux-mediatek@lists.infradead.org>, Ryder Lee <ryder.lee@mediatek.com>
+Subject: [PATCH] mt76: mt7921: report HE MU radiotap
+Date: Fri, 13 Aug 2021 06:48:24 +0800
+Message-ID:
+ <c340d189992eb10288fb8f050ae513f1c15da179.1628807229.git.objelf@gmail.com>
+X-Mailer: git-send-email 1.7.9.5
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210812_155035_611048_08FB4E49
+X-CRM114-Status: GOOD ( 14.07 )
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: Sean Wang <sean.wang@mediatek.com>
+
+Report HE MU/BF radiotap.
+
+That fixed HE MU packets dropped by mac80211 because they are missing the
+ieee80211_radiotap_he_mu header.
+
+Fixes: 163f4d22c118d ("mt76: mt7921: add MAC support")
+Co-developed-by: Ryder Lee <ryder.lee@mediatek.com>
+Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
+Co-developed-by: Eric-SY Chang <Eric-SY.Chang@mediatek.com>
+Signed-off-by: Eric-SY Chang <Eric-SY.Chang@mediatek.com>
+Tested-by: Eric-SY Chang <Eric-SY.Chang@mediatek.com>
+Signed-off-by: Sean Wang <sean.wang@mediatek.com>
+---
+ .../net/wireless/mediatek/mt76/mt7921/mac.c | 65 ++++++++++++++++---
+ .../net/wireless/mediatek/mt76/mt7921/mac.h | 8 +++
+ 2 files changed, 65 insertions(+), 8 deletions(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+index 296e0f7a1d14..7ee9ef2fb9f0 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.c
+@@ -180,12 +180,56 @@ mt7921_mac_decode_he_radiotap_ru(struct mt76_rx_status *status,
+ IEEE80211_RADIOTAP_HE_DATA2_RU_OFFSET);
+ }
+
++static void
++mt7921_mac_decode_he_mu_radiotap(struct sk_buff *skb,
++ struct mt76_rx_status *status,
++ __le32 *rxv)
++{
++ static const struct ieee80211_radiotap_he_mu mu_known = {
++ .flags1 = HE_BITS(MU_FLAGS1_SIG_B_MCS_KNOWN) |
++ HE_BITS(MU_FLAGS1_SIG_B_DCM_KNOWN) |
++ HE_BITS(MU_FLAGS1_CH1_RU_KNOWN) |
++ HE_BITS(MU_FLAGS1_SIG_B_SYMS_USERS_KNOWN) |
++ HE_BITS(MU_FLAGS1_SIG_B_COMP_KNOWN),
++ .flags2 = HE_BITS(MU_FLAGS2_BW_FROM_SIG_A_BW_KNOWN) |
++ HE_BITS(MU_FLAGS2_PUNC_FROM_SIG_A_BW_KNOWN),
++ };
++ struct ieee80211_radiotap_he_mu *he_mu = NULL;
++
++ he_mu = skb_push(skb, sizeof(mu_known));
++ memcpy(he_mu, &mu_known, sizeof(mu_known));
++
++#define MU_PREP(f, v) le16_encode_bits(v, IEEE80211_RADIOTAP_HE_MU_##f)
++
++ he_mu->flags1 |= MU_PREP(FLAGS1_SIG_B_MCS, status->rate_idx);
++ if (status->he_dcm)
++ he_mu->flags1 |= MU_PREP(FLAGS1_SIG_B_DCM, status->he_dcm);
++
++ he_mu->flags2 |= MU_PREP(FLAGS2_BW_FROM_SIG_A_BW, status->bw) |
++ MU_PREP(FLAGS2_SIG_B_SYMS_USERS,
++ le32_get_bits(rxv[2], MT_CRXV_HE_NUM_USER));
++
++ he_mu->ru_ch1[0] = FIELD_GET(MT_CRXV_HE_RU0, cpu_to_le32(rxv[3]));
++
++ if (status->bw >= RATE_INFO_BW_40) {
++ he_mu->flags1 |= HE_BITS(MU_FLAGS1_CH2_RU_KNOWN);
++ he_mu->ru_ch2[0] =
++ FIELD_GET(MT_CRXV_HE_RU1, cpu_to_le32(rxv[3]));
++ }
++
++ if (status->bw >= RATE_INFO_BW_80) {
++ he_mu->ru_ch1[1] =
++ FIELD_GET(MT_CRXV_HE_RU2, cpu_to_le32(rxv[3]));
++ he_mu->ru_ch2[1] =
++ FIELD_GET(MT_CRXV_HE_RU3, cpu_to_le32(rxv[3]));
++ }
++}
++
+ static void
+ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
+ struct mt76_rx_status *status,
+ __le32 *rxv, u32 phy)
+ {
+- /* TODO: struct ieee80211_radiotap_he_mu */
+ static const struct ieee80211_radiotap_he known = {
+ .data1 = HE_BITS(DATA1_DATA_MCS_KNOWN) |
+ HE_BITS(DATA1_DATA_DCM_KNOWN) |
+@@ -193,6 +237,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
+ HE_BITS(DATA1_CODING_KNOWN) |
+ HE_BITS(DATA1_LDPC_XSYMSEG_KNOWN) |
+ HE_BITS(DATA1_DOPPLER_KNOWN) |
++ HE_BITS(DATA1_SPTL_REUSE_KNOWN) |
+ HE_BITS(DATA1_BSS_COLOR_KNOWN),
+ .data2 = HE_BITS(DATA2_GI_KNOWN) |
+ HE_BITS(DATA2_TXBF_KNOWN) |
+@@ -207,9 +252,12 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
+
+ he->data3 = HE_PREP(DATA3_BSS_COLOR, BSS_COLOR, rxv[14]) |
+ HE_PREP(DATA3_LDPC_XSYMSEG, LDPC_EXT_SYM, rxv[2]);
++ he->data4 = HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, rxv[11]);
+ he->data5 = HE_PREP(DATA5_PE_DISAMBIG, PE_DISAMBIG, rxv[2]) |
+ le16_encode_bits(ltf_size,
+ IEEE80211_RADIOTAP_HE_DATA5_LTF_SIZE);
++ if (cpu_to_le32(rxv[0]) & MT_PRXV_TXBF)
++ he->data5 |= HE_BITS(DATA5_TXBF);
+ he->data6 = HE_PREP(DATA6_TXOP, TXOP_DUR, rxv[14]) |
+ HE_PREP(DATA6_DOPPLER, DOPPLER, rxv[14]);
+
+@@ -217,8 +265,7 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
+ case MT_PHY_TYPE_HE_SU:
+ he->data1 |= HE_BITS(DATA1_FORMAT_SU) |
+ HE_BITS(DATA1_UL_DL_KNOWN) |
+- HE_BITS(DATA1_BEAM_CHANGE_KNOWN) |
+- HE_BITS(DATA1_SPTL_REUSE_KNOWN);
++ HE_BITS(DATA1_BEAM_CHANGE_KNOWN);
+
+ he->data3 |= HE_PREP(DATA3_BEAM_CHANGE, BEAM_CHNG, rxv[14]) |
+ HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
+@@ -232,17 +279,15 @@ mt7921_mac_decode_he_radiotap(struct sk_buff *skb,
+ break;
+ case MT_PHY_TYPE_HE_MU:
+ he->data1 |= HE_BITS(DATA1_FORMAT_MU) |
+- HE_BITS(DATA1_UL_DL_KNOWN) |
+- HE_BITS(DATA1_SPTL_REUSE_KNOWN);
++ HE_BITS(DATA1_UL_DL_KNOWN);
+
+ he->data3 |= HE_PREP(DATA3_UL_DL, UPLINK, rxv[2]);
+- he->data4 |= HE_PREP(DATA4_SU_MU_SPTL_REUSE, SR_MASK, rxv[11]);
++ he->data4 |= HE_PREP(DATA4_MU_STA_ID, MU_AID, rxv[7]);
+
+ mt7921_mac_decode_he_radiotap_ru(status, he, rxv);
+ break;
+ case MT_PHY_TYPE_HE_TB:
+ he->data1 |= HE_BITS(DATA1_FORMAT_TRIG) |
+- HE_BITS(DATA1_SPTL_REUSE_KNOWN) |
+ HE_BITS(DATA1_SPTL_REUSE2_KNOWN) |
+ HE_BITS(DATA1_SPTL_REUSE3_KNOWN) |
+ HE_BITS(DATA1_SPTL_REUSE4_KNOWN);
+@@ -606,9 +651,13 @@ int mt7921_mac_fill_rx(struct mt7921_dev *dev, struct sk_buff *skb)
+
+ mt7921_mac_assoc_rssi(dev, skb);
+
+- if (rxv && status->flag & RX_FLAG_RADIOTAP_HE)
++ if (rxv && status->flag & RX_FLAG_RADIOTAP_HE) {
+ mt7921_mac_decode_he_radiotap(skb, status, rxv, mode);
+
++ if (status->flag & RX_FLAG_RADIOTAP_HE_MU)
++ mt7921_mac_decode_he_mu_radiotap(skb, status, rxv);
++ }
++
+ if (!status->wcid || !ieee80211_is_data_qos(fc))
+ return 0;
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mac.h b/drivers/net/wireless/mediatek/mt76/mt7921/mac.h
+index 3af67fac213d..f0194c878037 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mac.h
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mac.h
+@@ -116,6 +116,7 @@ enum rx_pkt_type {
+ #define MT_PRXV_TX_DCM BIT(4)
+ #define MT_PRXV_TX_ER_SU_106T BIT(5)
+ #define MT_PRXV_NSTS GENMASK(9, 7)
++#define MT_PRXV_TXBF BIT(10)
+ #define MT_PRXV_HT_AD_CODE BIT(11)
+ #define MT_PRXV_FRAME_MODE GENMASK(14, 12)
+ #define MT_PRXV_SGI GENMASK(16, 15)
+@@ -138,8 +139,15 @@ enum rx_pkt_type {
+ #define MT_CRXV_HE_LTF_SIZE GENMASK(18, 17)
+ #define MT_CRXV_HE_LDPC_EXT_SYM BIT(20)
+ #define MT_CRXV_HE_PE_DISAMBIG BIT(23)
++#define MT_CRXV_HE_NUM_USER GENMASK(30, 24)
+ #define MT_CRXV_HE_UPLINK BIT(31)
+
++#define MT_CRXV_HE_RU0 GENMASK(7, 0)
++#define MT_CRXV_HE_RU1 GENMASK(15, 8)
++#define MT_CRXV_HE_RU2 GENMASK(23, 16)
++#define MT_CRXV_HE_RU3 GENMASK(31, 24)
++#define MT_CRXV_HE_MU_AID GENMASK(30, 20)
++
+ #define MT_CRXV_HE_SR_MASK GENMASK(11, 8)
+ #define MT_CRXV_HE_SR1_MASK GENMASK(16, 12)
+ #define MT_CRXV_HE_SR2_MASK GENMASK(20, 17)
diff --git a/myconfig b/myconfig
new file mode 100644
index 000000000000..037f3f219806
--- /dev/null
+++ b/myconfig
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+## NOTE: Basic Arch compat. options:
+
+# CONFIG_STACK_VALIDATION gives better stack traces. Also is enabled in all official kernel packages by Archlinux team
+scripts/config --enable CONFIG_STACK_VALIDATION
+
+# Enable IKCONFIG following Arch's philosophy
+scripts/config --enable CONFIG_IKCONFIG \
+ --enable CONFIG_IKCONFIG_PROC
+
+## XXX: This kernel package is primarily targeted at ASUS laptops, we switch to schedutil so the machine properly clocks down
+
+scripts/config --disable CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE
+scripts/config --enable CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL
+
+## NOTE: Add any options here that you'd like to change from kernel defaults
+
+# sync default hostname with Arch
+scripts/config --set-val CONFIG_DEFAULT_HOSTNAME archlinux
+
+# sync up BPF defaults with mainline
+scripts/config --enable CONFIG_BPF_PRELOAD \
+ --module CONFIG_BPF_PRELOAD_UMD
+scripts/config --enable CONFIG_BPF_LSM \
+ --disable CONFIG_BPF_UNPRIV_DEFAULT_OFF
+
+# compress our modules
+scripts/config --disable CONFIG_MODULE_COMPRESS_NONE \
+ --enable CONFIG_MODULE_COMPRESS_ZSTD
+
+# sync some settings with Arch:
+scripts/config --enable CONFIG_TASKS_RUDE_RCU \
+ --disable CONFIG_X86_MCELOG_LEGACY \
+ --enable CONFIG_X86_CPA_STATISTICS \
+ --module CONFIG_X86_PMEM_LEGACY \
+ --enable CONFIG_KPROBES_ON_FTRACE \
+ --enable CONFIG_UPROBES \
+ --enable CONFIG_LOCK_EVENT_COUNTS \
+ --enable CONFIG_MODULE_FORCE_LOAD \
+ --enable CONFIG_MODULE_FORCE_UNLOAD \
+ --enable CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS \
+ --enable CONFIG_BLK_DEV_THROTTLING_LOW \
+ --enable CONFIG_BLK_CGROUP_IOCOST \
+ --enable CONFIG_CMA \
+ --enable CONFIG_CMA_DEBUGFS \
+ --enable CONFIG_CMA_SYSFS \
+ --set-val CONFIG_CMA_AREAS 7 \
+ --enable CONFIG_ZSWAP_DEFAULT_ON \
+ --enable CONFIG_READ_ONLY_THP_FOR_FS \
+ --enable CONFIG_XFRM_SUB_POLICY \
+ --enable CONFIG_XFRM_MIGRATE \
+ --enable CONFIG_NET_KEY_MIGRATE \
+ --enable CONFIG_IPV6_OPTIMISTIC_DAD \
+ --enable CONFIG_IPV6_RPL_LWTUNNEL \
+ --enable CONFIG_NF_CONNTRACK_PROCFS \
+ --module CONFIG_NETFILTER_XT_TARGET_NOTRACK \
+ --disable CONFIG_DECNET \
+ --module CONFIG_IPDDP \
+ --enable CONFIG_IPDDP_ENCAP \
+ --disable CONFIG_X25 \
+ --disable CONFIG_LAPB
+
+scripts/config --enable CONFIG_TRACEPOINTS \
+ --disable CONFIG_IOSF_MBI_DEBUG \
+ --enable CONFIG_KVM_MMU_AUDIT \
+ --disable CONFIG_BLK_CMDLINE_PARSER \
+ --enable CONFIG_6LOWPAN_DEBUGFS \
+ --module CONFIG_6LOWPAN_GHC_EXT_HDR_HOP \
+ --module CONFIG_6LOWPAN_GHC_UDP \
+ --module CONFIG_6LOWPAN_GHC_ICMPV6 \
+ --module CONFIG_6LOWPAN_GHC_EXT_HDR_DEST \
+ --module CONFIG_6LOWPAN_GHC_EXT_HDR_FRAG \
+ --module CONFIG_6LOWPAN_GHC_EXT_HDR_ROUTE \
+ --enable CONFIG_IEEE802154_NL802154_EXPERIMENTAL \
+ --enable CONFIG_CLS_U32_PERF \
+ --module CONFIG_NET_ACT_IFE \
+ --enable CONFIG_BATMAN_ADV_BATMAN_V \
+ --enable CONFIG_CEPH_LIB_PRETTYDEBUG \
+ --module CONFIG_PCIEAER_INJECT \
+ --enable CONFIG_PCIE_ECRC \
+ --enable CONFIG_PCI_P2PDMA
+
+scripts/config --disable CONFIG_RAPIDIO \
+ --module CONFIG_CDROM \
+ --disable CONFIG_PARIDE \
+ --enable CONFIG_NVME_CORE \
+ --enable CONFIG_BLK_DEV_NVME \
+ --module CONFIG_FDDI \
+ --module CONFIG_PPP \
+ --module CONFIG_SLHC
+
+# package is throwing a warning re: lack of binutils support
+scripts/config --disable CONFIG_X86_X32
+# larger log buffer
+scripts/config --set-val CONFIG_LOG_BUF_SHIFT 18
+# msr as a module
+scripts/config --module CONFIG_X86_MSR
+# enable EFI var access
+scripts/config --enable CONFIG_EFI_VARS
+# enable module versioning
+scripts/config --enable CONFIG_MODVERSIONS
+# use a smaller connection tracking table
+scripts/config --set-val CONFIG_IP_VS_TAB_BITS 12
+# enable bluetooth high speed
+scripts/config --enable CONFIG_BT_HS
+# nein
+scripts/config --disable CONFIG_UEVENT_HELPER
+scripts/config --disable CONFIG_FW_LOADER_USER_HELPER
+# enable zram memory tracking
+scripts/config --enable CONFIG_ZRAM_MEMORY_TRACKING
+
+# enable another ACPI debugging module
+scripts/config --module CONFIG_ACPI_APEI_ERST_DEBUG
+
+# enable multigen LRU by default
+scripts/config --enable CONFIG_LRU_GEN_ENABLED
diff --git a/sphinx-workaround.patch b/sphinx-workaround.patch
new file mode 100644
index 000000000000..a6e2c4900290
--- /dev/null
+++ b/sphinx-workaround.patch
@@ -0,0 +1,19 @@
+diff --git i/Documentation/conf.py w/Documentation/conf.py
+index 6a767294887e..d1d145759fed 100644
+--- i/Documentation/conf.py
++++ w/Documentation/conf.py
+@@ -267,11 +267,9 @@ except ImportError:
+
+ html_static_path = ['sphinx-static']
+
+-html_context = {
+- 'css_files': [
+- '_static/theme_overrides.css',
+- ],
+-}
++html_css_files = [
++ '_static/theme_overrides.css',
++]
+
+ # Add any extra paths that contain custom files (such as robots.txt or
+ # .htaccess) here, relative to this directory. These files are copied
diff --git a/v2-mt76-mt7921-fix-kernel-warning-from-cfg80211_calculate_bitrate.patch b/v2-mt76-mt7921-fix-kernel-warning-from-cfg80211_calculate_bitrate.patch
new file mode 100644
index 000000000000..0675a0da8d86
--- /dev/null
+++ b/v2-mt76-mt7921-fix-kernel-warning-from-cfg80211_calculate_bitrate.patch
@@ -0,0 +1,194 @@
+From patchwork Fri Aug 13 18:09:18 2021
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+X-Patchwork-Submitter: Sean Wang <sean.wang@mediatek.com>
+X-Patchwork-Id: 12435999
+Return-Path:
+ <SRS0=ikIt=NE=lists.infradead.org=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@kernel.org>
+X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on
+ aws-us-west-2-korg-lkml-1.web.codeaurora.org
+X-Spam-Level:
+X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH,
+ DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,
+ INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,
+ URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no
+ version=3.4.0
+Received: from mail.kernel.org (mail.kernel.org [198.145.29.99])
+ by smtp.lore.kernel.org (Postfix) with ESMTP id 85987C4338F
+ for <linux-mediatek@archiver.kernel.org>;
+ Fri, 13 Aug 2021 18:09:54 +0000 (UTC)
+Received: from bombadil.infradead.org (bombadil.infradead.org
+ [198.137.202.133])
+ (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
+ (No client certificate requested)
+ by mail.kernel.org (Postfix) with ESMTPS id 2146E610E9
+ for <linux-mediatek@archiver.kernel.org>;
+ Fri, 13 Aug 2021 18:09:54 +0000 (UTC)
+DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2146E610E9
+Authentication-Results: mail.kernel.org;
+ dmarc=fail (p=none dis=none) header.from=mediatek.com
+Authentication-Results: mail.kernel.org;
+ spf=none smtp.mailfrom=lists.infradead.org
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=lists.infradead.org; s=bombadil.20210309; h=Sender:
+ Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:
+ List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC
+ :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:
+ Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:
+ List-Owner; bh=0aRwGg0dzrHWWaZO2O5cCjiCmhy/BM1FkSnKydYU94U=; b=wFYXBsHUY1HSRj
+ q4yZqsoyQEiREu26XJAgYDhNlHcil7ycnSAvWRNFUdtgdFqvUr/n4+nnjcHdgu5QeBPkTOae0zHrN
+ eTF4P1CXFx6aTV7UrFew61TxVAXBAYgC9ldlXs2XGpI7StVnqGyXjfmBuv1lHk4zX2vYbeYsPbWBx
+ qyGgdUnEmxrgTBywXuOItY+IXpBFpZb3ohwVvhswwaZkvkEvXpQqyV+/wLP96PcTvLMIErLpt2EEK
+ ZTQfSU1TxQNY2zrLjIuNwO2HPxcYMYn/AzizKtKY2DdcCsjbzkeCGGFhgbLB4pXYARSTsMQcGKOu1
+ u8MDEMWe9L/z2cIAGmCg==;
+Received: from localhost ([::1] helo=bombadil.infradead.org)
+ by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mEbci-00DKgu-D0; Fri, 13 Aug 2021 18:09:40 +0000
+Received: from mailgw01.mediatek.com ([216.200.240.184])
+ by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux))
+ id 1mEbcb-00DKfN-KS
+ for linux-mediatek@lists.infradead.org; Fri, 13 Aug 2021 18:09:37 +0000
+X-UUID: f9998e255f0e412581fa74b7d6003edb-20210813
+DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
+ d=mediatek.com;
+ s=dk;
+ h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From;
+ bh=1AX8F79qACvbJzGrhNwzJ3VCwjf7YRFcxyDJLJfDQcQ=;
+ b=HuMsM37M7Ro2lVCCei4I5lmVlrWt5LqTO+YB9HBEXvV9RG4MrKLlAuD9/xv4Y+0CKNPSAbtRPenwLJlVstSWUGO5uaZnKRZnSvKcbiwLpfa2o8oLXFcArfKAtNp0MwLxv388CRP01KAgJE0o8Nr9PdGoiEenr7g/ivsguVnY02g=;
+X-UUID: f9998e255f0e412581fa74b7d6003edb-20210813
+Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by
+ mailgw01.mediatek.com
+ (envelope-from <sean.wang@mediatek.com>)
+ (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256)
+ with ESMTP id 886096985; Fri, 13 Aug 2021 11:09:30 -0700
+Received: from MTKMBS02N2.mediatek.inc (172.21.101.101) by
+ MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Fri, 13 Aug 2021 11:09:28 -0700
+Received: from MTKCAS06.mediatek.inc (172.21.101.30) by
+ mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id
+ 15.0.1497.2; Sat, 14 Aug 2021 02:09:20 +0800
+Received: from mtkswgap22.mediatek.inc (172.21.77.33) by MTKCAS06.mediatek.inc
+ (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via
+ Frontend Transport; Sat, 14 Aug 2021 02:09:21 +0800
+From: <sean.wang@mediatek.com>
+To: <nbd@nbd.name>, <lorenzo.bianconi@redhat.com>
+CC: <sean.wang@mediatek.com>, <Soul.Huang@mediatek.com>,
+ <YN.Chen@mediatek.com>, <Leon.Yen@mediatek.com>,
+ <Eric-SY.Chang@mediatek.com>, <Deren.Wu@mediatek.com>, <km.lin@mediatek.com>,
+ <robin.chiu@mediatek.com>, <ch.yeh@mediatek.com>, <posh.sun@mediatek.com>,
+ <Eric.Liang@mediatek.com>, <Stella.Chang@mediatek.com>, <jemele@google.com>,
+ <yenlinlai@google.com>, <linux-wireless@vger.kernel.org>,
+ <linux-mediatek@lists.infradead.org>
+Subject: [PATCH v2] mt76: mt7921: fix kernel warning from
+ cfg80211_calculate_bitrate
+Date: Sat, 14 Aug 2021 02:09:18 +0800
+Message-ID:
+ <a781b573380564be395500898269f27e5e4d2ba9.1628877755.git.objelf@gmail.com>
+X-Mailer: git-send-email 1.7.9.5
+MIME-Version: 1.0
+X-MTK: N
+X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
+X-CRM114-CacheID: sfid-20210813_110933_758439_3A80BBD7
+X-CRM114-Status: GOOD ( 12.12 )
+X-BeenThere: linux-mediatek@lists.infradead.org
+X-Mailman-Version: 2.1.34
+Precedence: list
+List-Id: <linux-mediatek.lists.infradead.org>
+List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=unsubscribe>
+List-Archive: <http://lists.infradead.org/pipermail/linux-mediatek/>
+List-Post: <mailto:linux-mediatek@lists.infradead.org>
+List-Help: <mailto:linux-mediatek-request@lists.infradead.org?subject=help>
+List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-mediatek>,
+ <mailto:linux-mediatek-request@lists.infradead.org?subject=subscribe>
+Sender: "Linux-mediatek" <linux-mediatek-bounces@lists.infradead.org>
+Errors-To:
+ linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org
+
+From: Sean Wang <sean.wang@mediatek.com>
+
+Fix the kernel warning from cfg80211_calculate_bitrate
+due to the legacy rate is not parsed well in the current driver.
+
+Also, zeros struct rate_info before we fill it out to avoid the old value
+is kept such as rate->legacy.
+
+[ 790.921560] WARNING: CPU: 7 PID: 970 at net/wireless/util.c:1298 cfg80211_calculate_bitrate+0x354/0x35c [cfg80211]
+[ 790.987738] Hardware name: MediaTek Asurada rev1 board (DT)
+[ 790.993298] pstate: a0400009 (NzCv daif +PAN -UAO)
+[ 790.998104] pc : cfg80211_calculate_bitrate+0x354/0x35c [cfg80211]
+[ 791.004295] lr : cfg80211_calculate_bitrate+0x180/0x35c [cfg80211]
+[ 791.010462] sp : ffffffc0129c3880
+[ 791.013765] x29: ffffffc0129c3880 x28: ffffffd38305bea8
+[ 791.019065] x27: ffffffc0129c3970 x26: 0000000000000013
+[ 791.024364] x25: 00000000000003ca x24: 000000000000002f
+[ 791.029664] x23: 00000000000000d0 x22: ffffff8d108bc000
+[ 791.034964] x21: ffffff8d108bc0d0 x20: ffffffc0129c39a8
+[ 791.040264] x19: ffffffc0129c39a8 x18: 00000000ffff0a10
+[ 791.045563] x17: 0000000000000050 x16: 00000000000000ec
+[ 791.050910] x15: ffffffd3f9ebed9c x14: 0000000000000006
+[ 791.056211] x13: 00000000000b2eea x12: 0000000000000000
+[ 791.061511] x11: 00000000ffffffff x10: 0000000000000000
+[ 791.066811] x9 : 0000000000000000 x8 : 0000000000000000
+[ 791.072110] x7 : 0000000000000000 x6 : ffffffd3fafa5a7b
+[ 791.077409] x5 : 0000000000000000 x4 : 0000000000000000
+[ 791.082708] x3 : 0000000000000000 x2 : 0000000000000000
+[ 791.088008] x1 : ffffff8d3f79c918 x0 : 0000000000000000
+[ 791.093308] Call trace:
+[ 791.095770] cfg80211_calculate_bitrate+0x354/0x35c [cfg80211]
+[ 791.101615] nl80211_put_sta_rate+0x6c/0x2c0 [cfg80211]
+[ 791.106853] nl80211_send_station+0x980/0xaa4 [cfg80211]
+[ 791.112178] nl80211_get_station+0xb4/0x134 [cfg80211]
+[ 791.117308] genl_rcv_msg+0x3a0/0x440
+[ 791.120960] netlink_rcv_skb+0xcc/0x118
+[ 791.124785] genl_rcv+0x34/0x48
+[ 791.127916] netlink_unicast+0x144/0x1dc
+
+Fixes: 1c099ab44727 ("mt76: mt7921: add MCU support")
+Signed-off-by: Sean Wang <sean.wang@mediatek.com>
+---
+v2: don't do unnecessary line removal
+---
+ drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 11 +++++++++--
+ 1 file changed, 9 insertions(+), 2 deletions(-)
+
+diff --git a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+index cadb633639d3..9b35b5da3619 100644
+--- a/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
++++ b/drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
+@@ -328,11 +328,13 @@ mt7921_mcu_tx_rate_parse(struct mt76_phy *mphy,
+ struct rate_info *rate, u16 r)
+ {
+ struct ieee80211_supported_band *sband;
+- u16 flags = 0;
++ u16 flags = 0, rate_idx;
+ u8 txmode = FIELD_GET(MT_WTBL_RATE_TX_MODE, r);
+ u8 gi = 0;
+ u8 bw = 0;
++ bool cck = false;
+
++ memset(rate, 0, sizeof(*rate));
+ rate->mcs = FIELD_GET(MT_WTBL_RATE_MCS, r);
+ rate->nss = FIELD_GET(MT_WTBL_RATE_NSS, r) + 1;
+
+@@ -357,13 +359,18 @@ mt7921_mcu_tx_rate_parse(struct mt76_phy *mphy,
+
+ switch (txmode) {
+ case MT_PHY_TYPE_CCK:
++ cck = true;
++ fallthrough;
+ case MT_PHY_TYPE_OFDM:
+ if (mphy->chandef.chan->band == NL80211_BAND_5GHZ)
+ sband = &mphy->sband_5g.sband;
+ else
+ sband = &mphy->sband_2g.sband;
+
+- rate->legacy = sband->bitrates[rate->mcs].bitrate;
++ rate_idx = FIELD_GET(MT_TX_RATE_IDX, r);
++ rate_idx = mt76_get_rate(mphy->dev, sband, rate_idx,
++ cck);
++ rate->legacy = sband->bitrates[rate_idx].bitrate;
+ break;
+ case MT_PHY_TYPE_HT:
+ case MT_PHY_TYPE_HT_GF:
diff --git a/v5-asus-wmi-Add-support-for-platform_profile.patch b/v5-asus-wmi-Add-support-for-platform_profile.patch
new file mode 100644
index 000000000000..737c3bd2c15c
--- /dev/null
+++ b/v5-asus-wmi-Add-support-for-platform_profile.patch
@@ -0,0 +1,239 @@
+From ecb125585d4e69dda57647af19b8a8736b876cee Mon Sep 17 00:00:00 2001
+From: "Luke D. Jones" <luke@ljones.dev>
+Date: Fri, 13 Aug 2021 14:36:01 +1200
+Subject: [PATCH v5 1/1] asus-wmi: Add support for platform_profile
+
+Add initial support for platform_profile where the support is
+based on availability of ASUS_THROTTLE_THERMAL_POLICY.
+
+Because throttle_thermal_policy is used by platform_profile and is
+writeable separately to platform_profile any userspace changes to
+throttle_thermal_policy need to notify platform_profile.
+
+In future throttle_thermal_policy sysfs should be removed so that
+only one method controls the laptop power profile.
+
+Signed-off-by: Luke D. Jones <luke@ljones.dev>
+---
+ drivers/platform/x86/Kconfig | 1 +
+ drivers/platform/x86/asus-wmi.c | 130 +++++++++++++++++++++++++++++++-
+ 2 files changed, 127 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
+index d12db6c316ea..46dec48a36c1 100644
+--- a/drivers/platform/x86/Kconfig
++++ b/drivers/platform/x86/Kconfig
+@@ -281,6 +281,7 @@ config ASUS_WMI
+ select INPUT_SPARSEKMAP
+ select LEDS_CLASS
+ select NEW_LEDS
++ select ACPI_PLATFORM_PROFILE
+ help
+ Say Y here if you have a WMI aware Asus laptop (like Eee PCs or new
+ Asus Notebooks).
+diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
+index 90a6a0d00deb..cc5811844012 100644
+--- a/drivers/platform/x86/asus-wmi.c
++++ b/drivers/platform/x86/asus-wmi.c
+@@ -26,6 +26,7 @@
+ #include <linux/rfkill.h>
+ #include <linux/pci.h>
+ #include <linux/pci_hotplug.h>
++#include <linux/platform_profile.h>
+ #include <linux/power_supply.h>
+ #include <linux/hwmon.h>
+ #include <linux/hwmon-sysfs.h>
+@@ -219,6 +220,9 @@ struct asus_wmi {
+ bool throttle_thermal_policy_available;
+ u8 throttle_thermal_policy_mode;
+
++ struct platform_profile_handler platform_profile_handler;
++ bool platform_profile_support;
++
+ // The RSOC controls the maximum charging percentage.
+ bool battery_rsoc_available;
+
+@@ -2103,12 +2107,23 @@ static int throttle_thermal_policy_set_default(struct asus_wmi *asus)
+ static int throttle_thermal_policy_switch_next(struct asus_wmi *asus)
+ {
+ u8 new_mode = asus->throttle_thermal_policy_mode + 1;
++ int err;
+
+ if (new_mode > ASUS_THROTTLE_THERMAL_POLICY_SILENT)
+ new_mode = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
+
+ asus->throttle_thermal_policy_mode = new_mode;
+- return throttle_thermal_policy_write(asus);
++ err = throttle_thermal_policy_write(asus);
++ if (err)
++ return err;
++
++ /*
++ * Ensure that platform_profile updates userspace with the change to ensure
++ * that platform_profile and throttle_thermal_policy_mode are in sync.
++ */
++ platform_profile_notify();
++
++ return 0;
+ }
+
+ static ssize_t throttle_thermal_policy_show(struct device *dev,
+@@ -2124,9 +2139,10 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+ {
+- int result;
+- u8 new_mode;
+ struct asus_wmi *asus = dev_get_drvdata(dev);
++ u8 new_mode;
++ int result;
++ int err;
+
+ result = kstrtou8(buf, 10, &new_mode);
+ if (result < 0)
+@@ -2136,7 +2152,15 @@ static ssize_t throttle_thermal_policy_store(struct device *dev,
+ return -EINVAL;
+
+ asus->throttle_thermal_policy_mode = new_mode;
+- throttle_thermal_policy_write(asus);
++ err = throttle_thermal_policy_write(asus);
++ if (err)
++ return err;
++
++ /*
++ * Ensure that platform_profile updates userspace with the change to ensure
++ * that platform_profile and throttle_thermal_policy_mode are in sync.
++ */
++ platform_profile_notify();
+
+ return count;
+ }
+@@ -2144,6 +2168,94 @@ 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);
+
++/* Platform profile ***********************************************************/
++static int platform_profile_get(struct platform_profile_handler *pprof,
++ enum platform_profile_option *profile)
++{
++ struct asus_wmi *asus;
++ int tp;
++
++ asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
++
++ tp = asus->throttle_thermal_policy_mode;
++
++ if (tp < 0)
++ return tp;
++
++ switch (tp) {
++ case ASUS_THROTTLE_THERMAL_POLICY_DEFAULT:
++ *profile = PLATFORM_PROFILE_BALANCED;
++ break;
++ case ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST:
++ *profile = PLATFORM_PROFILE_PERFORMANCE;
++ break;
++ case ASUS_THROTTLE_THERMAL_POLICY_SILENT:
++ *profile = PLATFORM_PROFILE_QUIET;
++ break;
++ default:
++ return -EINVAL;
++ }
++
++ return 0;
++}
++
++static int platform_profile_set(struct platform_profile_handler *pprof,
++ enum platform_profile_option profile)
++{
++ struct asus_wmi *asus;
++ int tp;
++
++ asus = container_of(pprof, struct asus_wmi, platform_profile_handler);
++
++ switch (profile) {
++ case PLATFORM_PROFILE_PERFORMANCE:
++ tp = ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST;
++ break;
++ case PLATFORM_PROFILE_BALANCED:
++ tp = ASUS_THROTTLE_THERMAL_POLICY_DEFAULT;
++ break;
++ case PLATFORM_PROFILE_QUIET:
++ tp = ASUS_THROTTLE_THERMAL_POLICY_SILENT;
++ break;
++ default:
++ return -EOPNOTSUPP;
++ }
++
++ asus->throttle_thermal_policy_mode = tp;
++ return throttle_thermal_policy_write(asus);
++}
++
++static int platform_profile_setup(struct asus_wmi *asus)
++{
++ struct device *dev = &asus->platform_device->dev;
++ int err;
++
++ /*
++ * Not an error if a component platform_profile relies on is unavailable
++ * so early return, skipping the setup of platform_profile.
++ */
++ if (!asus->throttle_thermal_policy_available)
++ return 0;
++
++ dev_info(dev, "Using throttle_thermal_policy for platform_profile support\n");
++
++ asus->platform_profile_handler.profile_get = platform_profile_get;
++ asus->platform_profile_handler.profile_set = platform_profile_set;
++
++ set_bit(PLATFORM_PROFILE_QUIET, asus->platform_profile_handler.choices);
++ set_bit(PLATFORM_PROFILE_BALANCED,
++ asus->platform_profile_handler.choices);
++ set_bit(PLATFORM_PROFILE_PERFORMANCE,
++ asus->platform_profile_handler.choices);
++
++ err = platform_profile_register(&asus->platform_profile_handler);
++ if (err)
++ return err;
++
++ asus->platform_profile_support = true;
++ return 0;
++}
++
+ /* Backlight ******************************************************************/
+
+ static int read_backlight_power(struct asus_wmi *asus)
+@@ -2904,6 +3016,10 @@ static int asus_wmi_add(struct platform_device *pdev)
+ else
+ throttle_thermal_policy_set_default(asus);
+
++ err = platform_profile_setup(asus);
++ if (err)
++ goto fail_platform_profile_setup;
++
+ err = panel_od_check_present(asus);
+ if (err)
+ goto fail_panel_od;
+@@ -2993,6 +3109,9 @@ static int asus_wmi_add(struct platform_device *pdev)
+ asus_wmi_sysfs_exit(asus->platform_device);
+ fail_sysfs:
+ fail_throttle_thermal_policy:
++fail_platform_profile_setup:
++ if (asus->platform_profile_support)
++ platform_profile_remove();
+ fail_fan_boost_mode:
+ fail_egpu_enable:
+ fail_dgpu_disable:
+@@ -3017,6 +3136,9 @@ static int asus_wmi_remove(struct platform_device *device)
+ asus_fan_set_auto(asus);
+ asus_wmi_battery_exit(asus);
+
++ if (asus->platform_profile_support)
++ platform_profile_remove();
++
+ kfree(asus);
+ return 0;
+ }
+--
+2.31.1
+
diff --git a/v9-asus-wmi-Add-support-for-custom-fan-curves.patch b/v9-asus-wmi-Add-support-for-custom-fan-curves.patch
new file mode 100644
index 000000000000..bdff5aa67192
--- /dev/null
+++ b/v9-asus-wmi-Add-support-for-custom-fan-curves.patch
@@ -0,0 +1,790 @@
+From: "Luke D. Jones" <luke@ljones.dev>
+Subject [PATCH v9] asus-wmi: Add support for custom fan curves
+Date Sat, 4 Sep 2021 16:32:50 +1200
+
+
+Add support for custom fan curves found on some ASUS ROG laptops.
+
+These laptops have the ability to set a custom curve for the CPU
+and GPU fans via an ACPI method call. This patch enables this,
+additionally enabling custom fan curves per-profile, where profile
+here means each of the 3 levels of "throttle_thermal_policy".
+
+This patch adds two pwm<N> attributes to the hwmon sysfs,
+pwm1 for CPU fan, pwm2 for GPU fan. Both are under the hwmon of the
+name `asus_custom_fan_curve`.
+
+The fans have settings [1,2,3] under pwm<N>_enable:
+1. Enable and write settings out
+2. Disable and restore factory fan mode
+3. Same as 2, additionally restoring default factory curve.
+this is following `pwm[1-*]_enable`.
+
+Notes:
+- pwm<N>_enable = 0 is an invalid setting.
+- pwm is actually a percentage and is scaled on writing to device.
+
+Signed-off-by: Luke D. Jones <luke@ljones.dev>
+---
+ drivers/platform/x86/asus-wmi.c | 646 ++++++++++++++++++++-
+ include/linux/platform_data/x86/asus-wmi.h | 2 +
+ 2 files changed, 644 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
+index cc5811844012..ee244b9ea57e 100644
+--- a/drivers/platform/x86/asus-wmi.c
++++ b/drivers/platform/x86/asus-wmi.c
+@@ -106,8 +106,17 @@ module_param(fnlock_default, bool, 0444);
+
+ #define WMI_EVENT_MASK 0xFFFF
+
++#define FAN_CURVE_POINTS 8
++#define FAN_CURVE_BUF_LEN (FAN_CURVE_POINTS * 2)
++#define FAN_CURVE_DEV_CPU 0x00
++#define FAN_CURVE_DEV_GPU 0x01
++/* Mask to determine if setting temperature or percentage */
++#define FAN_CURVE_PWM_MASK 0x04
++
+ static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL };
+
++static int throttle_thermal_policy_write(struct asus_wmi *);
++
+ static bool ashs_present(void)
+ {
+ int i = 0;
+@@ -122,7 +131,8 @@ struct bios_args {
+ u32 arg0;
+ u32 arg1;
+ u32 arg2; /* At least TUF Gaming series uses 3 dword input buffer. */
+- u32 arg4;
++ u32 arg3;
++ u32 arg4; /* Some ROG laptops require a full 5 input args */
+ u32 arg5;
+ } __packed;
+
+@@ -173,6 +183,19 @@ enum fan_type {
+ FAN_TYPE_SPEC83, /* starting in Spec 8.3, use CPU_FAN_CTRL */
+ };
+
++/*
++ * The related ACPI method for testing availability also returns the factory
++ * default fan curves. We save them here so that a user can reset custom
++ * settings if required.
++ */
++struct fan_curve_data {
++ bool enabled;
++ u8 temps[FAN_CURVE_POINTS];
++ u8 percents[FAN_CURVE_POINTS];
++ u8 default_temps[FAN_CURVE_POINTS];
++ u8 default_percents[FAN_CURVE_POINTS];
++};
++
+ struct asus_wmi {
+ int dsts_id;
+ int spec;
+@@ -220,6 +243,11 @@ struct asus_wmi {
+ bool throttle_thermal_policy_available;
+ u8 throttle_thermal_policy_mode;
+
++ bool cpu_fan_curve_available;
++ bool gpu_fan_curve_available;
++ /* [throttle modes][fan count] */
++ struct fan_curve_data custom_fan_curves[2];
++
+ struct platform_profile_handler platform_profile_handler;
+ bool platform_profile_support;
+
+@@ -285,6 +313,105 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval)
+ }
+ EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method);
+
++static int asus_wmi_evaluate_method5(u32 method_id,
++ u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 *retval)
++{
++ struct bios_args args = {
++ .arg0 = arg0,
++ .arg1 = arg1,
++ .arg2 = arg2,
++ .arg3 = arg3,
++ .arg4 = arg4,
++ };
++ struct acpi_buffer input = { (acpi_size) sizeof(args), &args };
++ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
++ acpi_status status;
++ union acpi_object *obj;
++ u32 tmp = 0;
++
++ status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id,
++ &input, &output);
++
++ if (ACPI_FAILURE(status))
++ return -EIO;
++
++ obj = (union acpi_object *)output.pointer;
++ if (obj && obj->type == ACPI_TYPE_INTEGER)
++ tmp = (u32) obj->integer.value;
++
++ if (retval)
++ *retval = tmp;
++
++ kfree(obj);
++
++ if (tmp == ASUS_WMI_UNSUPPORTED_METHOD)
++ return -ENODEV;
++
++ return 0;
++}
++
++/*
++ * Returns as an error if the method output is not a buffer. Typically this
++ * means that the method called is unsupported.
++ */
++static int asus_wmi_evaluate_method_buf(u32 method_id,
++ u32 arg0, u32 arg1, u8 *ret_buffer, size_t size)
++{
++ struct bios_args args = {
++ .arg0 = arg0,
++ .arg1 = arg1,
++ .arg2 = 0,
++ };
++ struct acpi_buffer input = { (acpi_size) sizeof(args), &args };
++ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL };
++ acpi_status status;
++ union acpi_object *obj;
++ u32 int_tmp = 0;
++ int err = 0;
++
++ status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id,
++ &input, &output);
++
++ if (ACPI_FAILURE(status))
++ return -EIO;
++
++ obj = (union acpi_object *)output.pointer;
++
++ if (obj && obj->type == ACPI_TYPE_BUFFER) {
++ if (obj->buffer.length > size)
++ err = -ENOSPC;
++ if (obj->buffer.length == 0)
++ err = -ENODATA;
++ if (err) {
++ kfree(obj);
++ return err;
++ }
++ memcpy(ret_buffer, obj->buffer.pointer, obj->buffer.length);
++ }
++
++ if (obj && obj->type == ACPI_TYPE_INTEGER) {
++ int_tmp = (u32)obj->integer.value;
++
++ kfree(obj);
++ if (int_tmp == ASUS_WMI_UNSUPPORTED_METHOD)
++ return -ENODEV;
++ /*
++ * At least one method returns a 0 with no buffer if no arg
++ * is provided, such as ASUS_WMI_DEVID_CPU_FAN_CURVE
++ */
++ if (int_tmp == 0)
++ return -ENODATA;
++ return int_tmp;
++ }
++
++ kfree(obj);
++
++ if (obj == NULL)
++ return -ENODATA;
++
++ return 0;
++}
++
+ static int asus_wmi_evaluate_method_agfn(const struct acpi_buffer args)
+ {
+ struct acpi_buffer input;
+@@ -1806,6 +1933,13 @@ static ssize_t pwm1_enable_store(struct device *dev,
+ }
+
+ asus->fan_pwm_mode = state;
++
++ /* Must set to disabled if mode is toggled */
++ if (asus->cpu_fan_curve_available)
++ asus->custom_fan_curves[0].enabled = false;
++ if (asus->gpu_fan_curve_available)
++ asus->custom_fan_curves[1].enabled = false;
++
+ return count;
+ }
+
+@@ -2043,6 +2177,498 @@ static ssize_t fan_boost_mode_store(struct device *dev,
+ // Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
+ static DEVICE_ATTR_RW(fan_boost_mode);
+
++/* Custom fan curves per-profile **********************************************/
++
++static void fan_curve_copy_from_buf(struct fan_curve_data *data, u8 *buf)
++{
++ int i;
++
++ for (i = 0; i < FAN_CURVE_POINTS; i++) {
++ data->temps[i] = buf[i];
++ data->default_temps[i] = buf[i];
++ }
++
++ for (i = 0; i < FAN_CURVE_POINTS; i++) {
++ data->percents[i] = 255 * buf[i + 8] / 100;
++ data->default_percents[i] = 255 * buf[i + 8] / 100;
++ }
++}
++
++static u8 fan_curve_throttle_to_wmi_index(struct asus_wmi *asus)
++{
++ u8 mode = 0;
++
++ if (asus->throttle_thermal_policy_available)
++ mode = asus->throttle_thermal_policy_mode;
++ /*
++ * The index for ASUS_WMI_DEVID_<C/G>PU_FAN_CURVE is switched for
++ * OVERBOOST vs SILENT.
++ */
++ if (mode == 2)
++ mode = 1;
++ if (mode == 1)
++ mode = 2;
++
++ return mode;
++}
++
++static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
++{
++ u8 mode = fan_curve_throttle_to_wmi_index(asus);
++ int buf_len = FAN_CURVE_BUF_LEN;
++ struct fan_curve_data *curves;
++ u8 buf[FAN_CURVE_BUF_LEN];
++ int fan_idx = 0;
++ int err;
++
++ curves = &asus->custom_fan_curves[fan_idx];
++ err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
++ buf_len);
++ if (err)
++ return err;
++
++ fan_curve_copy_from_buf(curves, buf);
++
++ return 0;
++}
++
++/*
++ * Check if the ability to set fan curves on either fan exists, and populate
++ * with system defaults to provide users with a starting point.
++ *
++ * "fan_dev" is either CPU_FAN_CURVE or GPU_FAN_CURVE.
++ */
++static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
++ u32 fan_dev)
++{
++ int err;
++
++ *available = false;
++
++ err = fan_curve_get_factory_default(asus, fan_dev);
++ if (err) {
++ if (err == -ENODEV)
++ return 0;
++ return err;
++ }
++
++ *available = true;
++
++ return 0;
++}
++
++static struct fan_curve_data *
++fan_curve_data_select(struct asus_wmi *asus, struct device_attribute *attr)
++{
++ /* Determine which fan the attribute is for */
++ int nr = to_sensor_dev_attr_2(attr)->nr;
++ int fan = nr & FAN_CURVE_DEV_GPU;
++
++ return &asus->custom_fan_curves[fan];
++}
++
++static ssize_t fan_curve_show(struct device *dev, struct device_attribute *attr,
++ char *buf)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ struct fan_curve_data *data = fan_curve_data_select(asus, attr);
++ int value;
++
++ int index = to_sensor_dev_attr_2(attr)->index;
++
++ /* Determine if temperature or pwm */
++ int nr = to_sensor_dev_attr_2(attr)->nr;
++
++ if (nr & FAN_CURVE_PWM_MASK)
++ value = data->percents[index];
++ else
++ value = data->temps[index];
++
++ return sysfs_emit(buf, "%d\n", value);
++}
++
++/*
++ * "fan_dev" is the related WMI method such as ASUS_WMI_DEVID_CPU_FAN_CURVE.
++ */
++static int fan_curve_write(struct asus_wmi *asus,
++ struct device_attribute *attr, u32 fan_dev)
++{
++ struct fan_curve_data *data = fan_curve_data_select(asus, attr);
++
++ u32 arg1 = 0, arg2 = 0, arg3 = 0, arg4 = 0;
++ int ret, i, shift = 0;
++ u8 *temps = data->temps;
++ u8 *percents = data->percents;
++
++ /* Args must be in a percentage */
++ for (i = 0; i < FAN_CURVE_POINTS / 2; i++) {
++ arg1 += (100 * temps[i] / 255) << shift;
++ arg2 += (100 * temps[i + 4] / 255) << shift;
++ arg3 += (100 * percents[i] / 255) << shift;
++ arg4 += (100 * percents[i + 4] / 255) << shift;
++ shift += 8;
++ }
++
++ return asus_wmi_evaluate_method5(ASUS_WMI_METHODID_DEVS, fan_dev, arg1,
++ arg2, arg3, arg4, &ret);
++}
++
++/*
++ * Called on curve enable/disable, and by throttle mode change to apply
++ * fan curves for any enabled fans.
++ */
++static int fan_curve_write_data(struct asus_wmi *asus, struct device_attribute *attr)
++{
++ int err;
++
++ if (asus->cpu_fan_curve_available) {
++ err = fan_curve_write(asus, attr, ASUS_WMI_DEVID_CPU_FAN_CURVE);
++ if (err)
++ return err;
++ }
++
++ if (asus->gpu_fan_curve_available) {
++ err = fan_curve_write(asus, attr, ASUS_WMI_DEVID_GPU_FAN_CURVE);
++ if (err)
++ return err;
++ }
++
++ return 0;
++}
++
++static int fan_curve_verify(struct fan_curve_data *data)
++{
++ int i = 0;
++ u8 tmp = 0;
++ u8 prev_tmp = 0;
++
++ for (i = 0; i < FAN_CURVE_POINTS; i++) {
++ tmp = data->temps[i];
++ if (tmp < prev_tmp)
++ return -EINVAL;
++ prev_tmp = tmp;
++ }
++
++ tmp = 0;
++ prev_tmp = 0;
++ for (i = 0; i < FAN_CURVE_POINTS; i++) {
++ tmp = data->percents[i];
++ if (tmp < prev_tmp)
++ return -EINVAL;
++ prev_tmp = tmp;
++ }
++
++ return 0;
++}
++
++static ssize_t fan_curve_store(struct device *dev,
++ struct device_attribute *attr, const char *buf,
++ size_t count)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ struct fan_curve_data *data = fan_curve_data_select(asus, attr);
++ u8 value, old_value;
++ int err;
++
++ int index = to_sensor_dev_attr_2(attr)->index;
++ int nr = to_sensor_dev_attr_2(attr)->nr;
++ int pwm = nr & FAN_CURVE_PWM_MASK;
++
++ err = kstrtou8(buf, 10, &value);
++ if (err < 0)
++ return err;
++
++ if (pwm) {
++ old_value = data->percents[index];
++ data->percents[index] = value;
++ } else {
++ old_value = data->temps[index];
++ data->temps[index] = value;
++ }
++ /*
++ * The check here forces writing a curve graph in reverse,
++ * from highest to lowest.
++ */
++ err = fan_curve_verify(data);
++ if (err) {
++ if (pwm) {
++ dev_err(dev,
++ "a fan curve percentage was higher than the next in sequence\n");
++ data->percents[index] = old_value;
++ } else {
++ dev_err(dev,
++ "a fan curve temperature was higher than the next in sequence\n");
++ data->temps[index] = old_value;
++ }
++ return err;
++ }
++ /*
++ * Mark as disabled so we don't write for every point change which
++ * can cause issues. When user re-enables the curves will apply.
++ */
++ data->enabled = false;
++
++ return count;
++}
++
++static ssize_t fan_curve_enable_show(struct device *dev,
++ struct device_attribute *attr, char *buf)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ struct fan_curve_data *data = fan_curve_data_select(asus, attr);
++
++ return sysfs_emit(buf, "%d\n", data->enabled);
++}
++
++static int fan_curve_set_default(struct asus_wmi *asus)
++{
++ int err;
++
++ err = fan_curve_get_factory_default(
++ asus, ASUS_WMI_DEVID_CPU_FAN_CURVE);
++ if (err)
++ return err;
++ err = fan_curve_get_factory_default(
++ asus, ASUS_WMI_DEVID_GPU_FAN_CURVE);
++ if (err)
++ return err;
++ return 0;
++}
++
++static ssize_t fan_curve_enable_store(struct device *dev,
++ struct device_attribute *attr,
++ const char *buf, size_t count)
++{
++ struct asus_wmi *asus = dev_get_drvdata(dev);
++ struct fan_curve_data *data = fan_curve_data_select(asus, attr);
++ int value;
++ int err;
++
++ err = kstrtoint(buf, 10, &value);
++ if (err < 0)
++ return err;
++
++ switch (value) {
++ case 1:
++ data->enabled = true;
++ break;
++ case 2:
++ data->enabled = false;
++ break;
++ /* Auto + reset the fan curve data to defaults */
++ case 3:
++ err = fan_curve_set_default(asus);
++ if (err)
++ return err;
++ data->enabled = false;
++ break;
++ default:
++ return -EINVAL;
++ };
++
++ /*
++ * 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_available && !data->enabled) {
++ err = throttle_thermal_policy_write(asus);
++ if (err)
++ return err;
++ }
++ /* Similar is true for laptops with this fan */
++ if (asus->fan_type == FAN_TYPE_SPEC83) {
++ err = asus_fan_set_auto(asus);
++ if (err)
++ return err;
++ }
++ /*
++ * Machines without either need to write their defaults back always.
++ * This is more of a safeguard against ASUS faulty ACPI tables.
++ */
++ if (!asus->throttle_thermal_policy_available
++ && asus->fan_type != FAN_TYPE_SPEC83 && !data->enabled) {
++ err = fan_curve_set_default(asus);
++ if (err)
++ return err;
++ err = fan_curve_write_data(asus, attr);
++ if (err)
++ return err;
++ }
++
++ if (data->enabled) {
++ err = fan_curve_write_data(asus, attr);
++ if (err)
++ return err;
++ }
++
++ return count;
++}
++
++/* CPU */
++static SENSOR_DEVICE_ATTR_RW(pwm1_enable, fan_curve_enable, FAN_CURVE_DEV_CPU);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 0);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 1);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point3_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 2);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point4_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 3);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point5_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 4);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point6_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 5);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point7_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 6);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point8_temp, fan_curve,
++ FAN_CURVE_DEV_CPU, 7);
++
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point1_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 0);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point2_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 1);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point3_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 2);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point4_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 3);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point5_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 4);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point6_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 5);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point7_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 6);
++static SENSOR_DEVICE_ATTR_2_RW(pwm1_auto_point8_pwm, fan_curve,
++ FAN_CURVE_DEV_CPU | FAN_CURVE_PWM_MASK, 7);
++
++/* GPU */
++static SENSOR_DEVICE_ATTR_RW(pwm2_enable, fan_curve_enable, FAN_CURVE_DEV_GPU);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 0);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 1);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point3_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 2);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point4_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 3);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point5_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 4);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point6_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 5);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point7_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 6);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point8_temp, fan_curve,
++ FAN_CURVE_DEV_GPU, 7);
++
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point1_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 0);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point2_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 1);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point3_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 2);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point4_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 3);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point5_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 4);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point6_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 5);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point7_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 6);
++static SENSOR_DEVICE_ATTR_2_RW(pwm2_auto_point8_pwm, fan_curve,
++ FAN_CURVE_DEV_GPU | FAN_CURVE_PWM_MASK, 7);
++
++static struct attribute *asus_fan_curve_attr[] = {
++ /* CPU */
++ &sensor_dev_attr_pwm1_enable.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point1_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point2_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point3_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point4_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point5_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point6_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point7_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point8_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point1_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point2_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point3_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point4_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point5_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point6_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point7_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm1_auto_point8_pwm.dev_attr.attr,
++ /* GPU */
++ &sensor_dev_attr_pwm2_enable.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point1_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point2_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point3_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point4_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point5_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point6_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point7_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point8_temp.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point1_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point2_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point3_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point4_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point5_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point6_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point7_pwm.dev_attr.attr,
++ &sensor_dev_attr_pwm2_auto_point8_pwm.dev_attr.attr,
++ NULL
++};
++
++static umode_t asus_fan_curve_is_visible(struct kobject *kobj,
++ struct attribute *attr, int idx)
++{
++ struct device *dev = container_of(kobj, struct device, kobj);
++ struct asus_wmi *asus = dev_get_drvdata(dev->parent);
++
++ if (asus->cpu_fan_curve_available)
++ return 0644;
++
++ if (asus->gpu_fan_curve_available)
++ return 0644;
++
++ return 0;
++}
++
++static const struct attribute_group asus_fan_curve_attr_group = {
++ .is_visible = asus_fan_curve_is_visible,
++ .attrs = asus_fan_curve_attr,
++};
++__ATTRIBUTE_GROUPS(asus_fan_curve_attr);
++
++/*
++ * Must be initialised after throttle_thermal_policy_check_present() as
++ * we check the status of throttle_thermal_policy_available during init.
++ */
++static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
++{
++ struct device *dev = &asus->platform_device->dev;
++ struct device *hwmon;
++ int err;
++
++ err = fan_curve_check_present(asus, &asus->cpu_fan_curve_available,
++ ASUS_WMI_DEVID_CPU_FAN_CURVE);
++ if (err)
++ return err;
++
++ err = fan_curve_check_present(asus, &asus->gpu_fan_curve_available,
++ ASUS_WMI_DEVID_GPU_FAN_CURVE);
++ if (err)
++ return err;
++
++ hwmon = devm_hwmon_device_register_with_groups(
++ dev, "asus_custom_fan_curve", asus, asus_fan_curve_attr_groups);
++
++ if (IS_ERR(hwmon)) {
++ dev_err(dev,
++ "Could not register asus_custom_fan_curve device\n");
++ return PTR_ERR(hwmon);
++ }
++
++ return 0;
++}
++
+ /* Throttle thermal policy ****************************************************/
+
+ static int throttle_thermal_policy_check_present(struct asus_wmi *asus)
+@@ -2053,8 +2679,8 @@ static int throttle_thermal_policy_check_present(struct asus_wmi *asus)
+ asus->throttle_thermal_policy_available = false;
+
+ err = asus_wmi_get_devstate(asus,
+- ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY,
+- &result);
++ ASUS_WMI_DEVID_THROTTLE_THERMAL_POLICY,
++ &result);
+ if (err) {
+ if (err == -ENODEV)
+ return 0;
+@@ -2092,6 +2718,12 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus)
+ return -EIO;
+ }
+
++ /* Must set to disabled if mode is toggled */
++ if (asus->cpu_fan_curve_available)
++ asus->custom_fan_curves[0].enabled = false;
++ if (asus->gpu_fan_curve_available)
++ asus->custom_fan_curves[1].enabled = false;
++
+ return 0;
+ }
+
+@@ -2904,7 +3536,7 @@ static int show_call(struct seq_file *m, void *data)
+ if (ACPI_FAILURE(status))
+ return -EIO;
+
+- obj = (union acpi_object *)output.pointer;
++ obj = output.pointer;
+ if (obj && obj->type == ACPI_TYPE_INTEGER)
+ seq_printf(m, "%#x(%#x, %#x) = %#x\n", asus->debug.method_id,
+ asus->debug.dev_id, asus->debug.ctrl_param,
+@@ -3038,6 +3670,10 @@ static int asus_wmi_add(struct platform_device *pdev)
+ if (err)
+ goto fail_hwmon;
+
++ err = asus_wmi_custom_fan_curve_init(asus);
++ if (err)
++ goto fail_custom_fan_curve;
++
+ err = asus_wmi_led_init(asus);
+ if (err)
+ goto fail_leds;
+@@ -3109,6 +3745,7 @@ static int asus_wmi_add(struct platform_device *pdev)
+ asus_wmi_sysfs_exit(asus->platform_device);
+ fail_sysfs:
+ fail_throttle_thermal_policy:
++fail_custom_fan_curve:
+ fail_platform_profile_setup:
+ if (asus->platform_profile_support)
+ platform_profile_remove();
+@@ -3134,6 +3771,7 @@ static int asus_wmi_remove(struct platform_device *device)
+ asus_wmi_debugfs_exit(asus);
+ asus_wmi_sysfs_exit(asus->platform_device);
+ asus_fan_set_auto(asus);
++ throttle_thermal_policy_set_default(asus);
+ asus_wmi_battery_exit(asus);
+
+ if (asus->platform_profile_support)
+diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
+index 17dc5cb6f3f2..a571b47ff362 100644
+--- a/include/linux/platform_data/x86/asus-wmi.h
++++ b/include/linux/platform_data/x86/asus-wmi.h
+@@ -77,6 +77,8 @@
+ #define ASUS_WMI_DEVID_THERMAL_CTRL 0x00110011
+ #define ASUS_WMI_DEVID_FAN_CTRL 0x00110012 /* deprecated */
+ #define ASUS_WMI_DEVID_CPU_FAN_CTRL 0x00110013
++#define ASUS_WMI_DEVID_CPU_FAN_CURVE 0x00110024
++#define ASUS_WMI_DEVID_GPU_FAN_CURVE 0x00110025
+
+ /* Power */
+ #define ASUS_WMI_DEVID_PROCESSOR_STATE 0x00120012
+--
+2.31.1
diff --git a/x86-ACPI-State-Optimize-C3-entry-on-AMD-CPUs.patch b/x86-ACPI-State-Optimize-C3-entry-on-AMD-CPUs.patch
new file mode 100644
index 000000000000..ef0789b20f37
--- /dev/null
+++ b/x86-ACPI-State-Optimize-C3-entry-on-AMD-CPUs.patch
@@ -0,0 +1,58 @@
+From: Deepak Sharma <deepak.sharma@amd.com>
+To: <deepak.sharma@amd.com>
+CC: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
+ Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
+ Thomas Gleixner <tglx@linutronix.de>,
+ "Ingo Molnar" <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
+ "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@kernel.org>,
+ "H. Peter Anvin" <hpa@zytor.com>,
+ "open list:SUSPEND TO RAM" <linux-pm@vger.kernel.org>,
+ "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
+ <linux-kernel@vger.kernel.org>
+Subject: [PATCH] x86/ACPI/State: Optimize C3 entry on AMD CPUs
+Date: Wed, 18 Aug 2021 17:43:05 -0700
+Message-ID: <20210819004305.20203-1-deepak.sharma@amd.com>
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List: linux-kernel@vger.kernel.org
+List-Archive: <https://lore.kernel.org/lkml/>
+
+AMD CPU which support C3 shares cache. Its not necessary to flush the
+caches in software before entering C3. This will cause performance drop
+for the cores which share some caches. ARB_DIS is not used with current
+AMD C state implementation. So set related flags correctly.
+
+Signed-off-by: Deepak Sharma <deepak.sharma@amd.com>
+---
+ arch/x86/kernel/acpi/cstate.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/arch/x86/kernel/acpi/cstate.c b/arch/x86/kernel/acpi/cstate.c
+index 7de599eba7f0..62a5986d625a 100644
+--- a/arch/x86/kernel/acpi/cstate.c
++++ b/arch/x86/kernel/acpi/cstate.c
+@@ -79,6 +79,21 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
+ */
+ flags->bm_control = 0;
+ }
++ if (c->x86_vendor == X86_VENDOR_AMD) {
++ /*
++ * For all AMD CPUs that support C3, caches should not be
++ * flushed by software while entering C3 type state. Set
++ * bm->check to 1 so that kernel doesn't need to execute
++ * cache flush operation.
++ */
++ flags->bm_check = 1;
++ /*
++ * In current AMD C state implementation ARB_DIS is no longer
++ * used. So set bm_control to zero to indicate ARB_DIS is not
++ * required while entering C3 type state.
++ */
++ flags->bm_control = 0;
++ }
+ }
+ EXPORT_SYMBOL(acpi_processor_power_init_bm_check);
+
+--
+2.25.1
+
+