Bug 90161

Summary: Can't register new acpi battery -> No battery life on laptop
Product: ACPI Reporter: Lompik (lompik)
Component: Power-BatteryAssignee: Chen Yu (yu.c.chen)
Status: CLOSED CODE_FIX    
Severity: low CC: aaron.lu, anton, es, kenny.speer, lenb, mister.wardrop, rpl5454, rui.zhang, surface3surface3, tianyu.lan, valentin.lab_bugzilla.kernel.org, zismylaptop
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: v3.19-rc1 Subsystem:
Regression: No Bisected commit-id:
Attachments: acpidump on laptop

Description Lompik 2014-12-21 04:48:12 UTC
Hi,

I am running kernel 3.19-rc1 on a "Mircosoft surface 3" .However recent (23 Nov) changes made in the file 'drivers/acpi/battery.c' in the commit 40e7fcb19293cbdff02c74cb0668413480f82ea1 will prevent the battery of my laptop to be registered. the result in that the Battery driver will deferring the Probing of the device forever. 
Removing the 2 commited lines (1181) fixes the issues in my case and the battery shows up in '/sys/class/power_supply/BAT0'. 

Regards
--

**dmesg: Warning message before patch below :
[ 8551.693540] acpi PNP0C0A:00: Driver battery requests probe deferral

**dmesg: After the patch only one message is displayed about the battery :
[ 0.600055] ACPI: Battery Slot [BAT0] (battery present)



Specific patch reverting the commit:

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index d98ba43..4983b98 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -1181,9 +1181,6 @@ static int acpi_battery_add(struct acpi_device *device)
 	if (!device)
 		return -EINVAL;
 
-	if (device->dep_unmet)
-		return -EPROBE_DEFER;
-
 	battery = kzalloc(sizeof(struct acpi_battery), GFP_KERNEL);
 	if (!battery)
 		return -ENOMEM;
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 122599b..9535d73 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -1,4 +1,5 @@
 #!/bin/sh
+exit 0
 #
 # A depmod wrapper used by the toplevel Makefile
Comment 1 Aaron Lu 2014-12-22 07:45:51 UTC
acpidump please:
# acpidump > acpidump.txt
Comment 2 Lompik 2014-12-22 16:54:35 UTC
Created attachment 161631 [details]
acpidump on laptop

See attached
Comment 3 Lan Tianyu 2014-12-26 02:09:00 UTC
Please try the following patch.

diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index cb6066c..7089d38 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -870,6 +870,8 @@ static int acpi_ec_add(struct acpi_device *device)
 
        ret = ec_install_handlers(ec);
 
+       acpi_walk_dep_device_list(device->handle);
+
        /* EC is fully operational, allow queries */
        clear_bit(EC_FLAGS_QUERY_PENDING, &ec->flags);
Comment 4 Lompik 2014-12-30 09:11:10 UTC
Applying the patch fixes the issue !
Comment 5 Anton Anikin 2015-01-23 18:18:54 UTC
I have the same problem with MS Surface Pro 3 and 3.19-rc5 kernel
Comment 6 Aaron Lu 2015-01-27 07:52:37 UTC
Anton,
Can you please try the patch in comment #3?

Tianyu,
Any plan to upstream the patch?
Comment 7 Valentin Lab 2015-02-02 13:29:58 UTC
I had the same problem with MS Surface Pro 3, running 3.19rc1 to 3.19rc5. Then I applied this patch, and my battery icon is now there again. So this patch fixes the issue for me also.

Waiting for this fix to make it upstream.
Comment 8 Anton Anikin 2015-02-02 16:02:14 UTC
Same problem on 3.19-rc6
Comment 9 Rob 2015-02-03 16:04:33 UTC
trying to apply this patch. no luck can you please provide the syntax or are extra steps needed to apply (patch code in comment 3)- using 3.19RC7

thanks
Comment 10 Anton Anikin 2015-02-03 16:13:46 UTC
my patch file that works with 3.19-rc7 https://dl.dropboxusercontent.com/u/4080500/patch/battery.patch
Comment 11 mister.wardrop 2015-02-09 22:38:25 UTC
Why is this issue still marked as NEEDINFO? Is there anything else you need? If so, let me know. Looking forward to seeing this mainlined.
Comment 12 Lompik 2015-02-11 02:40:50 UTC
I do not have anymore issues. it is just a matter of someone submitting the patch. I believe  Lan Tianyu  is the best person to do this. If needed I can only submit something next week.
Comment 13 surface3surface3 2015-02-11 06:29:49 UTC
Patch in comment 3 also works with me.  (Comment 10 has the same patch?)  I can also submit.
Comment 14 Lompik 2015-02-12 04:22:05 UTC
Comment 10 has the same patch that works with 3.19.
Comment 15 mister.wardrop 2015-03-09 00:18:17 UTC
Is this likely to be committed in a 3.19 patch release? Or are we waiting for 4.0?
Comment 16 Keith McClelland 2015-03-09 14:05:47 UTC
This patch is not in 3.19 nor 4.0-RC2. It takes some detective work to find the spot to put it in 4.0 but then it works.
Comment 17 neoreeps 2015-03-30 01:30:59 UTC
Still an issue with 4.0-RC5 and 3.19.0-10 ... BTW, thank you for filing this and providing the diff ... building my own is a temporary option until this makes it into a release ...
Comment 18 Lompik 2015-04-03 18:11:55 UTC
Good news. A patch has been submitted to the mailing list. http://marc.info/?l=linux-acpi&m=142785305602658&w=2 . It still needs to get pulled into Linus kernel tree.
Comment 19 Len Brown 2015-07-22 00:38:10 UTC
shipped in Linux-4.1-rc1:

commit 1c832b3e85b6ac35e5f113fa4204eb725c54794e
Author: Lan Tianyu <tianyu.lan@intel.com>
Date:   Wed Apr 1 09:47:18 2015 +0800

    ACPI / EC: Call acpi_walk_dep_device_list() after installing EC opregion handler