lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240115122315.10250-1-mechakotik@gmail.com>
Date: Mon, 15 Jan 2024 15:22:17 +0300
From: Andrei Sabalenka <mechakotik@...il.com>
To: corentin.chary@...il.com,
	hdegoede@...hat.com,
	ilpo.jarvinen@...ux.intel.com,
	acpi4asus-user@...ts.sourceforge.net,
	platform-driver-x86@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	mechakotik@...il.com
Subject: [PATCH] platform/x86: asus-wmi: Re-enable custom fan curves after setting throttle_thermal_policy

When changing throttle_thermal_policy, all the custom fan curves are getting disabled. This patch re-enables all the custom fan curves that were enabled before changing throttle_thermal_policy.

I believe it makes asus-wmi sysfs interface more convenient, as it allows userspace to manage fan curves independently from platform_profile and throttle_thermal_policy. At the kernel level, custom fan curves should not be tied to "power profiles" scheme in any way, as it gives the user less freedom of controlling them.

Signed-off-by: Andrei Sabalenka <mechakotik@...il.com>
---
 drivers/platform/x86/asus-wmi.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 18be35fdb..c2e38f6d8 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3441,13 +3441,28 @@ 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[FAN_CURVE_DEV_CPU].enabled = false;
-	if (asus->gpu_fan_curve_available)
-		asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled = false;
-	if (asus->mid_fan_curve_available)
-		asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled = false;
+	/* Re-enable fan curves after profile change */
+	if (asus->cpu_fan_curve_available && asus->custom_fan_curves[FAN_CURVE_DEV_CPU].enabled) {
+		err = fan_curve_write(asus, &asus->custom_fan_curves[FAN_CURVE_DEV_CPU]);
+		if (err) {
+			pr_warn("Failed to re-enable CPU fan curve: %d\n", err);
+			return err;
+		}
+	}
+	if (asus->gpu_fan_curve_available && asus->custom_fan_curves[FAN_CURVE_DEV_GPU].enabled) {
+		err = fan_curve_write(asus, &asus->custom_fan_curves[FAN_CURVE_DEV_GPU]);
+		if (err) {
+			pr_warn("Failed to re-enable GPU fan curve: %d\n", err);
+			return err;
+		}
+	}
+	if (asus->mid_fan_curve_available && asus->custom_fan_curves[FAN_CURVE_DEV_MID].enabled) {
+		err = fan_curve_write(asus, &asus->custom_fan_curves[FAN_CURVE_DEV_MID]);
+		if (err) {
+			pr_warn("Failed to re-enable MID fan curve: %d\n", err);
+			return err;
+		}
+	}
 
 	return 0;
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