Commit Graph

85 Commits

Author SHA1 Message Date
Mario Limonciello
94874cd067 thunderbolt: Add a new subclassed thunderbolt firmware update type
Thunderbolt images brought in from the SPI don't have a FARB header.
Thunderbolt update images do.

So these two types of images need to be handled separately from the
firmware parser.
2020-05-06 11:13:51 -05:00
Mario Limonciello
ec44dd3353 Modernize the thunderbolt plugin.
Remove it's references to it's own GUdevclient and instead use
FuUdevDevice.

Some intentional casualties of the move:
* Plugin metadata around native and safe mode dropped.
  - These haven't been useful in debugging anything and aren't relevant
    on new hardware
* Extra GUID for 2 host controllers in same system dropped
  - Although this was normally static information BIOS operations like
    turning off PCI-E SD card reader or LAN controller changed things.
* The NVM version is parsed directly instead of through gudev to prevent
  cached data breaking change events.

Remaining TODO:
* Force power w/ thunderbolt-power doesn't work
2020-04-29 13:15:45 -05:00
Mario Limonciello
55a42ddcbb thunderbolt: Don't show safe mode errors for USB4 host controllers
USB4 Controllers were showing up like this:

USB4 Controller:
     Device ID:           3df660bc4bdb67fd6fc101b34c6fd8cd235e3f97
     Summary:             Unmatched performance for high-speed I/O
     Current version:     00.00
     Update Error:        Device is in safe mode
     GUID:                4d86f168-e1cc-5995-afd3-ae9df6a14f5e -> TBT-safemode
     Device Flags:         Internal device
                           Requires AC power
2020-04-23 14:13:38 -05:00
Mario Limonciello
97acc2bf74 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.
2020-03-28 09:52:38 -05:00
Mario Limonciello
e6d76a594c Revert "thunderbolt: Create a unique GUID including Thunderbolt controller path"
This reverts commit 7e38dffdcb.
2020-03-28 09:52:38 -05:00
Richard Hughes
f50ff2c27e Decouple the version format from the version itself
If we say that the version format should be the same for the `version_lowest`
and the `version_bootloader` then it does not always make sense to set it at
the same time.

Moving the `version_format` to a standalone first-class property also means it
can be typically be set in the custom device `_init()` function, which means we
don't need to worry about *changing* ther version format as set by the USB and
UDev superclass helpers.
2020-02-25 14:00:09 +00:00
Richard Hughes
9a68084dbc Always check for PLAIN when doing vercmp() operations
In 1de7cc we checked the version format when checking for update, but there are
many other places that are doing verfmt-insensitive comparisons. For instance,
the predicates in <requires> all fail if the device version format is plain.
his breaks updating some NVMe drives where the `ne` requirements are not
semantic versions.

To avoid trying to catch all the bugs in different places, and in case we have
a future verfmt that should be treated another way, refactor this out in to a
common function and deprecate the old function.
2020-02-20 15:49:27 +00:00
Richard Hughes
56ac823af9 Set the protocol per-device not per-plugin
Some plugins have devices with more than one protocol. Logically the protocol
belongs to the device, not the plugin, and in the future we could use this to
further check firmware that's about to be deployed.

This is also not exported into libfwupd (yet?) as it's remains a debug-feature
only -- protocols are not actually required for devices to be added.
2019-11-25 18:01:54 +00:00
Mario Limonciello
6abe21efbd trivial: stop including fu-hash.h as part of fu-plugin-vfuncs.h
Explicitly include it in all "in-tree" plugins.

If headers are exported out of tree we will likely explicitly not
export this header.
2019-11-25 09:29:46 +00:00
Mario Limonciello
e8ec462e07 trivial: thunderbolt: clarify error message
In an error block that checks for `NULL` sysfs, you will always see
`(null)` in the string.

```
FuPluginThunderbolt  Unable to read generation: failed get id generation for (null)
```
2019-11-11 16:16:51 -06:00
Richard Hughes
7cb0592f72 trivial: Fix a compile error with older versions of gudev
Just move the G_DEFINE_AUTOPTR_CLEANUP_FUNC to the internal header to avoid
forgetting to define this in each plugin.
2019-11-02 07:47:02 -05:00
Mario Limonciello
7e38dffdcb thunderbolt: Create a unique GUID including Thunderbolt controller path
Systems with multiple host controllers will most likely have a different
NVM image for each controller but there is no guarantee that the device_id
within the NVM image varies from one controller to another.

To account for this, build a GUID that contains the last element of the
Thunderbolt controller's udev path.

