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.
This commit is contained in:
Mario Limonciello 2019-10-16 16:28:54 -05:00 committed by Mario Limonciello
parent 0b7143da66
commit 97c1e727c4
10 changed files with 41 additions and 13 deletions

View File

@ -173,6 +173,12 @@ fwupd_device_flag_to_string (FwupdDeviceFlags device_flag)
return "can-verify"; return "can-verify";
if (device_flag == FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE) if (device_flag == FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE)
return "can-verify-image"; return "can-verify-image";
if (device_flag == FWUPD_DEVICE_FLAG_DUAL_IMAGE)
return "dual-image";
if (device_flag == FWUPD_DEVICE_FLAG_SELF_RECOVERY)
return "self-recovery";
if (device_flag == FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE)
return "usable-during-update";
if (device_flag == FWUPD_DEVICE_FLAG_UNKNOWN) if (device_flag == FWUPD_DEVICE_FLAG_UNKNOWN)
return "unknown"; return "unknown";
return NULL; return NULL;
@ -247,6 +253,12 @@ fwupd_device_flag_from_string (const gchar *device_flag)
return FWUPD_DEVICE_FLAG_CAN_VERIFY; return FWUPD_DEVICE_FLAG_CAN_VERIFY;
if (g_strcmp0 (device_flag, "can-verify-image") == 0) if (g_strcmp0 (device_flag, "can-verify-image") == 0)
return FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE; return FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE;
if (g_strcmp0 (device_flag, "dual-image") == 0)
return FWUPD_DEVICE_FLAG_DUAL_IMAGE;
if (g_strcmp0 (device_flag, "self-recovery") == 0)
return FWUPD_DEVICE_FLAG_SELF_RECOVERY;
if (g_strcmp0 (device_flag, "usable-during-update") == 0)
return FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE;
return FWUPD_DEVICE_FLAG_UNKNOWN; return FWUPD_DEVICE_FLAG_UNKNOWN;
} }

View File

@ -94,6 +94,9 @@ typedef enum {
* @FWUPD_DEVICE_FLAG_WILL_DISAPPEAR: Device will disappear after update and can't be verified * @FWUPD_DEVICE_FLAG_WILL_DISAPPEAR: Device will disappear after update and can't be verified
* @FWUPD_DEVICE_FLAG_CAN_VERIFY: Device checksums can be compared against metadata * @FWUPD_DEVICE_FLAG_CAN_VERIFY: Device checksums can be compared against metadata
* @FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE: Image can be dumped from device for verification * @FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE: Image can be dumped from device for verification
* @FWUPD_DEVICE_FLAG_DUAL_IMAGE: Device update architecture uses A/B partitions for updates
* @FWUPD_DEVICE_FLAG_SELF_RECOVERY: In flashing mode device will only accept intended payloads
* @FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE: Device remains usable while fwupd flashes or schedules the update
* *
* The device flags. * The device flags.
**/ **/
@ -125,6 +128,9 @@ typedef enum {
#define FWUPD_DEVICE_FLAG_WILL_DISAPPEAR (1u << 24) /* Since: 1.3.3 */ #define FWUPD_DEVICE_FLAG_WILL_DISAPPEAR (1u << 24) /* Since: 1.3.3 */
#define FWUPD_DEVICE_FLAG_CAN_VERIFY (1u << 25) /* Since: 1.3.3 */ #define FWUPD_DEVICE_FLAG_CAN_VERIFY (1u << 25) /* Since: 1.3.3 */
#define FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE (1u << 26) /* Since: 1.3.3 */ #define FWUPD_DEVICE_FLAG_CAN_VERIFY_IMAGE (1u << 26) /* Since: 1.3.3 */
#define FWUPD_DEVICE_FLAG_DUAL_IMAGE (1u << 27) /* Since: 1.3.3 */
#define FWUPD_DEVICE_FLAG_SELF_RECOVERY (1u << 28) /* Since: 1.3.3 */
#define FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE (1u << 29) /* Since: 1.3.3 */
#define FWUPD_DEVICE_FLAG_UNKNOWN G_MAXUINT64 /* Since: 0.7.3 */ #define FWUPD_DEVICE_FLAG_UNKNOWN G_MAXUINT64 /* Since: 0.7.3 */
typedef guint64 FwupdDeviceFlags; typedef guint64 FwupdDeviceFlags;

View File

@ -343,8 +343,10 @@ fu_ata_device_probe (FuUdevDevice *device, GError **error)
/* look at the PCI and USB depth to work out if in an external enclosure */ /* look at the PCI and USB depth to work out if in an external enclosure */
self->pci_depth = fu_udev_device_get_slot_depth (device, "pci"); self->pci_depth = fu_udev_device_get_slot_depth (device, "pci");
self->usb_depth = fu_udev_device_get_slot_depth (device, "usb"); self->usb_depth = fu_udev_device_get_slot_depth (device, "usb");
if (self->pci_depth <= 2 && self->usb_depth <= 2) if (self->pci_depth <= 2 && self->usb_depth <= 2) {
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE);
}
return TRUE; return TRUE;
} }

