Commit Graph

49 Commits

Author SHA1 Message Date
Richard Hughes
11bcf2677c synaptics-mst: Only probe devices that have opted-in
Fixes https://github.com/fwupd/fwupd/issues/3701
2021-09-03 21:14:37 +01:00
Richard Hughes
d4fb04d6fc Allow overriding the quirks directory at runtime 2021-09-03 21:14:37 +01:00
Mario Limonciello
946cfd63ac trivial: synaptics-mst: make self tests not write
The self tests shouldn't be writing the source directory, make sure
they open up files in read-only mode.
2021-09-03 15:10:38 -05:00
Mario Limonciello
55de39c077 trivial: reformat the whole tree to match new format 2021-08-24 11:18:40 -05:00
Apollo Ling
98f78f4b15 plugin/synaptics-mst: add support for cayenne/spyder 2021-08-19 22:49:38 -05:00
Richard Hughes
a5a978b3f6 Rename some confusing API
More than one person has asked about 'why call fu_plugin_update() for a
reinstall or downgrade' and I didn't have a very good answer.

The plugin API is not officially stable, and we should fix things to be
less confusing. Use the same verbs as the FuDevice vfuncs instead.
2021-08-06 19:49:53 +01:00
Mario Limonciello
798d1ed3ee trivial: update markdown for pre-commit style 2021-07-18 14:42:47 -05:00
Richard Hughes
d4bd5cca5a Standardize some of the device summary text
This is supposed to be 'Sentence case' with no trailing fullstop.
2021-07-09 07:07:07 +01:00
Richard Hughes
dfaae2e837 Move amdgpu safety check into the plugin
There are now multiple plugins using drm_dp_aux_dev interface which
may potentially be combined with an amdgpu. Prevent exercising this
interface with any plugin using DP aux unless a new enough kernel is
installed.
2021-07-04 17:49:36 +01:00
Richard Hughes
aaa77c6f51 Allow adding and removing custom flags on devices
The CustomFlags feature is a bit of a hack where we just join the flags
and store in the device metadata section as a string. This makes it
inefficient to check if just one flag exists as we have to split the
string to a temporary array each time.

Rather than adding to the hack by splitting, appending (if not exists)
then joining again, store the flags in the plugin privdata directly.

This allows us to support negating custom properties (e.g. ~hint) and
also allows quirks to append custom values without duplicating them on
each GUID match, e.g.

[USB\VID_17EF&PID_307F]
Plugin = customflag1
[USB\VID_17EF&PID_307F&HUB_0002]
Flags = customflag2

...would result in customflag1,customflag2 which is the same as you'd
get from an enumerated device flag doing the same thing.
2021-06-23 07:59:15 +01:00
Mario Limonciello
9e6a8bd318 trivial: Adjust synaptics-mst amdgpu safety check
The previous safety check was introduced due to a bug in the kernel
where it would produce a traceback and hang the offending process.

This code was fixed in kernel 5.2.0:
8ae5b1d78d

Add a new configuration option that will allow disabling the safety
checks if a new enough kernel is in place.  This configuration option
is necessary because some Linux distributions may backport drm, and thus
this commit but still need the feature to work.
2021-06-16 14:54:17 -05:00
Mario Limonciello
73cdf067ed trivial: fixup includes for a variety of plugins 2021-06-14 10:12:45 +01:00
Richard Hughes
b333e0045c Split out a shared system context
There is a lot of code in fwupd that just assigns a shared object type to
a FuPlugin, and then for each device on that plugin assigns that same shared
object to each FuDevice.

Rather than proxy several kinds of information stores over two different levels
of abstraction create a 'context' which contains the shared *system* state
between the daemon, the plugins and the daemon.

This will allow us to hold other per-machine state in the future, for instance
the system battery level or AC state.
2021-04-01 21:11:29 +01:00
Richard Hughes
52441f28a4 Allow objects to deserialize to XML
This makes a lot more sense; we can parse a firmware and export the same XML
we would use in a .builder.xml file. This allows us to two two things:

 * Check we can round trip from XML -> binary -> XML

 * Using a .builder.xml file we can check ->write() is endian safe
