Bug 83411 - /sys/class/power_supply/BAT0/current_now: No such device
Summary: /sys/class/power_supply/BAT0/current_now: No such device
Status: REJECTED DOCUMENTED
Alias: None
Product: ACPI
Classification: Unclassified
Component: Power-Battery (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Zhang Rui
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-29 01:43 UTC by Henry Gebhardt
Modified: 2020-05-28 04:38 UTC (History)
3 users (show)

See Also:
Kernel Version: 3.15.10-200.fc20.x86_64, 3.0.0, 3.0.101, 3.5.7, 3.15.7
Subsystem:
Regression: No
Bisected commit-id:


Attachments
acpidump -o acpidump.out (328.22 KB, application/octet-stream)
2014-08-29 02:19 UTC, Henry Gebhardt
Details
customized UPBS method (477.41 KB, application/octet-stream)
2014-12-03 05:44 UTC, Zhang Rui
Details
dmesg with new dsdt (64.31 KB, text/plain)
2014-12-07 15:42 UTC, Henry Gebhardt
Details

Description Henry Gebhardt 2014-08-29 01:43:17 UTC
I have a new Galago Ultrabook from System76. The folks at System76 suggested filing this bug.

Here is the problem: The file /sys/class/power_supply/BAT0/current_now does not report the current current when the battery is discharging. Instead,

    $ cat /sys/class/power_supply/BAT0/current_now 
    cat: /sys/class/power_supply/BAT0/current_now: No such device
    
The file reports a reasonable value only when running on AC.

The contents of the battery sysfs files follow. They were taken while running on battery power:

/sys/class/power_supply/BAT0/alarm: 0
/sys/class/power_supply/BAT0/capacity: 93
/sys/class/power_supply/BAT0/charge_full: 5149000
/sys/class/power_supply/BAT0/charge_full_design: 4800000
/sys/class/power_supply/BAT0/charge_now: 4793000
cat: /sys/class/power_supply/BAT0/current_now: No such device
/sys/class/power_supply/BAT0/current_now: 
/sys/class/power_supply/BAT0/cycle_count: 0
cat: /sys/class/power_supply/BAT0/device: Is a directory
/sys/class/power_supply/BAT0/device: 
/sys/class/power_supply/BAT0/manufacturer: Notebook
/sys/class/power_supply/BAT0/model_name: BAT
cat: /sys/class/power_supply/BAT0/power: Is a directory
/sys/class/power_supply/BAT0/power: 
/sys/class/power_supply/BAT0/present: 1
/sys/class/power_supply/BAT0/serial_number: 0001
/sys/class/power_supply/BAT0/status: Discharging
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory
/sys/class/power_supply/BAT0/subsystem: 
/sys/class/power_supply/BAT0/technology: Li-ion
/sys/class/power_supply/BAT0/type: Battery
/sys/class/power_supply/BAT0/uevent: POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=0
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=11100000
POWER_SUPPLY_VOLTAGE_NOW=12140000
POWER_SUPPLY_CHARGE_FULL_DESIGN=4800000
POWER_SUPPLY_CHARGE_FULL=5149000
POWER_SUPPLY_CHARGE_NOW=4793000
POWER_SUPPLY_CAPACITY=93
POWER_SUPPLY_MODEL_NAME=BAT
POWER_SUPPLY_MANUFACTURER=Notebook
POWER_SUPPLY_SERIAL_NUMBER=0001
/sys/class/power_supply/BAT0/voltage_min_design: 11100000
/sys/class/power_supply/BAT0/voltage_now: 12140000

$ uname -a
Linux mrbessel.localdomain 3.15.10-200.fc20.x86_64 #1 SMP Thu Aug 14 15:39:24 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

I have also tried stable kernel versions 3.0.0, 3.0.101, 3.5.7, 3.15.7 from git with the same result. I am currently running Fedora 20, but same results on Ubuntu 14.04.

The folks at System76 think this is a software issue. Let me know if you need any more information.
Comment 1 Lan Tianyu 2014-08-29 02:09:23 UTC
Could you provide the output of acpidump?
Comment 2 Henry Gebhardt 2014-08-29 02:19:57 UTC
Created attachment 148651 [details]
acpidump -o acpidump.out
Comment 3 Henry Gebhardt 2014-10-01 17:00:52 UTC
Is this the output you were looking for?
Comment 4 Zhang Rui 2014-12-03 05:44:34 UTC
Created attachment 159511 [details]
customized UPBS method

please follow the step 5/6/7 in https://01.org/linux-acpi/documentation/overriding-dsdt
to make your kernel run with this customized DSDT.
And then reboot and run "echo 1 > /sys/module/acpi/parameters/aml_debug_output"
and then re-cat the current_now sysfs file.
please attach the dmesg output after the above steps.
Comment 5 Henry Gebhardt 2014-12-07 15:42:25 UTC
Created attachment 159961 [details]
dmesg with new dsdt

OK, I think I did it right.
Comment 6 Zhang Rui 2015-02-15 08:30:44 UTC
It seems to be a BIOS bug to me.
the "No such device" error is caused by the follow ASL code

                    If (^^AC.ACFG)
                    {
                        If (LEqual (And (^^PCI0.LPCB.EC.BST0, 0x02), 0x02))
                        {
                            Or (Local0, 0x02, Local0)
                            And (^^PCI0.LPCB.EC.BPR0, 0xFFFF, Local1)
                        }
                    }
                    Else
                    {
                        Or (Local0, One, Local0)
                        And (^^PCI0.LPCB.EC.BPR0, 0xFFFF, Local1)
                    }

                    And (Local1, 0x8000, Local7)
                    If (LEqual (Local7, 0x8000))
                    {
                        Store (0xFFFFFFFF, Local1)
                    }

the return value of BPR0 is 0xFC2D, and the ASL checks bit 15 of BPR0, and if it is set, Local1 is set to 0xFFFFFFFF, and Local1 is the value that OS reads to get the "current_now".

I don't know why the ASL code is written in this way. Bug closed because this is apparently a BIOS issue and  we can do nothing in kernel/userspace.
Sorry that we can not help you about this issue.
Comment 7 Henry Gebhardt 2015-02-15 17:32:28 UTC
(In reply to Zhang Rui from comment #6)
> It seems to be a BIOS bug to me.
> ...
> Sorry that we can not help you about this issue.

OK, thank you for looking into this.

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