Bug 106591

Summary: Toshiba L750D - system doesn't recognise the battery - AMD A6
Product: ACPI Reporter: Bartosz (oliwa.bartosz)
Component: Power-BatteryAssignee: Zhang Rui (rui.zhang)
Status: CLOSED WILL_NOT_FIX    
Severity: high CC: aaron.lu, lenb, lv.zheng, rui.zhang
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 3.16.7-24-desktop Tree: Mainline
Regression: No
Attachments: Acpidump
dmesg
Debug-patch-to-force-disabling-ACPI-4.0-battery

Description Bartosz 2015-10-25 21:35:12 UTC
System does not recognise the battery (OpenSuse 13.2, Ubuntu 14.04, Thumbleweed). 


Tried options:

1) cat /proc/acpi/battery/BAT*/* - No such file.
2) dmesg | grep batt:

[ 10.993784] ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)
[ 11.015058] ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)
[ 11.036028] ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)
[ 11.057127] ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)
[ 11.078128] ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)

3) rpm -qa | grep acpi shows:

acpi-1.7-2.1.2.x86_64
acpid-2.0.22-2.1.2.x86_64
acpica-20150717-1.1.x86_64

4) journalctl -a shows:

kernel: ACPI Error: Method parse/execution failed [\_SB_.BAT1.UBIX] (Node ffff8801fe05afb8), AE_AML_PACKAGE_LIMIT (20140424/psparse-536)
kernel: ACPI Error: Method parse/execution failed [\_SB_.BAT1._BIX] (Node ffff8801fe05a0b8), AE_AML_PACKAGE_LIMIT (20140424/psparse-536)
kernel: ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)

5) Added lines in GRUB in YAST commandline 
a) acpi_osi="!Linux" - NO RESULTS 
b) acpi_osi= - NO RESULTS 

6) Unable to compile new kernel with changed DSDT (log below):

OpenSuse:/home/bartosz # cat /sys/firmware/acpi/tables/DSDT > DSDT.dat
OpenSuse:/home/bartosz # iasl -d DSDT.dat

Intel ACPI Component Architecture
ASL+ Optimizing Compiler version 20150717-64
Copyright (c) 2000 - 2015 Intel Corporation

Reading ACPI table from file   DSDT.dat - Length 00070373 (0x0112E5)
ACPI: DSDT 0x0000000000000000 0112E5 (v01 TOSQCI TOSQCI00 F0000000 ACPI 00040000)
Acpi table [DSDT] successfully installed and loaded
Pass 1 parse of [DSDT]
Pass 2 parse of [DSDT]
Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)

Parsing completed
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 6 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 3 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150717/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150717/dmextern-819)

Found 2 external control methods, reparsing with new information
Pass 1 parse of [DSDT]
Pass 2 parse of [DSDT]
Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)

Parsing completed
Disassembly completed
ASL Output:    DSDT.dsl - 680076 bytes

iASL Warning: There were 2 external control methods found during
disassembly, but additional ACPI tables to resolve these externals
were not specified. The resulting disassembler output file may not
compile because the disassembler did not know how many arguments
to assign to these methods. To specify the tables needed to resolve
external control method references, the -e option can be used to
specify the filenames. Note: SSDTs can be dynamically loaded at
runtime and may or may not be available via the host OS.
Example iASL invocations:
    iasl -e ssdt1.aml ssdt2.aml ssdt3.aml -d dsdt.aml
    iasl -e dsdt.aml ssdt2.aml -d ssdt1.aml
    iasl -e ssdt*.aml -d dsdt.aml

In addition, the -fe option can be used to specify a file containing
control method external declarations with the associated method
argument counts. Each line of the file must be of the form:
    External (<method pathname>, MethodObj, <argument count>)
Invocation:
    iasl -fe refs.txt -d dsdt.aml
OpenSuse:/home/bartosz # nano DSDT.dsl

----------------------

Changed twice:

FIRST TIME:

OperationRegion (EMEM, SystemMemory, 0xFF808001, 0x013F)
to 
OperationRegion (EMEM, EmbeddedControl, 0×00, 0x013F)

SECOND TIME:

OperationRegion (EMEM, SystemMemory, 0×FF808001, 0x013F) to OperationRegion (EMEM, EmbeddedControl, 0×00, 0×FF)

-----------------------

OpenSuse:/home/bartosz # iasl -tc DSDT.dsl

Intel ACPI Component Architecture
ASL+ Optimizing Compiler version 20150717-64
Copyright (c) 2000 - 2015 Intel Corporation

Compiler aborting due to parser-detected syntax error(s)
DSDT.dsl    801:                     \_SB.ALIB (0x06, XX05, \_SB.ALIB (0x06, XX06, \_SB.PCI0.PB5.XPPR (Zero), Sleep (0x14), Notify (\_SB.PCI0.PB5, 
Error    6126 -                                     syntax error, unexpected PARSEOP_SLEEP, expecting ',' or ')' ^ 

DSDT.dsl    801:                     \_SB.ALIB (0x06, XX05, \_SB.ALIB (0x06, XX06, \_SB.PCI0.PB5.XPPR (Zero), Sleep (0x14), Notify (\_SB.PCI0.PB5, 
Error    6126 -                                                                             syntax error, unexpected ',' ^ 

DSDT.dsl    832:                         \_SB.ALIB (0x06, XX05, Else
Error    6126 -                                                   ^ syntax error, unexpected PARSEOP_ELSE, expecting ',' or ')'

DSDT.dsl    835:                             }, P80H = 0x0F1A, Else
Error    6126 - syntax error, unexpected ',' ^ 

DSDT.dsl    835:                             }, P80H = 0x0F1A, Else
Error    6126 -                syntax error, unexpected ',' ^ 

DSDT.dsl    841:                                     \_SB.ALIB (0x06, XX05, Else
Error    6126 -   syntax error, unexpected PARSEOP_ELSE, expecting ',' or ')' ^ 

DSDT.dsl    844:                                         }, P80H = 0x021A, Else
Error    6126 -             syntax error, unexpected ',' ^ 

DSDT.dsl    844:                                         }, P80H = 0x021A, Else
Error    6126 -                            syntax error, unexpected ',' ^ 

DSDT.dsl    874:                                                     \_SB.ALIB (0x06, XX05, Else
Error    6126 -                   syntax error, unexpected PARSEOP_ELSE, expecting ',' or ')' ^ 

DSDT.dsl    877:                                                         }, HPOK = One, P80H = 0x1F1A)
Error    6126 -                             syntax error, unexpected ',' ^ 

DSDT.dsl    877:                                                         }, HPOK = One, P80H = 0x1F1A)
Error    6126 -                                         syntax error, unexpected ',' ^ 

DSDT.dsl    877:                                                         }, HPOK = One, P80H = 0x1F1A)
Error    6126 -                                                        syntax error, unexpected ')' ^ 

DSDT.dsl    887:                                                     \_SB.ALIB (0x06, XX05, Else
Error    6126 -                   syntax error, unexpected PARSEOP_ELSE, expecting ',' or ')' ^ 

DSDT.dsl    890:                                                         }, Local2 = Zero, While ((Local2 < 0x0F))
Error    6126 -                             syntax error, unexpected ',' ^ 

DSDT.dsl    890:                                                         }, Local2 = Zero, While ((Local2 < 0x0F))
Error    6126 -                                            syntax error, unexpected ',' ^ 

DSDT.dsl    939:                                                         })
Error    6126 -                             syntax error, unexpected ')' ^ 

DSDT.dsl    968:                                                         \_SB.ALIB (0x06, XX05, Else
Error    6126 -                       syntax error, unexpected PARSEOP_ELSE, expecting ',' or ')' ^ 

DSDT.dsl    971:                                                             }, If (HPOK)
Error    6126 -                                 syntax error, unexpected ',' ^ 

DSDT.dsl    974:                                                             })
Error    6126 -                                 syntax error, unexpected ')' ^ 

DSDT.dsl    978:                                         })
Error    6126 -             syntax error, unexpected ')' ^ 

ASL Input:     DSDT.dsl - 980 lines, 680073 bytes, 505 keywords
Hex Dump:      DSDT.hex - 172 bytes

Compilation complete. 20 Errors, 0 Warnings, 0 Remarks, 0 Optimizations
OpenSuse:/home/bartosz # cd linux-4.2.4/
OpenSuse:/home/bartosz/linux-4.2.4 # cp -vi /boot/config-`uname -r` .config
„/boot/config-3.16.7-24-desktop” -> „.config”
OpenSuse:/home/bartosz/linux-4.2.4 # cd include/
OpenSuse:/home/bartosz/linux-4.2.4/include # cp -vi /home/bartosz/DSDT.hex /home/bartosz/linux-4.2.4/include/
„/home/bartosz/DSDT.hex” -> „/home/bartosz/linux-4.2.4/include/DSDT.hex”
OpenSuse:/home/bartosz/linux-4.2.4 # nano .config

--------------------------

Changed options in .config: 

CONFIG_STANDALONE=n
CONFIG_ACPI_CUSTOM_DSDT=y
CONFIG_ACPI_CUSTOM_DSDT_FILE="DSDT.hex"

---------------------------

bartosz@OpenSuse:~> make menuconfig

---------------------------

Checked the AMD ACPI Power...(NEW) and saved .config


---------------------------

bartosz@OpenSuse:~/linux-4.2.4> make

(...)In file included from drivers/acpi/osl.c:63:0:
include/DSDT.hex:1:1: error: unterminated comment
 /*
 ^
drivers/acpi/osl.c: In function ‘acpi_os_table_override’:
drivers/acpi/osl.c:745:44: error: ‘AmlCode’ undeclared (first use in this function)
   *new_table = (struct acpi_table_header *)AmlCode;
                                            ^
drivers/acpi/osl.c:745:44: note: each undeclared identifier is reported only once for each function it appears in
scripts/Makefile.build:258: polecenia dla obiektu 'drivers/acpi/osl.o' nie powiodły się
make[2]: *** [drivers/acpi/osl.o] Błąd 1
scripts/Makefile.build:403: polecenia dla obiektu 'drivers/acpi' nie powiodły się
make[1]: *** [drivers/acpi] Błąd 2
Makefile:949: polecenia dla obiektu 'drivers' nie powiodły się
make: *** [drivers] Błąd 2


Info: Błąd means ERROR in English;
nie powiodły się -  failed.
Comment 1 Aaron Lu 2015-10-27 05:56:45 UTC
acpidump please:
# acpidump > acpidump.txt
Comment 2 Bartosz 2015-10-27 17:55:18 UTC
Created attachment 191291 [details]
Acpidump
Comment 3 Bartosz 2015-10-27 18:58:37 UTC
Also making lighter/brighter or darker screen doesn't work to, either with fn keys or in the system. I feel it is conencted with battery issue, because settings are in the power management options.
Comment 4 Aaron Lu 2015-10-28 07:21:49 UTC
I can't even disassemble the table:

$ iasl -d dsdt.dat 

Intel ACPI Component Architecture
ASL+ Optimizing Compiler version 20150515-64
Copyright (c) 2000 - 2015 Intel Corporation

Reading ACPI table from file   dsdt.dat - Length 00070373 (0x0112E5)
ACPI: DSDT 0x0000000000000000 0112E5 (v01 TOSQCI TOSQCI00 F0000000 ACPI 00040000)
Acpi table [DSDT] successfully installed and loaded
Pass 1 parse of [DSDT]
Pass 2 parse of [DSDT]
Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)

Parsing completed
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 6 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 3 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150515/dmextern-819)
ACPI Error: External method arg count mismatch _SB_.ALIB: Current 5, attempted 2 (20150515/dmextern-819)

Found 2 external control methods, reparsing with new information
Pass 1 parse of [DSDT]
Pass 2 parse of [DSDT]
Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)

Parsing completed
Segmentation fault (core dumped)

Maybe I need to upgrade the iasl tool shipped in Fedora 22...
Comment 5 Aaron Lu 2015-10-28 07:30:30 UTC
Upgraded to acpica-tools-20150818-2.fc22.x86_64 works now.

I'll need Lv's help to take a look at the _BIX control method, as for the backlight issue, do you have any directory under /sys/class/backlight?

Please also attach full dmesg after boot.
Comment 6 Bartosz 2015-10-28 16:31:07 UTC
Created attachment 191411 [details]
dmesg
Comment 7 Bartosz 2015-10-28 16:31:24 UTC
https://bugzilla.kernel.org/show_bug.cgi?id=106591

bartosz@OpenSuse:/sys/class/backlight> pwd
/sys/class/backlight
bartosz@OpenSuse:/sys/class/backlight> ls
radeon_bl0  toshiba
Comment 8 Aaron Lu 2015-12-16 03:18:13 UTC
(In reply to Bartosz from comment #7)
> https://bugzilla.kernel.org/show_bug.cgi?id=106591
> 
> bartosz@OpenSuse:/sys/class/backlight> pwd
> /sys/class/backlight
> bartosz@OpenSuse:/sys/class/backlight> ls
> radeon_bl0  toshiba

Does manually change backlight work there?
e.g. to manually change backlight using the radeon_bl0 interface, you can:
# cd radeon_bl0
# cat max_brightness
XXX
# echo a_value_smaller_than_XXX > brightness
see if backlight changes.
Comment 9 Bartosz 2015-12-16 16:18:47 UTC
Hi, thank you for your response.

Your method works! The monitor went darker when I typed 100.
Comment 10 Aaron Lu 2015-12-17 01:49:16 UTC
And what about the other interface, i.e. toshiba?
Comment 11 Bartosz 2015-12-17 16:24:57 UTC
OpenSuse:/sys/class/backlight/toshiba # ls
actual_brightness  bl_power  brightness  device  max_brightness  power  subsystem  type  uevent

changing brightness in toshiba doesn't work, it is the same effect when I hit Fn + F6 or F7 (the dialog shows that brightness is changing in KDE but in fact nothing happens)
Comment 12 Aaron Lu 2015-12-18 01:55:24 UTC
Then I suppose you can add: acpi_backlight=native to kernel cmdline and see if the radeon interface is the only one left in /sys/class/backlight directory, then the user space should pick the correct interface to use.
Comment 13 Bartosz 2015-12-21 21:57:04 UTC
where, how to do it?
Comment 14 Aaron Lu 2015-12-22 02:03:55 UTC
Please google how to add kernel cmdline option, you are probably using grub2, add that to search keyword too. An example:
http://askubuntu.com/questions/19486/how-do-i-add-a-kernel-boot-parameter
Comment 15 Bartosz 2015-12-22 20:05:01 UTC
Ok I did:

1. sudo nano /etc/default/grub

2. in file added a cmdline:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=native"

3. saved and then:

4. sudo update-grub

5. sudo reboot

6. bartosz@bartosz-L750D:/sys/class/backlight$ ls
radeon_bl0  toshiba
Comment 16 Bartosz 2015-12-22 20:06:04 UTC
nothing happens, results the same, fn + f6/f7 don't make any effect.
Comment 17 Aaron Lu 2015-12-23 01:51:31 UTC
It seems you are using an old kernel, the said cmdline option works with a v4.2 or above kernel.
Comment 18 Bartosz 2015-12-23 07:02:49 UTC
I'm using 3.19, so I have to wait for a new version of linux (kubuntu)?
Comment 19 Aaron Lu 2015-12-23 07:29:35 UTC
You can build a new kernel. If that's not an option, maybe you can try: acpi_backlight=video. This will, theoretically, disable the vendor(toshiba here) interface. But I'm afraid it will make the acpi_videoX interface appear. Anyway, worth a try :-)
Comment 20 Aaron Lu 2015-12-23 07:31:51 UTC
Lv,
Any hint if the problem of _BIX is a firmware issue or ACPICA?
Comment 21 Bartosz 2016-01-06 12:53:29 UTC
I've made a Lubuntu 15.04 USB Drive and tried it live and could manage the brightness via function keys. But there were still problem with battery.
Comment 22 Zhang Rui 2016-01-07 01:29:00 UTC
[   11.403369] ACPI Exception: AE_AML_PACKAGE_LIMIT, Index (0x000000011) is beyond end of object (length 0xD) (20140424/exoparg2-420)
[   11.403382] ACPI Error: Method parse/execution failed [\_SB_.BAT1.UBIX] (Node ffff8801fe05afb8), AE_AML_PACKAGE_LIMIT (20140424/psparse-536)
[   11.403391] ACPI Error: Method parse/execution failed [\_SB_.BAT1._BIX] (Node ffff8801fe05a0b8), AE_AML_PACKAGE_LIMIT (20140424/psparse-536)
[   11.403398] ACPI Exception: AE_AML_PACKAGE_LIMIT, Evaluating _BIX (20140424/battery-461)

We can see that ACPI battery driver fails to probe the device because of broken _BIX control method.

There are two ways to fix the battery issue.
1. push Toshiba to fix the BIOS for this platform.
2. Force disabling _BIX on this platform so that the ACPI battery driver can fall back to use _BIF, which should also work for you. Debug patch attached, but unfortunately I don't think this can be included in upstream kernel...

IMO, this bug can be closed as it's not a kernel issue.
Please feel free to reopen it if you still have any questions.
Comment 23 Zhang Rui 2016-01-07 01:30:01 UTC
Created attachment 198891 [details]
Debug-patch-to-force-disabling-ACPI-4.0-battery
Comment 24 Bartosz 2016-01-09 17:54:23 UTC
Sorry I'm total beginner with this kind of issue? Can you write step by step what to do? Thanks.
Comment 25 Zhang Rui 2016-01-10 02:00:26 UTC
Okay.
are you able to build a custom kernel? Say, download the kernel source and build the kernel by yourself.
If yes, I can show you how to patch your custom kernel with the patch file attached in comment #23.
If no, then I'm afraid I cannot help on this...