2021-03-15 12:07:30 +00:00
Richard Hughes
35a5962991 synaptics-mst: Add support for writing firmware 2021-03-10 16:35:43 -06:00
Richard Hughes
1981c63d58 Remove FuFirmwareImage and just use FuFirmware instead
This allows us to 'nest' firmware formats, and removes a ton of duplication.

The aim here is to deprecate FuFirmwareImage -- it's almost always acting
as a 'child' FuFirmware instance, and even copies most of the vfuncs to allow
custom types. If I'm struggling to work out what should be a FuFirmware and
what should be a FuFirmwareImage then a plugin author has no hope.

For simple payloads we were adding bytes into an image and then the image into
a firmware. This gets really messy when most plugins are treating the FuFirmware
*as* the binary firmware file.

The GBytes saved in the FuFirmware would be considered the payload with the
aim of not using FuFirmwareImage in the single-image case.
2021-03-09 21:14:12 +00:00
Richard Hughes
c81b755872 Be more strict for custom quirk keys
Rather than trying to guess typos, force each plugin to register the quirk
keys it supports, so we can show a sensible warning if required at startup on
the console.
2021-03-03 08:30:34 +00:00
Richard Hughes
7d132b728c Simplify the quirk file format
The best way of not getting something wrong is to not require it in the first
place...

All plugins now use DeviceInstanceId-style quirk matches and we can just drop
the prefix in all files. We were treating HwId=, Guid= and DeviceInstanceId= in
exactly the same way -- they're just converted to GUIDs when building the silo!
2021-03-03 08:30:34 +00:00
Richard Hughes
f878a7bcba synaptics-mst: Use DeviceInstanceIDs to merge quirk metadata
This means we can use the standard ->set_quirk_kv() vfunc rather than using
FuQuirks directly with a custom group. Also use a plugin prefix for quirk keys.
2021-03-03 08:30:34 +00:00
Richard Hughes
b3f9841924 Support more than one protocol for a given device
Devices may want to support more than one protocol, and for some devices
(e.g. Unifying peripherals stuck in bootloader mode) you might not even be able
to query for the correct protocol anyway.
2021-03-01 16:14:36 +00:00
Richard Hughes
078beafb2d Add a new internal flag to opt-in to GUID matching
It is far too easy to forget to set FWUPD_DEVICE_FLAG_NO_GUID_MATCHING for new
plugins, and without it it all works really well *until* a user has two devices
of the same type installed at the same time and then one 'disappears' for hard
to explain reasons. Typically we only need it for replug anyway!

Explicitly opt-in to this rarely-required behaviour, with the default to just
use the physical and logical IDs. Also document the update behavior for each
plugin to explain why the flag is being used.

This allows you to have two identical Unifying plugged in without one of them
being hidden from the user, at the same time allowing a HIDRAW<->USB transition
when going to and from bootloader and runtime modes.

This removes the workaround added in 99eb3f06b6.

Fixes https://github.com/fwupd/fwupd/issues/2915
2021-02-25 15:47:25 +00:00
Richard Hughes
a647ae05d1 synaptics-mst: Do not allow updating a device with no customer ID
This is typically when the OEM is using the reference hardware design.

Prevent updates, as there might be a new bug introduced in the reference
firmware that only manifests on one OEM's product. It's up to the OEM to do the
testing and validation.

We need something to tie it back to a physical device model if it's using a
reference firmware and we want to update it.
2021-02-22 15:53:58 +00:00
Richard Hughes
5f9e4730f1 synaptics-mst: Read the customer ID (board ID) in a more safe way
Also split out the firmware parsing to an object so we can check the firmware
using firmware-parse and also fuzz it.

See also: https://github.com/fwupd/fwupd/issues/1665
2021-02-22 13:57:34 +00:00
Richard Hughes
2e1245728f Call the superclass directly from subclassed devices
This allows a device subclass to call the parent method after doing an initial
action, or even deliberately not call the *generic* parent method at all.

