Re: [PATCH] ACPI: battery: Handle a negated 16-bit discharge rate
From: Rafael J. Wysocki (Intel)
Date: Fri Nov 20 2026 - 08:32:43 EST
On Sat, Nov 14, 2026 at 11:08 PM Ana Veto <green.koala2979@xxxxxxxxxxxx> wrote:
>
> On the MSI Claw 8 EX AI+ (MS-1T91, BIOS E1T91IMS.10D), _BST reports the
> discharge rate as 0xffff03a6 while 934 mA flow. The DSDT reads the EC's
> signed 16-bit current (0xfc5a, -934 mA) zero-extended, negates it with
> "~Local1 + 1" and does not mask the result to 16 bits. The magnitude is
> left in the low 16 bits (0x03a6) and the upper bits are set, so the
> int rate_now is negative (-64602).
>
> The existing quirk checks only the sign of the low 16 bits, which are
> positive here, so the value passes through: current_now reads about
> -64.6 A while discharging, battery overlays compute about 1055 W from
> it, and upower shows no energy rate and no time to empty.
>
> Also take abs((s16)rate_now) when rate_now as a whole is negative.
>
> Tested on the device with a v7.3.3-based kernel: current_now reads
> 624000 uA at 14668000 uV while discharging (9.2 W), and battery overlays
> show a normal wattage.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Ana Veto <green.koala2979@xxxxxxxxxxxx>
> ---
> drivers/acpi/battery.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index 43a7543..45a4db5 100644
> --- a/drivers/acpi/battery.c
> +++ b/drivers/acpi/battery.c
> @@ -703,11 +703,13 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
>
> /* For buggy DSDTs that report negative 16-bit values for either
> * charging or discharging current and/or report 0 as 65536
> - * due to bad math.
> + * due to bad math, or that negate the zero-extended 16-bit value
> + * (0xfc5a becomes 0xffff03a6), which leaves the magnitude in the
> + * low 16 bits and makes the rate negative.
> */
> if (battery->power_unit == ACPI_BATTERY_POWER_UNIT_MA &&
> battery->rate_now != ACPI_BATTERY_VALUE_UNKNOWN &&
> - (s16)(battery->rate_now) < 0) {
> + ((s16)(battery->rate_now) < 0 || battery->rate_now < 0)) {
> battery->rate_now = abs((s16)battery->rate_now);
> pr_warn_once(FW_BUG "(dis)charge rate invalid.\n");
> }
> --
Applied as 7.5 material, thanks!