Commit Graph

75 Commits

Author SHA1 Message Date
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
Mario Limonciello
a98df55d82 Disable -Wunused-function on clang builds (Closes #467)
GLib creates two static inline functions for paramaters that may
not be used that set off warnings in clang but not gcc.

Ignore these on clang builds everywhere that
G_DEFINE_AUTOPTR_CLEANUP_FUNC is used.
2018-04-17 10:10:43 +01:00
Richard Hughes
50aea367b7 thunderbolt: Enforce the thunderbolt version is xx.yy
Fixes: https://github.com/hughsie/fwupd/issues/387
2018-02-12 12:48:13 -06:00
Mario Limonciello
a31895b316 thunderbolt: Report safe mode and native in success/fail 2018-02-09 14:43:56 +00:00
Richard Hughes
2de8f13b2c Allow each plugin to opt-in to the recoldplug action
Recoldplug is really not required for the USB based plugins, and we should
restrict this action to plugins that have inter-dependencies on each other.
2018-01-17 20:19:58 +00:00
Yehezkel Bernat
9157104100 thunderbolt: handle "native" mode
Kernel v4.15 added support for native enumeration of Thunderbolt
topology. The enumeration mode affects both the BIOS and TBT FW
operation so they must agree on it. Platforms may support both modes,
native and "legacy" (or "BIOS-assist").

This change makes sure the new image is compatible with the current
controller mode (otherwise the BIOS and TBT FW will not be alligned on
it at least until next boot) and also adds a new GUID generation logic
for a controller in "native" mode so LVFS could contain 2 images, one for
the "legacy" mode and one for "native".

Signed-off-by: Yehezkel Bernat <yehezkel.bernat@intel.com>
2018-01-08 16:28:23 +00:00
Richard Hughes
024cc230ed Add fu_device_set_progress_full()
This allows the plugin to use the raw byte values as a progress counter without
first converting to a percentage.
2017-12-08 09:36:57 +00:00
Richard Hughes
4a036018f7 Set the progress and state on the FuDevice, not the FuPlugin
This makes more sense; we're updating the device, not the plugin itself.

This also means we don't need to funnel everything through callbacks like
GFileProgressCallback and we can also update the state without adding an
explicit callback to each derived device type.
2017-11-30 20:51:52 +00:00
Mario Limonciello
f3269994a6 thunderbolt: ignore useless thunderbolt device types
Kernel 4.15 adds support for Thunderbolt P2P devices via
CONFIG_THUNDERBOLT_NET.  When turned on and activated fwupd will
show an empty device representing the IP connection between machines.

These device types aren't useful in fwupd and should be filtered.

Suggested-by: Mika Westerberg <mika.westerberg@intel.com>
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
2017-11-20 16:41:47 -06:00
Richard Hughes
b6f79556f1 Use a SHA1 hash for the internal DeviceID
It's actually less scary to see a SHA1 hash than it is to see a path like
/sys/devices/pci0000:00/0000:00:1d.0/usb1/1-1/1-1.2. It's also way easier to
copy and paste into the various fwupdmgr command that require a device ID and
also means we can match a partial prefix much like git allows.

If we also move to a model where plugins can be changed during different stages
of the update (e.g. during detach) then the device might change connection type
and then the sysfs path not only becomes difficult to paste, but incorrect.

Session software doesn't care about the format of the device ID (it is supposed
to be an implementation detail) and so there's no API or ABI break here. A few
plugins also needed to be ported, but nothing too worrying.
2017-11-16 07:18:36 +00:00
Richard Hughes
c1c2fec6f5 Add optional icons to each device
This allows us to show the devices in a GUI with a nice icon. Some of the icon
mappings are not perfect and I'll be asking the GNOME designers for some
additions to the icon specification.

Custom vendor icons can also be specified, and /usr/share/fwupd/icons would be
a good place to put them. If vendor icons are used they should show a physical
device with the branding, rather than just the vendor logo.
2017-09-11 17:27:35 +01:00