thunderbolt: add configuration option to force retimer enumeration

Change-Id: I300b94291d6d989b4b1c88daaadc5f0f49ac88be
This commit is contained in:
Daniel Campello 2022-03-18 10:02:33 -06:00 committed by Daniel Campello
parent 8624f454d6
commit f58217a0ab
4 changed files with 18 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include <fwupdplugin.h>
#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);

View File

@ -9,6 +9,13 @@
#include <fwupdplugin.h>
/**
* 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

View File

@ -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);

View File

@ -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