Sample GUID strings from an XPS 9380 (which only contains one host controller):
```
  Guid:                 0f401ed2-b847-532a-adc8-3193fc737be6 <- TBT-00d408af-native
  Guid:                 420b0596-f5cb-5fd7-8416-c99d48ad8de9 <- TBT-00d408af-native-0000:05:00.0
```

This commit follows the presumption that the kernel will enumerate the controllers
in the same order every time.
2019-10-30 14:19:36 -05:00
Mario Limonciello
97c1e727c4 Add new device flags indicating update resilience
fwupd clients will ideally use this information as part of a policy to schedule
updates in the background without user interactions on safe devices.
2019-10-17 11:38:46 -05:00
Mario Limonciello
50202f5a89 thunderbolt: some more clarifications when using ICL
Currently ICL shows up like this:
```
├─Unknown Device:
│     Device ID:           d066959bf1b0da600f4fcaab5aa31cab3ff05eee
│     Summary:             Unmatched performance for high-speed I/O
│     Current version:     71.00
│     Update Error:        Missing non-active nvmem
│     Flags:               internal|require-ac|registered
│     GUID:                e72e778e-94f7-5ed2-b560-1c1262ee217c
```

Which isn't very useful to end users.  Instead show the generic name
`Thunderbolt Controller` which matches the behavior change we've made
in UEFI FW and Touchpad FW items too.

```
├─Thunderbolt Controller:
│     Device ID:           d066959bf1b0da600f4fcaab5aa31cab3ff05eee
│     Summary:             Unmatched performance for high-speed I/O
│     Current version:     71.00
│     Update Error:        Missing non-active nvmem
│     Flags:               internal|require-ac|registered
│     GUID:                e72e778e-94f7-5ed2-b560-1c1262ee217c
```

Also, quite the messages about missing vid/did as these won't exist
on ICL either.
2019-10-16 10:35:04 +02:00
Mario Limonciello
83f8108def thunderbolt: recognize new 'generation' sysfs attribute
Use this attribute to determine whether or not to try to read 'native'
from the Thunderbolt NVM image at probe time.

This attribute is new to kernel 5.5.
2019-10-09 10:25:37 -04:00
Mario Limonciello
20cc9eebc5 Try to only show DMI product name once
* libfwupd: export new property HostProduct
* clients: Use this property for setting the title of trees

Before:
```
○
├─XPS 13 7390 TPM 2.0:
│     Device ID:           c56e9f77cfee65151bdef90310776f9d62827f5a
│     Summary:             Platform TPM device
│     Current version:     7.2.1.0
│     Vendor:              Dell Inc.
│     Update Error:        Updating disabled due to TPM ownership
│     Flags:               internal|require-ac|registered
└─XPS 13 7390 System Firmware:
      Device ID:           b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2
      Current version:     0.1.1.1
      Minimum Version:     0.1.1.1
      Vendor:              Dell Inc.
      Flags:               internal|updatable|require-ac|registered|needs-reboot

```

