main: Remove restoring profile from kernel

Remove restoring the problem from the on-disk kernel file, as was done
for the platform_profile, as we want to implement actual persistence
across reboots.

We need to be the ones saving that data, as the kernel doesn't know
whether the profile changes are temporary, or permanent, and whether the
user was the one initiating that change.
This commit is contained in:
Bastien Nocera 2021-07-05 17:04:46 +02:00
parent bca6f4da50
commit 12a6d18d99
7 changed files with 14 additions and 45 deletions

View file

@ -693,9 +693,6 @@ static void
start_profile_drivers (PpdApp *data)
{
guint i;
PpdProfile prev_profile;
prev_profile = data->active_profile;
for (i = 0; i < G_N_ELEMENTS (objects); i++) {
GObject *object;
@ -724,7 +721,7 @@ start_profile_drivers (PpdApp *data)
continue;
}
result = ppd_driver_probe (driver, &prev_profile);
result = ppd_driver_probe (driver);
if (result == PPD_PROBE_RESULT_FAIL) {
g_debug ("probe() failed for driver %s, skipping",
ppd_driver_get_driver_name (driver));
@ -766,12 +763,6 @@ start_profile_drivers (PpdApp *data)
goto bail;
}
if (prev_profile != data->active_profile) {
g_debug ("Using '%s' as current profile from probed driver",
ppd_profile_to_str (prev_profile));
data->active_profile = prev_profile;
}
/* Set initial state */
activate_target_profile (data, data->active_profile, PPD_PROFILE_ACTIVATION_REASON_RESET);

View file

@ -143,8 +143,7 @@ envvar_set (const char *key)
}
static PpdProbeResult
ppd_driver_fake_probe (PpdDriver *driver,
PpdProfile *prev_profile)
ppd_driver_fake_probe (PpdDriver *driver)
{
PpdDriverFake *fake;

View file

@ -107,8 +107,7 @@ open_policy_dir (void)
}
static gboolean
ppd_driver_intel_pstate_probe (PpdDriver *driver,
PpdProfile *prev_profile)
ppd_driver_intel_pstate_probe (PpdDriver *driver)
{
PpdDriverIntelPstate *pstate = PPD_DRIVER_INTEL_PSTATE (driver);
g_autoptr(GDir) dir = NULL;

View file

@ -253,8 +253,7 @@ find_dytc (GUdevDevice *dev,
}
static PpdProbeResult
ppd_driver_platform_profile_probe (PpdDriver *driver,
PpdProfile *prev_profile)
ppd_driver_platform_profile_probe (PpdDriver *driver)
{
PpdDriverPlatformProfile *self = PPD_DRIVER_PLATFORM_PROFILE (driver);
g_autoptr(GFile) acpi_platform_profile = NULL;
@ -289,8 +288,6 @@ ppd_driver_platform_profile_probe (PpdDriver *driver,
return self->probe_result;
}
*prev_profile = read_platform_profile ();
/* Lenovo-specific proximity sensor */
self->device = ppd_utils_find_device ("platform",
(GCompareFunc) find_dytc,

View file

@ -217,24 +217,14 @@ ppd_driver_init (PpdDriver *self)
}
PpdProbeResult
ppd_driver_probe (PpdDriver *driver,
PpdProfile *previous_profile)
ppd_driver_probe (PpdDriver *driver)
{
PpdProfile profile = PPD_PROFILE_UNSET;
PpdProbeResult ret;
g_return_val_if_fail (PPD_IS_DRIVER (driver), FALSE);
g_return_val_if_fail (previous_profile != NULL, FALSE);
if (!PPD_DRIVER_GET_CLASS (driver)->probe)
return PPD_PROBE_RESULT_SUCCESS;
ret = PPD_DRIVER_GET_CLASS (driver)->probe (driver, &profile);
if (ret == PPD_PROBE_RESULT_SUCCESS &&
profile != PPD_PROFILE_UNSET &&
ppd_profile_has_single_flag (profile))
*previous_profile = profile;
return ret;
return PPD_DRIVER_GET_CLASS (driver)->probe (driver);
}
gboolean

View file

@ -68,8 +68,7 @@ struct _PpdDriverClass
{
GObjectClass parent_class;
PpdProbeResult (* probe) (PpdDriver *driver,
PpdProfile *previous_profile);
PpdProbeResult (* probe) (PpdDriver *driver);
gboolean (* activate_profile) (PpdDriver *driver,
PpdProfile profile,
PpdProfileActivationReason reason,
@ -77,7 +76,7 @@ struct _PpdDriverClass
};
#ifndef __GTK_DOC_IGNORE__
PpdProbeResult ppd_driver_probe (PpdDriver *driver, PpdProfile *previous_profile);
PpdProbeResult ppd_driver_probe (PpdDriver *driver);
gboolean ppd_driver_activate_profile (PpdDriver *driver,
PpdProfile profile, PpdProfileActivationReason reason, GError **error);
const char *ppd_driver_get_driver_name (PpdDriver *driver);

View file

@ -310,9 +310,8 @@ class Tests(dbusmock.DBusTestCase):
profiles = self.get_dbus_property('Profiles')
self.assertEqual(len(profiles), 3)
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('balanced'))
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('performance'))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
@ -428,6 +427,7 @@ class Tests(dbusmock.DBusTestCase):
self.assertEqual(profiles[0]['Profile'], 'power-saver')
self.assertEqual(profiles[2]['Driver'], 'platform_profile')
self.assertEqual(profiles[2]['Profile'], 'performance')
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('performance'))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
# lapmode detected
@ -518,7 +518,7 @@ class Tests(dbusmock.DBusTestCase):
profiles = self.get_dbus_property('Profiles')
self.assertEqual(len(profiles), 3)
# Was set in platform_profile before we loaded the drivers
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
self.assertEqual(self.get_dbus_property('PerformanceDegraded'), '')
self.stop_daemon()
@ -538,11 +538,8 @@ class Tests(dbusmock.DBusTestCase):
self.assertEqual(len(profiles), 3)
self.assertEqual(profiles[0]['Driver'], 'platform_profile')
self.assertEqual(profiles[0]['Profile'], 'power-saver')
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'power-saver')
self.assertEqual(self.read_sysfs_file("sys/firmware/acpi/platform_profile"), b'cool')
# Check that we can set the power-saver/cool profile again
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('balanced'))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
self.assertEqual(self.read_sysfs_file("sys/firmware/acpi/platform_profile"), b'balanced')
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('power-saver'))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'power-saver')
self.assertEqual(self.read_sysfs_file("sys/firmware/acpi/platform_profile"), b'cool')
@ -555,8 +552,6 @@ class Tests(dbusmock.DBusTestCase):
profiles = self.get_dbus_property('Profiles')
self.assertEqual(len(profiles), 3)
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('balanced'))
cookie = self.call_dbus_method('HoldProfile', GLib.Variant("(sss)", ('performance', 'testReason', 'testApplication')))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
@ -622,8 +617,7 @@ class Tests(dbusmock.DBusTestCase):
profiles = self.get_dbus_property('Profiles')
self.assertEqual(len(profiles), 3)
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'performance')
self.set_dbus_property('ActiveProfile', GLib.Variant.new_string('balanced'))
self.assertEqual(self.get_dbus_property('ActiveProfile'), 'balanced')
# Test every order of holding and releasing power-saver and performance
# hold performance and then power-saver, release in the same order