Bug 245778 - ACPI not detecting battery properly on HP Spectre x360 13-ap0053dx 13-CURRENT between base r359837 and base r360134
Summary: ACPI not detecting battery properly on HP Spectre x360 13-ap0053dx 13-CURREN...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Conrad Meyer
URL:
Keywords: needs-qa, regression
Depends on:
Blocks:
 
Reported: 2020-04-21 04:33 UTC by Neel Chauhan
Modified: 2020-04-23 17:30 UTC (History)
4 users (show)

See Also:


Attachments
dmesg on r360134/HP Spectre x360 13-ap0053dx (70.64 KB, text/plain)
2020-04-21 04:33 UTC, Neel Chauhan
no flags Details
DSDT for HP Spectre x360 13-ap0053dx (366.02 KB, application/octet-stream)
2020-04-21 04:36 UTC, Neel Chauhan
no flags Details
Working dmesg on HP Spectre x360 13-ap0053dx (70.78 KB, text/plain)
2020-04-22 01:45 UTC, Neel Chauhan
no flags Details
acpidump -dt of the HP Spectre x360 13-ap0053dx (8.96 KB, text/plain)
2020-04-22 01:46 UTC, Neel Chauhan
no flags Details
battery_sysctls_debug_messages_lenovoA485 (2.21 KB, text/plain)
2020-04-22 21:21 UTC, Evilham
no flags Details
acpidump_dt_lenovoA485 (765.56 KB, text/plain)
2020-04-22 21:23 UTC, Evilham
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Neel Chauhan freebsd_committer freebsd_triage 2020-04-21 04:33:52 UTC
Created attachment 213626 [details]
dmesg on r360134/HP Spectre x360 13-ap0053dx

On a HP Spectre x360 13-ap0053dx running 13-CURRENT r360134, I get this when running acpiconf -i 0:

root@spectre:/home/neel # acpiconf -i 0
Design capacity:	0 mWh
Last full capacity:	0 mWh
Technology:		primary (non-rechargeable)
Design voltage:		0 mV
Capacity (warn):	0 mWh
Capacity (low):		0 mWh
Cycle Count:		0
Mesurement Accuracy:	0 %
Max Sampling Time:	0 ms
Min Sampling Time:	0 ms
Max Average Interval:	0 ms
Min Average Interval:	0 ms
Low/warn granularity:	0 mWh
Warn/full granularity:	0 mWh
Model number:		
Serial number:		
Type:			
OEM info:		
State:			not present
Present voltage:	unknown
root@spectre:/home/neel #


Also, hw.acpi.acline appears if my system is plugged in when it isn't:

root@spectre:/home/neel # sysctl hw.acpi.acline
hw.acpi.acline: 1
root@spectre:/home/neel # 

I have attached a dmesg and will upload a DSDT log.
Comment 1 Neel Chauhan freebsd_committer freebsd_triage 2020-04-21 04:36:14 UTC
Created attachment 213627 [details]
DSDT for HP Spectre x360 13-ap0053dx
Comment 2 Neel Chauhan freebsd_committer freebsd_triage 2020-04-21 04:41:46 UTC
Using my "old" kernel with build r359837 works.
Comment 3 Neel Chauhan freebsd_committer freebsd_triage 2020-04-22 00:25:54 UTC
I think r360131 (Bug 245757) broke this, but can't confirm.

The HP x360 13-ap0053dx gives many ACPI errors on bootup, and r360131 suppresses ACPI probes on an "error" which prevents the OS (and GNOME) from getting the battery status.
Comment 4 Conrad Meyer freebsd_committer freebsd_triage 2020-04-22 00:52:25 UTC
Can you provide a dmesg from the working configuration?  There are no acpi_ec errors in the original report.

Additionally, please attach the output of 'acpidump -dt'; the raw DSDT table doesn't seem to be parseable.

> r360131 suppresses ACPI probes on an "error" 

This is not an especially accurate summary of 360131.
Comment 5 Neel Chauhan freebsd_committer freebsd_triage 2020-04-22 01:45:02 UTC
Created attachment 213660 [details]
Working dmesg on HP Spectre x360 13-ap0053dx

Here's the dmesg of the working system.

acpidump -dt will be posted shortly.
Comment 6 Neel Chauhan freebsd_committer freebsd_triage 2020-04-22 01:46:09 UTC
Created attachment 213661 [details]
acpidump -dt of the HP Spectre x360 13-ap0053dx

Here's the acpidump output.
Comment 7 Neel Chauhan freebsd_committer freebsd_triage 2020-04-22 01:58:00 UTC
If I manually revert r360131 myself in my own /usr/src, battery status and backlight control hotkeys works normally.

Post-r360131, acpi_ec does not load on my Spectre.
Comment 8 Conrad Meyer freebsd_committer freebsd_triage 2020-04-22 21:09:39 UTC
Thanks Neel for the rapid report and information.  I will try to take a look today.
Comment 9 Evilham 2020-04-22 21:21:14 UTC
Created attachment 213705 [details]
battery_sysctls_debug_messages_lenovoA485

