From b3ab935ac8cbd842fe1d071f518ac837fd43a2c7 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Tue, 16 Mar 2021 16:17:42 +0100 Subject: [PATCH] intel-pstate: Fix inhibition not being detected We should have inhibited the performance profile when "no_turbo" was set to "1", but we didn't take the linefeed into account, so we never actually read that value. --- src/ppd-driver-intel-pstate.c | 1 + tests/integration-test | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ppd-driver-intel-pstate.c b/src/ppd-driver-intel-pstate.c index d5f0bf3..4f104af 100644 --- a/src/ppd-driver-intel-pstate.c +++ b/src/ppd-driver-intel-pstate.c @@ -80,6 +80,7 @@ update_no_turbo (PpdDriverIntelPstate *pstate) gboolean turbo_disabled = FALSE; if (g_file_get_contents (pstate->no_turbo_path, &contents, NULL, NULL)) { + contents = g_strchomp (contents); if (g_strcmp0 (contents, "1") == 0) turbo_disabled = TRUE; } diff --git a/tests/integration-test b/tests/integration-test index e8702c5..4ff8ab2 100755 --- a/tests/integration-test +++ b/tests/integration-test @@ -317,7 +317,7 @@ class Tests(dbusmock.DBusTestCase): pstate_dir = os.path.join(self.testbed.get_root_dir(), "sys/devices/system/cpu/intel_pstate") os.makedirs(pstate_dir) with open(os.path.join(pstate_dir, "no_turbo") ,'w') as no_turbo: - no_turbo.write("0") + no_turbo.write("0\n") self.start_daemon() @@ -342,7 +342,7 @@ class Tests(dbusmock.DBusTestCase): # Disable turbo with open(os.path.join(pstate_dir, "no_turbo") ,'w') as no_turbo: - no_turbo.write("1") + no_turbo.write("1\n") self.assertEventually(lambda: self.have_text_in_log('File monitor change happened for ')) self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')