diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2023-04-19 11:19:15 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-05-03 12:38:43 +0000 |
commit | f922a6be2d1e1e7c763da783e2a97de38bee39bc (patch) | |
tree | 97e0bb9c7a09462c33b69bb1edd7210cefc33724 | |
parent | 22c4d88a24a990632bfd63982019f066ce0cceb8 (diff) | |
download | ModemManager-f922a6be2d1e1e7c763da783e2a97de38bee39bc.tar.gz |
broadband-modem-mbim: ensure cached state info is reseted on disable
So that it is reloaded fresh once re-enabled, otherwise we may be
using stale state values that are not in sync with the state reported
in the interface skeletons.
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 56 |
2 files changed, 43 insertions, 15 deletions
diff --git a/meson.build b/meson.build index 09ae4488a..c6ed8cfbb 100644 --- a/meson.build +++ b/meson.build @@ -252,7 +252,7 @@ config_h.set('WITH_BUILTIN_PLUGINS', enable_builtin_plugins) # MBIM support (enabled by default) enable_mbim = get_option('mbim') if enable_mbim - mbim_glib_dep = dependency('mbim-glib', version: '>= 1.29.2') + mbim_glib_dep = dependency('mbim-glib', version: '>= 1.29.5') endif config_h.set('WITH_MBIM', enable_mbim) diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index 6d9ede7c4..1ebdabe9e 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -137,15 +137,25 @@ struct _MMBroadbandModemMbimPrivate { ProcessNotificationFlag setup_flags; ProcessNotificationFlag enable_flags; + /* Runtime cached state while enabled, to be cleaned up once disabled */ + gchar *current_operator_id; + gchar *current_operator_name; GList *pco_list; + MbimDataClass available_data_classes; + MbimDataClass highest_available_data_class; + MbimRegisterState reg_state; + MbimPacketServiceState packet_service_state; + guint64 packet_service_uplink_speed; + guint64 packet_service_downlink_speed; + MbimSubscriberReadyState last_ready_state; /* 3GPP registration helpers */ - gchar *current_operator_id; - gchar *current_operator_name; + gulong enabling_signal_id; gchar *requested_operator_id; MbimDataClass requested_data_class; /* 0 for defaults/auto */ - GTask *pending_allowed_modes_action; - gulong enabling_signal_id; + + /* Allowed modes helpers */ + GTask *pending_allowed_modes_action; /* USSD helpers */ GTask *pending_ussd_action; @@ -153,16 +163,6 @@ struct _MMBroadbandModemMbimPrivate { /* SIM hot swap setup */ gboolean sim_hot_swap_configured; - /* Access technology and registration updates */ - MbimDataClass available_data_classes; - MbimDataClass highest_available_data_class; - MbimRegisterState reg_state; - MbimPacketServiceState packet_service_state; - guint64 packet_service_uplink_speed; - guint64 packet_service_downlink_speed; - - MbimSubscriberReadyState last_ready_state; - /* For notifying when the mbim-proxy connection is dead */ gulong mbim_device_removed_id; @@ -5725,6 +5725,27 @@ common_setup_cleanup_unsolicited_events_3gpp_finish (MMIfaceModem3gpp *self, } static void +cleanup_enabled_cache (MMBroadbandModemMbim *self) +{ + g_clear_pointer (&self->priv->current_operator_id, g_free); + g_clear_pointer (&self->priv->current_operator_name, g_free); + g_list_free_full (self->priv->pco_list, g_object_unref); + self->priv->pco_list = NULL; + self->priv->available_data_classes = MBIM_DATA_CLASS_NONE; + self->priv->highest_available_data_class = MBIM_DATA_CLASS_NONE; + self->priv->reg_state = MBIM_REGISTER_STATE_UNKNOWN; + self->priv->packet_service_state = MBIM_PACKET_SERVICE_STATE_UNKNOWN; + self->priv->packet_service_uplink_speed = 0; + self->priv->packet_service_downlink_speed = 0; + + /* NOTE: FLAG_SUBSCRIBER_INFO is managed both via 3GPP unsolicited + * events and via SIM hot swap setup. We only reset the last ready state + * if SIM hot swap context is not using it. */ + if (!self->priv->sim_hot_swap_configured) + self->priv->last_ready_state = MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED; +} + +static void cleanup_unsolicited_events_3gpp (MMIfaceModem3gpp *_self, GAsyncReadyCallback callback, gpointer user_data) @@ -5747,6 +5768,9 @@ cleanup_unsolicited_events_3gpp (MMIfaceModem3gpp *_self, if (self->priv->is_slot_info_status_supported) self->priv->setup_flags &= ~PROCESS_NOTIFICATION_FLAG_SLOT_INFO_STATUS; common_setup_cleanup_unsolicited_events (self, FALSE, callback, user_data); + + /* Runtime cached state while enabled, to be cleaned up once disabled */ + cleanup_enabled_cache (self); } static void @@ -9412,7 +9436,11 @@ mm_broadband_modem_mbim_init (MMBroadbandModemMbim *self) self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, MM_TYPE_BROADBAND_MODEM_MBIM, MMBroadbandModemMbimPrivate); + self->priv->available_data_classes = MBIM_DATA_CLASS_NONE; + self->priv->highest_available_data_class = MBIM_DATA_CLASS_NONE; + self->priv->reg_state = MBIM_REGISTER_STATE_UNKNOWN; self->priv->packet_service_state = MBIM_PACKET_SERVICE_STATE_UNKNOWN; + self->priv->last_ready_state = MBIM_SUBSCRIBER_READY_STATE_NOT_INITIALIZED; } static void |