Bug 440609 - Powerdevil sometimes does not notice that my laptop has been cut from the power supply and runs on battery
Summary: Powerdevil sometimes does not notice that my laptop has been cut from the pow...
Status: RESOLVED DUPLICATE of bug 423556
Alias: None
Product: Powerdevil
Classification: Plasma
Component: general (show other bugs)
Version: 5.22.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-04 20:40 UTC by postix
Modified: 2022-01-30 01:51 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
udevadm monitor -k (7.12 KB, text/plain)
2021-08-05 16:06 UTC, postix
Details
udevadm monitor -k (7.20 KB, text/plain)
2021-08-05 16:08 UTC, postix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2021-08-04 20:40:48 UTC
SUMMARY

Running Fedora 34 powerdevil does not always notice that I have unplugged my Thinkpad X1 Gen5.
If I notice this issue myself, it helps by re-plugging the cable in and de-attaching it again.

I would like to help you with more information if you let me know what you need and how I can retrieve it for you to debug this issue further.


SOFTWARE/OS VERSIONS
Operating System: Fedora 34
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.84.0
Qt Version: 5.15.2
Kernel Version: 5.13.5
Graphics Platform: X11
Comment 1 postix 2021-08-05 15:28:13 UTC
I have tried to trigger it again and watched journalctl's output, maybe it gives a clue:

