From 97acc2bf74f602b7225a7d6c986915b376c2997b Mon Sep 17 00:00:00 2001 From: Mario Limonciello Date: Tue, 24 Mar 2020 14:20:43 -0500 Subject: [PATCH] thunderbolt: Rather than hardcoding to PCI slot numbers, use domain in GUID This allows the PCI topology to change, but assumes that thunderbolt host controllers are enumerated in the same order every time. It won't matter if the first controller jumped from bus 5 to 7 and consequently the second from 65 to 71, but rather that the first was enumerated followed by the second. --- plugins/thunderbolt/README.md | 6 ++++++ plugins/thunderbolt/fu-plugin-thunderbolt.c | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/plugins/thunderbolt/README.md b/plugins/thunderbolt/README.md index 63a2f7033..914257cb3 100644 --- a/plugins/thunderbolt/README.md +++ b/plugins/thunderbolt/README.md @@ -31,6 +31,12 @@ When the device is in "safe mode" the GUID is hardcoded using: * `TBT-$(vid)$(pid)-native` when native, and `TBT-$(vid)$(pid)` otherwise. +Additionally for host system thunderbolt controllers another GUID is added +containing the domain designation of the controller. This is intended to be +used for systems with multiple host controllers to disambiguiate between controllers. + +* `TBT-$(vid)$(pid)-native-controller$(num)` + Vendor ID Security ------------------ diff --git a/plugins/thunderbolt/fu-plugin-thunderbolt.c b/plugins/thunderbolt/fu-plugin-thunderbolt.c index ecc402e1a..124ca48f5 100644 --- a/plugins/thunderbolt/fu-plugin-thunderbolt.c +++ b/plugins/thunderbolt/fu-plugin-thunderbolt.c @@ -282,6 +282,7 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device) g_autofree gchar *version = NULL; g_autofree gchar *vendor_id = NULL; g_autofree gchar *device_id = NULL; + g_autofree gchar *domain_id = NULL; g_autoptr(FuDevice) dev = NULL; g_autoptr(GError) error_vid = NULL; g_autoptr(GError) error_did = NULL; @@ -357,6 +358,7 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device) /* USB4 controllers don't have a concept of legacy vs native * so don't try to read a native attribute from their NVM */ if (is_host && gen < 4) { + g_autofree gchar *domain = g_path_get_basename (devpath); g_autoptr(GError) native_error = NULL; if (!fu_plugin_thunderbolt_is_native (device, &is_native, @@ -368,6 +370,12 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device) fu_plugin_add_report_metadata (plugin, "ThunderboltNative", is_native ? "True" : "False"); + domain_id = g_strdup_printf ("TBT-%04x%04x%s-controller%s", + (guint) vid, + (guint) did, + is_native ? "-native" : "", + domain); + } vendor_id = g_strdup_printf ("TBT:0x%04X", (guint) vid); device_id = g_strdup_printf ("TBT-%04x%04x%s", @@ -409,6 +417,8 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device) fu_device_set_vendor_id (dev, vendor_id); if (device_id != NULL) fu_device_add_instance_id (dev, device_id); + if (domain_id != NULL) + fu_device_add_instance_id (dev, domain_id); if (version != NULL) fu_device_set_version (dev, version); if (is_host)