OSDN Git Service

ACPI: SBS: Fix handling of Smart Battery Selectors
authorArmin Wolf <W_Armin@gmx.de>
Fri, 24 Mar 2023 20:26:28 +0000 (21:26 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 30 Mar 2023 17:01:05 +0000 (19:01 +0200)
commit3bd554e03ef412438b42862cb088ddc4e2a2561b
treee1fcda5c8f62dbbd24f89418f16caf9c3f5758bc
parente5b492c6bb900fcf9722e05f4a10924410e170c1
ACPI: SBS: Fix handling of Smart Battery Selectors

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: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/sbs.c