It also simplifies the plugins; you no longer have to remember what the plugin
is deriving from and accidentally clobber the wrong superclass method.
2021-02-18 16:18:34 +00:00
Richard Hughes
a22c13c637 Move the plugin build logic to the plugins themselves 2021-02-18 14:46:20 +00:00
Richard Hughes
525f71f54b Merge the _udev_device() and _usb_device() vfuncs
There are now two 'backends' of device plug/unplug events, and there is about
to become three. Rather than just adding two more vfuncs for every backend type
define common ones that all providers can use.

Also fix up the existing in-tree plugins to use the new vfunc names and filter
on the correct GType.
2021-02-10 12:04:05 +00:00
Mario Limonciello
75835b4a0b Use FWUPD_COMPILATION define to indicate an in tree build
When this is done, include:
* Including the hash
* Including anything that is not ABI stable in plugins yet

Suggested-by: Simon McVittie <smcv@debian.org>
2021-01-22 14:01:25 -06:00
Richard Hughes
5c9b1fcc81 Only include the start year in the copyright header
The end year is legally and functionally redundant, and more importantly causes
cherry-pick conflicts when trying to maintain old branches. Use git for history.
2021-01-07 14:48:16 +00:00
Richard Hughes
eddaed0c11 Allow specifying more than one VendorID for a device
Asking the user for the UID mapping isn't working very well, as it requires lots
of manual handholding. It also doesn't work very well when the device vendor
does not actually have a PCI ID or if the vendor has split into two entities.

Just use the OUI address as an additional VendorID and match any of the device
IDs against any of the metadata-supplied values.
2021-01-04 22:30:20 +00:00
Richard Hughes
eac6edd7c5 synaptics-mst: Improve reliability by waiting 2 seconds after writing data
On failure, you get this:

    no device found on drm_dp_aux5: Memory query failed: failed to write command
    failed to get device after update: failed to wait for detach replug
2020-11-10 13:13:48 +00:00
Richard Hughes
58993ac005 trivial: Fix some error prefixes 2020-11-06 09:57:03 +00:00
Mario Limonciello
8aa5d41eb7 Add external interface messages 2020-10-26 12:05:20 -05:00
Richard Hughes
6450d0deb4 Add FwupdInstallFlags of _IGNORE_CHECKSUM, _IGNORE_VID_PID and _IGNORE_POWER
The FWUPD_INSTALL_FLAG_FORCE flag has really unclear semantics, and ignoring a
file CRC, checksum or model ID should only be done when using fwupdtool actually
debugging a plugin or firmware parser.

Use the existing --force flag when we want a "gentle nudge" like reuploading
previously processed reports.
2020-10-07 13:15:09 +01:00
Richard Hughes
9a07407401 Use the FuUdevDevice ->to_string() output
Print the sysfs path for devices deriving from FuUdevDevice, which also allows
us to use FU_UDEV_DEVICE_DEBUG without monkey-patching the plugins that also
define a device_class->to_string() vfunc.
2020-09-03 16:50:41 +01:00
Mario Limonciello
5de5dd3582 Install the installed tests
Move binaries out of fwupd tree to https://github.com/fwupd/fwupd-test-firmware

Fixes some of https://github.com/fwupd/fwupd/issues/1956
2020-08-28 10:10:43 -05:00
mendel5
db2906d49c fu-plugin-synaptics-mst.c: replace github.com/hughsie with github.com/fwupd 2020-07-28 14:28:15 -05:00
Mario Limonciello
838ae163e3 dell-dock: prevent updates to occur via synaptics-mst plugin
Although they normally work, some failures have been reported in the field
related to the MST hub not responding in the MST plugin.

When these failures have occurred the dell_dock plugin also fails to
enumerate.

So rather than allow some people who don't have dell_dock compiled to
update their MST hub using synaptics_mst, perform ALL updates for
mst hub via dell_dock.