```
--> Unplug

No log. Displays "on Battery"

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

--> Plug in

Aug 05 16:21:12 fedora kernel: ucsi_acpi USBC000:00: UCSI_GET_PDOS failed (-95)

Displays "AC power connected"

-----------------------------------------------------------------------------------------
--> Unplug
No log. Displays "on Battery"
-----------------------------------------------------------------------------------------
--> Plug in

Aug 05 16:22:35 fedora systemd[1]: Started dbus-:1.10-org.kde.powerdevil.backlighthelper@9.service.
Aug 05 16:22:35 fedora audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@9 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:22:36 fedora kernel: ucsi_acpi USBC000:00: UCSI_GET_PDOS failed (-95)
Aug 05 16:22:45 fedora systemd[1]: dbus-:1.10-org.kde.powerdevil.backlighthelper@9.service: Deactivated successfully.
Aug 05 16:22:45 fedora audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@9 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

Displays "AC power connected"
-----------------------------------------------------------------------------------------
--> Unplug

Aug 05 16:24:30 fedora kernel: ucsi_acpi USBC000:00: UCSI_GET_PDOS failed (-95)

Displays "AC power connected"

--> AFTER A MINUTE

Aug 05 16:25:07 fedora kwin_x11[3102]: qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 65032, resource id: 85983243, major code: 18 (ChangeProperty), minor code: 0
Aug 05 16:25:51 fedora systemd[1]: Started dbus-:1.10-org.kde.powerdevil.backlighthelper@12.service.
Aug 05 16:25:51 fedora audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@12 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:26:00 fedora systemd[1]: dbus-:1.10-org.kde.powerdevil.backlighthelper@12.service: Deactivated successfully.
Aug 05 16:26:00 fedora audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@12 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:26:06 fedora systemd[1]: Started dbus-:1.10-org.kde.powerdevil.backlighthelper@13.service.
Aug 05 16:26:06 fedora audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@13 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:26:15 fedora systemd[1]: dbus-:1.10-org.kde.powerdevil.backlighthelper@13.service: Deactivated successfully.
Aug 05 16:26:15 fedora audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@13 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:26:21 fedora systemd[1]: Started dbus-:1.10-org.kde.powerdevil.backlighthelper@14.service.
Aug 05 16:26:21 fedora audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@14 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:26:30 fedora systemd[1]: dbus-:1.10-org.kde.powerdevil.backlighthelper@14.service: Deactivated successfully.
Aug 05 16:26:30 fedora audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@14 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Aug 05 16:26:38 fedora systemd[1]: Started dbus-:1.10-org.kde.powerdevil.backlighthelper@15.service.
Aug 05 16:26:38 fedora audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@15 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

Aug 05 16:26:48 fedora systemd[1]: dbus-:1.10-org.kde.powerdevil.backlighthelper@15.service: Deactivated successfully.
Aug 05 16:26:48 fedora audit[1]: SERVICE_STOP pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='unit=dbus-:1.10-org.kde.powerdevil.backlighthelper@15 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'

---> Displays "On Battery"
```
Comment 2 Nate Graham 2021-08-05 15:36:48 UTC
Is it 100% reproducible when you unplug your laptop while it's asleep/suspended? If so, then it's a kernel bug: https://bugzilla.kernel.org/show_bug.cgi?id=210425
Comment 3 postix 2021-08-05 15:40:06 UTC
(In reply to Nate Graham from comment #2)
> Is it 100% reproducible when you unplug your laptop while it's
> asleep/suspended? If so, then it's a kernel bug:
> https://bugzilla.kernel.org/show_bug.cgi?id=210425

Nope, it happens too, when it's suspended, but it's not 100% reproducible unfortunately.
Comment 4 Nate Graham 2021-08-05 15:43:44 UTC
You mean, it also happens then it's *not* suspended as well?
Comment 5 postix 2021-08-05 15:44:51 UTC
(In reply to Nate Graham from comment #4)
> You mean, it also happens then it's *not* suspended as well?

Right! It also happens while I am working or the system is idling but not suspended.
Comment 6 postix 2021-08-05 15:48:14 UTC
(Sorry, I wish I could edit messages here as sometimes something comes to my mind a moment later after I have posted already.)


Nonetheless, I feel you may be right and it's likely to be a Kernel bug and Plasma/powerdevil cannot do anything about it. I may report it at bugzilla.kernel.org too.
Comment 7 postix 2021-08-05 16:06:12 UTC
Created attachment 140547 [details]
udevadm monitor -k

The Kernel is obviously always notified about changes to the power supply, even when the bug happens.
Comment 8 postix 2021-08-05 16:08:21 UTC
Created attachment 140548 [details]
udevadm monitor -k
Comment 9 Nate Graham 2021-08-17 21:33:21 UTC
Thanks for the info. I'm a bit out of my depth here, but does that mean that you think the kernel and udev are doing their part and the problem is in powerdevil?
Comment 10 postix 2021-08-18 10:30:09 UTC
(In reply to Nate Graham from comment #9)
> Thanks for the info. I'm a bit out of my depth here,
Unfortunately, me too at the moment!

> but does that mean that
> you think the kernel and udev are doing their part and the problem is in powerdevil?

Could be, but I will have to investigate more in depth next month, when I have more leisure time.
Anyway, I will come back to it and adjust the bug report accordingly.
Comment 11 Méven Car 2021-10-20 09:44:06 UTC
Powerdevil does not handle directly battery state monitoring and relies on upower to do that.

You can compare your results with "upower -d" and "upower -m" (monitor), and probably can report a bug there.

https://gitlab.freedesktop.org/upower/upower/-/issues/22 seems like a good candidate.

For reference we had a similar bug considered to be an upstream bug.
https://bugs.kde.org/show_bug.cgi?id=423556

But it seems upstream upower could benefit from your help in diagnosing the bug.
Comment 12 Méven Car 2021-10-20 09:44:52 UTC
(In reply to Méven Car from comment #11)
> Powerdevil does not handle directly battery state monitoring and relies on
> upower to do that.
> 
> You can compare your results with "upower -d" and "upower -m" (monitor), and
> probably can report a bug there.
> 
> https://gitlab.freedesktop.org/upower/upower/-/issues/22 seems like a good
> candidate.

https://gitlab.freedesktop.org/upower/upower/-/issues/126 is a better issue to work with.
Comment 13 Méven Car 2021-10-20 09:48:07 UTC
Git commit 01df6cf933c1a48928ff72af7cb520183130ff05 by Méven Car.
Committed on 20/10/2021 at 09:47.
Pushed by meven into branch 'master'.

Applet batteryMonitor: Hide applet only when Fully charged and plugged in

M  +1    -1    applets/batterymonitor/package/contents/ui/batterymonitor.qml

https://invent.kde.org/plasma/plasma-workspace/commit/01df6cf933c1a48928ff72af7cb520183130ff05
Comment 14 Méven Car 2021-10-20 09:52:33 UTC
Comment at is most relevant.
https://gitlab.freedesktop.org/upower/upower/-/issues/126#note_696455
Comment 15 postix 2021-10-20 13:07:19 UTC
Thank you Méven, I will look into the upstream discussions on freedesktop.org.
Comment 16 Nicolas Fella 2021-12-22 20:42:48 UTC

*** This bug has been marked as a duplicate of bug 423556 ***
Comment 17 sai 2022-01-30 01:48:47 UTC
Is this issue resolved? I still face this bug, and it makes it difficult as now the laptop does not suspend when I close the lid as it thinks it is plugged in. Could anyone please comment on whether this is resolved

Thanks!
Comment 18 Nate Graham 2022-01-30 01:51:58 UTC
It's the same issue as Bug 423556, which is an upstream issue. See https://gitlab.freedesktop.org/upower/upower/-/issues/126.

See also https://community.kde.org/Get_Involved/Issue_Reporting#Understand_what_the_resolution_statuses_mean

*** This bug has been marked as a duplicate of bug 423556 ***