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.
This commit is contained in:
Mario Limonciello 2020-03-24 14:20:43 -05:00 committed by Mario Limonciello
parent e6d76a594c
commit 97acc2bf74
2 changed files with 16 additions and 0 deletions

View File

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

View File

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