From 8d6dbd9009a3be3d50c7dec3ac4cb56e58ce697c Mon Sep 17 00:00:00 2001 From: Jarvis Jiang Date: Fri, 22 Oct 2021 20:28:02 +0800 Subject: [PATCH] modem-manager: Add the logic of inhibiting modemmanager device in mbim-qdu It may make sense to have the modem not doing anything during the upgrade, so the inhibition would make total sense. Signed-off-by: Jarvis Jiang --- plugins/modem-manager/fu-mbim-qdu-updater.c | 15 ++--------- plugins/modem-manager/fu-mm-device.c | 14 +++++++--- plugins/modem-manager/fu-mm-device.h | 3 +++ .../modem-manager/fu-plugin-modem-manager.c | 26 +++++++++---------- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/plugins/modem-manager/fu-mbim-qdu-updater.c b/plugins/modem-manager/fu-mbim-qdu-updater.c index 5756ce815..a217e9412 100644 --- a/plugins/modem-manager/fu-mbim-qdu-updater.c +++ b/plugins/modem-manager/fu-mbim-qdu-updater.c @@ -270,16 +270,6 @@ typedef struct { FuProgress *progress; } WriteContext; -static gboolean -fu_mbim_qdu_updater_reboot_timeout(gpointer user_data) -{ - WriteContext *ctx = user_data; - g_ptr_array_unref(ctx->chunks); - g_main_loop_quit(ctx->mainloop); - - return G_SOURCE_REMOVE; -} - static void fu_mbim_qdu_updater_file_write_ready(MbimDevice *device, GAsyncResult *res, gpointer user_data) { @@ -322,9 +312,8 @@ fu_mbim_qdu_updater_file_write_ready(MbimDevice *device, GAsyncResult *res, gpoi return; } - fu_progress_set_status(ctx->progress, FWUPD_STATUS_DEVICE_RESTART); - /* device will auto reboot right after update finish */ - g_timeout_add_seconds(10, fu_mbim_qdu_updater_reboot_timeout, ctx); + g_ptr_array_unref(ctx->chunks); + g_main_loop_quit(ctx->mainloop); } static void diff --git a/plugins/modem-manager/fu-mm-device.c b/plugins/modem-manager/fu-mm-device.c index 6367443da..4371d6d5d 100644 --- a/plugins/modem-manager/fu-mm-device.c +++ b/plugins/modem-manager/fu-mm-device.c @@ -54,6 +54,7 @@ struct _FuMmDevice { gchar *detach_fastboot_at; gint port_at_ifnum; gint port_qmi_ifnum; + gint port_mbim_ifnum; /* fastboot detach handling */ gchar *port_at; @@ -138,6 +139,13 @@ fu_mm_device_get_port_qmi_ifnum(FuMmDevice *device) return device->port_qmi_ifnum; } +gint +fu_mm_device_get_port_mbim_ifnum(FuMmDevice *device) +{ + g_return_val_if_fail(FU_IS_MM_DEVICE(device), -1); + return device->port_mbim_ifnum; +} + static gboolean validate_firmware_update_method(MMModemFirmwareUpdateMethod methods, GError **error) { @@ -380,7 +388,7 @@ fu_mm_device_probe_default(FuDevice *device, GError **error) fu_mm_utils_get_port_info(self->port_mbim, &mbim_device_bus, &mbim_device_sysfs_path, - NULL, + &self->port_mbim_ifnum, NULL); if (device_sysfs_path == NULL && mbim_device_sysfs_path != NULL) { device_sysfs_path = g_steal_pointer(&mbim_device_sysfs_path); @@ -1171,8 +1179,6 @@ fu_mm_device_write_firmware_mbim_qdu(FuDevice *device, return FALSE; fu_progress_set_status(progress, FWUPD_STATUS_DEVICE_READ); - fu_device_set_remove_delay(device, MAX_WAIT_TIME_SECS * 1000); - fu_device_add_flag(device, FWUPD_DEVICE_FLAG_WAIT_FOR_REPLUG); version = fu_mm_device_get_firmware_version_mbim(device, error); if (version == NULL) return FALSE; @@ -1553,6 +1559,7 @@ fu_mm_device_new(MMManager *manager, MMObject *omodem) self->omodem = g_object_ref(omodem); self->port_at_ifnum = -1; self->port_qmi_ifnum = -1; + self->port_mbim_ifnum = -1; return self; } @@ -1571,6 +1578,7 @@ fu_plugin_mm_inhibited_device_info_new(FuMmDevice *device) info->detach_fastboot_at = g_strdup(fu_mm_device_get_detach_fastboot_at(device)); info->port_at_ifnum = fu_mm_device_get_port_at_ifnum(device); info->port_qmi_ifnum = fu_mm_device_get_port_qmi_ifnum(device); + info->port_mbim_ifnum = fu_mm_device_get_port_mbim_ifnum(device); info->inhibited_uid = g_strdup(fu_mm_device_get_inhibition_uid(device)); return info; diff --git a/plugins/modem-manager/fu-mm-device.h b/plugins/modem-manager/fu-mm-device.h index 60952195b..9a444f2d1 100644 --- a/plugins/modem-manager/fu-mm-device.h +++ b/plugins/modem-manager/fu-mm-device.h @@ -25,6 +25,8 @@ gint fu_mm_device_get_port_at_ifnum(FuMmDevice *device); gint fu_mm_device_get_port_qmi_ifnum(FuMmDevice *device); +gint +fu_mm_device_get_port_mbim_ifnum(FuMmDevice *device); MMModemFirmwareUpdateMethod fu_mm_device_get_update_methods(FuMmDevice *device); @@ -42,6 +44,7 @@ struct FuPluginMmInhibitedDeviceInfo { gchar *detach_fastboot_at; gint port_at_ifnum; gint port_qmi_ifnum; + gint port_mbim_ifnum; }; FuPluginMmInhibitedDeviceInfo * fu_plugin_mm_inhibited_device_info_new(FuMmDevice *device); diff --git a/plugins/modem-manager/fu-plugin-modem-manager.c b/plugins/modem-manager/fu-plugin-modem-manager.c index 297fa1190..15a8364ff 100644 --- a/plugins/modem-manager/fu-plugin-modem-manager.c +++ b/plugins/modem-manager/fu-plugin-modem-manager.c @@ -247,8 +247,20 @@ fu_plugin_mm_device_removed_cb(MMManager *manager, MMObject *modem, FuPlugin *pl if (dev == NULL) return; g_debug("removed modem: %s", mm_object_get_path(modem)); + +#if MM_CHECK_VERSION(1, 17, 1) + /* No information will be displayed during the upgrade process if the + * device is removed, the main reason is that device is "removed" from + * ModemManager, but it still exists in the system */ + if (!(fu_mm_device_get_update_methods(FU_MM_DEVICE(dev)) & + MM_MODEM_FIRMWARE_UPDATE_METHOD_MBIM_QDU)) { + fu_plugin_cache_remove(plugin, object_path); + fu_plugin_device_remove(plugin, FU_DEVICE(dev)); + } +#else fu_plugin_cache_remove(plugin, object_path); fu_plugin_device_remove(plugin, FU_DEVICE(dev)); +#endif /* MM_CHECK_VERSION(1,17,1) */ } static void @@ -376,13 +388,6 @@ fu_plugin_detach(FuPlugin *plugin, FuDevice *device, FuProgress *progress, GErro FuPluginData *priv = fu_plugin_get_data(plugin); g_autoptr(FuDeviceLocker) locker = NULL; -#if MM_CHECK_VERSION(1, 17, 1) - /* skip update_detach, as MBIM modem doesn't change port layout. */ - if (fu_mm_device_get_update_methods(FU_MM_DEVICE(device)) & - MM_MODEM_FIRMWARE_UPDATE_METHOD_MBIM_QDU) - return TRUE; - -#endif /* MM_CHECK_VERSION(1,17,1) */ /* open device */ locker = fu_device_locker_new(device, error); if (locker == NULL) @@ -419,13 +424,6 @@ fu_plugin_attach(FuPlugin *plugin, FuDevice *device, FuProgress *progress, GErro { g_autoptr(FuDeviceLocker) locker = NULL; -#if MM_CHECK_VERSION(1, 17, 1) - /* skip update_attach, as MBIM modem doesn't change port layout. */ - if (fu_mm_device_get_update_methods(FU_MM_DEVICE(device)) & - MM_MODEM_FIRMWARE_UPDATE_METHOD_MBIM_QDU) - return TRUE; - -#endif /* MM_CHECK_VERSION(1,17,1) */ /* open device */ locker = fu_device_locker_new(device, error); if (locker == NULL)