diff options
author | dragonn | 2021-08-29 10:20:07 +0200 |
---|---|---|
committer | dragonn | 2021-08-29 10:20:07 +0200 |
commit | ffb7bbdb69c0c2ab889de2322c64074baf102fc0 (patch) | |
tree | cd3f0fbe9eeadac4c7181804cfcb8b2d53ebe1ba | |
parent | 9d5052ad55f5ff26d1663e2b43930621c2eec291 (diff) | |
download | aur-ffb7bbdb69c0c2ab889de2322c64074baf102fc0.tar.gz |
5.13.13
-rw-r--r-- | .SRCINFO | 16 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | PKGBUILD | 17 | ||||
-rw-r--r-- | sys-kernel_arch-sources-g14_files-0046-fan-curvers.patch | 789 | ||||
-rw-r--r-- | sys-kernel_arch-sources-g14_files-9001-v5.13.13-s0ix-patch-2021-08-28.patch (renamed from sys-kernel_arch-sources-g14_files-9001-v5.13.2-s0ix-patch-2021-08-05.patch) | 92 | ||||
-rw-r--r-- | sys-kernel_arch-sources-g14_files-9002-amd-pmc-delay-test.patch | 44 |
6 files changed, 418 insertions, 542 deletions
@@ -1,7 +1,7 @@ pkgbase = linux-g14 pkgdesc = Linux - pkgver = 5.13.12.arch1 - pkgrel = 2 + pkgver = 5.13.13.arch1 + pkgrel = 1 url = https://lab.retarded.farm/zappel/asus-rog-zephyrus-g14/ arch = x86_64 license = GPL2 @@ -16,7 +16,7 @@ pkgbase = linux-g14 makedepends = git makedepends = gcc>=11.0 options = !strip - source = archlinux-linux::git+https://github.com/archlinux/linux?signed#tag=v5.13.12-arch1 + source = archlinux-linux::git+https://github.com/archlinux/linux?signed#tag=v5.13.13-arch1 source = config source = choose-gcc-optimization.sh source = sys-kernel_arch-sources-g14_files-0004-5.8+--more-uarches-for-kernel.patch::https://raw.githubusercontent.com/graysky2/kernel_compiler_patch/a8d200f422f4b2abeaa6cfcfa37136b308e6e33e/more-uarches-for-kernel-5.8%2B.patch @@ -34,9 +34,9 @@ pkgbase = linux-g14 source = sys-kernel_arch-sources-g14_files-8011-Bluetooth-btusb-Add-support-for-Lite-On-Mediatek-Chi.patch source = sys-kernel_arch-sources-g14_files-8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch source = sys-kernel_arch-sources-g14_files-8014-mt76-mt7921-Add-mt7922-support.patch - source = sys-kernel_arch-sources-g14_files-9001-v5.13.2-s0ix-patch-2021-08-05.patch + source = sys-kernel_arch-sources-g14_files-9001-v5.13.13-s0ix-patch-2021-08-28.patch + source = sys-kernel_arch-sources-g14_files-9002-amd-pmc-delay-test.patch source = sys-kernel_arch-sources-g14_files-9002-amd-pmc-smu-register-dump-for-diagnostics.patch - source = sys-kernel_arch-sources-g14_files-9003-ACPI-PM-s2idle-Invert-Microsoft-UUID-entry-and-exit.patch source = sys-kernel_arch-sources-g14_files-9004-HID-asus-Reduce-object-size-by-consolidating-calls.patch source = sys-kernel_arch-sources-g14_files-9005-acpi-battery-Always-read-fresh-battery-state-on-update.patch source = sys-kernel_arch-sources-g14_files-9006-amd-c3-entry.patch @@ -56,15 +56,15 @@ pkgbase = linux-g14 sha256sums = 32bbcde83406810f41c9ed61206a7596eb43707a912ec9d870fd94f160d247c1 sha256sums = e2d312ea95d18e91801d131a2b5d03cf2175d3088cac6f84a19410078a5b6b14 sha256sums = 4ef12029ea73ca924b6397e1de4911e84d9e77ddaccdab1ef579823d848524e8 - sha256sums = d7243b89a21cdca61e753526b82cea24af0bd28bfa0158843c31226037f39d97 + sha256sums = 6fe5fe83e06d552f541bdca55d0d9e2cd6e70dd3047c01da749a0ff57fe706cc sha256sums = ed28a8051514f8c228717a5cdd13191b1c58181e0228d972fbe2af5ee1d013d7 sha256sums = de8c9747637768c4356c06aa65c3f157c526aa420f21fdd5edd0ed06f720a62e sha256sums = 67ebf477b2ecbf367ea3fee1568eeb3de59de7185ef5ed66b81ae73108f6693c sha256sums = 2163cb2e394a013042a40cd3b00dae788603284b20d71e262995366c5534e480 sha256sums = a01cf700d79b983807e2285be1b30df6e02db6adfd9c9027fe2dfa8ca5a74bc9 - sha256sums = c097278b0421bcfd80f24b37bd58d7c9b3e809eaf3c391c73def1451fa366c8b + sha256sums = 41d7a48f113b3924595d327ea3031d1b14c611835e111c46438b9d85219cd76c + sha256sums = d8dd84c26a44af618c6d1b68723e3bf0f8f50165af04fe090256afb0f931713e sha256sums = 6e629d4a032165f39202a702ad518a050c9305f911595a43bc34ce0c1d45d36b - sha256sums = 5b7b8f450282a15d0832b171e82fc5639de1cb7aa495efe6e6c7989ebeb8ca36 sha256sums = 544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4 sha256sums = f7a4bf6293912bfc4a20743e58a5a266be8c4dbe3c1862d196d3a3b45f2f7c90 sha256sums = ee8794a551e33226900654d5c806183bf3b9b2e06f64fdc322987215d233d399 diff --git a/.gitignore b/.gitignore index 0dc162744a9c..30c1b03f4b98 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ archlinux-linux .vscode xanmod-rog-PKGBUILD linux +test +fedora-kernel-*.zip
\ No newline at end of file @@ -1,8 +1,8 @@ # Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> pkgbase=linux-g14 -pkgver=5.13.12.arch1 -pkgrel=2 +pkgver=5.13.13.arch1 +pkgrel=1 pkgdesc='Linux' _srctag=v${pkgver%.*}-${pkgver##*.} url="https://lab.retarded.farm/zappel/asus-rog-zephyrus-g14/" @@ -53,12 +53,13 @@ source=( "sys-kernel_arch-sources-g14_files-8013-mt76-mt7921-Fix-out-of-order-process-by-invalid-even.patch" "sys-kernel_arch-sources-g14_files-8014-mt76-mt7921-Add-mt7922-support.patch" - # squashed s0ix enablement through 2021-08-05 - "sys-kernel_arch-sources-g14_files-9001-v5.13.2-s0ix-patch-2021-08-05.patch" + # squashed s0ix enablement through 2021-08-28 + "sys-kernel_arch-sources-g14_files-9001-v5.13.13-s0ix-patch-2021-08-28.patch" + "sys-kernel_arch-sources-g14_files-9002-amd-pmc-delay-test.patch" # a small amd_pmc SMU debugging patch per Mario Limonciello @AMD "sys-kernel_arch-sources-g14_files-9002-amd-pmc-smu-register-dump-for-diagnostics.patch" - "sys-kernel_arch-sources-g14_files-9003-ACPI-PM-s2idle-Invert-Microsoft-UUID-entry-and-exit.patch" + #"sys-kernel_arch-sources-g14_files-9003-ACPI-PM-s2idle-Invert-Microsoft-UUID-entry-and-exit.patch" "sys-kernel_arch-sources-g14_files-9004-HID-asus-Reduce-object-size-by-consolidating-calls.patch" "sys-kernel_arch-sources-g14_files-9005-acpi-battery-Always-read-fresh-battery-state-on-update.patch" @@ -85,15 +86,15 @@ sha256sums=('SKIP' '32bbcde83406810f41c9ed61206a7596eb43707a912ec9d870fd94f160d247c1' 'e2d312ea95d18e91801d131a2b5d03cf2175d3088cac6f84a19410078a5b6b14' '4ef12029ea73ca924b6397e1de4911e84d9e77ddaccdab1ef579823d848524e8' - 'd7243b89a21cdca61e753526b82cea24af0bd28bfa0158843c31226037f39d97' + '6fe5fe83e06d552f541bdca55d0d9e2cd6e70dd3047c01da749a0ff57fe706cc' 'ed28a8051514f8c228717a5cdd13191b1c58181e0228d972fbe2af5ee1d013d7' 'de8c9747637768c4356c06aa65c3f157c526aa420f21fdd5edd0ed06f720a62e' '67ebf477b2ecbf367ea3fee1568eeb3de59de7185ef5ed66b81ae73108f6693c' '2163cb2e394a013042a40cd3b00dae788603284b20d71e262995366c5534e480' 'a01cf700d79b983807e2285be1b30df6e02db6adfd9c9027fe2dfa8ca5a74bc9' - 'c097278b0421bcfd80f24b37bd58d7c9b3e809eaf3c391c73def1451fa366c8b' + '41d7a48f113b3924595d327ea3031d1b14c611835e111c46438b9d85219cd76c' + 'd8dd84c26a44af618c6d1b68723e3bf0f8f50165af04fe090256afb0f931713e' '6e629d4a032165f39202a702ad518a050c9305f911595a43bc34ce0c1d45d36b' - '5b7b8f450282a15d0832b171e82fc5639de1cb7aa495efe6e6c7989ebeb8ca36' '544464bf0807b324120767d55867f03014a9fda4e1804768ca341be902d7ade4' 'f7a4bf6293912bfc4a20743e58a5a266be8c4dbe3c1862d196d3a3b45f2f7c90' 'ee8794a551e33226900654d5c806183bf3b9b2e06f64fdc322987215d233d399') diff --git a/sys-kernel_arch-sources-g14_files-0046-fan-curvers.patch b/sys-kernel_arch-sources-g14_files-0046-fan-curvers.patch index d9adfc927112..aa6919698f41 100644 --- a/sys-kernel_arch-sources-g14_files-0046-fan-curvers.patch +++ b/sys-kernel_arch-sources-g14_files-0046-fan-curvers.patch @@ -1,7 +1,7 @@ -From 770f400736f971ae3fe60ed83f43452eee128204 Mon Sep 17 00:00:00 2001 +From 094c3ed89ed4a86933f69838679f4222ba288aa4 Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" <luke@ljones.dev> -Date: Thu, 19 Aug 2021 10:42:17 +1200 -Subject: [PATCH v5 1/1] asus-wmi: Add support for custom fan curves +Date: Sun, 29 Aug 2021 13:21:23 +1200 +Subject: [PATCH v6] asus-wmi: Add support for custom fan curves Add support for custom fan curves found on some ASUS ROG laptops. @@ -10,74 +10,102 @@ 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". +The format for input fan curves is +"30:1,49:2,59:3,69:4,79:31,89:49,99:56,109:58" +where each block of "30:1," is one point on the curve, and 30c, 1% +of fan RPM up to 100%. This follows the internal WMI format. This +format was chosen as it is used heavily by pre-existing utilities +that were based on using the acpi_call module. Further, each pair +can be defined as "T[ c:]P[ %,]" resulting in "30c:1%,", "30c1 " +or similar with a max of two chars between values. + Signed-off-by: Luke D. Jones <luke@ljones.dev> --- - drivers/platform/x86/asus-wmi.c | 666 +++++++++++++++++++++ + drivers/platform/x86/asus-wmi.c | 488 ++++++++++++++++++++- include/linux/platform_data/x86/asus-wmi.h | 2 + - 2 files changed, 668 insertions(+) + 2 files changed, 488 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c -index cc5811844012..1b19894285e6 100644 +index cc5811844012..dccdd41917ff 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c -@@ -108,6 +108,11 @@ module_param(fnlock_default, bool, 0444); +@@ -106,8 +106,23 @@ module_param(fnlock_default, bool, 0444); + + #define WMI_EVENT_MASK 0xFFFF ++/* The number of ASUS_THROTTLE_THERMAL_POLICY_* available */ ++#define NUM_FAN_CURVE_PROFILES 3 ++#define NUM_FAN_CURVE_POINTS 8 ++#define NUM_FAN_CURVE_DATA (NUM_FAN_CURVE_POINTS * 2) ++ static const char * const ashs_ids[] = { "ATK4001", "ATK4002", NULL }; -+static int throttle_thermal_policy_write(struct asus_wmi*); -+static ssize_t fan_curve_store(struct asus_wmi *asus, const char *buf, -+ size_t count, u32 dev, char **curve, -+ char *default_curve); ++/* ++ * The order here matters, index positions reflect ++ * ASUS_THROTTLE_THERMAL_POLICY_<name> ++ */ ++static const char * const fan_curve_names[] = { ++ "balanced", "performance", "quiet" ++}; ++ ++static int throttle_thermal_policy_write(struct asus_wmi *); + static bool ashs_present(void) { int i = 0; -@@ -122,6 +127,7 @@ struct bios_args { +@@ -122,7 +137,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; ++ u32 arg4; /* Some ROG laptops require a full 5 input args */ u32 arg5; } __packed; -@@ -173,6 +179,21 @@ enum fan_type { + +@@ -173,6 +189,29 @@ enum fan_type { FAN_TYPE_SPEC83, /* starting in Spec 8.3, use CPU_FAN_CTRL */ }; ++enum fan_device { ++ FAN_DEVICE_CPU = 0, ++ FAN_DEVICE_GPU, ++}; ++ ++/* ++ * Each temps[n] is paired with percents[n] ++ */ +struct fan_curve { -+ char *balanced; -+ char *balanced_default; -+ char *performance; -+ char *performance_default; -+ char *quiet; -+ char *quiet_default; ++ u8 temps[NUM_FAN_CURVE_POINTS]; ++ u8 percents[NUM_FAN_CURVE_POINTS]; +}; + -+struct enabled_fan_curves { -+ bool balanced; -+ bool performance; -+ bool quiet; ++/* ++ * 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 { ++ struct fan_curve custom; ++ struct fan_curve defaults; +}; + struct asus_wmi { int dsts_id; int spec; -@@ -220,6 +241,14 @@ struct asus_wmi { +@@ -220,6 +259,11 @@ struct asus_wmi { bool throttle_thermal_policy_available; u8 throttle_thermal_policy_mode; + bool cpu_fan_curve_available; -+ struct fan_curve cpu_fan_curve; -+ -+ bool gpu_fan_curve_available; -+ struct fan_curve gpu_fan_curve; -+ -+ struct enabled_fan_curves enabled_fan_curve_profiles; ++ bool gpu_fan_curve_available; ++ bool fan_curves_enabled[NUM_FAN_CURVE_PROFILES]; ++ struct fan_curve_data throttle_fan_curves[NUM_FAN_CURVE_PROFILES][2]; + struct platform_profile_handler platform_profile_handler; bool platform_profile_support; -@@ -285,6 +314,85 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) +@@ -285,6 +329,84 @@ int asus_wmi_evaluate_method(u32 method_id, u32 arg0, u32 arg1, u32 *retval) } EXPORT_SYMBOL_GPL(asus_wmi_evaluate_method); @@ -121,7 +149,7 @@ index cc5811844012..1b19894285e6 100644 +/* + * 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) +{ @@ -151,9 +179,8 @@ index cc5811844012..1b19894285e6 100644 + return int_tmp; + } + -+ if (obj && obj->type == ACPI_TYPE_BUFFER && obj->buffer.length >= 16) { ++ if (obj && obj->type == ACPI_TYPE_BUFFER) + memcpy(ret_buffer, obj->buffer.pointer, obj->buffer.length); -+ } + + kfree(obj); + @@ -163,412 +190,290 @@ index cc5811844012..1b19894285e6 100644 static int asus_wmi_evaluate_method_agfn(const struct acpi_buffer args) { struct acpi_buffer input; -@@ -2043,6 +2151,455 @@ static ssize_t fan_boost_mode_store(struct device *dev, +@@ -2043,6 +2165,330 @@ 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 copy_fan_curve_buf(struct fan_curve *data, u8 *buf) ++{ ++ int i; ++ ++ for (i = 0; i < NUM_FAN_CURVE_POINTS; i++) ++ data->temps[i] = buf[i]; ++ ++ for (i = 0; i < NUM_FAN_CURVE_POINTS; i++) ++ data->percents[i] = buf[i + 8]; ++} ++ ++static void init_fan_curve(struct fan_curve_data *curves, ++ u8 *buf, u32 dev) ++{ ++ copy_fan_curve_buf(&curves->custom, buf); ++ copy_fan_curve_buf(&curves->defaults, buf); ++} ++ ++/* ++ * Check if the ability to set fan curves on either fan exists, and store the ++ * defaults for recall later plus to provide users with a starting point. ++ * ++ * "dev" is either CPU_FAN_CURVE or GPU_FAN_CURVE. ++ */ +static int custom_fan_check_present(struct asus_wmi *asus, -+ bool *available, u32 dev) ++ bool *available, u32 dev) +{ -+ struct fan_curve *curves = &asus->cpu_fan_curve; -+ u8 *b = kzalloc(16 * sizeof(u8), GFP_KERNEL); -+ /* 15 punctuation marks + 16 sets of numbers up to 3 char each */ -+ int str_len = 15 + 16 * 3; ++ struct fan_curve_data *curves; ++ u8 buf[NUM_FAN_CURVE_DATA]; ++ int fan_idx = 0; + int err; + + *available = false; -+ + if (dev == ASUS_WMI_DEVID_GPU_FAN_CURVE) -+ curves = &asus->gpu_fan_curve; ++ fan_idx = 1; + + /* Balanced default */ -+ err = asus_wmi_evaluate_method_buf(asus->dsts_id, dev, 0, b); ++ curves = ++ &asus->throttle_fan_curves[ASUS_THROTTLE_THERMAL_POLICY_DEFAULT][fan_idx]; ++ err = asus_wmi_evaluate_method_buf(asus->dsts_id, dev, 0, buf); + if (err) { + if (err == -ENODEV) + return 0; + return err; + } -+ -+ curves->balanced = kzalloc(str_len * sizeof(char), GFP_KERNEL); -+ if (!curves->balanced) -+ return -ENOMEM; -+ -+ curves->balanced_default = kzalloc(str_len * sizeof(char), GFP_KERNEL); -+ if (!curves->balanced_default) -+ return -ENOMEM; -+ -+ sprintf(curves->balanced, "%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d", -+ b[0], b[8], b[1], b[9], b[2], b[10], b[3], b[11], -+ b[4], b[12], b[5], b[13], b[6], b[14], b[7], b[15]); -+ sprintf(curves->balanced_default, curves->balanced); -+ -+ /* Quiet default */ -+ err = asus_wmi_evaluate_method_buf(asus->dsts_id, dev, 1, b); ++ init_fan_curve(curves, buf, dev); ++ ++ /* ++ * Quiet default. The index num for ACPI method does not match the ++ * throttle_thermal number, same for Performance. ++ */ ++ curves = ++ &asus->throttle_fan_curves[ASUS_THROTTLE_THERMAL_POLICY_SILENT][fan_idx]; ++ err = asus_wmi_evaluate_method_buf(asus->dsts_id, dev, 1, buf); + if (err) { + if (err == -ENODEV) + return 0; + return err; + } -+ -+ curves->quiet = kzalloc(str_len * sizeof(char), GFP_KERNEL); -+ if (!curves->quiet) -+ return -ENOMEM; -+ -+ curves->quiet_default = kzalloc(str_len * sizeof(char), GFP_KERNEL); -+ if (!curves->quiet_default) -+ return -ENOMEM; -+ -+ sprintf(curves->quiet, "%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d", -+ b[0], b[8], b[1], b[9], b[2], b[10], b[3], b[11], -+ b[4], b[12], b[5], b[13], b[6], b[14], b[7], b[15]); -+ sprintf(curves->quiet_default, curves->quiet); ++ init_fan_curve(curves, buf, dev); + + /* Performance default */ -+ err = asus_wmi_evaluate_method_buf(asus->dsts_id, dev, 2, b); ++ curves = ++ &asus->throttle_fan_curves[ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST][fan_idx]; ++ err = asus_wmi_evaluate_method_buf(asus->dsts_id, dev, 2, buf); + if (err) { + if (err == -ENODEV) + return 0; + return err; + } -+ -+ curves->performance = kzalloc(str_len * sizeof(char), GFP_KERNEL); -+ if (!curves->performance) -+ return -ENOMEM; -+ -+ curves->performance_default = kzalloc(str_len * sizeof(char), GFP_KERNEL); -+ if (!curves->performance_default) -+ return -ENOMEM; -+ -+ sprintf(curves->performance, -+ "%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d,%d:%d", -+ b[0], b[8], b[1], b[9], b[2], b[10], b[3], b[11], -+ b[4], b[12], b[5], b[13], b[6], b[14], b[7], b[15]); -+ sprintf(curves->performance_default, curves->performance); -+ -+ kfree(b); ++ init_fan_curve(curves, buf, dev); + + *available = true; + return 0; +} + -+/* -+ * The expected input is of the format -+ * "30:1,49:2,59:3,69:4,79:31,89:49,99:56,109:58" -+ * where a pair is 30:1, with 30 = temperature, and 1 = percentage -+*/ -+static int fan_curve_check_valid(const char *curve) ++static ssize_t fan_curve_show(struct device *dev, ++ struct device_attribute *attr, char *buf) +{ -+ char * buf, *set, *set_end, *pair_tmp, *pair, *pair_end; -+ int err, ret; -+ -+ char *set_delimiter = ","; -+ char *pair_delimiter = ":"; -+ bool pair_start = true; -+ u32 prev_percent = 0; -+ u32 prev_temp = 0; -+ u32 percent = 0; -+ u32 temp = 0; -+ -+ buf = set_end = pair_end = kstrdup(curve, GFP_KERNEL); -+ -+ while( (set = strsep(&set_end, set_delimiter)) != NULL ) { -+ pair_tmp = kstrdup(set, GFP_KERNEL); -+ pair_start = true; -+ while( (pair = strsep(&pair_tmp, pair_delimiter)) != NULL ) { -+ err = kstrtouint(pair, 10, &ret); -+ if (err) { -+ kfree(pair_tmp); -+ kfree(buf); -+ return err; -+ } -+ -+ if (pair_start) { -+ temp = ret; -+ pair_start = false; -+ } else { -+ percent = ret; -+ } -+ } -+ kfree(pair_tmp); ++ struct asus_wmi *asus = dev_get_drvdata(dev); ++ /* index maps to ASUS_THROTTLE_THERMAL_POLICY_DEFAULT */ ++ int nr = to_sensor_dev_attr_2(attr)->nr; ++ /* dev maps to ASUS_WMI_DEVID_[C/G]PU_FAN_CURVE */ ++ int index = to_sensor_dev_attr_2(attr)->index; + -+ if (temp < prev_temp || percent < prev_percent || percent > 100) { -+ pr_info("Fan curve invalid"); -+ pr_info("A value is sequentially lower or percentage is > 100"); -+ kfree(buf); -+ return -EINVAL; -+ } ++ struct fan_curve *dat = &asus->throttle_fan_curves[nr][index].custom; ++ int len = 0; ++ int i = 0; + -+ prev_temp = temp; -+ prev_percent = percent; ++ for (i = 0; i < NUM_FAN_CURVE_POINTS; i++) { ++ len += sysfs_emit_at(buf, len, "%dc:%d%%", ++ dat->temps[i], dat->percents[i]); ++ if (i < NUM_FAN_CURVE_POINTS - 1) ++ len += sysfs_emit_at(buf, len, ","); + } -+ kfree(buf); -+ -+ return 0; ++ len += sysfs_emit_at(buf, len, "\n"); ++ return len; +} + -+static int fan_curve_write(struct asus_wmi *asus, u32 dev, char *curve) ++/* ++ * "dev" is the related WMI method such as ASUS_WMI_DEVID_CPU_FAN_CURVE. ++ */ ++static int fan_curve_write(struct asus_wmi *asus, u32 dev, ++ struct fan_curve *curve) +{ -+ char * buf, *set, *pair_tmp, *pair, *set_end, *pair_end; -+ int err, ret; -+ -+ char *set_delimiter = ","; -+ char *pair_delimiter = ":"; -+ bool half_complete = false; -+ bool pair_start = true; -+ u32 percent = 0; -+ u32 shift = 0; -+ u32 temp = 0; -+ u32 arg1 = 0; -+ u32 arg2 = 0; -+ u32 arg3 = 0; -+ u32 arg4 = 0; -+ -+ buf = set_end = pair_end = kstrdup(curve, GFP_KERNEL); -+ -+ while( (set = strsep(&set_end, set_delimiter)) != NULL ) { -+ pair_tmp = kstrdup(set, GFP_KERNEL); -+ pair_start = true; -+ while( (pair = strsep(&pair_tmp, pair_delimiter)) != NULL ) { -+ err = kstrtouint(pair, 10, &ret); -+ if (err) { -+ kfree(pair_tmp); -+ kfree(buf); -+ return err; -+ } -+ -+ if (pair_start) { -+ temp = ret; -+ pair_start = false; -+ } else { -+ percent = ret; -+ } -+ } -+ kfree(pair_tmp); -+ -+ if (!half_complete) { -+ arg1 += temp << shift; -+ arg3 += percent << shift; -+ } else { -+ arg2 += temp << shift; -+ arg4 += percent << shift; -+ } -+ shift += 8; -+ -+ if (shift == 32) { -+ shift = 0; -+ half_complete = true; -+ } -+ } -+ kfree(buf); -+ -+ return asus_wmi_evaluate_method5(ASUS_WMI_METHODID_DEVS, dev, -+ arg1, arg2, arg3, arg4, &ret); ++ int ret; ++ u32 arg1, arg2, arg3, arg4; ++ ++ arg1 = curve->temps[0]; ++ arg2 = curve->temps[4]; ++ arg1 += curve->temps[1] << 8; ++ arg2 += curve->temps[5] << 8; ++ arg1 += curve->temps[2] << 16; ++ arg2 += curve->temps[6] << 16; ++ arg1 += curve->temps[3] << 24; ++ arg2 += curve->temps[7] << 24; ++ ++ ++ arg3 = curve->percents[0]; ++ arg4 = curve->percents[4]; ++ arg3 += curve->percents[1] << 8; ++ arg4 += curve->percents[5] << 8; ++ arg3 += curve->percents[2] << 16; ++ arg4 += curve->percents[6] << 16; ++ arg3 += curve->percents[3] << 24; ++ arg4 += curve->percents[7] << 24; ++ ++ return asus_wmi_evaluate_method5(ASUS_WMI_METHODID_DEVS, dev, ++ arg1, arg2, arg3, arg4, &ret); +} + -+static ssize_t fan_curve_store(struct asus_wmi *asus, const char *buf, -+ size_t count, u32 dev, char **curve, -+ char *default_curve) ++/* ++ * Called only by throttle_thermal_policy_write() ++ */ ++static int fan_curve_write_data(struct asus_wmi *asus) +{ -+ int err; ++ struct fan_curve_data *cpu; ++ struct fan_curve_data *gpu; ++ int err, mode; + -+ /* Allow a user to write "" or " " to erase a curve setting */ -+ if (strlen(buf) <= 1 || strcmp(buf, " \n") == 0) { -+ kfree(*curve); -+ *curve = kstrdup(default_curve, GFP_KERNEL); -+ err = throttle_thermal_policy_write(asus); ++ mode = asus->throttle_thermal_policy_mode; ++ cpu = &asus->throttle_fan_curves[mode][FAN_DEVICE_CPU]; ++ gpu = &asus->throttle_fan_curves[mode][FAN_DEVICE_GPU]; ++ ++ if (asus->fan_curves_enabled[mode]) { ++ err = fan_curve_write(asus, ASUS_WMI_DEVID_CPU_FAN_CURVE, &cpu->custom); + if (err) + return err; -+ return count; + } + -+ err = fan_curve_check_valid(buf); -+ if (err) -+ return err; -+ -+ if (*curve) -+ kfree(*curve); -+ -+ /* Always save fan curve if it is valid */ -+ *curve = kstrdup(buf, GFP_KERNEL); -+ -+ /* Maybe activate fan curve if in associated mode */ -+ err = throttle_thermal_policy_write(asus); -+ -+ if (err) -+ return err; ++ if (asus->fan_curves_enabled[mode]) { ++ err = fan_curve_write(asus, ASUS_WMI_DEVID_GPU_FAN_CURVE, &gpu->custom); ++ if (err) ++ return err; ++ } + -+ return count; ++ return 0; +} + +/* -+ * CPU Fan Curves -+*/ -+ -+static ssize_t cpu_fan_curve_balanced_show(struct device *dev, -+ struct device_attribute *attr, char *buf) ++ * The expected input is 8 sets of number pairs, where "53c30%" temperacture ++ * and fan RPM percentage. The pair can be of the format "T[ c:]P[ %,]". ++ * ++ */ ++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); -+ return scnprintf(buf, PAGE_SIZE, "%s\n", asus->cpu_fan_curve.balanced); -+} -+ -+static ssize_t cpu_fan_curve_balanced_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return fan_curve_store(asus, buf, count, ASUS_WMI_DEVID_CPU_FAN_CURVE, -+ &asus->cpu_fan_curve.balanced, -+ asus->cpu_fan_curve.balanced_default); -+} -+ -+static DEVICE_ATTR_RW(cpu_fan_curve_balanced); -+ -+static ssize_t cpu_fan_curve_performance_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return scnprintf(buf, PAGE_SIZE, "%s\n", asus->cpu_fan_curve.performance); -+} -+ -+static ssize_t cpu_fan_curve_performance_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return fan_curve_store(asus, buf, count, ASUS_WMI_DEVID_CPU_FAN_CURVE, -+ &asus->cpu_fan_curve.performance, -+ asus->cpu_fan_curve.performance_default); -+} -+ -+static DEVICE_ATTR_RW(cpu_fan_curve_performance); -+ -+static ssize_t cpu_fan_curve_quiet_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return scnprintf(buf, PAGE_SIZE, "%s\n", asus->cpu_fan_curve.quiet); -+} ++ u8 temps[NUM_FAN_CURVE_POINTS]; ++ u8 percents[NUM_FAN_CURVE_POINTS]; ++ /* tmp1 and tmp2 exist only to allow matching to succeed */ ++ char *tmp1; ++ char *tmp2; ++ int err; + -+static ssize_t cpu_fan_curve_quiet_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return fan_curve_store(asus, buf, count, ASUS_WMI_DEVID_CPU_FAN_CURVE, -+ &asus->cpu_fan_curve.quiet, -+ asus->cpu_fan_curve.quiet_default); -+} ++ /* index maps to ASUS_THROTTLE_THERMAL_POLICY_DEFAULT */ ++ int nr = to_sensor_dev_attr_2(attr)->nr; ++ /* dev maps to ASUS_WMI_DEVID_[C/G]PU_FAN_CURVE */ ++ int index = to_sensor_dev_attr_2(attr)->index; ++ /* Variable format, values must at least be separated by these */ ++ char part[] = "%d%2[ c:]%d%2[ %%,\n]%n"; ++ u32 prev_percent = 0; ++ u32 prev_temp = 0; ++ u32 percent = 0; ++ u32 temp = 0; ++ int len = 0; ++ int idx = 0; ++ int at = 0; + -+static DEVICE_ATTR_RW(cpu_fan_curve_quiet); ++ struct fan_curve_data *curve = &asus->throttle_fan_curves[nr][index]; + -+/* -+ * GPU Fan Curves -+*/ ++ /* Allow a user to write "" or " " to erase a curve setting */ ++ if (strlen(buf) <= 1 || strcmp(buf, "\n") == 0) { ++ memcpy(&curve->custom, &curve->defaults, NUM_FAN_CURVE_DATA); ++ err = throttle_thermal_policy_write(asus); ++ if (err) ++ return err; ++ return count; ++ } + -+static ssize_t gpu_fan_curve_balanced_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return scnprintf(buf, PAGE_SIZE, "%s\n", asus->gpu_fan_curve.balanced); -+} ++ /* parse the buf */ ++ while (sscanf(&buf[at], part, &temp, &tmp1, &percent, &tmp2, &len) == 4) { ++ if (temp < prev_temp || percent < prev_percent) { ++ pr_info("Fan curve invalid: a value is sequentially lower"); ++ return -EINVAL; ++ } + -+static ssize_t gpu_fan_curve_balanced_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return fan_curve_store(asus, buf, count, ASUS_WMI_DEVID_GPU_FAN_CURVE, -+ &asus->gpu_fan_curve.balanced, -+ asus->gpu_fan_curve.balanced_default); -+} ++ if (percent > 100) { ++ pr_info("Fan curve invalid: percentage > 100"); ++ return -EINVAL; ++ } + -+static DEVICE_ATTR_RW(gpu_fan_curve_balanced); ++ prev_temp = temp; ++ prev_percent = percent; + -+static ssize_t gpu_fan_curve_performance_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return scnprintf(buf, PAGE_SIZE, "%s\n", asus->gpu_fan_curve.performance); -+} ++ temps[idx] = temp; ++ percents[idx] = percent; ++ at += len; ++ idx += 1; ++ } + -+static ssize_t gpu_fan_curve_performance_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return fan_curve_store(asus, buf, count, ASUS_WMI_DEVID_GPU_FAN_CURVE, -+ &asus->gpu_fan_curve.performance, -+ asus->gpu_fan_curve.performance_default); -+} ++ if (idx != NUM_FAN_CURVE_POINTS) { ++ pr_info("Fan curve invalid: incomplete string: %d", idx); ++ return -EINVAL; ++ } + -+static DEVICE_ATTR_RW(gpu_fan_curve_performance); ++ memcpy(&curve->custom.temps, &temps, NUM_FAN_CURVE_POINTS); ++ memcpy(&curve->custom.percents, &percents, NUM_FAN_CURVE_POINTS); + -+static ssize_t gpu_fan_curve_quiet_show(struct device *dev, -+ struct device_attribute *attr, char *buf) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return scnprintf(buf, PAGE_SIZE, "%s\n", asus->gpu_fan_curve.quiet); -+} ++ /* Maybe activate fan curve if in associated mode */ ++ err = throttle_thermal_policy_write(asus); ++ if (err) ++ return err; + -+static ssize_t gpu_fan_curve_quiet_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *buf, size_t count) -+{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); -+ return fan_curve_store(asus, buf, count, ASUS_WMI_DEVID_GPU_FAN_CURVE, -+ &asus->gpu_fan_curve.quiet, -+ asus->gpu_fan_curve.quiet_default); ++ return count; +} + -+static DEVICE_ATTR_RW(gpu_fan_curve_quiet); ++static SENSOR_DEVICE_ATTR_2_RW(cpu_fan_curve_balanced, fan_curve, ++ ASUS_THROTTLE_THERMAL_POLICY_DEFAULT, ++ FAN_DEVICE_CPU); ++static SENSOR_DEVICE_ATTR_2_RW(cpu_fan_curve_performance, fan_curve, ++ ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST, ++ FAN_DEVICE_CPU); ++static SENSOR_DEVICE_ATTR_2_RW(cpu_fan_curve_quiet, fan_curve, ++ ASUS_THROTTLE_THERMAL_POLICY_SILENT, ++ FAN_DEVICE_CPU); ++ ++static SENSOR_DEVICE_ATTR_2_RW(gpu_fan_curve_balanced, fan_curve, ++ ASUS_THROTTLE_THERMAL_POLICY_DEFAULT, ++ FAN_DEVICE_GPU); ++static SENSOR_DEVICE_ATTR_2_RW(gpu_fan_curve_performance, fan_curve, ++ ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST, ++ FAN_DEVICE_GPU); ++static SENSOR_DEVICE_ATTR_2_RW(gpu_fan_curve_quiet, fan_curve, ++ ASUS_THROTTLE_THERMAL_POLICY_SILENT, ++ FAN_DEVICE_GPU); + +/* -+ * Active curves per profile -+*/ -+ -+static int enabled_fan_curve_profiles_check_present(struct asus_wmi *asus) -+{ -+ if (!asus->cpu_fan_curve_available || !asus->gpu_fan_curve_available) -+ return -ENODEV; -+ -+ return 0; -+} -+ ++ * Profiles with enabled fan curve setting ++ */ + +static int enabled_fan_curve_profiles_write(struct asus_wmi *asus, -+ const char *names) ++ const char *names) +{ -+ char *buf, *set, *set_end; -+ int err; ++ char *buf, *set, *set_end; ++ int err, index; + -+ buf = set_end = kstrdup(names, GFP_KERNEL); ++ buf = set_end = kstrdup(names, GFP_KERNEL); + + /* Reset before checking */ -+ asus->enabled_fan_curve_profiles.balanced = false; -+ asus->enabled_fan_curve_profiles.quiet = false; -+ asus->enabled_fan_curve_profiles.performance = false; -+ -+ while( (set = strsep(&set_end, " ")) != NULL ) { -+ if (set == NULL) -+ set = buf; -+ -+ pr_info("SET: %s", set); -+ pr_info("SET: %d", strcmp(set, "quiet")); -+ pr_info("SET: %d", strcmp(set, "quiet\n")); -+ -+ if (strcmp(set, "balanced") == 0 -+ || strcmp(set, "balanced\n") == 0) -+ asus->enabled_fan_curve_profiles.balanced = true; -+ -+ if (strcmp(set, "quiet") == 0 -+ || strcmp(set, "quiet\n") == 0) -+ asus->enabled_fan_curve_profiles.quiet = true; -+ -+ if (strcmp(set, "performance") == 0 -+ || strcmp(set, "performance\n") == 0) -+ asus->enabled_fan_curve_profiles.performance = true; ++ asus->fan_curves_enabled[ASUS_THROTTLE_THERMAL_POLICY_DEFAULT] = false; ++ asus->fan_curves_enabled[ASUS_THROTTLE_THERMAL_POLICY_SILENT] = false; ++ asus->fan_curves_enabled[ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST] = false; ++ ++ while ((set = strsep(&set_end, " ")) != NULL) { ++ index = sysfs_match_string(fan_curve_names, set); ++ if (index >= 0) ++ asus->fan_curves_enabled[index] = true; + } + + err = throttle_thermal_policy_write(asus); @@ -584,19 +489,16 @@ index cc5811844012..1b19894285e6 100644 + struct device_attribute *attr, char *buf) +{ + struct asus_wmi *asus = dev_get_drvdata(dev); -+ int len = 0; -+ -+ if (asus->enabled_fan_curve_profiles.balanced) -+ len += sysfs_emit_at(buf, len, "balanced "); -+ -+ if (asus->enabled_fan_curve_profiles.performance) -+ len += sysfs_emit_at(buf, len, "performance "); ++ int i, len = 0; + -+ if (asus->enabled_fan_curve_profiles.quiet) -+ len += sysfs_emit_at(buf, len, "quiet "); ++ for (i = 0; i < NUM_FAN_CURVE_PROFILES; i++) { ++ if (asus->fan_curves_enabled[i]) { ++ len += sysfs_emit_at(buf, len, fan_curve_names[i]); ++ len += sysfs_emit_at(buf, len, " "); ++ } ++ } + + len += sysfs_emit_at(buf, len, "\n"); -+ + return len; +} + @@ -604,14 +506,14 @@ index cc5811844012..1b19894285e6 100644 + struct device_attribute *attr, + const char *buf, size_t count) +{ -+ struct asus_wmi *asus = dev_get_drvdata(dev); ++ struct asus_wmi *asus = dev_get_drvdata(dev); + int err; + + err = enabled_fan_curve_profiles_write(asus, buf); + if (err) + return err; + -+ return count; ++ return count; +} + +static DEVICE_ATTR_RW(enabled_fan_curve_profiles); @@ -619,154 +521,85 @@ index cc5811844012..1b19894285e6 100644 /* Throttle thermal policy ****************************************************/ static int throttle_thermal_policy_check_present(struct asus_wmi *asus) -@@ -2067,6 +2624,59 @@ static int throttle_thermal_policy_check_present(struct asus_wmi *asus) - return 0; - } - -+static int throttle_thermal_policy_write_cpu_curves(struct asus_wmi *asus) -+{ -+ char *curve = NULL; -+ int err, mode; -+ -+ mode = asus->throttle_thermal_policy_mode; -+ -+ if (mode == ASUS_THROTTLE_THERMAL_POLICY_DEFAULT -+ && asus->enabled_fan_curve_profiles.balanced) { -+ curve = asus->cpu_fan_curve.balanced; -+ } else if (mode == ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST -+ && asus->enabled_fan_curve_profiles.performance) { -+ curve = asus->cpu_fan_curve.performance; -+ } else if (mode == ASUS_THROTTLE_THERMAL_POLICY_SILENT -+ && asus->enabled_fan_curve_profiles.quiet) { -+ curve = asus->cpu_fan_curve.quiet; -+ } -+ -+ if (curve != NULL) { -+ err = fan_curve_write(asus, ASUS_WMI_DEVID_CPU_FAN_CURVE, curve); -+ if (err) -+ return err; -+ } -+ return 0; -+} -+ -+ -+static int throttle_thermal_policy_write_gpu_curves(struct asus_wmi *asus) -+{ -+ char *curve = NULL; -+ int err, mode; -+ -+ mode = asus->throttle_thermal_policy_mode; -+ -+ if (mode == ASUS_THROTTLE_THERMAL_POLICY_DEFAULT -+ && asus->enabled_fan_curve_profiles.balanced) { -+ curve = asus->gpu_fan_curve.balanced; -+ } else if (mode == ASUS_THROTTLE_THERMAL_POLICY_OVERBOOST -+ && asus->enabled_fan_curve_profiles.performance) { -+ curve = asus->gpu_fan_curve.performance; -+ } else if (mode == ASUS_THROTTLE_THERMAL_POLICY_SILENT -+ && asus->enabled_fan_curve_profiles.quiet) { -+ curve = asus->gpu_fan_curve.quiet; -+ } -+ -+ if (curve != NULL) { -+ err = fan_curve_write(asus, ASUS_WMI_DEVID_GPU_FAN_CURVE, curve); -+ if (err) -+ return err; -+ } -+ return 0; -+} -+ - static int throttle_thermal_policy_write(struct asus_wmi *asus) - { - int err; -@@ -2092,6 +2702,26 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus) +@@ -2092,6 +2538,12 @@ static int throttle_thermal_policy_write(struct asus_wmi *asus) return -EIO; } -+ if (asus->cpu_fan_curve_available) { -+ err = throttle_thermal_policy_write_cpu_curves(asus); -+ if (err) { -+ dev_warn(&asus->platform_device->dev, -+ "Failed to set custom CPU curve for thermal policy: %d\n", -+ err); -+ return err; -+ } -+ } -+ -+ if (asus->gpu_fan_curve_available) { -+ err = throttle_thermal_policy_write_gpu_curves(asus); -+ if (err) { -+ dev_warn(&asus->platform_device->dev, -+ "Failed to set custom GPU curve for thermal policy: %d\n", -+ err); ++ if (asus->cpu_fan_curve_available || asus->gpu_fan_curve_available) { ++ err = fan_curve_write_data(asus); ++ if (err) + return err; -+ } + } + return 0; } -@@ -2711,6 +3341,13 @@ static struct attribute *platform_attributes[] = { +@@ -2711,6 +3163,13 @@ static struct attribute *platform_attributes[] = { &dev_attr_als_enable.attr, &dev_attr_fan_boost_mode.attr, &dev_attr_throttle_thermal_policy.attr, -+ &dev_attr_cpu_fan_curve_balanced.attr, -+ &dev_attr_cpu_fan_curve_performance.attr, -+ &dev_attr_cpu_fan_curve_quiet.attr, -+ &dev_attr_gpu_fan_curve_balanced.attr, -+ &dev_attr_gpu_fan_curve_performance.attr, -+ &dev_attr_gpu_fan_curve_quiet.attr, ++ &sensor_dev_attr_cpu_fan_curve_balanced.dev_attr.attr, ++ &sensor_dev_attr_cpu_fan_curve_performance.dev_attr.attr, ++ &sensor_dev_attr_cpu_fan_curve_quiet.dev_attr.attr, ++ &sensor_dev_attr_gpu_fan_curve_balanced.dev_attr.attr, ++ &sensor_dev_attr_gpu_fan_curve_performance.dev_attr.attr, ++ &sensor_dev_attr_gpu_fan_curve_quiet.dev_attr.attr, + &dev_attr_enabled_fan_curve_profiles.attr, &dev_attr_panel_od.attr, NULL }; -@@ -2741,6 +3378,20 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, +@@ -2741,6 +3200,20 @@ 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_cpu_fan_curve_balanced.attr) ++ else if (attr == &sensor_dev_attr_cpu_fan_curve_balanced.dev_attr.attr) + ok = asus->cpu_fan_curve_available; -+ else if (attr == &dev_attr_cpu_fan_curve_performance.attr) ++ else if (attr == &sensor_dev_attr_cpu_fan_curve_performance.dev_attr.attr) + ok = asus->cpu_fan_curve_available; -+ else if (attr == &dev_attr_cpu_fan_curve_quiet.attr) ++ else if (attr == &sensor_dev_attr_cpu_fan_curve_quiet.dev_attr.attr) + ok = asus->cpu_fan_curve_available; -+ else if (attr == &dev_attr_gpu_fan_curve_balanced.attr) ++ else if (attr == &sensor_dev_attr_gpu_fan_curve_balanced.dev_attr.attr) + ok = asus->gpu_fan_curve_available; -+ else if (attr == &dev_attr_gpu_fan_curve_performance.attr) ++ else if (attr == &sensor_dev_attr_gpu_fan_curve_performance.dev_attr.attr) + ok = asus->gpu_fan_curve_available; -+ else if (attr == &dev_attr_gpu_fan_curve_quiet.attr) ++ else if (attr == &sensor_dev_attr_gpu_fan_curve_quiet.dev_attr.attr) + ok = asus->gpu_fan_curve_available; + else if (attr == &dev_attr_enabled_fan_curve_profiles.attr) + ok = asus->cpu_fan_curve_available || asus->gpu_fan_curve_available; else if (attr == &dev_attr_panel_od.attr) ok = asus->panel_overdrive_available; -@@ -3016,6 +3667,20 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -2904,7 +3377,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, +@@ -3016,6 +3489,16 @@ static int asus_wmi_add(struct platform_device *pdev) else throttle_thermal_policy_set_default(asus); + err = custom_fan_check_present(asus, &asus->cpu_fan_curve_available, + ASUS_WMI_DEVID_CPU_FAN_CURVE); + if (err) -+ goto fail_throttle_fan_curve; ++ goto fail_custom_fan_curve; + -+ err = custom_fan_check_present(asus, &asus->gpu_fan_curve_available, ++ err = custom_fan_check_present(asus, &asus->gpu_fan_curve_available, + ASUS_WMI_DEVID_GPU_FAN_CURVE); + if (err) -+ goto fail_throttle_fan_curve; -+ -+ err = enabled_fan_curve_profiles_check_present(asus); -+ if (err) -+ goto fail_throttle_fan_curve; ++ goto fail_custom_fan_curve; + err = platform_profile_setup(asus); if (err) goto fail_platform_profile_setup; -@@ -3109,6 +3774,7 @@ static int asus_wmi_add(struct platform_device *pdev) +@@ -3109,6 +3592,7 @@ static int asus_wmi_add(struct platform_device *pdev) asus_wmi_sysfs_exit(asus->platform_device); fail_sysfs: fail_throttle_thermal_policy: -+fail_throttle_fan_curve: ++fail_custom_fan_curve: fail_platform_profile_setup: if (asus->platform_profile_support) platform_profile_remove(); diff --git a/sys-kernel_arch-sources-g14_files-9001-v5.13.2-s0ix-patch-2021-08-05.patch b/sys-kernel_arch-sources-g14_files-9001-v5.13.13-s0ix-patch-2021-08-28.patch index 58dc9e11a0e6..6c44b9da37a4 100644 --- a/sys-kernel_arch-sources-g14_files-9001-v5.13.2-s0ix-patch-2021-08-05.patch +++ b/sys-kernel_arch-sources-g14_files-9001-v5.13.13-s0ix-patch-2021-08-28.patch @@ -1,11 +1,32 @@ -From 6c661da8add5168cee3b745594d66173189bc8a2 Mon Sep 17 00:00:00 2001 +From e0bda89bd4057c851932c59ddb5bd3890005214f Mon Sep 17 00:00:00 2001 From: Scott B <28817345+foundObjects@users.noreply.github.com> -Date: Thu, 5 Aug 2021 02:39:45 -0700 -Subject: [PATCH] v5.13.8 s0ix patch 2021-08-05 +Date: Tue, 24 Aug 2021 21:21:09 -0700 +Subject: [PATCH] v5.13.13-s0ix patch 2021-08-24 Squashed commit of the following: -commit 8f506eaa976e148acdc856704a655659cadd279e +commit 3ba8d2ed7f58ddf970dfe2bc1bfb93b9b3d66190 +Author: Mario Limonciello <mario.limonciello@amd.com> +Date: Mon Aug 9 20:40:04 2021 -0500 + + ACPI: PM: s2idle: Invert Microsoft UUID entry and exit + + It was reported by a user with a Dell m15 R5 (5800H) that + the keyboard backlight was turning on when entering suspend + and turning off when exiting (the opposite of how it should be). + + The user bisected it back to commit 5dbf50997578 ("ACPI: PM: + s2idle: Add support for new Microsoft UUID"). Previous to that + commit the LEDs didn't turn off at all. Confirming in the spec, + these were reversed when introduced. + + Fix them to match the spec. + + BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1230#note_1021836 + Fixes: 5dbf50997578 ("ACPI: PM: s2idle: Add support for new Microsoft UUID") + Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> + +commit 606229f0125a3af622a407797ca94fade1ea1993 Author: Mario Limonciello <mario.limonciello@amd.com> Date: Wed Jul 7 09:16:47 2021 -0500 @@ -19,7 +40,7 @@ Date: Wed Jul 7 09:16:47 2021 -0500 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> -commit fd065a1e8ee224a0c550662f3812e987c6d21fa6 +commit a1c785973ae351de6448f88b7c19dd26b8f70540 Author: Mario Limonciello <mario.limonciello@amd.com> Date: Wed Jun 30 14:46:06 2021 -0500 @@ -60,7 +81,7 @@ Date: Wed Jun 30 14:46:06 2021 -0500 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> -commit cd38229157b4ed96831763fed09a2ef1d67466b2 +commit 0f7dadec802150229cc8e6c74e0e7b3b2e53a9fd Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: Tue Jun 29 14:18:03 2021 +0530 @@ -72,7 +93,7 @@ Date: Tue Jun 29 14:18:03 2021 +0530 Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> -commit 6cbf4ca877f9a7763eb7ceaec82884f7542b8584 +commit e787353c8c9ff51b8cf23cb68f31aa44fea6a4b8 Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: Tue Jun 29 14:18:02 2021 +0530 @@ -84,7 +105,7 @@ Date: Tue Jun 29 14:18:02 2021 +0530 Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> -commit b08043dc2dc982e77f2a620f6ac64dcc77085796 +commit 7e46535ba2b3eb3a91ada3241208429f01b5811c Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: Tue Jun 29 14:18:01 2021 +0530 @@ -104,7 +125,7 @@ Date: Tue Jun 29 14:18:01 2021 +0530 Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> -commit abfb68f228563b457a9f7f2c8db8f9946f1c082d +commit d9ddd835b8c990895bad75cdc46bf376b0e5a96d Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: Tue Jun 29 14:18:00 2021 +0530 @@ -123,7 +144,7 @@ Date: Tue Jun 29 14:18:00 2021 +0530 Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> -commit df0f8a8e29ae2d10f34d0f1ba879cd6df0004871 +commit b5849744bf0f7fba2b498511681447b9a0eb1d1b Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Date: Tue Jun 29 14:17:59 2021 +0530 @@ -135,18 +156,7 @@ Date: Tue Jun 29 14:17:59 2021 +0530 Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> -commit 0dd5c53f0d5b1a07b0473562a6be34005eb852a2 -Author: Marcin Bachry <hegel666@gmail.com> -Date: Tue Mar 16 15:28:51 2021 -0400 - - PCI: quirks: Quirk PCI d3hot delay for AMD xhci - - Renoir needs a similar delay. - - Signed-off-by: Marcin Bachry <hegel666@gmail.com> - Signed-off-by: Alex Deucher <alexander.deucher@amd.com> - -commit df67da22f52dcde4ca3bba9609f9605565b3cfaf +commit 58fdac16c271d4695a627751a4dbea899101d0ea Author: Mario Limonciello <mario.limonciello@amd.com> Date: Thu Jun 17 11:42:12 2021 -0500 @@ -162,7 +172,7 @@ Date: Thu Jun 17 11:42:12 2021 -0500 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> -commit c53aff424e31bcb6706d6c7b8a6c06f0bca05a19 +commit 36b57e1cf35997a22cb01f1832729a8f833ad6c8 Author: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> Date: Thu Jun 17 11:42:11 2021 -0500 @@ -176,7 +186,7 @@ Date: Thu Jun 17 11:42:11 2021 -0500 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> -commit 2019bfd57b6fe44cae0d356f54b948bfd707fa97 +commit c4d632cf2df5bc7e2d8dccd8de8d3984e59f8e40 Author: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> Date: Thu Jun 17 11:42:10 2021 -0500 @@ -187,7 +197,7 @@ Date: Thu Jun 17 11:42:10 2021 -0500 Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> -commit d9c8d6d7d178fbfedddc1d1a9f27d189cb8a4df9 +commit 8ab790396d0bd01b73755cedb3873ea60f7327dd Author: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> Date: Thu Jun 17 11:42:09 2021 -0500 @@ -205,7 +215,7 @@ Date: Thu Jun 17 11:42:09 2021 -0500 Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> -commit 9f339765df127c0973766c4c282aab07999292a8 +commit 18da9bb5a1742a867963541c171e55d290c86868 Author: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> Date: Thu Jun 17 11:42:08 2021 -0500 @@ -216,7 +226,7 @@ Date: Thu Jun 17 11:42:08 2021 -0500 Signed-off-by: Pratik Vishwakarma <Pratik.Vishwakarma@amd.com> -commit 6e853c597c7786939ea18e03e161d4b098a5201c +commit 4e4c8f117e567a8c97d4d94c7f813285beb38d53 Author: Mario Limonciello <mario.limonciello@amd.com> Date: Wed Jun 9 13:40:18 2021 -0500 @@ -263,7 +273,7 @@ Date: Wed Jun 9 13:40:18 2021 -0500 Tested-by: Julian Sikorski <belegdol@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> -commit fd82413988169aa648d1507298b925f73e5b0ce4 +commit b8914e70b7a47a61430a6372f41912991f71e2eb Author: Mario Limonciello <mario.limonciello@amd.com> Date: Wed Jun 9 13:40:17 2021 -0500 @@ -290,10 +300,9 @@ Date: Wed Jun 9 13:40:17 2021 -0500 drivers/acpi/x86/s2idle.c | 157 +++++++++++++++++-------- drivers/acpi/x86/utils.c | 25 ++++ drivers/nvme/host/pci.c | 28 +---- - drivers/pci/quirks.c | 3 + drivers/platform/x86/amd-pmc.c | 204 ++++++++++++++++++++++++++++++--- include/linux/acpi.h | 5 + - 8 files changed, 372 insertions(+), 91 deletions(-) + 7 files changed, 369 insertions(+), 91 deletions(-) diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 9d2d3b9bb8b5..0cfdef2fc3ad 100644 @@ -357,7 +366,7 @@ index e21611c9a170..7ac01b03ba67 100644 Device properties -------------------------------------------------------------------------- */ diff --git a/drivers/acpi/x86/s2idle.c b/drivers/acpi/x86/s2idle.c -index 2d7ddb8a8cb6..1c507804fb10 100644 +index 2d7ddb8a8cb6..b16c245bbe5b 100644 --- a/drivers/acpi/x86/s2idle.c +++ b/drivers/acpi/x86/s2idle.c @@ -32,6 +32,9 @@ static const struct acpi_device_id lps0_device_ids[] = { @@ -567,7 +576,7 @@ index 2d7ddb8a8cb6..1c507804fb10 100644 + 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); -+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, ++ 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); @@ -596,7 +605,7 @@ index 2d7ddb8a8cb6..1c507804fb10 100644 + if (lps0_dsm_func_mask_microsoft > 0) { + acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT, + lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); -+ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_ENTRY, ++ acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT, + lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); + acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON, + lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft); @@ -694,20 +703,6 @@ index d963f25fc7ae..66455e2261d0 100644 /* * Some systems use a bios work around to ask for D3 on * platforms that support kernel managed suspend. -diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c -index 6d74386eadc2..446f8f7b0ee4 100644 ---- a/drivers/pci/quirks.c -+++ b/drivers/pci/quirks.c -@@ -1900,6 +1900,9 @@ static void quirk_ryzen_xhci_d3hot(struct pci_dev *dev) - } - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e0, quirk_ryzen_xhci_d3hot); - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x15e1, quirk_ryzen_xhci_d3hot); -+/* Renoir XHCI requires longer delay when transitioning from D0 to -+ * D3hot */ -+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, 0x1639, quirk_ryzen_xhci_d3hot); - - #ifdef CONFIG_X86_IO_APIC - static int dmi_disable_ioapicreroute(const struct dmi_system_id *d) diff --git a/drivers/platform/x86/amd-pmc.c b/drivers/platform/x86/amd-pmc.c index ca95c2a52e26..663a4ca0580d 100644 --- a/drivers/platform/x86/amd-pmc.c @@ -1082,4 +1077,5 @@ index c60745f657e9..dd0dafd21e33 100644 #if defined(CONFIG_ACPI) && defined(CONFIG_PM_SLEEP) -- -2.32.0 +2.33.0 + diff --git a/sys-kernel_arch-sources-g14_files-9002-amd-pmc-delay-test.patch b/sys-kernel_arch-sources-g14_files-9002-amd-pmc-delay-test.patch new file mode 100644 index 000000000000..5c1d59cc0ddf --- /dev/null +++ b/sys-kernel_arch-sources-g14_files-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 + |