• Armin Wolf's avatar
    ACPI: SBS: Fix handling of Smart Battery Selectors · 3bd554e0
    Armin Wolf authored
    The "Smart Battery Selector" standard says that when writing
    SelectorState (0x1), the nibbles which should not be modified
    need to be masked with 0xff. This is necessary since in contrast
    to a "Smart Battery Manager", the last three nibbles are writable.
    
    Failing to do so might trigger the following cycle:
    1. Host accidentally changes power source of the system (3rd nibble)
       when selecting a battery.
    2. Power source is invalid, Selector changes to another power source.
    3. Selector notifies host that it changed the power source.
    4. Host re-reads some batteries.
    5. goto 1 for each re-read battery.
    
    This loop might also be entered when a battery which is not present
    is selected for SMBus access. In the end some workqueues fill up,
    which causes the system to lockup upon suspend/shutdown.
    
    Fix this by correctly masking the value to be written, and avoid
    selecting batteries which are absent.
    
    Tested on a Acer Travelmate 4002WLMi.
    Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    3bd554e0
sbs.c 19.1 KB