After:
```
XPS 13 7390
│
├─TPM 2.0:
│     Device ID:           c56e9f77cfee65151bdef90310776f9d62827f5a
│     Summary:             Platform TPM device
│     Current version:     7.2.1.0
│     Vendor:              Dell Inc.
│     Update Error:        Updating disabled due to TPM ownership
│     Flags:               internal|require-ac|registered
└─System Firmware:
      Device ID:           b6c08fb9e5384d9d101853cc1ca20cf0ce2df2e2
      Current version:     0.1.1.1
      Minimum Version:     0.1.1.1
      Vendor:              Dell Inc.
      Flags:               internal|updatable|require-ac|registered|needs-reboot
```
2019-09-05 11:22:39 -05:00
Mario Limonciello
6865dd3bac thunderbolt: Add support for kernel safety checks (Fixes: #1312)
There are commits to the Thunderbolt kernel driver that make sure
that the upgrade process goes smoothly.  If these commits aren't
present then it will look like a fwupd problem, when it's actually
a kernel problem.

When this issue was reported it appeared that commit
e4be8c9b6a
was missing from the locally tested kernel, but it's impossible
to determine that from userspace.

Prevent running the thunderbolt plugin on older kernels than that
set in `$sysconfdir/fwupd/thunderbolt.conf`.

By default that is set to 4.13.0, but if a distribution vendor has
backported all the necessary support it can be decreased to a lower
version for distro packages.
2019-08-28 11:06:18 -05:00
Mario Limonciello
71d2f62dc2 trivial: update references of hughsie/fwupd to fwupd/fwupd 2019-08-22 09:47:52 -05:00
Mario Limonciello
4fa965a9f7 thunderbolt: Fix logic to work properly with ICL thunderbolt controller
This controller isn't flashable in fwupd, but fwupd can display information
about it.
* Use a generic device ID (similar to safemode)
* Build device name attribute from DMI data
2019-08-19 13:16:10 -05:00
Mario Limonciello
ffe7fe24bc trivial: Update icons for Thunderbolt and MST devices 2019-07-30 13:15:20 -07:00
Mario Limonciello
a1a4a3378a trivial: thunderbolt: catch failure setting up device
Fixes: b3aa793539 ("thunderbolt: Convert the instance IDs as we never open the device")
2019-07-15 08:12:26 -07:00
Yehezkel Bernat
6b5f5d13c7 trivial: Fix typos in error messages 2019-07-05 12:48:17 +01:00
Richard Hughes
5079f26f0e Never guess the version format from the version string
This leads to madness, as some formats are supersets of the detected types,
e.g. 'intel-me' is detected as 'quad' and 'bcd' is detected as 'pair'.

Where the version format is defined in a specification or hardcoded in the
source use a hardcoded enum value, otherwise use a quirk override.

Additionally, warn if the version does not match the defined version format
2019-04-30 09:25:41 +01:00
Mario Limonciello
cc3d560571 thunderbolt: Set require-ac for Thunderbolt devices (Fixes: #1142) 2019-04-09 03:15:30 -04:00
Richard Hughes
b3aa793539 thunderbolt: Convert the instance IDs as we never open the device 2019-02-07 18:56:15 +00:00
Richard Hughes
65c81921b6 Add fu_device_add_instance_id() and prefer explicit conversion 2019-02-04 15:19:57 +00:00
Mario Limonciello
d6e453b0ba dell-dock: Add support for flashing Thunderbolt over I2C
This uses an API in the Realtek USB 3.1G2 controller to perform
the flash procedure.
2019-01-24 16:23:00 +00:00
Richard Hughes
f425d29a28 Show a console warning if loading an out-of-tree plugin
Fixes https://github.com/hughsie/fwupd/issues/950
2019-01-19 07:26:20 +00:00
Mario Limonciello
78efa4d2a6 trivial: thunderbolt: If unable to find inactive nvmem, don't mark updatable
This situation may happen in the future in systems where the TBT NVM is embedded
in a different location and only upgradable through system firmware.
2019-01-15 10:33:52 -06:00
Richard Hughes
9729584ee4 Allow plugins to define support for a 'well-known' protocol
Future metadata from the LVFS will set the protocol the firmware is expected to
use. As vendors love to re-use common terms like DFU for incompatible protocols,
namespace them with the controlling company ID with an approximate reverse DNS
namespace.

This also allows more than one plugin to define support for the same protocol,
for instance rts54hid+rts54hub and synapticsmst+dell-dock.
2018-12-14 18:15:01 +00:00
Mario Limonciello
d73fbe08ce thunderbolt: Remove a superfluous boundary condition when verifying update
`g_ascii_strtoull` returns 0 and sets `errno` to `-EINVAL` only when
the base is invalid.  It's hardcoded to `16` so this is impossible.
Reading `-EINVAL` from `errno` is incorrect in these circumstances.

Fixes: https://github.com/hughsie/fwupd/issues/879
2018-12-03 14:28:48 -06:00
Richard Hughes
75b965d01d Shut down the daemon after 2h of inactivity
Plugins are allowed to 'opt-out' of this behaviour using _RULE_INHIBITS_IDLE.
This should be used where waking up the hardware to coldplug is expensive,
either from a power consumption point of view, or if other artifacts are going
to be seem -- for instance if the screen flickers when probing display devices.

This functionality is also inhibited when the actual upgrade is happening,
for obvious reasons.

Admins can turn off this auto-sleep behaviour by editing the daemon.conf file.

Fixes https://github.com/hughsie/fwupd/issues/417
2018-11-21 18:54:44 +00:00
Richard Hughes
86b79fb039 Speed up fwupd startup by loading less thunderbolt firmware
We load the Thunderbolt controller firmware to see if the controller is in
native mode, as this changes the GUID. If the controller is asleep the firmware
is not cached by the kernel and it can take more than 4 seconds to read out
504kB of firmware.

We only need the first two 64-byte chunks, so only read what is required.
This speeds up fwupd starting substantially, and also means we don't have to
allocate a giant chunk of heap memory just to inspect one byte.

Fixes: https://github.com/hughsie/fwupd/issues/848
2018-11-14 16:21:52 +00:00
Richard Hughes
840184929b trivial: Fix some function prefixes for Thunderbolt 2018-11-14 16:21:52 +00:00
Mario Limonciello
845896c954 thunderbolt: Use replugging from the daemon (Closes: #730) 2018-09-26 07:56:12 -05:00
Mario Limonciello
e6c324229a trivial: thunderbolt: don't reuse GError error_local in update function
It should only be used for the one (optionally) non-critical failure
in valiation failing.
2018-09-18 15:49:59 -05:00
Richard Hughes
c125ec02ed Clarify what the platform ID actually is by renaming it
It wasn't hugely clear what the platform ID was actually meant to represent. In
some cases it was being used like a physical ID, in others it was a logical ID,
and in others it was both. In some cases it was even used as a sysfs path.

Clear up all the confusion by splitting the platform ID into two parts, an
optional *physical* ID to represent the electrical connection, and an optional
*logical* ID to disambiguate composite devices with the same physical ID.

Also create an explicit sysfs_path getter for FuUdevDevice to make this clear.

This allows WAIT_FOR_REPLUG to always work, rather than depending on the order
that the GUIDs were added, and that the kernel would always return the same
sysfs path (which it doesn't have to do, especially for hidraw devices).
2018-09-06 16:22:46 +01:00
Mario Limonciello
5b9bf049a3 thunderbolt: Allow failing validation checks if device flag set
As an example use case earlier development versions of a Thunderbolt module
may contain DROM corresponding to one model ID and transition to another
model ID. Even if lying about the GUIDs supported by the device via a
quirk the Thunderbolt validation will fail because the device isn't
intended for that system.

This should only be used during development.
2018-09-05 08:03:28 -05:00
Richard Hughes
4adf3bb52c trivial: Remove duplicate header includes 2018-09-04 08:22:39 -05:00
Mario Limonciello
926da40a88 thunderbolt: Move setting parentage of TB16 into quirks 2018-08-28 18:30:00 +01:00
Richard Hughes
95227a919d trivial: Move gudev to the core plugin deps 2018-08-26 19:38:58 +01:00
Mika Westerberg
511517ad88 thunderbolt: Use fu_plugin_thunderbolt_parse_version () everywhere
Currently we only parse the nvm_version attribute according fwupd
expectations when the device is initially added. Elsewhere we just use
the raw version as is which might be problematic as the version format
can change in the middle (for example "33.02" vs. "33.2"). Fix this so
that fu_plugin_thunderbolt_udev_get_version () always returns parsed
version string.

Update self tests accordingly to have "parsed" version to which we
compare against.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2018-08-12 10:58:16 +01:00
Mika Westerberg
dd7e7d97e8 thunderbolt: Increase retry timeout from 20 to 200 ms
At least with Titan Ridge devices 50 * 20 ms is way too short time
reading nvm_version so most of the time the daemon fails to figure out
the version of the just connected device. To make it work better with
Titan Ridge devices increase the timeout to 50 * 200 ms.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2018-08-09 14:18:55 +01:00
Mika Westerberg
b9ac0aa179 thunderbolt: Handle -EAGAIN from nvm_version elsewhere as well
There are other places in the plugin where we read nvm_version and it
can return -EAGAIN as well. To make sure it works consistenly accross
the plugin factor reading nvm_version to a helper function and use instead.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2018-08-09 14:18:55 +01:00
Richard Hughes
02c90d8a03 Remove the unused Emacs indenting headers from all source files
Fixes https://github.com/hughsie/fwupd/issues/636
2018-08-09 12:48:04 +01:00
Mario Limonciello
c4afb99620 trivial: thunderbolt: Don't re-use GErrors
In instances that we keep processing (such as warnings) these should
be dedicated error variables.
2018-08-01 06:36:07 +01:00
Mario Limonciello
25d51d1429 thunderbolt: Handle -EAGAIN from the kernel better when reading NVM (Closes #608)
Sometimes during initialization trying to read nvm_version will fail
with -EAGAIN.  In these instances keep trying to read.
2018-08-01 06:36:07 +01:00
Mario Limonciello
9fea78eb04 thunderbolt: show ErrorMessage when in safe mode 2018-07-18 16:32:26 -05:00
Mario Limonciello
51308e648a Adjust all licensing to LGPL 2.1+ (Closes: #526) 2018-05-29 09:03:13 +01:00
Mario Limonciello
6e0663ae6c thunderbolt: Set known parent for Thunderbolt devices in Dell TB16 2018-05-03 08:07:04 +01:00