lenovo-thinklmi: Disable changing sleep mode on Ryzen 6000 systems

S3 is not supported by AMD and is not exposed in the GUI on these
systems.  Lenovo however exports it to their WMI interface and changing
it will means it can only be changed from the OS.
This commit is contained in:
Mario Limonciello 2022-08-30 15:11:33 -05:00 committed by Mario Limonciello
parent ad461d504d
commit ea64db7d19

View File

@ -8,6 +8,7 @@
#include <fwupdplugin.h>
#define SLEEP_MODE "com.thinklmi.SleepState"
#define BOOT_ORDER_LOCK "com.thinklmi.BootOrderLock"
static gboolean
@ -27,13 +28,23 @@ fu_plugin_lenovo_thinklmi_startup(FuPlugin *plugin, FuProgress *progress, GError
}
static void
fu_plugin_lenovo_thinklmi_device_registered(FuPlugin *plugin, FuDevice *device)
fu_plugin_lenovo_thinklmi_cpu_registered(FuContext *ctx, FuDevice *device)
{
FuContext *ctx = fu_plugin_get_context(plugin);
FwupdBiosSetting *attr;
/* Ryzen 6000 doesn't support S3 even if the BIOS offers it */
if (fu_device_has_instance_id(device, "CPUID\\PRO_0&FAM_19&MOD_44")) {
FwupdBiosSetting *attr = fu_context_get_bios_setting(ctx, SLEEP_MODE);
if (g_strcmp0(fu_device_get_plugin(device), "uefi_capsule") != 0)
return;
if (attr != NULL) {
g_debug("Setting %s to read-only", fwupd_bios_setting_get_name(attr));
fwupd_bios_setting_set_read_only(attr, TRUE);
}
}
}
static void
fu_plugin_lenovo_thinklmi_uefi_capsule_registered(FuContext *ctx, FuDevice *device)
{
FwupdBiosSetting *attr;
/* check if boot order lock is turned on */
attr = fu_context_get_bios_setting(ctx, BOOT_ORDER_LOCK);
@ -55,6 +66,17 @@ fu_plugin_lenovo_thinklmi_device_registered(FuPlugin *plugin, FuDevice *device)
}
}
static void
fu_plugin_lenovo_thinklmi_device_registered(FuPlugin *plugin, FuDevice *device)
{
if (g_strcmp0(fu_device_get_plugin(device), "uefi_capsule") == 0) {
fu_plugin_lenovo_thinklmi_uefi_capsule_registered(fu_plugin_get_context(plugin),
device);
} else if (g_strcmp0(fu_device_get_plugin(device), "cpu") == 0) {
fu_plugin_lenovo_thinklmi_cpu_registered(fu_plugin_get_context(plugin), device);
}
}
void
fu_plugin_init_vfuncs(FuPluginVfuncs *vfuncs)
{