Laptop (T490) does not reliably detect change from AC to BAT

Hello forum,

i got a problem with my T490 - it does not reliably and in time detect that AC is unplugged.
If I remove the AC (which is USB-C on this machine) it does not detect - mostly after a view minutes it does - sometimes it does not.

The other way round - from BAT to AC is immediately recognized.

The running kernel is 5.8.5-2 but same is true for 5.7.19-2.

When I unplug I get these messages:

dmesg -w
[14377.052592] ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20200528/psargs-330)
[14377.052628] ACPI Error: Aborting method \_SB.PCI0.LPCB.EC._Q27 due to previous error (AE_NOT_FOUND) (20200528/psparse-529)

udevadm monitor
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[14375.189343] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
UDEV  [14376.106619] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)

If at some point the system recognises its in BAT mode now I get this additional messages in udevadm:

udevadm monitor
KERNEL[14496.031770] change   /devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight (backlight)
UDEV  [14496.033668] change   /devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight (backlight)

But tlp for example does not switch into BAT mode then still

tlp-stat -s
--- TLP 1.3.1 --------------------------------------------

+++ System Info
System         = LENOVO ThinkPad T490 20N2004AGE
BIOS           = N2IET90W (1.68 )
Release        = "Manjaro Linux"
Kernel         = 5.8.3-2-MANJARO #1 SMP PREEMPT Sat Aug 22 12:35:25 UTC 2020 x86_64
/proc/cmdline  = BOOT_IMAGE=/boot/vmlinuz-5.8-x86_64 root=UUID=fc4a43ed-568f-4c5f-b70e-267676a30677 rw i915.modeset=1 i915.fastboot=1 nmi_watchdog=0 nowatchdog cryptdevice=UUID=82dce2e7-d80f-4317-a9d9-458ce4bd1e52:luks-82dce2e7-d80f-4317-a9d9-458ce4bd1e52 root=/dev/mapper/luks-82dce2e7-d80f-4317-a9d9-458ce4bd1e52 apparmor=1 security=apparmor resume=/dev/mapper/luks-dae8d075-4f8e-4bdd-a837-b2e5053c1bf3 udev.log_priority=3
Init system    = systemd 
Boot mode      = UEFI

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 08:03:01,    262 sec(s) ago
Mode           = AC
Power source   = battery

But if I run tlp start it will correctly restart in BAT mode. (PS: TLP is just a side effect it seems as I already purged and reinstalled it with fresh config)

Any ideas where else to look for debugging or even an idea how to fix it? =)

I had a somewhat similar problem - backing to kernel 5.7 fixed it

Have you tried any other kernel since? I mean its a fix - for now, as 5.7 just got declared EOL - but nothing that will last for ever.
I will give 5.4 a try - if that works it will be a pain to find a kernel regression I fear.

Have you explored the possibility of a hardware issue? Maybe seeing if it changes even in system bios with charge/power lights on the system? Different power adapter?

I ask because I had something similar on an Asus Zenbook UX31e and it turned out that I had to replace the barrel jack on the laptop – it was starting to break from such a tiny barrel and the torquing in usage over the years.

Indeed, that was my very first worry as this was why I had to get the T490 in the first place as my T450s experienced a fatality in the power-delivery circuit and did not charge anymore.
I ruled that out, it does charge, it does register the charger (after all after some minutes also the OS does eventually) and if turned off (so only the baseboard controller running) it does as it should, same if kept in the BIOS or in GRUB.

I tried 3 Lenovo OEM USB-C powerbricks, on each of the two avaliable USB-C ports of the machine so can rule a AW fault out as good as I can.

tl;dr - the only obvious differences between working and not working hide here.

The only thing changed between kernels 5.8.5-2 and 5.4.61-1 is in udevadm monitor:

KERNEL[368.816512] change   /devices/platform/USBC000:00/typec/port1 (typec)
KERNEL[368.816544] remove   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
UDEV  [368.820110] change   /devices/platform/USBC000:00/typec/port1 (typec)
UDEV  [368.821909] remove   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)

Alright, now that I am back at the LTS kernel (5.4.61-1) it does work and the outputs are as follows for unplugging AC:

udevadm monitor 
monitor will print the received events for:
UDEV - the event which udev sends out after rule processing
KERNEL - the kernel uevent

KERNEL[368.694774] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
KERNEL[368.816512] change   /devices/platform/USBC000:00/typec/port1 (typec)
KERNEL[368.816544] remove   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
UDEV  [368.820110] change   /devices/platform/USBC000:00/typec/port1 (typec)
UDEV  [368.821909] remove   /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
UDEV  [368.987101] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
KERNEL[369.004287] change   /devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight (backlight)
UDEV  [369.006753] change   /devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight (backlight)
dmesg -w
[  369.433662] ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20190816/psargs-330)
[  369.433688] ACPI Error: Aborting method \_SB.PCI0.LPCB.EC._Q27 due to previous error (AE_NOT_FOUND) (20190816/psparse-529)
journalctl -f
Sep 02 17:24:16 hk-01 kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20190816/psargs-330)
Sep 02 17:24:16 hk-01 kernel: ACPI Error: Aborting method \_SB.PCI0.LPCB.EC._Q27 due to previous error (AE_NOT_FOUND) (20190816/psparse-529)

and for plugging AC back in:

udevadm monitor
KERNEL[459.123779] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
KERNEL[459.275711] change   /devices/platform/USBC000:00/typec/port1 (typec)
KERNEL[459.275782] add      /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
UDEV  [459.281817] change   /devices/platform/USBC000:00/typec/port1 (typec)
UDEV  [459.286295] add      /devices/platform/USBC000:00/typec/port1/port1-partner (typec)
UDEV  [462.492093] change   /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:19/PNP0C09:00/PNP0C0A:00/power_supply/BAT0 (power_supply)
KERNEL[462.513504] change   /devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight (backlight)
UDEV  [462.516600] change   /devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight (backlight)
dmesg -w
[  459.845868] ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20190816/psargs-330)
[  459.845893] ACPI Error: Aborting method \_SB.PCI0.LPCB.EC._Q26 due to previous error (AE_NOT_FOUND) (20190816/psparse-529)
journalctl -f
Sep 02 17:25:47 hk-01 kernel: ACPI BIOS Error (bug): Could not resolve symbol [\_SB.PCI0.RP09.PEGP.NVDN], AE_NOT_FOUND (20190816/psargs-330)
Sep 02 17:25:47 hk-01 kernel: ACPI Error: Aborting method \_SB.PCI0.LPCB.EC._Q26 due to previous error (AE_NOT_FOUND) (20190816/psparse-529)

So it seems as only thing changed is running kernel it lies in there? Anyone any idea how to further debug that? I mean I am not new to Linux but neither a dev…

Hello - its me again. Newest findings after trying around a bit more. The problem is caused by booting without the AC (USB-C) beeing atached to the system.

When the machine boots without the power-brick atached two devices are missing from “gnome-power-statistics”:
line_power_ucsi_source_psy_USBC000o001
and
line_power_ucsi_source_psy_USBC000o002
in that case only

line_power_AC

is present and the change in AC/BAT is not detected.

If these two USB devices are present only the USBC000o002 ever changes its “Online” value to true. The USBC000o001 never changes no mater which of the systems two USBC ports I plug the charger into.