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

RFE: add a 'lower power adapter' mode. #494

Closed
marcmerlin opened this issue May 28, 2020 · 8 comments
Closed

RFE: add a 'lower power adapter' mode. #494

marcmerlin opened this issue May 28, 2020 · 8 comments

Comments

@marcmerlin
Copy link

marcmerlin commented May 28, 2020

Currently, there is a battery mode and AC mode.
On bigger laptops like thinkpad P73, the power adapter is as big as 230W (!)
(this is without counting broken design where the laptop actively tries to reject any power supply smaller than 170W even if it only needs 40W at the moment, details and hardware workaround here: http://marc.merlins.org/perso/electronics/post_2020-05-04_Hacking-Power-Supplies-and-Battery-Pack-To-Get-Around-ThinkPad-P73-Broken-Power-Supply-Design.html )

There is a need where you get external power, but you want to limit use over the charging plug:

  • because you are using an external battery pack
  • because you're plugged into an airplane with limited wattage
  • similarly you're using a car 12V adapter and many cars limit that power to 100W
  • or even you're using a 90W adapter with a laptop that could use 150W or more if it runs at full power and tries to charge the battery.

So, it would be great to have a power mode for 'limited AC draw' to handle any of the cases above. It would be hard to auto detect via udev, but you could just run the command from the command line after plugging in the power supply.

@linrunner
Copy link
Owner

linrunner commented May 28, 2020

Hi,

thanks for your suggestion.

I have no plans to introduce a third power profile besides AC an BAT.

It would require a third line for the majority of settings and in addition, would clutter up the documentation and require really extensive code changes.

By contrast I estimate the number of potential users to be very small, but the impact would affect the whole user base.

Apart from that I have my doubts if an effective solution is possible solely based on kernel settings without supporting changes in Lenovo's firmware. If you look at how Lenovo has (finally) messed up the Intel DPTF topic, there's little hope for that.

@marcmerlin
Copy link
Author

marcmerlin commented May 28, 2020

no problem, I'll just hack up something on my side, thanks for tlp

@marcmerlin
Copy link
Author

marcmerlin commented May 28, 2020

If anyone finds this bug and needs to do the same thing than me, here's what I did

  1. 2 config files with a small diff to force battery mode even when on limited AC and mostly turn off battery charging
  2. ln -snf correctconfig tlp.conf; tlp start

hope this helps someone

sauron:/etc# diff -u tlp.conf.sauron.lowpower tlp.conf.sauron.power
--- tlp.conf.sauron.lowpower	2020-05-31 09:24:55.437014708 -0700
+++ tlp.conf.sauron.power	2020-05-31 08:05:43.779303327 -0700
@@ -33,13 +33,13 @@
 # Concerns some desktop and embedded hardware only.
 # Default: <none>
 
-TLP_DEFAULT_MODE=BAT
+#TLP_DEFAULT_MODE=AC
 
 # Operation mode select: 0=depend on power source, 1=always use TLP_DEFAULT_MODE
 # Note: use in conjunction with TLP_DEFAULT_MODE=BAT for BAT settings on AC.
 # Default: 0
 
-TLP_PERSISTENT_DEFAULT=1
+#TLP_PERSISTENT_DEFAULT=0
 
 # Power supply class to ignore when determining operation mode: AC, BAT.
 # Note: try on laptops where operation mode AC/BAT is incorrectly detected.
@@ -78,9 +78,7 @@
 # Default: <none>
 
 #CPU_SCALING_GOVERNOR_ON_AC=performance
-# TUNE ME to, go faster
-#CPU_SCALING_GOVERNOR_ON_AC=ondemand
-CPU_SCALING_GOVERNOR_ON_AC=powersave
+CPU_SCALING_GOVERNOR_ON_AC=ondemand
 CPU_SCALING_GOVERNOR_ON_BAT=powersave
 
 # Set the min/max frequency available for the scaling governor.
@@ -91,8 +89,7 @@
 #CPU_SCALING_MIN_FREQ_ON_AC=0
 #CPU_SCALING_MAX_FREQ_ON_AC=0
 #CPU_SCALING_MIN_FREQ_ON_BAT=0
-# TUNE ME to, go faster
-CPU_SCALING_MAX_FREQ_ON_AC=1200000
+CPU_SCALING_MAX_FREQ_ON_AC=4800000
 CPU_SCALING_MAX_FREQ_ON_BAT=800000
 
 # Set Intel CPU energy/performance policies HWP.EPP and EPB:
@@ -107,7 +104,8 @@
 # Default: balance_performance (AC), balance_power (BAT)
 
 # FIXME performance for higher perf
-CPU_ENERGY_PERF_POLICY_ON_AC=balance_performance
+#CPU_ENERGY_PERF_POLICY_ON_AC=balance_performance
+CPU_ENERGY_PERF_POLICY_ON_AC=performance
 # FIXME balance-power
 CPU_ENERGY_PERF_POLICY_ON_BAT=power
 
@@ -442,7 +440,7 @@
 # Main / Internal battery (values in %)
 # Default: <none>
 
-START_CHARGE_THRESH_BAT0=05
+START_CHARGE_THRESH_BAT0=75
 STOP_CHARGE_THRESH_BAT0=80
 
 # Ultrabay / Slice / Replaceable battery (values in %)

@linrunner
Copy link
Owner

linrunner commented May 29, 2020

A simpler and (imho) more robust approach (no config change necessary) would be to use manual mode:

tlp bat

This will persist until the next reboot or

tlp start

The charge thresholds may be changed with

tlp setcharge 15 80

linrunner added a commit to linrunner/tlp-doc that referenced this issue May 29, 2020
@marcmerlin
Copy link
Author

marcmerlin commented May 29, 2020

@linrunner I thought about this, but there are 2 issues:

  1. if the laptop is drawing just a bit too much, it will occasionally quick out the power supply and reconnect to it as it recovers, causing power plug/unplug events. This would revert to high power mode until I type 'tlp bat' every time
  2. more of an issue, if the laptop is fully running and tries to charge batteries, it can use over 100W which will instantly reject the power supply that can't keep up, faster than I can type 'tlp bat'
    For one, battery charging cannot be on for any amount of time, of that will cause up to an extra 100W of load as it's a big battery and a fast charger. but even without the battery charging, the laptop will use triple the amount of power if I don't throttle all the chips down.

So basically the 2 config file and symlink trick is the only thing I could get to work.

@linrunner
Copy link
Owner

linrunner commented May 29, 2020

Which TLP version do you use?

Manual mode will survive power unplug/plug events and even a suspend/resume cycle since TLP 1.2.

The same applies to the thresholds unless you configured RESTORE_THRESHOLDS_ON_BAT=1.

@marcmerlin
Copy link
Author

marcmerlin commented May 31, 2020

@linrunner I have 1.3.1-2, but I don't think I was clear, let me explain

  1. I'm on batteries, laptop is happily running with 15W
  2. I plug in a 90W power supply, tlp switches to power mode, spins up all the CPUs, puts the batteries to charging, laptop tries to draw 150W (yes, it does that), power supply fails, dips voltage, laptop goes back on batteries
  3. and it bounces back and forth at 1Hz or more, quicker than I can type 'tlp bat' when on AC mode

the only way around this is to have another power mode that does not spin up everything and take so much power. This is why I made 2 config files with 2 different settings for AC.

@linrunner
Copy link
Owner

linrunner commented Jun 3, 2020

I think you'd best try what I suggested, step by step:

  1. You're on battery, TLP is in auto mode, BAT profile is active

  2. You select manual mode with

    sudo tlp bat
    
  3. You plugin the 90W power supply

  4. Because TLP is in manual mode, BAT profile sticks (until reboot or tlp start)

https://linrunner.de/tlp/usage/tlp.html#battery-mode

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