Skip to content

Commit 1af89de

Browse files
committed
thermal: core: Do not fail cdev registration because of invalid initial state
It is reported that commit 31a0fa0 ("thermal/debugfs: Pass cooling device state to thermal_debug_cdev_add()") causes the ACPI fan driver to fail probing on some systems which turns out to be due to the _FST control method returning an invalid value until _FSL is first evaluated for the given fan. If this happens, the .get_cur_state() cooling device callback returns an error and __thermal_cooling_device_register() fails as uses that callback after commit 31a0fa0. Arguably, _FST should not return an invalid value even if it is evaluated before _FSL, so this may be regarded as a platform firmware issue, but at the same time it is not a good enough reason for failing the cooling device registration where the initial cooling device state is only needed to initialize a thermal debug facility. Accordingly, modify __thermal_cooling_device_register() to avoid calling thermal_debug_cdev_add() instead of returning an error if the initial .get_cur_state() callback invocation fails. Fixes: 31a0fa0 ("thermal/debugfs: Pass cooling device state to thermal_debug_cdev_add()") Closes: https://lore.kernel.org/linux-acpi/[email protected] Reported-by: Laura Nao <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]> Acked-by: Daniel Lezcano <[email protected]> Tested-by: Laura Nao <[email protected]>
1 parent ae2170d commit 1af89de

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/thermal/thermal_core.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,9 +999,17 @@ __thermal_cooling_device_register(struct device_node *np,
999999
if (ret)
10001000
goto out_cdev_type;
10011001

1002+
/*
1003+
* The cooling device's current state is only needed for debug
1004+
* initialization below, so a failure to get it does not cause
1005+
* the entire cooling device initialization to fail. However,
1006+
* the debug will not work for the device if its initial state
1007+
* cannot be determined and drivers are responsible for ensuring
1008+
* that this will not happen.
1009+
*/
10021010
ret = cdev->ops->get_cur_state(cdev, &current_state);
10031011
if (ret)
1004-
goto out_cdev_type;
1012+
current_state = ULONG_MAX;
10051013

10061014
thermal_cooling_device_setup_sysfs(cdev);
10071015

@@ -1016,7 +1024,8 @@ __thermal_cooling_device_register(struct device_node *np,
10161024
return ERR_PTR(ret);
10171025
}
10181026

1019-
thermal_debug_cdev_add(cdev, current_state);
1027+
if (current_state <= cdev->max_state)
1028+
thermal_debug_cdev_add(cdev, current_state);
10201029

10211030
/* Add 'this' new cdev to the global cdev list */
10221031
mutex_lock(&thermal_list_lock);

0 commit comments

Comments
 (0)