Skip to contentSkip to conversation

ACPI / fan: Properly handle fine grain control

PATCH Superseded Srinivas Pandruvada 2 participants 3 messages Jan 13, 2022 – Jan 14, 2022

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI / fan: Properly handle fine grain control

When _FIF object specifies support for fine grain control, then fan speed can be set from 0 to 100% with the recommended minimum "step size" via _FSL object. Here the control value doesn't need to match any value from _FPS object.

Currently we have a simple solution implemented which just pick maximum control value from _FPS to display the actual state, but this is not optimal when there is a big window between two control values in _FPS. Also there is no way to set to any speed which doesn't match control values in _FPS. The system firmware can start the fan at speed which doesn't match any control value.

To support fine grain control via thermal sysfs:
- cooling device max state is not _FPS state count but it will be 100 / _FIF.step_size
- cooling device current state is 100 / _FIF.step_size
- cooling device set state will set the control value curr_state * _FIF.step_size plus any adjustment for 100%. By the spec, when control value do not sum to 100% because of _FIF.step_size, OSPM may select an appropriate ending Level increment to reach 100%.

Also publish the actual fan rpm in sysfs in the same place where _FIF objects are displayed. Knowing fan rpm is helpful to reduce noise level and use passive control instead. Also fan performance may not be same over time, so the same control value may not be enough to run the fan at a speed. So a feedback value of speed is helpful. This sysfs attribute is called "fan_speed_rpm".

---
This is not a urgent patch for the current merge cycle.

 .../acpi/fan_performance_states.rst           |  10 ++
 drivers/acpi/fan.c                            | 137 ++++++++++++++----
 2 files changed, 122 insertions(+), 25 deletions(-)
Documentation/admin-guide/acpi/fan_performance_states.rst +10 -0
index 98fe5c333121..2a5988d747e5 100644
@@ -60,3 +60,13 @@ For example::
 
 When a given field is not populated or its value provided by the platform
 firmware is invalid, the "not-defined" string is shown instead of the value.
+
+ACPI Fan Performance Feedback
+=============================
+
+The optional _FST object provides status information for the fan device.
+This includes field to provide current fan speed in revolutions per minute
+at which the fan is rotating.
+
+This speed is presented in the sysfs using the attribute "fan_speed_rpm",
+in the same directory as performance states.
drivers/acpi/fan.c +112 -25

222 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw
I love your patch! Yet something to improve:

Hi Srinivas,

I love your patch! Yet something to improve:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linux/master linus/master v5.16 next-20220114] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Srinivas-Pandruvada/ACPI-fan-Properly-handle-fine-grain-control/20220114-064818
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: i386-randconfig-a003 (https://download.01.org/0day-ci/archive/20220114/202201141519.esDIoL2I-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/f30ef71d0435cd8735ee418eeb0bfc71a58a4554
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Srinivas-Pandruvada/ACPI-fan-Properly-handle-fine-grain-control/20220114-064818 git checkout f30ef71d0435cd8735ee418eeb0bfc71a58a4554
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

ld: drivers/acpi/fan.o: in function `fan_get_max_state':

>> drivers/acpi/fan.c:100: undefined reference to `__udivdi3'

ld: drivers/acpi/fan.o: in function `fan_set_state_acpi4':
drivers/acpi/fan.c:222: undefined reference to `__udivdi3'
ld: drivers/acpi/fan.o: in function `fan_get_state_acpi4':
drivers/acpi/fan.c:160: undefined reference to `__udivdi3'

vim +100 drivers/acpi/fan.c

    91	
    92	/* thermal cooling device callbacks */
    93	static int fan_get_max_state(struct thermal_cooling_device *cdev, unsigned long
    94				     *state)
    95	{
    96		struct acpi_device *device = cdev->devdata;
    97		struct acpi_fan *fan = acpi_driver_data(device);
    98	
    99		if (fan->fif.fine_grain_ctrl)
 > 100			*state = 100 / fan->fif.step_size;

101 else if (fan->acpi4)
102 *state = fan->fps_count - 1;
103 else
104 *state = 1;
105
106 return 0;
107 }
108

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to Srinivas Pandruvada
I love your patch! Yet something to improve:

Hi Srinivas,

I love your patch! Yet something to improve:

[auto build test ERROR on rafael-pm/linux-next]
[also build test ERROR on linux/master linus/master v5.16 next-20220114] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Srinivas-Pandruvada/ACPI-fan-Properly-handle-fine-grain-control/20220114-064818
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: i386-defconfig (https://download.01.org/0day-ci/archive/20220114/202201141638.lm8dtLqR-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

reproduce (this is a W=1 build):
# https://github.com/0day-ci/linux/commit/f30ef71d0435cd8735ee418eeb0bfc71a58a4554
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Srinivas-Pandruvada/ACPI-fan-Properly-handle-fine-grain-control/20220114-064818 git checkout f30ef71d0435cd8735ee418eeb0bfc71a58a4554
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

ld: drivers/acpi/fan.o: in function `fan_get_max_state':

>> fan.c:(.text+0x28): undefined reference to `__udivdi3'

ld: drivers/acpi/fan.o: in function `fan_set_cur_state':
fan.c:(.text+0x18e): undefined reference to `__udivdi3'
ld: drivers/acpi/fan.o: in function `fan_get_cur_state':
fan.c:(.text+0x3d5): undefined reference to `__udivdi3'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org