Race condition between upowerd and kernel module managing keyboard brightness
Submitted by Carlo Caione
Assigned to Richard Hughes @hughsient
Link to original bug (#101244)
Description
The problem I see is that sometimes I'm unable to change the keyboard brightness acting on the media keys because gnome-settings-daemon complains with:
gsd_power_backlight_abs_to_percentage: assertion 'max > min' failed
of course the value of the current and maximum brightness is correctly set in the sysfs entry and I'm able also to change the brightness acting directly on the sysfs attribute.
I traced back the cause of this problem to a race condition between upowerd and the loading of the kernel module managing the keyboard brightness.
On my setup the keyboard brightness is managed by the hid_asus module. This module creates the sysfs attributes when probed. Since the module is not included in the initramfs, sometimes upowerd is loaded before the module kernel is actually probed. When this happens since the sysfs entry is not present yet, upower thinks that there is no led device and among other things the value of max_brightness is not updated and keeps being 0.
At a later time the 'hid_asus' module is loaded and the sysfs entry is created. When now I act on the media buttons to change the keyboard brightness the signal is correctly intercepted by gnome-settings-daemon but manager->priv->kbd_brightness_max is 0, hitting the assertion.
Of course if I kill and restart upower everything starts working fine again.