Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ACPI / fan: Fix error reading cur_state

On some platforms with ACPI4 variable speed fan, reading cur_state from
cooling device returns "invalid value" error. This confuses user space
applications.

This issue occurs as the current driver doesn't take account of
"FineGrainControl" from _FIF(Fan Information). When the "FineGrainControl"
is set, _FSL(FSL Set Level) takes argument as a percent, which doesn't
have to match from any control value from _FPS(Fan Performance States).
It is also possible that the Fan is not actually running at the requested
speed returning a lower speed.
On some platforms the BIOS is setting fan speed to a level during boot,
which will not have an exact match to _FPS control values. The current
implementation will treat this level as invalid value.

The simple change is to atleast return state corresponding to a maximum
control value in the _FPS compared to the current level.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Srinivas Pandruvada and committed by
Rafael J. Wysocki
84baf172 c8d2bc9b

+11 -1
+11 -1
drivers/acpi/fan.c
··· 129 129 130 130 control = obj->package.elements[1].integer.value; 131 131 for (i = 0; i < fan->fps_count; i++) { 132 - if (control == fan->fps[i].control) 132 + /* 133 + * When Fine Grain Control is set, return the state 134 + * corresponding to maximum fan->fps[i].control 135 + * value compared to the current speed. Here the 136 + * fan->fps[] is sorted array with increasing speed. 137 + */ 138 + if (fan->fif.fine_grain_ctrl && control < fan->fps[i].control) { 139 + i = (i > 0) ? i - 1 : 0; 133 140 break; 141 + } else if (control == fan->fps[i].control) { 142 + break; 143 + } 134 144 } 135 145 if (i == fan->fps_count) { 136 146 dev_dbg(&device->dev, "Invalid control value returned\n");