Bug 197175 - Incorrect (?) capacity reported for SMP battery
Summary: Incorrect (?) capacity reported for SMP battery
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: Intel Linux
: P1 normal
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-09 19:48 UTC by Ryan Hendrickson
Modified: 2017-11-18 03:32 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.13.3
Subsystem:
Regression: No
Bisected commit-id:


Attachments
hard-coded fix (590 bytes, patch)
2017-11-18 03:32 UTC, Ryan Hendrickson
Details | Diff

Description Ryan Hendrickson 2017-10-09 19:48:20 UTC
I have Arch Linux installed on a late-2008 Macbook Pro with an Apple-branded A1281 battery. The capacity reported by /sys/class/power_supply/BAT0/capacity is being reported by various tools as the amount of charge in my battery. I haven't found any documentation indicating whether capacity should be 100*charge_now/charge_full or 100*charge_now/charge_full_design, but it seems to be the latter, which means that from Gnome, it looks like my battery charges up to ~75% and is then suddenly "full". Is this something that can be corrected in the appropriate battery driver? The little green hardware lights on the side of the laptop do report the "correct" battery capacity (they're 6/8 lit when the kernel is reporting capacity in the 50s), so I think the battery firmware is operating as expected, and UPower/everything downstream seems to be reading from /sys, which is why I'm reporting a bug here.

Here's everything in my /sys/class/power_supply/BAT0:

> alarm: 300000
> capacity: 75
> charge_full: 3567000
> charge_full_design: 4600000
> charge_now: 3430000
> current_avg: 0
> current_now: 0
> cycle_count: 51
> manufacturer: SMP
> model_name: bq20z951
> present: 1
> status: Full
> technology: Li-ion
> temp: 321
> type: Battery
> uevent: POWER_SUPPLY_NAME=BAT0 POWER_SUPPLY_STATUS=Full
> POWER_SUPPLY_PRESENT=1 POWER_SUPPLY_TECHNOLOGY=Li-ion
> POWER_SUPPLY_CYCLE_COUNT=51 POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10950000
> POWER_SUPPLY_VOLTAGE_NOW=12473000 POWER_SUPPLY_CURRENT_NOW=0
> POWER_SUPPLY_CURRENT_AVG=0 POWER_SUPPLY_CAPACITY=75
> POWER_SUPPLY_CHARGE_FULL_DESIGN=4600000 POWER_SUPPLY_CHARGE_FULL=3567000
> POWER_SUPPLY_CHARGE_NOW=3430000 POWER_SUPPLY_TEMP=321
> POWER_SUPPLY_MODEL_NAME=bq20z951 POWER_SUPPLY_MANUFACTURER=SMP
> voltage_min_design: 10950000
> voltage_now: 12473000
Comment 1 Ryan Hendrickson 2017-11-18 03:32:23 UTC
Created attachment 260711 [details]
hard-coded fix

I've been running with this patch for almost a month now. It's surely not a general fix as it always ignores battery->state_of_charge; I assume the driver should check the battery model or cleverly try to detect if this issue is present somehow, but I don't know what the right way to do that is. So this works for me, and hopefully helps someone else.

Note You need to log in before you can comment on or make changes to this bug.