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

[Dell] Battery Care (as of Linux 6.12) #379

Open
hyperfekt opened this issue Jan 9, 2019 · 60 comments
Open

[Dell] Battery Care (as of Linux 6.12) #379

hyperfekt opened this issue Jan 9, 2019 · 60 comments

Comments

@hyperfekt
Copy link

hyperfekt commented Jan 9, 2019

EDIT by @linrunner

The wait is over: an initial version of the Dell plugin is ready to test.
[EDIT] Kernel 6.12 is required.
Testing instructions -> #379 (comment)

===============================================================================================
My understanding is that currently only ThinkPad devices have advanced battery features available, due to the existence of tp_smapi.
For Dell devices there exists the 'Dell Command | Configure' which appears to provide similar functionality in regards to battery management, for example running off AC power and express charging, even though the interface is rather suboptimal.
That's all the more reason to build a tool for it, but the question is if it should be this one.

@linrunner
Copy link
Owner

These are Windows binaries, dear. If you want things moving, implement a kernel interface e.g. driver for your hardware. See: #321

@hyperfekt
Copy link
Author

I'm afraid you are mistaken, there are Linux binaries available as well: https://www.dell.com/support/article/us/en/04/sln311302/dell-command-configure?lang=en

@linrunner
Copy link
Owner

linrunner commented Jan 20, 2019

I see.

--PrimaryBattChargeCfg seems do to charge thresholds. Did you spot something like force_discharge (for recalibration)?

Contras:

  • I didn't see source downloads and there are binary packages for Ubuntu 16.04 and RHEL 6/7 only.
  • I won't call a closed source tool from inside TLP and would still prefer using the generic kernel interface mentioned above.

@linrunner linrunner changed the title advanced battery features for dell devices Advanced battery features for Dell devices Jan 20, 2019
@linrunner
Copy link
Owner

linrunner commented Mar 7, 2019

Yesterday I stumbled over smbios-utils: https://github.com/dell/libsmbios/ Any volunteers to check out and document how to use it? Command line args are a bit cryptic.

ps. I don't have Dell hardware within reach.

@spockfish
Copy link

My daily machine is a Dell XPS running openSUSE with TLP. So what do you exactly need?

@linrunner
Copy link
Owner

linrunner commented Apr 3, 2019

General question: are Dell battery features similar enough to the ThinkPad approach so one can integrate them into the existing TLP commands (setcharge/discharge/recalibrate):

  • What are the exact commands (with binary path) to set the start and stop threshold?
  • Valid ranges for the threshold values/parameters?
  • How to read back actual threshold values from the firmware
  • What is the exact command to check Dell battery features are actually supported on a laptop?
  • Is there a command to discharge a battery while AC is connected?
  • How to select primary / secondary battery in the above commands on Dell laptops (if dual batteries models exist)?

@spockfish
Copy link

Ok. I've got the latest smbios installed. It's shipped with openSUSE, so that's the good news. The bad news is that I get nothing out of it. For example, a 'sudo smbios-battery-ctl --battery-charge' results in this:

Libsmbios version : 2.4.2
smbios-battery-ctl version : 2.4.2
 
 Supported battery charging features: 
         NIL
 
 Battery charging Status: 
         NIL

No difference what so ever with AC plugged in or not. So I'm not sure if this libsmbios is actually bringing something to the table...

@linrunner
Copy link
Owner

Dead end? Just for the record: could you post the output of

tlp-stat -s

@marmistrz
Copy link

marmistrz commented May 26, 2019

As for the first three points: the relevant option is described in the manual here
As for the last two points, I can't find anything that would allow it.

I'm also getting NILs from smbios, I'm going to report it in the libsmbios repository.

In any case, smbios-battery-ctl is pretty low-level could do the trick, but on the other hand, I'm not sure if it wouldn't conflict with the BIOS settings.

$ tlp-stat -s                                                                              
--- TLP 1.2.2 --------------------------------------------

+++ System Info
System         = Dell Inc.  Vostro 3580
BIOS           = 1.0.0
Kernel         = 4.19.45-1-lts #1 SMP Wed May 22 13:02:41 CEST 2019 x86_64
/proc/cmdline  = BOOT_IMAGE=/vmlinuz-linux-lts <mount-related options>
Init system    = systemd 
Boot mode      = UEFI

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 02:29:23,      8 sec(s) ago
Mode           = battery
Power source   = battery

@linrunner
Copy link
Owner

linrunner commented May 28, 2019

Thanks. Just for the record:

cctk --PrimaryBattChargeCfg=Custom:50-70

@marmistrz
Copy link

marmistrz commented May 28, 2019

/remark: the reply was substantially edited

On the other hand, I have second thoughts about introducing a proprietary opt-dependency to tlp.

It appears that smbios already exposes the API using the low-level token API: token_list.csv
Still

# smbios-token-ctl -i 0x0349

prints the token as a bool, which is clearly invalid

================================================================================
  Token: 0x0349 - Primary Battery Custom Charge Start (NA)
  value: bool = false
   Desc: Sets the percentage value at which the battery charging will start Impl
         ementation Note: This field must be in the range [50, 95] with a step v
         alue of 1 and at least 5% less than Primary Custom Charge End

Trying to access the token directly using the Python bindings is weird but feasible - they numeric values are encoded as 2-byte little-endian integers.

# ipython
In [1]: from libsmbios_c import smbios_token                                                                                                                                                  
In [2]: t = smbios_token.TokenTable()  
In [3]: tok = t[0x0349]       
In [7]: tok.getString()                                                                                                                                                                       
Out[7]: b'2\x00'
In [9]: tok.getType()                                                                                                                                                                         
Out[9]: 218
In [10]: tok.isBool()             # What the hell?                                                                                                                                                              
Out[10]: True
In [11]: tok.isString()                                                                                                                                                                       
Out[11]: True 
In [20]: int.from_bytes(tok.getString(), "little")                                                                                                                                      
Out[20]: 50
In [21]: int.from_bytes(t[0x034A].getString(), "little")                                                                                                                                      
Out[21]: 90

Probably the best idea would be to contribute the API to smbios-battery-ctl and only use the shell tool through tlp.

While I can't guarantee code contributions to this one (I'll see what I can do), I can promise I'll test the changes related to power-management on Dell laptops.

For reference, here's the issue about smbios-battery-ctl returning NILs: dell/libsmbios#71

@linrunner
Copy link
Owner

linrunner commented May 29, 2019

However, i'm not going to include code that calls a proprietary tool.

ps. and i would definitely prefer a kernel solution that uses the natacpi framework laid out in #321.

@marmistrz
Copy link

marmistrz commented May 29, 2019

On the other hand, I have second thoughts about introducing a proprietary opt-dependency to tlp.

However, i'm not going to include code that calls a proprietary tool.
ps. and i would definitely prefer a kernel solution that uses the natacpi framework laid out in #321.

What I meant was that cctk is proprietary and that I think it may be a bad idea to depend on it ;) It's great that we agree on this. :)

So we can either use libsmbios (GPL2) or natacpi. It looks like I've already solved the major obstacles, so I think I can extend smbios-battery-ctl to support PrimaryBatteryChargeCfg during the weekend.

I won't be able to help with natacpi in any other way than testing. You may consider contacting the Dell developers. (I'm not affiliated with Dell in any way, I'm just using a laptop produced by the company)

@marmistrz
Copy link

@linrunner let me know if you're ok with this CLI

@marmistrz
Copy link

@linrunner the pull request to dell/libsmbios has been merged. You can now use it to implement tlp fullcharge and tlp setcharge on Dell laptops.

@linrunner
Copy link
Owner

OK, then let's get started.

I'll need a bit more than just the description of the CLI because the routines in func.d/35-tlp-func-batt do a lot of checks before actually writing anything - and I don't have the hardware of course ...

I need the exact commands and their corresponding outputs / return codes for the following:

(1) Is libsmbios installed and is it supporting the new CLI?

OK, i'll guess we just have to check for smbios-battery-ctl in the PATH.

(2) Does the laptop actually support thresholds?

(3) Reading the thresholds

(4) Writing the thresholds (+ what happens with invalid param values?)

(5) Checking for batteries: are Dell laptops BAT0 only or are there models with two batteries?

For reference: I'll call the feature dellsm in TLP.

@userofryzen
Copy link

What happened here? I was very interested in this work as I am thinking in buying a dell device

@awehrfritz
Copy link

awehrfritz commented Jan 15, 2020

For reference: I'll call the feature dellsm in TLP.

@linrunner and @marmistrz: did you start implementing this somewhere? For instance, is there a branch that contains the initial pluming for using smbios rather than one of the kernel modules?

I have a Dell Latitude laptop that supports setting the thresholds in the bios or via the cctk utility and I would be interested in getting this to work in TLP.

@marmistrz
Copy link

marmistrz commented Jan 15, 2020

Sorry, I completely forgot about it. Unfortunately, smbios didn't have a new release after my changes accepted, so you need to patch smbios-battery-ctl manually.

OK, then let's get started.

I'll need a bit more than just the description of the CLI because the routines in func.d/35-tlp-func-batt do a lot of checks before actually writing anything - and I don't have the hardware of course ...

I need the exact commands and their corresponding outputs / return codes for the following:

(1) Is libsmbios installed and is it supporting the new CLI?
OK, i'll guess we just have to check for smbios-battery-ctl in the PATH.

You can probably grep smbios-battery-ctl --help

(2) Does the laptop actually support thresholds?

I don't know, but I guess that smbios-battery-ctl would return an error

(3) Reading the thresholds

smbios-battery-ctl --get-charging-cfg

(4) Writing the thresholds (+ what happens with invalid param values?)

smbios-battery-ctl --set-charging-mode X
smbios-battery-ctl --set-custom-charge-interval low high

I don't know what happens if params are invalid.

(5) Checking for batteries: are Dell laptops BAT0 only or are there models with two batteries?

No idea. For all those things I don't know about it's probably best to ask in dell/libsmbios (e.g. through github issues)

See also this fragment from --help.

  --get-charging-cfg    Get the current Primary Battery Charge Configuration
  --set-charging-mode=<MODE>
                        Set the current Primary Battery Charge Configuration.
                        Valid choices are: ['primarily_ac', 'adaptive',
                        'custom', 'standard', 'express']
  --set-custom-charge-interval=<START> <END>
                        Set the percentage bounds for custom charge. Both must
                        be integers. START must lie in the range [50, 95], END
                        must lie in the range [55, 100], END must be at least
                        (START + 5)

@linrunner
Copy link
Owner

I have no plans to implement this myself. Reasons are:

  1. It's hopeless without a Dell laptop at hand for try and error
  2. I've not enough time

@linrunner
Copy link
Owner

linrunner commented Oct 1, 2024

Will be released with [EDIT] 6.12 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86/dell?id=ab58016c68cc5b8c3622e38b7db64994e4833d9f

Anybody willing to test if I supply a plugin?

@AkechiShiro
Copy link

AkechiShiro commented Oct 1, 2024

Will see if I can test, thanks a lot for the work done here

EDIT: Sorry read your message a little too fast, I skipped that you needed to write a plugin, will wait for it, thanks !

@linrunner
Copy link
Owner

@AkechiShiro Wait a minute. I have to write the plugin first. Stay tuned and thanks for your help.

@linrunner
Copy link
Owner

@AkechiShiro I would need the output of tlp-stat -s -b. Thanks.

@AkechiShiro
Copy link

AkechiShiro commented Oct 4, 2024

Under Linux 6.11's kernel right ?

EDIT : Is there a specific commit I should use to build tlp befire running this command ?

I'm aware the command is working on the latest release
@linrunner

I'll upload the output from the release I have installed at the moment, if that is enough, I'll let you check

@linrunner
Copy link
Owner

linrunner commented Oct 4, 2024

@AkechiShiro if you already run 6.11 then I'd prefer

 grep . /sys/class/power_supply/BAT?/*

Otherwise

tlp-stat -s -b

suffices atm.

@linrunner
Copy link
Owner

@AkechiShiro You shall/need not build anything atm. Just show the output requested above, works with any recent TLP version. I just need some facts about Dell laptops. Thanks.

@AkechiShiro
Copy link

AkechiShiro commented Oct 4, 2024

Here is the output :

--- TLP 1.6.1 --------------------------------------------

+++ System Info
System = Dell Inc. Latitude 5320
BIOS = 1.38.0
OS Release = NixOS 24.05 (Uakari)
Kernel = 6.6.51 #1-NixOS SMP PREEMPT_DYNAMIC Thu Sep 12 09:11:45 UTC 2024 x86_64
/proc/cmdline = init=/nix/store/qzl0q13j9xljfkil8qsam3h9jba0z6f8-nixos-system-hostname-24.05.4997.086b448a5d54/init root=fstab loglevel=4
Init system = systemd
Boot mode = UEFI
Suspend mode = [s2idle]

+++ TLP Status
State = disabled
RDW state = not installed
Last run = unknown
Mode = unknown
Power source = AC

+++ Battery Care
Plugin: generic
Supported features: none available

+++ Battery Status: BAT0
/sys/class/power_supply/BAT0/manufacturer = SWD-ATL4.175
/sys/class/power_supply/BAT0/model_name = DELL 1PP6312
/sys/class/power_supply/BAT0/cycle_count = 0 (or not supported)
/sys/class/power_supply/BAT0/charge_full_design = 4077 [mAh]
/sys/class/power_supply/BAT0/charge_full = 1937 [mAh]
/sys/class/power_supply/BAT0/charge_now = 1937 [mAh]
/sys/class/power_supply/BAT0/current_now = 1 [mA]
/sys/class/power_supply/BAT0/status = Full

/sys/class/power_supply/BAT0/charge_control_start_threshold = (not available)
/sys/class/power_supply/BAT0/charge_control_end_threshold = (not available)

Charge = 100.0 [%]
Capacity = 47.5 [%]

linrunner added a commit that referenced this issue Oct 4, 2024
    * Supports Dell laptops
    * Requires dell_laptop module as of Linux 6.11
    * Start and stop threshold
    * Force discharge not supported

    * charge_control_start_threshold:
      - Valid values: 50..95
      - Default value: 95

    * charge_control_end_threshold:
      - Valid values: 55..100
      - Default value: 100

References:
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86/dell?id=ab58016c68cc5b8c3622e38b7db64994e4833d9f
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/x86/dell/dell-laptop.c
* #379 (comment)
@linrunner
Copy link
Owner

linrunner commented Oct 4, 2024

The wait is over: an initial version of the Dell plugin is ready to test.

[EDIT] Kernel 6.12 is required.

For the test you either need TLP 1.7.0, supplemented by the download of /usr/share/tlp/bat.d/65-dell, or you can build a package for your distribution based on [EDIT] main branch (Arch users may use tlp-git from AUR).

I need at least the output of

sudo tlp-stat -s -b -v

Please also run the automatic test script (with sudo or as root) and show the output:
unit-tests/charge-thresholds_dell -- Note: charge-thresholds_dell-simulate is not meant.

It requires the tool clitest to be installed. Should be available as a package in most distributions.

@hyperfekt @cheng3100 @gagath @marmistrz @awehrfritz @zalaps @spockfish @raduburla @AkechiShiro

@linrunner
Copy link
Owner

@AkechiShiro Is something keeping you from testing?

@serycjon
Copy link

serycjon commented Oct 6, 2024

Hi, here are my outputs.

tlp-stat results
--- TLP 1.7.0 --------------------------------------------

+++ System Info
System         = Dell Inc.  Latitude 5491
BIOS           = 1.15.0
OS Release     = Arch Linux
Kernel         = 6.11.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 30 Sep 2024 23:49:50 +0000 x86_64
/proc/cmdline  = BOOT_IMAGE=/boot/vmlinuz-linux root=UUID=d8c139f4-1622-47b9-8e7c-f927e363cc0a rw loglevel=3 quiet
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = s2idle [deep]

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = 02:17:27 PM, 308 sec(s) ago
Mode           = AC
Power source   = AC

+++ Battery Care
Plugin: dell
Supported features: none available
Driver usage:
* natacpi (dell_laptop) = inactive (laptop not supported)

+++ Battery Status: BAT0
/sys/class/power_supply/BAT0/manufacturer                   = SMP
/sys/class/power_supply/BAT0/model_name                     = DELL GD1JP65
/sys/class/power_supply/BAT0/cycle_count                    =      0 (or not supported)
/sys/class/power_supply/BAT0/charge_full_design             =   8947 [mAh]
/sys/class/power_supply/BAT0/charge_full                    =   7284 [mAh]
/sys/class/power_supply/BAT0/charge_now                     =   5629 [mAh]
/sys/class/power_supply/BAT0/current_now                    =      1 [mA]
/sys/class/power_supply/BAT0/status                         = Not charging

Charge                                                      =   77.3 [%]
Capacity                                                    =   81.4 [%]

unit test results
#1	# +++ Dell laptops +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#2	#
#3	# --- tlp start
#4	sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#5	sudo tlp start -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#6	sudo tlp start -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #6, line 16] sudo tlp start -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration at START_CHARGE_THRESH_BAT0="100": not specified, invalid or out of range (50..95). Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#7	sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #7, line 19] sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="0": not specified, invalid or out of range (55..100). Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#8	sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #8, line 22] sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="101": not specified, invalid or out of range (55..100). Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#9	sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #9, line 25] sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1 @@
-Error in configuration: START_CHARGE_THRESH_BAT0 > STOP_CHARGE_THRESH_BAT0 - 5. Battery skipped.
 TLP started in AC mode (auto).
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#10	sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#11	sudo tlp start -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#12	sudo tlp start -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#13	#
#14	# --- tlp setcharge w/o arguments
#15	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" X_SOC_CHECK=0
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #15, line 36] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" X_SOC_CHECK=0
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  start =  60
-  stop  = 100 (no change)
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#16	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #16, line 40] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100"
@@ -1 +1 @@
-Error in configuration at START_CHARGE_THRESH_BAT0="100": not specified, invalid or out of range (50..95). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#17	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #17, line 42] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0"
@@ -1 +1 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="0": not specified, invalid or out of range (55..100). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#18	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #18, line 44] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101"
@@ -1 +1 @@
-Error in configuration at STOP_CHARGE_THRESH_BAT0="101": not specified, invalid or out of range (55..100). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#19	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #19, line 46] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91"
@@ -1 +1 @@
-Error in configuration: START_CHARGE_THRESH_BAT0 > STOP_CHARGE_THRESH_BAT0 - 5. Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#20	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #20, line 48] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  start =  90
-  stop  =  95
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#21	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #21, line 52] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  start =  90 (no change)
-  stop  =  95 (no change)
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#22	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #22, line 56] sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  stop  = 100
-  start =  95
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#23	sudo tlp setcharge -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#24	#
#25	# --- tlp setcharge w/ arguments
#26	sudo tlp setcharge 60 100 -- X_SOC_CHECK=0
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #26, line 64] sudo tlp setcharge 60 100 -- X_SOC_CHECK=0
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  start =  60
-  stop  = 100 (no change)
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#27	sudo tlp setcharge 100 100 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #27, line 68] sudo tlp setcharge 100 100 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: start charge threshold (100) for BAT0 is not specified, invalid or out of range (50..95). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#28	sudo tlp setcharge 50 0 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #28, line 70] sudo tlp setcharge 50 0 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: stop charge threshold (0) for BAT0 is not specified, invalid or out of range (55..100). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#29	sudo tlp setcharge 50 101 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #29, line 72] sudo tlp setcharge 50 101 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: stop charge threshold (101) for BAT0 is not specified, invalid or out of range (55..100). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#30	sudo tlp setcharge XYZZY 0 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #30, line 74] sudo tlp setcharge XYZZY 0 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: start charge threshold (XYZZY) for BAT0 is not specified, invalid or out of range (50..95). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#31	sudo tlp setcharge 50 XYZZY -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #31, line 76] sudo tlp setcharge 50 XYZZY -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: stop charge threshold (XYZZY) for BAT0 is not specified, invalid or out of range (55..100). Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#32	sudo tlp setcharge 90 91 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #32, line 78] sudo tlp setcharge 90 91 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: start threshold > stop threshold - 5 for BAT0. Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#33	sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #33, line 80] sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  start =  90
-  stop  =  95
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#34	sudo tlp setcharge 90 95 -- X_THRESH_SIMULATE_READERR="1"
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #34, line 84] sudo tlp setcharge 90 95 -- X_THRESH_SIMULATE_READERR="1"
@@ -1 +1 @@
-Error: could not read current charge threshold(s) for BAT0. Aborted.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#35	sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #35, line 86] sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  start =  90 (no change)
-  stop  =  95 (no change)
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#36	sudo tlp setcharge DEF DEF -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #36, line 90] sudo tlp setcharge DEF DEF -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1,3 +1 @@
-Setting temporary charge thresholds for BAT0:
-  stop  = 100
-  start =  95
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#37	sudo tlp setcharge BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #37, line 94] sudo tlp setcharge BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: battery BAT1 not present.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#38	sudo tlp setcharge 0 3 BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #38, line 96] sudo tlp setcharge 0 3 BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: battery BAT1 not present.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#39	sudo tlp setcharge XYZZY ABCDE BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #39, line 98] sudo tlp setcharge XYZZY ABCDE BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
@@ -1 +1 @@
-Error: battery BAT1 not present.
+Error: battery charge thresholds not available.
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#40	#
#41	# --- tlp-stat
#42	sudo tlp-stat -b | grep -E 'charge_(control|behaviour)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #42, line 102] sudo tlp-stat -b | grep -E 'charge_(control|behaviour)'
@@ -1,2 +0,0 @@
-/sys/class/power_supply/BAT0/charge_control_start_threshold =     95 [%]
-/sys/class/power_supply/BAT0/charge_control_end_threshold   =    100 [%]
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#43	sudo tlp-stat -b -- X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #43, line 105] sudo tlp-stat -b -- X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
@@ -1,2 +0,0 @@
-/sys/class/power_supply/BAT0/charge_control_start_threshold = (not available) [%]
-/sys/class/power_supply/BAT0/charge_control_end_threshold   = (not available) [%]
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#44	#
#45	# --- Reset test machine to configured thresholds
#46	sudo tlp setcharge BAT0  > /dev/null 2>&1
#47	#

FAIL: 28 of 47 tests failed

@linrunner
Copy link
Owner

linrunner commented Oct 6, 2024

@serycjon thanks for testing.

Something fundamental seems to be missing. The sources of the driver say something about an attribute charge_types and custom charging mode. Please show:

grep . /sys/class/power_supply/BAT0/* 2> /dev/null | grep -v uevent

@serycjon
Copy link

serycjon commented Oct 6, 2024

I didn't do anything except what was mentioned in #379 (comment)
Maybe I need to first enable some driver?

Output of grep . /sys/class/power_supply/BAT0/* 2> /dev/null | grep -v uevent:

/sys/class/power_supply/BAT0/alarm:0
/sys/class/power_supply/BAT0/capacity:77
/sys/class/power_supply/BAT0/capacity_level:Normal
/sys/class/power_supply/BAT0/charge_full:7284000
/sys/class/power_supply/BAT0/charge_full_design:8947000
/sys/class/power_supply/BAT0/charge_now:5627000
/sys/class/power_supply/BAT0/current_now:1000
/sys/class/power_supply/BAT0/cycle_count:0
/sys/class/power_supply/BAT0/manufacturer:SMP
/sys/class/power_supply/BAT0/model_name:DELL GD1JP65
/sys/class/power_supply/BAT0/present:1
/sys/class/power_supply/BAT0/serial_number:3356
/sys/class/power_supply/BAT0/status:Not charging
/sys/class/power_supply/BAT0/technology:Li-poly
/sys/class/power_supply/BAT0/type:Battery
/sys/class/power_supply/BAT0/voltage_min_design:7600000
/sys/class/power_supply/BAT0/voltage_now:8206000

@linrunner
Copy link
Owner

The necessary module dell_laptop is loaded, otherwise the plugin would not be activated at all. I will email the kernel dev.

@linrunner
Copy link
Owner

linrunner commented Oct 6, 2024

Oops. I think I was wrong about the kernel version in which the feature is merged. Seems to be coming with 6.12:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86/dell?id=84bbfe6b6435658132df2880258d34babe46d3e0

Then we'll just have to wait. Unless you want to install an 6.12-rc1.

@AkechiShiro
Copy link

AkechiShiro commented Oct 6, 2024

Sorry @linrunner, I just couldn't find the time to test yet, I will probably wait for 6.12 as well

@serycjon
Copy link

serycjon commented Oct 7, 2024

@linrunner I have never tweaked with kernel, so I will probably wait. The 6.12 will be probably released quite soon - maybe in a month or so? Judging only from the historical data (https://en.wikipedia.org/wiki/Linux_kernel_version_history#Releases_6.x.y).

@linrunner linrunner changed the title [Dell] Battery Wear Control [Dell] Battery Care (as of Linux 6.12) Oct 10, 2024
@langemar
Copy link

Hi,
as fedora rawhide provides a suitable kernel for testing I gave it a shot. Please let me know if I can provide further information.

best regrads
markus

# tlp-stat -s -b
root@localhost-live:~/TLP-1.7.0# tlp-stat -s -b
--- TLP 1.7.0 --------------------------------------------

+++ System Info
System         = Dell Inc.  Latitude 3450
BIOS           = 1.8.0
EC Firmware    = 1.5
OS Release     = Fedora Linux 42 (Workstation Edition Prerelease)
Kernel         = 6.12.0-0.rc4.20241025gitae90f6a6170d.42.fc42.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Oct 25 15:16:46 UTC 2024 x86_64
/proc/cmdline  = BOOT_IMAGE=/images/pxeboot/vmlinuz root=live:CDLABEL=Fedora-WS-Live-rawh-20241027-n-0 rd.live.image rd.live.check quiet
Init system    = systemd 
Boot mode      = UEFI
Suspend mode   = [s2idle]
SELinux status = enabled (enforcing)

+++ TLP Status
State          = enabled
RDW state      = enabled
Last run       = unknown
Mode           = unknown
Power source   = AC

Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.

+++ Battery Care
Plugin: dell
Supported features: charge thresholds
Driver usage:
* natacpi (dell_laptop) = active (charge thresholds)
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  50..95(default)
* STOP_CHARGE_THRESH_BAT0/1:   55..100(default)

+++ Battery Status: BAT0
/sys/class/power_supply/BAT0/manufacturer                   = BYD
/sys/class/power_supply/BAT0/model_name                     = DELL 7RDGP45O
/sys/class/power_supply/BAT0/cycle_count                    =      2
/sys/class/power_supply/BAT0/charge_full_design             =   3685 [mAh]
/sys/class/power_supply/BAT0/charge_full                    =   3685 [mAh]
/sys/class/power_supply/BAT0/charge_now                     =   2926 [mAh]
/sys/class/power_supply/BAT0/current_now                    =      1 [mA]
/sys/class/power_supply/BAT0/status                         = Not charging

/sys/class/power_supply/BAT0/charge_control_start_threshold =     60 [%]
/sys/class/power_supply/BAT0/charge_control_end_threshold   =     80 [%]
/sys/class/power_supply/BAT0/charge_types                   = Trickle Fast Standard Adaptive [Custom] [%]

Charge                                                      =   79.4 [%]
Capacity                                                    =  100.0 [%]
# grep . /sys/class/power_supply/BAT0/* 2> /dev/null | grep -v ueven
root@localhost-live:~/TLP-1.7.0# grep . /sys/class/power_supply/BAT0/* 2> /dev/null | grep -v ueven
/sys/class/power_supply/BAT0/alarm:368000
/sys/class/power_supply/BAT0/capacity:79
/sys/class/power_supply/BAT0/capacity_level:Normal
/sys/class/power_supply/BAT0/charge_control_end_threshold:80
/sys/class/power_supply/BAT0/charge_control_start_threshold:60
/sys/class/power_supply/BAT0/charge_full:3685000
/sys/class/power_supply/BAT0/charge_full_design:3685000
/sys/class/power_supply/BAT0/charge_now:2926000
/sys/class/power_supply/BAT0/charge_types:Trickle Fast Standard Adaptive [Custom]
/sys/class/power_supply/BAT0/current_now:1000
/sys/class/power_supply/BAT0/cycle_count:2
/sys/class/power_supply/BAT0/eppid:CN07RDGPBDS0045O50COA02
/sys/class/power_supply/BAT0/manufacturer:BYD
/sys/class/power_supply/BAT0/model_name:DELL 7RDGP45O
/sys/class/power_supply/BAT0/present:1
/sys/class/power_supply/BAT0/serial_number:419
/sys/class/power_supply/BAT0/status:Not charging
/sys/class/power_supply/BAT0/technology:Li-poly
/sys/class/power_supply/BAT0/temp:242
/sys/class/power_supply/BAT0/type:Battery
/sys/class/power_supply/BAT0/voltage_min_design:11400000
/sys/class/power_supply/BAT0/voltage_now:12011000
# lsmod | grep dell
root@localhost-live:~/TLP-1.7.0# lsmod | grep dell
dell_pc                12288  0
platform_profile       12288  1 dell_pc
dell_rbtn              20480  0
dell_laptop            45056  0
dell_wmi               32768  1 dell_laptop
dell_smbios            36864  3 dell_wmi,dell_pc,dell_laptop
dell_smm_hwmon         28672  0
dcdbas                 24576  1 dell_smbios
dell_wmi_sysman        61440  0
dell_wmi_descriptor    20480  2 dell_wmi,dell_smbios
dell_wmi_ddv           28672  0
firmware_attributes_class    12288  1 dell_wmi_sysman
rfkill                 40960  11 iwlmvm,bluetooth,dell_laptop,dell_rbtn,cfg80211
sparse_keymap          12288  2 intel_hid,dell_wmi
video                  81920  4 dell_wmi,dell_laptop,xe,i915
wmi                    28672  8 dell_wmi_sysman,video,dell_wmi_ddv,dell_wmi,wmi_bmof,dell_smm_hwmon,dell_smbios,dell_wmi_descriptor
# unit-tests/charge-thresholds_dell
root@localhost-live:~/TLP-1.7.0# unit-tests/charge-thresholds_dell 
#1	# +++ Dell laptops +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#2	#
#3	# --- tlp start
#4	sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #4, line 12] sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1 +1,3 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#5	sudo tlp start -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #5, line 14] sudo tlp start -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1 +1,3 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#6	sudo tlp start -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #6, line 16] sudo tlp start -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1,4 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 Error in configuration at START_CHARGE_THRESH_BAT0="100": not specified, invalid or out of range (50..95). Battery skipped.
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#7	sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #7, line 19] sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1,4 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 Error in configuration at STOP_CHARGE_THRESH_BAT0="0": not specified, invalid or out of range (55..100). Battery skipped.
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#8	sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #8, line 22] sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1,4 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 Error in configuration at STOP_CHARGE_THRESH_BAT0="101": not specified, invalid or out of range (55..100). Battery skipped.
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#9	sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #9, line 25] sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1,2 +1,4 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 Error in configuration: START_CHARGE_THRESH_BAT0 > STOP_CHARGE_THRESH_BAT0 - 5. Battery skipped.
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#10	sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #10, line 28] sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1 +1,3 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#11	sudo tlp start -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #11, line 30] sudo tlp start -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
@@ -1 +1,3 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#12	sudo tlp start -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #12, line 32] sudo tlp start -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
@@ -1 +1,3 @@
+Error: TLP's power saving will not apply on boot because tlp.service is not enabled --> Invoke 'systemctl enable tlp.service' to ensure the full functionality of TLP.
+
 TLP started in AC mode (auto).
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#13	#
#14	# --- tlp setcharge w/o arguments
#15	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" X_SOC_CHECK=0
#16	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100"
#17	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0"
#18	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101"
#19	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91"
#20	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
#21	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
#22	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#23	sudo tlp setcharge -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#24	#
#25	# --- tlp setcharge w/ arguments
#26	sudo tlp setcharge 60 100 -- X_SOC_CHECK=0
#27	sudo tlp setcharge 100 100 -- X_BAT_PLUGIN_SIMULATE=dell
#28	sudo tlp setcharge 50 0 -- X_BAT_PLUGIN_SIMULATE=dell
#29	sudo tlp setcharge 50 101 -- X_BAT_PLUGIN_SIMULATE=dell
#30	sudo tlp setcharge XYZZY 0 -- X_BAT_PLUGIN_SIMULATE=dell
#31	sudo tlp setcharge 50 XYZZY -- X_BAT_PLUGIN_SIMULATE=dell
#32	sudo tlp setcharge 90 91 -- X_BAT_PLUGIN_SIMULATE=dell
#33	sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
#34	sudo tlp setcharge 90 95 -- X_THRESH_SIMULATE_READERR="1"
#35	sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
#36	sudo tlp setcharge DEF DEF -- X_BAT_PLUGIN_SIMULATE=dell
#37	sudo tlp setcharge BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
#38	sudo tlp setcharge 0 3 BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
#39	sudo tlp setcharge XYZZY ABCDE BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
#40	#
#41	# --- tlp-stat
#42	sudo tlp-stat -b | grep -E 'charge_(control|behaviour)'
#43	sudo tlp-stat -b -- X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
#44	#
#45	# --- Reset test machine to configured thresholds
#46	sudo tlp setcharge BAT0  > /dev/null 2>&1
#47	#
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[FAILED #47, line 111] #
@@ -1 +0,0 @@
-
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FAIL: 10 of 47 tests failed

@linrunner
Copy link
Owner

linrunner commented Oct 27, 2024

@langemar looks promising. Could you please enable the service

sudo systemctl enable tlp.service

then run the automatic test again

unit-tests/charge-thresholds_dell

@langemar
Copy link

langemar commented Oct 27, 2024

Of course:

If have enabled and started the service
systemctl enable --now tlp.service
Please let me know if you need it enabled only or anything else.

# unit-tests/charge-thresholds_dell
root@localhost-live:~/TLP-1.7.0# unit-tests/charge-thresholds_dell
#1	# +++ Dell laptops +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#2	#
#3	# --- tlp start
#4	sudo tlp start -- START_CHARGE_THRESH_BAT0= STOP_CHARGE_THRESH_BAT0= START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#5	sudo tlp start -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#6	sudo tlp start -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#7	sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#8	sudo tlp start -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#9	sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#10	sudo tlp start -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#11	sudo tlp start -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF" START_CHARGE_THRESH_BAT1= STOP_CHARGE_THRESH_BAT1=
#12	sudo tlp start -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#13	#
#14	# --- tlp setcharge w/o arguments
#15	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="60" STOP_CHARGE_THRESH_BAT0="100" X_SOC_CHECK=0
#16	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="100" STOP_CHARGE_THRESH_BAT0="100"
#17	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="0"
#18	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="50" STOP_CHARGE_THRESH_BAT0="101"
#19	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="91"
#20	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
#21	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="90" STOP_CHARGE_THRESH_BAT0="95"
#22	sudo tlp setcharge -- START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#23	sudo tlp setcharge -- NATACPI_ENABLE=0 START_CHARGE_THRESH_BAT0="DEF" STOP_CHARGE_THRESH_BAT0="DEF"
#24	#
#25	# --- tlp setcharge w/ arguments
#26	sudo tlp setcharge 60 100 -- X_SOC_CHECK=0
#27	sudo tlp setcharge 100 100 -- X_BAT_PLUGIN_SIMULATE=dell
#28	sudo tlp setcharge 50 0 -- X_BAT_PLUGIN_SIMULATE=dell
#29	sudo tlp setcharge 50 101 -- X_BAT_PLUGIN_SIMULATE=dell
#30	sudo tlp setcharge XYZZY 0 -- X_BAT_PLUGIN_SIMULATE=dell
#31	sudo tlp setcharge 50 XYZZY -- X_BAT_PLUGIN_SIMULATE=dell
#32	sudo tlp setcharge 90 91 -- X_BAT_PLUGIN_SIMULATE=dell
#33	sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
#34	sudo tlp setcharge 90 95 -- X_THRESH_SIMULATE_READERR="1"
#35	sudo tlp setcharge 90 95 -- X_BAT_PLUGIN_SIMULATE=dell
#36	sudo tlp setcharge DEF DEF -- X_BAT_PLUGIN_SIMULATE=dell
#37	sudo tlp setcharge BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
#38	sudo tlp setcharge 0 3 BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
#39	sudo tlp setcharge XYZZY ABCDE BAT1 -- X_BAT_PLUGIN_SIMULATE=dell
#40	#
#41	# --- tlp-stat
#42	sudo tlp-stat -b | grep -E 'charge_(control|behaviour)'
#43	sudo tlp-stat -b -- X_THRESH_SIMULATE_READERR=1 | grep -E 'charge_(control|behaviour)'
#44	#
#45	# --- Reset test machine to configured thresholds
#46	sudo tlp setcharge BAT0  > /dev/null 2>&1
#47	#
OK: 47 of 47 tests passed

@linrunner
Copy link
Owner

@langemar Looks perfect now. Thank your very much for testing.

Finally, you could check whether the thresholds work as set.

ps. The service did not have to be started. It was just a matter of activating it so that the warning message does not interfere with the target/actual comparison of the output. Of course, it must also be activated for regular operation of TLP.

@langemar
Copy link

langemar commented Oct 27, 2024 via email

@linrunner
Copy link
Owner

Once I set a value smbios shows the set values.

@langemar Please don't bother any further, that information is enough for me.

linrunner added a commit that referenced this issue Oct 28, 2024
    * Supports Dell laptops
    * Requires dell_laptop module as of Linux 6.12
    * Start and stop threshold
    * Force discharge not supported

    * charge_control_start_threshold:
      - Valid values: 50..95
      - Default value: 95

    * charge_control_end_threshold:
      - Valid values: 55..100
      - Default value: 100

References:
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/platform/x86/dell?id=ab58016c68cc5b8c3622e38b7db64994e4833d9f
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/platform/x86/dell/dell-laptop.c
* #379 (comment)
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