Hello, I believe I also identified the same issue running 360179, traced it back to the patch for PR 245757 as well.
If I go back to r360081, battery still works fine.

The hardware in question is a Lenovo A485 (AMD Ryzen CPU) running the latest BIOS (nothing changed besides a new OS revision).

The attached file contains the battery-related sysctls, build information and the debugging messages that now appear on dmesg.

Would happily help test patches and provide more information.
Comment 10 Evilham 2020-04-22 21:23:08 UTC
Created attachment 213706 [details]
acpidump_dt_lenovoA485
Comment 11 Conrad Meyer freebsd_committer freebsd_triage 2020-04-23 02:13:29 UTC
(In reply to Neel Chauhan from comment #6)
The acpidump seems to be missing disassembled DSDT, unfortunately.

@Neel, @Evilham, please try the following change.

--- a/sys/dev/acpica/acpi_ec.c
+++ b/sys/dev/acpica/acpi_ec.c
@@ -443,6 +443,8 @@ acpi_ec_probe(device_t dev)

     if (buf.Pointer)
        AcpiOsFree(buf.Pointer);
+
+    ret = rc;
 out:
     if (ret <= 0) {
        snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s",

In the case where there was no error when we got to 'out', r360131 inadvertently left 'ret' with the initial ENXIO value.  The patch above restores the pre-r360131 return value if no errors occurred.

If that change doesn't work, here's one with further debugging in all of the error cases:

--- a/sys/dev/acpica/acpi_ec.c
+++ b/sys/dev/acpica/acpi_ec.c
@@ -397,6 +397,7 @@ acpi_ec_probe(device_t dev)
      */
     peer = devclass_get_device(acpi_ec_devclass, params->uid);
     if (peer != NULL && device_is_alive(peer)) {
+       device_printf(dev, "XXX duplicate case\n");
        device_disable(dev);
        goto out;
     }
@@ -417,8 +418,10 @@ acpi_ec_probe(device_t dev)
     }

     obj = (ACPI_OBJECT *)buf.Pointer;
-    if (obj == NULL)
+    if (obj == NULL) {
+       device_printf(dev, "XXX _GPE NULL result\n");
        goto out;
+    }

     switch (obj->Type) {
     case ACPI_TYPE_INTEGER:
@@ -426,12 +429,16 @@ acpi_ec_probe(device_t dev)
        params->gpe_bit = obj->Integer.Value;
        break;
     case ACPI_TYPE_PACKAGE:
-       if (!ACPI_PKG_VALID(obj, 2))
+       if (!ACPI_PKG_VALID(obj, 2)) {
+           device_printf(dev, "XXX _GPE invalid PKG\n");
            goto out;
+       }
        params->gpe_handle = acpi_GetReference(NULL, &obj->Package.Elements[0]);
        if (params->gpe_handle == NULL ||
-           acpi_PkgInt32(obj, 1, &params->gpe_bit) != 0)
+           acpi_PkgInt32(obj, 1, &params->gpe_bit) != 0) {
+               device_printf(dev, "XXX _GPE NULL handle or bad bit\n");
                goto out;
+       }
        break;
     default:
        device_printf(dev, "_GPE has invalid type %d\n", obj->Type);
@@ -443,6 +450,8 @@ acpi_ec_probe(device_t dev)

     if (buf.Pointer)
        AcpiOsFree(buf.Pointer);
+
+    ret = rc;
 out:
     if (ret <= 0) {
        snprintf(desc, sizeof(desc), "Embedded Controller: GPE %#x%s%s",
Comment 12 Evilham 2020-04-23 12:54:58 UTC
The first patch (ret = rc;) fixed it for me, and the debug messages also disappeared for this instance of ACPI things.

I take it they'll still be around for the cases in which they were intended.

Thank you :-).
Comment 13 Conrad Meyer freebsd_committer freebsd_triage 2020-04-23 17:24:36 UTC
Thanks for the quick test!  This was a total brain-o on my part in r360131; sorry.
Comment 14 commit-hook freebsd_committer freebsd_triage 2020-04-23 17:30:10 UTC
A commit references this bug:

Author: cem
Date: Thu Apr 23 17:30:03 UTC 2020
New revision: 360224
URL: https://svnweb.freebsd.org/changeset/base/360224

Log:
  acpi_ec(4): Don't probe erroneously if success occurred

  In r360131, acpi_ec probe was changed to not clobber an error status prior to
  several error cases that did not explicitly set the error variable before
  goto'ing the exit path.  However, I did not notice that the error variable was
  not set to success in the success path.  That caused all successful probes to
  fail, which is obviously undesirable.

  PR:		245778
  Reported by:	Neel Chauhan <neel AT neelc.org>, Evilham <contact AT evilham.com>
  Tested by:	Evilham
  X-MFC-With:	r360131

Changes:
  head/sys/dev/acpica/acpi_ec.c