View File

@ -1,7 +1,7 @@
# ColorHug1 # ColorHug1
[DeviceInstanceId=USB\VID_273F&PID_1000] [DeviceInstanceId=USB\VID_273F&PID_1000]
Plugin = colorhug Plugin = colorhug
Flags = is-bootloader Flags = is-bootloader,self-recovery
Guid = 40338ceb-b966-4eae-adae-9c32edfcc484 Guid = 40338ceb-b966-4eae-adae-9c32edfcc484
FirmwareSizeMin = 0x2000 FirmwareSizeMin = 0x2000
FirmwareSizeMax = 0x8000 FirmwareSizeMax = 0x8000
@ -10,7 +10,7 @@ InstallDuration = 8
[DeviceInstanceId=USB\VID_273F&PID_1001] [DeviceInstanceId=USB\VID_273F&PID_1001]
Plugin = colorhug Plugin = colorhug
Flags = none Flags = self-recovery
Summary = An open source display colorimeter Summary = An open source display colorimeter
Icon = colorimeter-colorhug Icon = colorimeter-colorhug
Guid = 40338ceb-b966-4eae-adae-9c32edfcc484 Guid = 40338ceb-b966-4eae-adae-9c32edfcc484
@ -20,7 +20,7 @@ InstallDuration = 8
# ColorHug2 # ColorHug2
[DeviceInstanceId=USB\VID_273F&PID_1004] [DeviceInstanceId=USB\VID_273F&PID_1004]
Plugin = colorhug Plugin = colorhug
Flags = none Flags = self-recovery
Summary = An open source display colorimeter Summary = An open source display colorimeter
Icon = colorimeter-colorhug Icon = colorimeter-colorhug
Guid = 2082b5e0-7a64-478a-b1b2-e3404fab6dad Guid = 2082b5e0-7a64-478a-b1b2-e3404fab6dad
@ -31,7 +31,7 @@ InstallDuration = 8
[DeviceInstanceId=USB\VID_273F&PID_1005] [DeviceInstanceId=USB\VID_273F&PID_1005]
Plugin = colorhug Plugin = colorhug
Flags = is-bootloader Flags = is-bootloader,self-recovery
Guid = 2082b5e0-7a64-478a-b1b2-e3404fab6dad Guid = 2082b5e0-7a64-478a-b1b2-e3404fab6dad
CounterpartGuid = USB\VID_273F&PID_1004 CounterpartGuid = USB\VID_273F&PID_1004
InstallDuration = 8 InstallDuration = 8
@ -39,7 +39,7 @@ InstallDuration = 8
# ColorHugALS # ColorHugALS
[DeviceInstanceId=USB\VID_273F&PID_1007] [DeviceInstanceId=USB\VID_273F&PID_1007]
Plugin = colorhug Plugin = colorhug
Flags = halfsize,none Flags = halfsize,self-recovery
Summary = An open source ambient light sensor Summary = An open source ambient light sensor
Guid = 84f40464-9272-4ef7-9399-cd95f12da696 Guid = 84f40464-9272-4ef7-9399-cd95f12da696
FirmwareSizeMin = 0x1000 FirmwareSizeMin = 0x1000
@ -49,7 +49,7 @@ InstallDuration = 5
[DeviceInstanceId=USB\VID_273F&PID_1006] [DeviceInstanceId=USB\VID_273F&PID_1006]
Plugin = colorhug Plugin = colorhug
Flags = halfsize,is-bootloader Flags = halfsize,is-bootloader,self-recovery
Guid = 84f40464-9272-4ef7-9399-cd95f12da696 Guid = 84f40464-9272-4ef7-9399-cd95f12da696
CounterpartGuid = USB\VID_273F&PID_1007 CounterpartGuid = USB\VID_273F&PID_1007
InstallDuration = 5 InstallDuration = 5

