From f58217a0ab6fe2d1e636f8ad9ca3d376c2d97919 Mon Sep 17 00:00:00 2001 From: Daniel Campello Date: Fri, 18 Mar 2022 10:02:33 -0600 Subject: [PATCH] thunderbolt: add configuration option to force retimer enumeration Change-Id: I300b94291d6d989b4b1c88daaadc5f0f49ac88be --- plugins/thunderbolt/fu-plugin-thunderbolt.c | 5 +++++ plugins/thunderbolt/fu-thunderbolt-common.h | 7 +++++++ plugins/thunderbolt/fu-thunderbolt-controller.c | 4 +++- plugins/thunderbolt/thunderbolt.conf | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/plugins/thunderbolt/fu-plugin-thunderbolt.c b/plugins/thunderbolt/fu-plugin-thunderbolt.c index ee81181e0..26b191069 100644 --- a/plugins/thunderbolt/fu-plugin-thunderbolt.c +++ b/plugins/thunderbolt/fu-plugin-thunderbolt.c @@ -8,6 +8,7 @@ #include +#include "fu-thunderbolt-common.h" #include "fu-thunderbolt-controller.h" #include "fu-thunderbolt-firmware-update.h" #include "fu-thunderbolt-firmware.h" @@ -36,6 +37,8 @@ fu_plugin_thunderbolt_device_created(FuPlugin *plugin, FuDevice *dev, GError **e fu_plugin_add_rule(plugin, FU_PLUGIN_RULE_INHIBITS_IDLE, "thunderbolt requires device wakeup"); + if (fu_plugin_get_config_value_boolean(plugin, "RetimerOfflineMode")) + fu_device_add_private_flag(dev, FU_THUNDERBOLT_DEVICE_FLAG_FORCE_ENUMERATION); return TRUE; } @@ -77,6 +80,7 @@ fu_plugin_thunderbolt_composite_prepare(FuPlugin *plugin, GPtrArray *devices, GE for (guint i = 0; i < devices->len; i++) { FuDevice *dev = g_ptr_array_index(devices, i); if ((g_strcmp0(fu_device_get_plugin(dev), "thunderbolt") == 0) && + fu_device_has_private_flag(dev, FU_THUNDERBOLT_DEVICE_FLAG_FORCE_ENUMERATION) && fu_device_has_internal_flag(dev, FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE)) { return fu_thunderbolt_retimer_set_parent_port_offline(dev, error); } @@ -90,6 +94,7 @@ fu_plugin_thunderbolt_composite_cleanup(FuPlugin *plugin, GPtrArray *devices, GE for (guint i = 0; i < devices->len; i++) { FuDevice *dev = g_ptr_array_index(devices, i); if ((g_strcmp0(fu_device_get_plugin(dev), "thunderbolt") == 0) && + fu_device_has_private_flag(dev, FU_THUNDERBOLT_DEVICE_FLAG_FORCE_ENUMERATION) && fu_device_has_internal_flag(dev, FU_DEVICE_INTERNAL_FLAG_NO_AUTO_REMOVE)) { g_usleep(FU_THUNDERBOLT_RETIMER_CLEANUP_DELAY); return fu_thunderbolt_retimer_set_parent_port_online(dev, error); diff --git a/plugins/thunderbolt/fu-thunderbolt-common.h b/plugins/thunderbolt/fu-thunderbolt-common.h index 9ebd2155a..610f460ed 100644 --- a/plugins/thunderbolt/fu-thunderbolt-common.h +++ b/plugins/thunderbolt/fu-thunderbolt-common.h @@ -9,6 +9,13 @@ #include +/** + * FU_THUNDERBOLT_DEVICE_FLAG_FORCE_ENUMERATION: + * + * Forces composite device components to be enumerated. + */ +#define FU_THUNDERBOLT_DEVICE_FLAG_FORCE_ENUMERATION (1ull << 1) + gboolean fu_thunderbolt_udev_set_port_online(FuUdevDevice *device, GError **error); gboolean diff --git a/plugins/thunderbolt/fu-thunderbolt-controller.c b/plugins/thunderbolt/fu-thunderbolt-controller.c index fd5573d77..43daec3e7 100644 --- a/plugins/thunderbolt/fu-thunderbolt-controller.c +++ b/plugins/thunderbolt/fu-thunderbolt-controller.c @@ -289,7 +289,9 @@ fu_thunderbolt_controller_setup(FuDevice *device, GError **error) } else { fu_device_add_internal_flag(device, FU_DEVICE_INTERNAL_FLAG_REPLUG_MATCH_GUID); } - if (self->controller_kind == FU_THUNDERBOLT_CONTROLLER_KIND_HOST) { + if (self->controller_kind == FU_THUNDERBOLT_CONTROLLER_KIND_HOST && + fu_device_has_private_flag(FU_DEVICE(self), + FU_THUNDERBOLT_DEVICE_FLAG_FORCE_ENUMERATION)) { g_autoptr(GError) error_local = NULL; if (!fu_thunderbolt_controller_setup_usb4(self, &error_local)) g_warning("failed to setup host: %s", error_local->message); diff --git a/plugins/thunderbolt/thunderbolt.conf b/plugins/thunderbolt/thunderbolt.conf index d6a61d169..efaecb4bf 100644 --- a/plugins/thunderbolt/thunderbolt.conf +++ b/plugins/thunderbolt/thunderbolt.conf @@ -7,3 +7,6 @@ MinimumKernelVersion=4.13.0 # Forces delaying activation until shutdown/logout/reboot DelayedActivation=false + +# Uses offline mode interface to update retimers +RetimerOfflineMode=false