```
18:06:24:0324 FuPluginSynapticsMST no device found on drm_dp_aux1: VMM5331 inside Dell dock is only supported by dell_dock
```
2020-05-28 08:59:07 -05:00
Mario Limonciello
768a2680a6 Introduce a new flag skips-restart
This flag is used internally by plugins to indicate that they will
skip the phase of firmware installation that power cycles a device.

It is intended to be set by quirks or other environment settings.
2020-05-06 15:13:40 -05:00
Richard Hughes
464eacdc53 libfwupdplugin: Use fu_device_locker_close() 2020-03-26 15:23:10 -05:00
Richard Hughes
d66a445ada synaptics-mst: Use fu_device_locker_close() 2020-03-26 15:23:10 -05:00
Richard Hughes
69b761ce64 trivial: Export fu_device_add_instance_id_full() for plugins to use
Sometimes we only want to add the instance ID to get the quirk matches, and it
is confusing to see the "fake" IDs in the 'fwupdmgr get-devices' output.
2020-03-24 14:43:31 +00: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
de5573c68b synaptics-mst: Allow MST to fall back if no PCI device is marked as parent
At the moment not having a udev parent was causing the dock device to not be
detected.
2020-02-12 17:15:28 +00:00
Richard Hughes
bc49d019cd synaptics-mst: Fix trivial thinko caused by the wrong dock connected 2020-02-12 09:48:07 +00:00
Richard Hughes
af3b91d490 Set up more parent devices for various Lenovo USB hubs 2020-02-11 11:22:20 +00:00
Mario Limonciello
da2adf0e6f trivial: synaptics-mst: adjust last part of triplet to be 2 digits not 3
Synaptics versions are encoded as BCD, the largest version that will
ever be represented in this field is '99'.

Using 3 digits in this field has caused multiple problems in upgrades from
LVFS.

1. Devices are being upgraded when not necessary.
IE `5.3.10 > 5.3.010`

2. Device upgrades are deemed failures as follows:

```
BootTime=1571436076,
CompileVersion(com.redhat.efivar)=37,
CompileVersion(com.redhat.fwupdate)=12,
CompileVersion(org.freedesktop.fwupd)=1.3.2,
CompileVersion(org.freedesktop.gusb)=0.3.0,
CpuArchitecture=x86_64,
DistroId=fedora,
DistroVariant=workstation,
DistroVersion=32,
FirmwareId=1915,
Flags=4194346,
Guid=f15aa55c-9cd5-5942-85ae-a6bf8740b96c,
MachineId=97aa89528b88d9631867a4e20c68a5208124ef592e19d05f0c5e7d22bd4d7afb,
Plugin=synapticsmst,
RuntimeVersion(com.dell.libsmbios)=2.4,
RuntimeVersion(com.redhat.fwupdate)=12,
RuntimeVersion(org.freedesktop.appstream-glib)=0.7.14,
RuntimeVersion(org.freedesktop.fwupd)=1.3.2,
RuntimeVersion(org.kernel)=5.4.0-0.rc2.git2.1.fc32.x86_64,
UpdateError=device version not updated on success, 05.03.10 != 5.03.010,
UpdateState=failed,
VersionNew=05.03.10,
VersionOld=5.03.010

```
2020-01-22 15:22:11 -06:00
Mario Limonciello
7442b7ba77 synaptics-mst: Skip self tests for systems with amdgpu
No need to fail these self tests when using amdgpu, just skip them.
Fixes unrelated issue found in #1183

Signed-off-by: Richard Hughes <richard@hughsie.com>
2020-01-08 08:44:01 +00:00
Richard Hughes
63b9ac8844 Don't always get the vendor ID for udev devices using the parent
Fixes bugs like https://github.com/fwupd/fwupd/issues/1673
2020-01-06 14:48:58 +00:00
Mario Limonciello
fd6ffd6dac trivial: rename synapticsmst to synaptics-mst
This brings the naming nomenclature inline with the other plugins
2019-12-12 13:59:41 -06:00