View File

@ -33,7 +33,7 @@ Plugin = dell_dock
Vendor = Dell Inc Vendor = Dell Inc
Icon = dock-usb Icon = dock-usb
FirmwareSize = 0x10000 FirmwareSize = 0x10000
Flags = require-ac,updatable Flags = require-ac,updatable,dual-image,usable-during-update
DellDockUnlockTarget = 8 DellDockUnlockTarget = 8
DellDockBlobMajorOffset = 0x7F6E DellDockBlobMajorOffset = 0x7F6E
DellDockBlobMinorOffset = 0x7F6F DellDockBlobMinorOffset = 0x7F6F
@ -48,7 +48,7 @@ Vendor = Dell Inc
Plugin = dell_dock Plugin = dell_dock
Icon = dock-usb Icon = dock-usb
FirmwareSize = 0x10000 FirmwareSize = 0x10000
Flags = require-ac,updatable,has-bridge Flags = require-ac,updatable,has-bridge,dual-image,usable-during-update
DellDockUnlockTarget = 7 DellDockUnlockTarget = 7
DellDockBlobMajorOffset = 0x7F52 DellDockBlobMajorOffset = 0x7F52
DellDockBlobMinorOffset = 0x7F53 DellDockBlobMinorOffset = 0x7F53
@ -64,7 +64,7 @@ Vendor = Dell Inc
Icon = dock-usb Icon = dock-usb
FirmwareSizeMin = 0x1FFC0 FirmwareSizeMin = 0x1FFC0
FirmwareSizeMax = 0x20000 FirmwareSizeMax = 0x20000
Flags = require-ac Flags = require-ac,dual-image,self-recovery,usable-during-update
Children = FuDellDockStatus|USB\VID_413C&PID_B06E&hub&status,FuDellDockMst|MST-panamera-vmm5331-259 Children = FuDellDockStatus|USB\VID_413C&PID_B06E&hub&status,FuDellDockMst|MST-panamera-vmm5331-259
DellDockUnlockTarget = 1 DellDockUnlockTarget = 1
DellDockBoardMin = 6 DellDockBoardMin = 6
@ -78,6 +78,7 @@ Name = Package level of Dell dock
Summary = A representation of dock update status Summary = A representation of dock update status
Plugin = dell_dock Plugin = dell_dock
Vendor = Dell Inc Vendor = Dell Inc
Flags = self-recovery,usable-during-update
FirmwareSize = 24 FirmwareSize = 24
InstallDuration = 5 InstallDuration = 5
DellDockBlobVersionOffset = 0x14 DellDockBlobVersionOffset = 0x14
@ -89,7 +90,7 @@ Summary = Multi Stream Transport controller
Vendor = Dell Inc Vendor = Dell Inc
Plugin = synapticsmst Plugin = synapticsmst
ParentGuid = USB\VID_413C&PID_B06E&hub&embedded ParentGuid = USB\VID_413C&PID_B06E&hub&embedded
Flags = skip-restart,require-ac Flags = skip-restart,require-ac,dual-image,usable-during-update
FirmwareSize=524288 FirmwareSize=524288
DellDockUnlockTarget = 9 DellDockUnlockTarget = 9
InstallDuration = 95 InstallDuration = 95
@ -107,7 +108,7 @@ Vendor = Dell Inc
ParentGuid = USB\VID_413C&PID_B06E&hub&embedded ParentGuid = USB\VID_413C&PID_B06E&hub&embedded
FirmwareSizeMin=0x40000 FirmwareSizeMin=0x40000
FirmwareSizeMax=0x80000 FirmwareSizeMax=0x80000
Flags = require-ac Flags = require-ac,dual-image
Icon = thunderbolt Icon = thunderbolt
InstallDuration = 22 InstallDuration = 22
DellDockInstallDurationI2C = 181 DellDockInstallDurationI2C = 181

