Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLP wrongly running in battery mode on desktop PC #768

Open
alienth opened this issue Oct 29, 2024 · 6 comments
Open

TLP wrongly running in battery mode on desktop PC #768

alienth opened this issue Oct 29, 2024 · 6 comments

Comments

@alienth
Copy link

alienth commented Oct 29, 2024

[x] I've read and accepted the Bug Reporting Howto
[x] I've provided all required tlp-stat outputs via Gist (see below)

Describe the bug

TLP believes I'm running on battery and is enacting battery-mode settings as a result. My desktop PC has no battery. This might be due to my mouse having a battery, which it is detecting.

Initially discovered because my hard disk was spinning down every 15 seconds.

tlp-stat output: https://gist.github.com/alienth/60f3b53004d7849f1906241ec1868550
tlp-stat --psup output: https://gist.github.com/alienth/55ff4f906b5fd1d3e94f1b7ae8e7e819

Expected behavior

TLP should not be detecting me in battery mode when my PC has no battery.

"Works fine" is not enough to analyze the problem!

To Reproduce

Unclear how to reproduce. Probably a combination of specific hardware and my kernel version.

Additional context

Running Ubuntu Oracular, kernel 6.11.0-9-generic, TLP 1.6.1

@alienth
Copy link
Author

alienth commented Oct 29, 2024

Looks similar to #313, which was fixed in 1.1. Maybe a regression but I haven't checked to be sure.

@alienth
Copy link
Author

alienth commented Oct 29, 2024

This is not a regression of #313 - I do happen to have a mouse with a battery, but TLP is rightly excluding that.

What it is reading is the UCSI "power supply", which I'm guessing happens to exist due to the USB-C ports on my motherboard. The type of this power supply is USB, and its online state is 0.

/sys/class/power_supply/ucsi-source-psy-0-00081/type:USB
/sys/class/power_supply/ucsi-source-psy-0-00081/online:0

Because of this, ac0seen gets set to 1, which results in get_sys_power_supply returning 1, which erroneously indicates the system is running on a "battery".

ac0seen=1

TLP/tlp-func-base.in

Lines 933 to 935 in 7ee67a0

if [ "$ac0seen" = "1" ]; then
# AC offline remembered --> battery mode
_syspwr=1

@alienth
Copy link
Author

alienth commented Oct 29, 2024

This is fixable by setting TLP_PS_IGNORE to USB. Wondering if there is some way the logic could be adjusted to handle this correctly by default, though. It would be easily for someone to accidentally end up in this state, leading to performance problems plaguing them with no clear cause.

@alienth
Copy link
Author

alienth commented Oct 29, 2024

Also filed a bug with Ubuntu: https://bugs.launchpad.net/ubuntu/+source/tlp/+bug/2085812

Oracular installs TLP by default, so anyone on an Ubuntu desktop having a UCSI device is likely to be bitten by this.

@alienth
Copy link
Author

alienth commented Oct 29, 2024

Somewhat related symptom here with some discussion of the ucsi-psy driver: https://lore.kernel.org/all/[email protected]/T/

@linrunner
Copy link
Owner

Wondering if there is some way the logic could be adjusted to handle this correctly by default, though.

Unfortunately I am not aware of any magical heuristics that gets along with all the faulty or incomplete ACPI BIOS implementations which cause power source detection problems. That is why TLP_PS_IGNORE remains the method of choice. However, I will gladly accept pull requests ...

A correct BIOS implementation would provide this (via the kernel):

/sys/class/power_supply/AC/type: Mains
/sys/class/power_supply/AC/online: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants