Commit graph

238 commits

Author SHA1 Message Date
Bastien Nocera
e83b4556bf 0.11.1 2022-05-02 17:07:24 +02:00
Bastien Nocera
bd2d4202e8 README: Document how the Intel P-State driver works
It used to just tweak a single file, but it's now (unfortunately) complicated
enough that it needs to be documented.
2022-05-02 15:07:07 +02:00
Bastien Nocera
afed35451d tests: Add test case for Intel P-State in passive mode 2022-05-02 14:47:22 +02:00
Bastien Nocera
23103bca59 intel-pstate: Don't change scaling_governor if P-State isn't active
On systems without HWP support, or when the Intel P-State driver runs in
"passive" mode, the CPU is effectively controlled by cpufreq governors.

Only modify the cpufreq scaling_governor if the Intel P-State driver is in
active mode.

See https://www.kernel.org/doc/html/v5.17/admin-guide/pm/intel_pstate.html#operation-modes

Closes: #91
2022-05-02 14:42:37 +02:00
Bastien Nocera
29151898b6 0.11 2022-04-29 14:29:31 +02:00
Bastien Nocera
5260fae7cf tests: Test with a non-default scaling_governor
Check that the daemon is resetting the value on startup, and add
scaling_governor sysfs files for all the intel-pstate tests.
2022-04-28 15:25:52 +02:00
Bastien Nocera
fb41403b8e main: Change default scaling_governor on startup
Otherwise energy_performance_preference might not be writable. This can
happen on systems where the default cpufreq scaling governor has been
changed.

See https://bugzilla.redhat.com/show_bug.cgi?id=2079898