View File

@ -224,6 +224,8 @@ fu_dell_dock_tbt_probe (FuDevice *device, GError **error)
fu_device_set_physical_id (device, fu_device_get_physical_id (parent)); fu_device_set_physical_id (device, fu_device_get_physical_id (parent));
fu_device_set_logical_id (FU_DEVICE (device), "tbt"); fu_device_set_logical_id (FU_DEVICE (device), "tbt");
fu_device_add_instance_id (device, DELL_DOCK_TBT_INSTANCE_ID); fu_device_add_instance_id (device, DELL_DOCK_TBT_INSTANCE_ID);
/* this is true only when connected to non-thunderbolt port */
fu_device_add_flag (device, FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE);
return TRUE; return TRUE;
} }

View File

@ -351,8 +351,10 @@ fu_nvme_device_probe (FuUdevDevice *device, GError **error)
/* look at the PCI depth to work out if in an external enclosure */ /* look at the PCI depth to work out if in an external enclosure */
self->pci_depth = fu_udev_device_get_slot_depth (device, "pci"); self->pci_depth = fu_udev_device_get_slot_depth (device, "pci");
if (self->pci_depth <= 2) if (self->pci_depth <= 2) {
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_INTERNAL);
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE);
}
/* all devices need at least a warm reset, but some quirked drives /* all devices need at least a warm reset, but some quirked drives
* need a full "cold" shutdown and startup */ * need a full "cold" shutdown and startup */

View File

@ -1196,6 +1196,7 @@ fu_synapticsmst_device_rescan (FuDevice *device, GError **error)
case FU_SYNAPTICSMST_FAMILY_PANAMERA: case FU_SYNAPTICSMST_FAMILY_PANAMERA:
fu_device_set_firmware_size_max (device, 0x80000); fu_device_set_firmware_size_max (device, 0x80000);
fu_device_add_instance_id (device, "MST-panamera"); fu_device_add_instance_id (device, "MST-panamera");
fu_device_add_flag (device, FWUPD_DEVICE_FLAG_DUAL_IMAGE);
break; break;
default: default:
break; break;

View File

@ -379,6 +379,7 @@ fu_plugin_thunderbolt_add (FuPlugin *plugin, GUdevDevice *device)
(guint) did, (guint) did,
is_native ? "-native" : ""); is_native ? "-native" : "");
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (dev, FWUPD_DEVICE_FLAG_DUAL_IMAGE);
} else { } else {
device_id = g_strdup ("TBT-fixed"); device_id = g_strdup ("TBT-fixed");
fu_device_set_update_error (dev, "Missing non-active nvmem"); fu_device_set_update_error (dev, "Missing non-active nvmem");

View File

@ -901,6 +901,7 @@ fu_plugin_coldplug (FuPlugin *plugin, GError **error)
"RequireShimForSecureBoot", "RequireShimForSecureBoot",
data->require_shim_for_sb); data->require_shim_for_sb);
fu_device_add_flag (FU_DEVICE (dev), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (dev), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_add_flag (FU_DEVICE (dev), FWUPD_DEVICE_FLAG_USABLE_DURING_UPDATE);
} }
fu_plugin_device_add (plugin, FU_DEVICE (dev)); fu_plugin_device_add (plugin, FU_DEVICE (dev));
} }