[PATCH] iface-modem-3gpp: ignore initial registration check result when appropriate

Ben Chan benchan at chromium.org
Fri Jan 12 07:47:28 UTC 2018


When a modem is being enabled, an initial registration check is
scheduled to determine the current registration state and access
technology. The initial registration check is performed asynchronously
and may not complete before the modem state is transitioned to
'enabled'. When the modem is disabled shortly afterwards, the
registration state is transitioned to 'unknown' and the modem state is
transitioned to 'disabled'. But the completion of the initial
registration check after that can transition the registration state and
modem state to a wrong state. This patch addresses the issue by ignoring
a registration state update if the modem isn't already enabled or being
enabled.
---
 src/mm-iface-modem-3gpp.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c
index e1a61ced..f5abc092 100644
--- a/src/mm-iface-modem-3gpp.c
+++ b/src/mm-iface-modem-3gpp.c
@@ -1205,10 +1205,28 @@ update_registration_state (MMIfaceModem3gpp *self,
         new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_SMS_ONLY ||
         new_state == MM_MODEM_3GPP_REGISTRATION_STATE_HOME_CSFB_NOT_PREFERRED ||
         new_state == MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING_CSFB_NOT_PREFERRED) {
+        MMModemState modem_state;
+
         /* If already reloading registration info, skip it */
         if (ctx->reloading_registration_info)
             return;
 
+        /* If the modem isn't already enabled or being enabled, this
+         * registration state update is due to a previously scheduled
+         * initial registration check when the modem was being enabled.
+         * We need to ignore it as otherwise it may cause an incorrect
+         * transition of the registration state and modem state when the
+         * modem is being disabled. */
+        modem_state = MM_MODEM_STATE_UNKNOWN;
+        g_object_get (self,
+                      MM_IFACE_MODEM_STATE, &modem_state,
+                      NULL);
+        if (modem_state < MM_MODEM_STATE_ENABLING) {
+            mm_dbg ("Modem %s: 3GPP Registration state change ignored as modem isn't enabled",
+                    g_dbus_object_get_object_path (G_DBUS_OBJECT (self)));
+            return;
+        }
+
         mm_info ("Modem %s: 3GPP Registration state changed (%s -> registering)",
                  g_dbus_object_get_object_path (G_DBUS_OBJECT (self)),
                  mm_modem_3gpp_registration_state_get_string (old_state));
-- 
2.16.0.rc1.238.g530d649a79-goog



More information about the ModemManager-devel mailing list