Closes: #90
2022-04-28 15:17:45 +02:00
Bastien Nocera
588fe2cc08 tests: Add tests for error reporting when profile can't be set 2022-04-28 14:42:35 +02:00
Bastien Nocera
b028f276e6 ci: Run tests with tmpdir in the build tree
This should allow using chattr to make files immutable, which only works
on ext{2,3,4} and not tmpfs.
2022-04-28 14:42:35 +02:00
Bastien Nocera
79c7ee282d ci: Run tests before make a dist
As the dist runs the tests, best run the tests first, should fail
earlier.
2022-04-28 14:31:07 +02:00
Bastien Nocera
53e77cf572 ci: Install e2fsprogs to get access to chattr tool 2022-04-28 14:11:50 +02:00
Bastien Nocera
b12907c14a main: Catch D-Bus errors when running "set" command
Before:
Traceback (most recent call last):
  File "/usr/bin/powerprofilesctl", line 262, in <module>
    main()
  File "/usr/bin/powerprofilesctl", line 216, in main
    _set(args[0])
  File "/usr/bin/powerprofilesctl", line 111, in _set
    proxy.Set('(ssv)',
  File "/usr/lib/python3.10/site-packages/gi/overrides/Gio.py", line 349, in __call__
    result = self.dbus_proxy.call_sync(self.method_name, arg_variant,
gi.repository.GLib.GError: g-io-error-quark: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code26: Error writing '/sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference': Device or resource busy (26)

After:
Failed to communicate with power-profiles-daemon: g-io-error-quark: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code26: Error writing '/sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference': Device or resource busy (26)
2022-04-28 14:00:47 +02:00
Bastien Nocera
6719ced657 main: Return D-Bus error on profile activation failure
Throw a D-Bus error when activating a profile fails:
gi.repository.GLib.GError: g-io-error-quark: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dio_2derror_2dquark.Code26: Error writing '/sys/devices/system/cpu/cpufreq/policy1/energy_performance_preference': Device or resource busy (26)

Closes: #90
2022-04-28 14:00:47 +02:00
Bastien Nocera
d000f9a3ff main: Add error reporting to internal activate_target_profile()
This will allow propagating potential errors.
2022-04-28 14:00:47 +02:00
Bastien Nocera
d352d5a2cb utils: Better debug and error messages
Add debugging and make error messages better on errors.
2022-04-28 14:00:47 +02:00
Bastien Nocera
d57a45fd23 utils: Fix ignored write errors
Because fprintf() is buffered unless disabled and we weren't checking
for the fclose() return value, we were returning without errors when
there should have been some.
2022-04-28 14:00:47 +02:00
Bastien Nocera
4bf9871b6f ci: Skip tests when dependencies are missing 2022-04-28 13:54:14 +02:00
Bastien Nocera
3d9a706ba0 ci: Fail CI when tests are skipped 2022-04-28 13:54:14 +02:00
Bastien Nocera
f6cfb32568 build: Fix run_command() call
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
2022-04-27 16:04:05 +02:00
Bastien Nocera
1be33091a4 tests: Add tests for both trickle-charge changes 2022-02-12 23:13:06 +01:00
Bastien Nocera
f48f6ca28d trickle-charge: Don't change charge type on system chargers
We're supposed to only change the charge type of devices attached to us.

Closes: #85
2022-02-12 23:02:42 +01:00
Bastien Nocera
92cf0278b0 trickle-charge: Don't write to already configured supplies
Don't write charge type to devices that are already setup with that
charge type, it serves no purpose and might cause bugs in some drivers.
2022-02-12 23:00:46 +01:00
Bastien Nocera
b9730ebc3c README: Add missing text from last commit 2022-01-31 11:23:01 +01:00
Bastien Nocera
6acc53daca README: Mention possible service conflicts
Mention problems with tlp's packaging in Fedora and Debian-derivatives.

See https://bugzilla.redhat.com/show_bug.cgi?id=2028701#c11
and https://github.com/linrunner/TLP/issues/564
2022-01-31 11:09:41 +01:00
Bastien Nocera
ca79f80635 intel-pstate: Don't show degraded perf with CPUs with no turbo
Don't show a degraded performance, caused by "no_turbo" being set,
when the CPU doesn't support TurboBoost at all.

Closes: #75
2022-01-31 10:50:47 +01:00
Bastien Nocera
c63503be97 tests: Add test to detect CPUs without Turbo support
Reproduces the hardware mentioned in
https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/75
2022-01-31 10:50:47 +01:00
Bastien Nocera
3375973baf README: Add some end-user documentation
Enough data to get started using the project.
2021-11-17 17:03:06 +01:00
Bastien Nocera
ae8e90892b tests: Write tests for traceback avoidance on D-Bus errors 2021-11-08 16:27:56 +01:00
Bastien Nocera
fd1664dfe2 main: Error out on D-Bus communication errors
The bug reporting tool in Fedora, in its infinite wisdom, considers
innocuous exceptions that occur when system daemons aren't running
to be bug report worthy.

Catch all the D-Bus communication errors, print an error message
detailing the problem and exit with a return value of 1 when they occur
instead of printing an exception.

See:
https://bugzilla.redhat.com/show_bug.cgi?id=2019536
https://bugzilla.redhat.com/show_bug.cgi?id=2020251
https://bugzilla.redhat.com/show_bug.cgi?id=2020941
2021-11-08 16:27:56 +01:00
Bastien Nocera
0aef9d6a2f build: Require polkit 0.114
It's required for the g_autoptr() support we use. For older
distributions shipping older versions of polkit, it is recommended that
you backport the g_autoptr() support to your version of polkit and
amend the required version in this project.
2021-11-02 17:18:17 +01:00
Bastien Nocera
215690be0f 0.10.1 2021-10-28 11:25:13 +02:00
Sebastian Keller
30dbd321d8 main: Fix HoldProfile still happening when unauthorised
The HoldProfile method was correctly throwing an error back to the
caller but was still carrying on to hold a profile.

This could cause a double-free in the daemon, and unwanted profile
changes for users.

** (power-profiles-daemon:55299): DEBUG: 10:48:10.411: (:1.0) requesting to hold profile 'performance', reason: ''
** (power-profiles-daemon:55299): DEBUG: 10:48:10.422: Setting active profile 'performance' for reason 'program-hold' (current: 'balanced')
==55299== Invalid read of size 8
==55299==    at 0x4AA40F9: g_type_check_instance_is_fundamentally_a (gtype.c:4088)
==55299==    by 0x4A8DA08: g_object_unref (gobject.c:3484)
==55299==    by 0x4B17702: UnknownInlinedFun (gmain.c:1666)
==55299==    by 0x4B17702: g_source_callback_unref (gmain.c:1659)
==55299==    by 0x4B1B8BB: g_source_destroy_internal (gmain.c:1331)
==55299==    by 0x4B1D47F: UnknownInlinedFun (gmain.c:3411)
==55299==    by 0x4B1D47F: g_main_context_dispatch (gmain.c:4099)
==55299==    by 0x4B72287: g_main_context_iterate.constprop.0 (gmain.c:4175)
==55299==    by 0x4B1C902: g_main_loop_run (gmain.c:4373)
==55299==    by 0x403C10: main (power-profiles-daemon.c:1006)
==55299==  Address 0x54edc60 is 0 bytes inside a block of size 104 free'd
==55299==    at 0x48430E4: free (vg_replace_malloc.c:872)
==55299==    by 0x4B220BC: g_free (gmem.c:199)
==55299==    by 0x4B3C6FF: g_slice_free1 (gslice.c:1183)
==55299==    by 0x4AA2EF4: g_type_free_instance (gtype.c:2008)
==55299==    by 0x49B4840: g_dbus_method_invocation_return_value_internal (gdbusmethodinvocation.c:528)
==55299==    by 0x4064F2: hold_profile (power-profiles-daemon.c:568)
==55299==    by 0x4064F2: handle_method_call (power-profiles-daemon.c:711)
==55299==    by 0x49A4451: call_in_idle_cb.lto_priv.0 (gdbusconnection.c:4916)
==55299==    by 0x4B1952A: g_idle_dispatch (gmain.c:5897)
==55299==    by 0x4B1D33E: UnknownInlinedFun (gmain.c:3381)
==55299==    by 0x4B1D33E: g_main_context_dispatch (gmain.c:4099)
==55299==    by 0x4B72287: g_main_context_iterate.constprop.0 (gmain.c:4175)
==55299==    by 0x4B1C902: g_main_loop_run (gmain.c:4373)
==55299==    by 0x403C10: main (power-profiles-daemon.c:1006)
==55299==  Block was alloc'd at
==55299==    at 0x484086F: malloc (vg_replace_malloc.c:381)
==55299==    by 0x4B257A8: g_malloc (gmem.c:106)
==55299==    by 0x4B3D1E4: g_slice_alloc (gslice.c:1072)
==55299==    by 0x4B3D84D: g_slice_alloc0 (gslice.c:1098)
==55299==    by 0x4AA81F4: g_type_create_instance (gtype.c:1911)
==55299==    by 0x4A8FCAC: g_object_new_internal (gobject.c:1945)
==55299==    by 0x4A90C7C: g_object_new_with_properties (gobject.c:2114)
==55299==    by 0x4A91780: g_object_new (gobject.c:1785)
==55299==    by 0x49D8033: UnknownInlinedFun (gdbusmethodinvocation.c:369)
==55299==    by 0x49D8033: schedule_method_call.constprop.0 (gdbusconnection.c:4946)
==55299==    by 0x49A45B9: validate_and_maybe_schedule_method_call.lto_priv.0 (gdbusconnection.c:5048)
==55299==    by 0x499C57A: UnknownInlinedFun (gdbusconnection.c:5091)
==55299==    by 0x499C57A: UnknownInlinedFun (gdbusconnection.c:7172)
==55299==    by 0x499C57A: UnknownInlinedFun (gdbusconnection.c:2344)
==55299==    by 0x499C57A: on_worker_message_received (gdbusconnection.c:2258)
==55299==    by 0x49B0082: UnknownInlinedFun (gdbusprivate.c:488)
==55299==    by 0x49B0082: UnknownInlinedFun (gdbusprivate.c:484)
==55299==    by 0x49B0082: UnknownInlinedFun (gdbusprivate.c:516)
==55299==    by 0x49B0082: _g_dbus_worker_do_read_cb (gdbusprivate.c:801)
==55299==

(power-profiles-daemon:55299): GLib-GObject-CRITICAL **: 10:48:10.427: g_object_unref: assertion 'G_IS_OBJECT (object)' failed
2021-10-28 11:19:11 +02:00
Bastien Nocera
393cb81aa8 tests: Add test for HoldProfile when not authorised 2021-10-28 11:19:11 +02:00
Bastien Nocera
141d2ee64f tests: Rename test_not_allowed()
It only tests for the ActiveProfile authorisation.
2021-10-28 11:19:11 +02:00
Bastien Nocera
41f00d4ed5 main: Use f-string when listing profiles
As advised by pylint:
src/powerprofilesctl:144:19: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
2021-10-28 11:16:13 +02:00
Bastien Nocera
f83685732b build: Make pylint test optional
As power-profiles-daemon keeps getting built with slightly different
versions of pylint with newer warnings, disable pylint test by default
to avoid getting bug reports about it.

Closes: #52
2021-10-06 10:22:10 +02:00
Bastien Nocera
ea3faa1eab 0.10.0 2021-10-04 16:01:30 +02:00
Bastien Nocera
06af2327e4 README: Add mention of asusctl
See https://gitlab.freedesktop.org/hadess/power-profiles-daemon/-/issues/36
2021-10-04 15:11:18 +02:00
Bastien Nocera
2a25f7d4cd tests: Test when switch-profile permission isn't granted 2021-09-28 17:19:40 +02:00
Bastien Nocera
3aca4e9d01 main: Check whether user is allowed to perform action
Check whether a particular user/D-Bus client is allowed to switch
or hold power profiles.

Closes: #47
2021-09-28 13:07:49 +02:00
Bastien Nocera
bb92c628b4 tests: Start mock polkitd in the tests
And allow all us to perform all the actions.
2021-09-28 12:57:44 +02:00
Bastien Nocera
9d6e1735f3 data: Add polkit policy description
Describe and set defaults for switching and holding power profiles.
2021-09-28 12:55:59 +02:00
Bastien Nocera
112df0446d main: Print version on startup
Makes it easier to see startup too.
2021-09-07 23:00:12 +02:00
Bastien Nocera
50d1f5e03a tests: Split the integration test into individual tests
unittest_inspector.py lists the tests in the integration-test.py script,
which are then added as individual tests.
2021-09-07 23:00:12 +02:00
Bastien Nocera
e9f5b04258 tests: Rename integration test script
Add the python suffix.
2021-09-07 23:00:12 +02:00
Bastien Nocera
4ee64adc81 tests: Move test config file to a private directory
If we are to run all the tests in parallel, we need to make sure that
each instance of the daemon gets its own configuration file, otherwise
all of them will be trying to change each other's config behind their
backs.
2021-09-07 23:00:12 +02:00
Bastien Nocera
c48108763b tests: Remove extra spaces 2021-08-23 13:19:44 +02:00
Bastien Nocera
6701c99680 main: Update documentation for PpdDriver
The drivers have needed to handle all the profiles they support since
c7fb31632b where we stopped using a
placeholder driver when a profile wasn't handled.
2021-08-09 11:26:11 +02:00
Bastien Nocera
3fa5eafe57 README: Add mention of system76-power
Closes: #26
2021-08-06 18:42:15 +02:00
Bastien Nocera
42b3341b29 main: Follow pylint recommendation and use "with"
src/powerprofilesctl:185:4: R1732: Consider using 'with' for resource-allocating operations (consider-using-with)

Closes: #35
2021-08-05 15:58:24 +02:00