Bug 60519

Summary: Wrong battery information reported on Samsung NP540U3C
Product: ACPI Reporter: Jan Hoffmann (jan)
Component: Power-BatteryAssignee: Lan Tianyu (tianyu.lan)
Status: CLOSED CODE_FIX    
Severity: normal CC: aaron.lu, fcr
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.34 and newer Subsystem:
Regression: Yes Bisected commit-id:
Attachments: Output of acpidump
debug.patch
Output of acpidump on NEC LZ750/LS

Description Jan Hoffmann 2013-07-05 14:01:42 UTC
Created attachment 106809 [details]
Output of acpidump

The battery information reported in sysfs is wrong since kernel 2.6.34. In older versions the information is correct.

The affected device is a Samsung NP540U3C. The output of acpidump is attached.
These are the contents of /sys/class/power_supply/BAT1/uevent:

Correct information on 2.6.33:
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Full
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7500000
POWER_SUPPLY_VOLTAGE_NOW=8638000
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_CHARGE_FULL_DESIGN=6890000
POWER_SUPPLY_CHARGE_FULL=6800000
POWER_SUPPLY_CHARGE_NOW=6800000
POWER_SUPPLY_MODEL_NAME=
POWER_SUPPLY_MANUFACTURER=SAMSUNG Electronics
POWER_SUPPLY_SERIAL_NUMBER=

Wrong information on 2.6.34:
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Unknown
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Unknown
POWER_SUPPLY_CYCLE_COUNT=204
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=1000
POWER_SUPPLY_VOLTAGE_NOW=8638000
POWER_SUPPLY_CURRENT_NOW=0
POWER_SUPPLY_POWER_NOW=0
POWER_SUPPLY_ENERGY_FULL_DESIGN=1000
POWER_SUPPLY_ENERGY_FULL=6890000
POWER_SUPPLY_ENERGY_NOW=6800000
POWER_SUPPLY_MODEL_NAME=
POWER_SUPPLY_MANUFACTURER=LION
POWER_SUPPLY_SERIAL_NUMBER=
Comment 1 Aaron Lu 2013-07-09 07:59:51 UTC
v2.6.34 adds support for extended battery, I think that caused this problem, but I don't see why. Tianyu, maybe you have some idea.
Comment 2 Lan Tianyu 2013-07-12 03:16:56 UTC
Sorry for later response, could you check whether this issue takes place on the latest upstream kernel(v3.10)?
Comment 3 Jan Hoffmann 2013-07-12 09:19:13 UTC
Yes, the problem occurs on kernel 3.10, as well.
Comment 4 Lan Tianyu 2013-07-15 05:27:09 UTC
How about unloading and then reloading acpi battery driver?
Comment 5 Jan Hoffmann 2013-07-15 10:38:44 UTC
I tried unloading and loading the module battery, but that didn't change anything.

I only tried with kernel 3.9, though, as I don't have another kernel with the battery driver compiled as module right now. I can try again with 3.10 later.
Comment 6 Jan Hoffmann 2013-07-15 20:48:33 UTC
There's no change either on 3.10 when unloading/reloading the battery module.
Comment 7 Lan Tianyu 2013-07-29 02:47:07 UTC
Created attachment 107031 [details]
debug.patch

Please try this patch.
Comment 8 Jan Hoffmann 2013-07-29 17:01:42 UTC
With this patch applied, the battery info seems to be correct: 

$ cat /sys/class/power_supply/BAT1/uevent 
POWER_SUPPLY_NAME=BAT1
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=11
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7500000
POWER_SUPPLY_VOLTAGE_NOW=8427000
POWER_SUPPLY_CURRENT_NOW=841000
POWER_SUPPLY_CHARGE_FULL_DESIGN=6890000
POWER_SUPPLY_CHARGE_FULL=6800000
POWER_SUPPLY_CHARGE_NOW=6460000
POWER_SUPPLY_CAPACITY=95
POWER_SUPPLY_MODEL_NAME=
POWER_SUPPLY_MANUFACTURER=SAMSUNG Electronics
POWER_SUPPLY_SERIAL_NUMBER=
Comment 9 Lan Tianyu 2013-07-30 01:42:26 UTC
Yes, these info looks correct compared with the output from _BIF on 2.6.33. The _BIX is used instead of _BIF above 2.6.34. The parsing of _BIX is wrong in the acpi battery driver. I will send fix patch to acpi maillist. Thanks for test.
Comment 10 Lan Tianyu 2013-07-30 02:05:38 UTC
https://patchwork.kernel.org/patch/2835212/
Comment 11 Lan Tianyu 2013-08-05 03:21:46 UTC
The fix patch has been merged into Linux upstream tree.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=016d5baad04269e8559332df05f89bd95b52d6ad
Comment 12 Francisco Castro 2013-10-01 01:02:43 UTC
However this "fix" breaks the battery support for my laptop, a NEC LZ750/LS, logging the error:

[    2.273992] ACPI Warning: For \_SB_.PCI0.LPCB.EC__.BAT1._BIX: Return Package is too small - found 19 elements, expected 20 (20121018/nspredef-679)
[    2.274007] battery: probe of PNP0C0A:00 failed with error -14
Comment 13 Francisco Castro 2013-10-09 09:07:04 UTC
Created attachment 110471 [details]
Output of acpidump on NEC LZ750/LS