From 9a42bf462e0ff08699a72ff6316bd3dab9707b91 Mon Sep 17 00:00:00 2001 From: David Barbion Date: Sat, 1 May 2021 23:59:01 +0200 Subject: [PATCH] fix: backport fan_speed for pwm-fan hwmon kernel module This patch brings back the fan_speed file which can be used to set or read fan speeds setting. The /sys file contains for integer for setting fan speed depending thermal CPU/GPU condition. related to #1662 --- CHANGELOG.md | 3 + RELEASE-NOTES.md | 7 ++ TESTING.md | 4 + .../5.4/0002-cpu-fan-speed.patch | 77 +++++++++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 board/recalbox/odroidxu4/kernel_patches/5.4/0002-cpu-fan-speed.patch diff --git a/CHANGELOG.md b/CHANGELOG.md index 77e226e401..b44e942084 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Change Log All notable changes to this project will be documented in this file. +## [NEXT] +- Bring back fan speed setting on odroidxu4 (#1662) + ## [7.2.1-Reloaded] - Fix arcade view systems missing model3, atomiswave, naomi, naomigd, daphné - Fix video lag on ppsspp diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index e9ac0cee46..d1f934c727 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,11 @@ # Release notes +## Next + +### Fixes +- Bring back fan speed setting on Odroid XU4 + + ## 7.2.1-Reloaded ### Fixes @@ -34,6 +40,7 @@ - Force volume of all outputs to 100% - Fix crash when running a game from the search window + ## 7.2-Reloaded ### News diff --git a/TESTING.md b/TESTING.md index 0f34c4f890..39ba58bae8 100644 --- a/TESTING.md +++ b/TESTING.md @@ -11,6 +11,10 @@ Toutes les cases doivent être cochées avant la release stable. Pour les pending features, elles ne seront activées que si les beta testeurs les valident selon les critères de qualité de Recalbox. +## [NEXT] +- [ ] Test odroidxu4 fan speeds are set on boot (#1662) +- + ## [7.2.1-Reloaded] - [ ] Run any game on PPSSPP rpi4 and check is vsync is on. - [ ] Run games from the search window when its video snap is playing. Should not crash anymore. diff --git a/board/recalbox/odroidxu4/kernel_patches/5.4/0002-cpu-fan-speed.patch b/board/recalbox/odroidxu4/kernel_patches/5.4/0002-cpu-fan-speed.patch new file mode 100644 index 0000000000..6845ef0826 --- /dev/null +++ b/board/recalbox/odroidxu4/kernel_patches/5.4/0002-cpu-fan-speed.patch @@ -0,0 +1,77 @@ +--- linux-e6c0e203b790f6e703395db0234ec340696817f3/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi 2021-05-01 22:38:02.471156092 +0200 ++++ linux-e6c0e203b790f6e703395db0234ec340696817f3/arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi 2021-05-01 22:39:01.510598743 +0200 +@@ -65,6 +65,8 @@ + fan0: pwm-fan { + compatible = "pwm-fan"; + pwms = <&pwm 0 20972 0>; ++ cooling-min-state = <0>; ++ cooling-max-state = <3>; + #cooling-cells = <2>; + cooling-levels = <0 120 180 240>; + }; +--- linux-e6c0e203b790f6e703395db0234ec340696817f3/drivers/hwmon/pwm-fan.c 2021-05-01 23:33:24.787785425 +0200 ++++ linux-e6c0e203b790f6e703395db0234ec340696817f3/drivers/hwmon/pwm-fan.c 2021-05-01 23:40:23.749411368 +0200 +@@ -129,6 +129,49 @@ + return sprintf(buf, "%u\n", ctx->pwm_value); + } + ++static ssize_t set_fan_speed(struct device *dev, struct device_attribute *attr, ++ const char *buf, size_t count) ++{ ++ struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); ++ unsigned int speed_0, speed_1, speed_2, speed_3; ++ ++ if(sscanf(buf, "%u %u %u %u\n", &speed_0, &speed_1, &speed_2, &speed_3) != 4) { ++ dev_err(dev, "invalid speed input"); ++ return -EINVAL; ++ } ++ ++ if(!(speed_0 < speed_1 && speed_1 < speed_2 && speed_2 < speed_3)){ ++ dev_err(dev, "fan speeds must be increasing in value"); ++ return count; ++ } ++ ++ dev_info(dev, "fan_speeds : %s [%d %d %d %d] \n", ++ __func__, speed_0, speed_1, speed_2, speed_3); ++ ++ mutex_lock(&ctx->lock); ++ ctx->pwm_fan_cooling_levels[0] = speed_0; ++ ctx->pwm_fan_cooling_levels[1] = speed_1; ++ ctx->pwm_fan_cooling_levels[2] = speed_2; ++ ctx->pwm_fan_cooling_levels[3] = speed_3; ++ mutex_unlock(&ctx->lock); ++ ++ return count; ++} ++ ++static ssize_t show_fan_speed(struct device *dev, struct device_attribute *attr, ++ char *buf) ++{ ++ struct pwm_fan_ctx *ctx = dev_get_drvdata(dev); ++ int lenght = 0, i; ++ ++ mutex_lock(&ctx->lock); ++ for (i = 0; i <= ctx->pwm_fan_max_state; i++) ++ lenght += sprintf(buf+lenght, "%u ", ctx->pwm_fan_cooling_levels[i]); ++ mutex_unlock(&ctx->lock); ++ ++ return lenght; ++} ++ + static ssize_t rpm_show(struct device *dev, + struct device_attribute *attr, char *buf) + { +@@ -139,10 +182,13 @@ + + static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); + static SENSOR_DEVICE_ATTR_RO(fan1_input, rpm, 0); ++static SENSOR_DEVICE_ATTR(fan_speed, S_IRUGO | S_IWUSR, show_fan_speed, ++ set_fan_speed, 0); + + static struct attribute *pwm_fan_attrs[] = { + &sensor_dev_attr_pwm1.dev_attr.attr, + &sensor_dev_attr_fan1_input.dev_attr.attr, ++ &sensor_dev_attr_fan_speed.dev_attr.attr, + NULL, + }; + -- GitLab