UPSTREAM: iface-modem: Increase unlock_required retries
If a SIM is known to exist, for e.g. if it was created during load_sim_slots,
persist a few more times before giving up on the SIM to be ready. There
are modems on which the SIM takes more than 15s to be ready, luckily,
they happen to be QMI modems where the SIM's iccid in load_sim_slots
lets us know that there is a sim.
BUG=b:185217136
TEST=none, upstream patch
Change-Id: Id6126870ce4ce708db15db7d0472018d3979e4ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/modemmanager-next/+/2888707
Tested-by: Pavan Holla <pholla@google.com>
Auto-Submit: Pavan Holla <pholla@google.com>
Reviewed-by: Andrew Lassalle <andrewlassalle@chromium.org>
Commit-Queue: Pavan Holla <pholla@google.com>
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 2e9a300..88ba1a2 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -342,8 +342,6 @@
/*****************************************************************************/
/* Helper method to load unlock required, considering retries */
-#define MAX_RETRIES 6
-
typedef struct {
guint retries;
guint pin_check_timeout_id;
@@ -379,6 +377,28 @@
return G_SOURCE_REMOVE;
}
+#define MAX_RETRIES_NO_SIM 6
+#define MAX_RETRIES_SIM_EXISTS 30
+static guint
+get_max_retries (MMIfaceModem *self)
+{
+ g_autoptr(MMBaseSim) sim = NULL;
+
+ g_object_get (self,
+ MM_IFACE_MODEM_SIM,
+ &sim,
+ NULL);
+ /* If a SIM is known to exist, for e.g. if it was created during load_sim_slots,
+ persist a few more times before giving up on the SIM to be ready. There
+ are modems on which the SIM takes more than 15s to be ready, luckily,
+ they happen to be QMI modems where the SIM's iccid in load_sim_slots
+ lets us know that there is a sim. */
+ if (sim)
+ return MAX_RETRIES_SIM_EXISTS;
+
+ return MAX_RETRIES_NO_SIM;
+}
+
static void
load_unlock_required_ready (MMIfaceModem *self,
GAsyncResult *res,
@@ -414,7 +434,7 @@
}
/* For the remaining ones, retry if possible */
- if (ctx->retries < MAX_RETRIES) {
+ if (ctx->retries < get_max_retries (self)) {
ctx->retries++;
mm_obj_dbg (self, "retrying (%u) unlock required check", ctx->retries);
@@ -432,7 +452,7 @@
MM_MOBILE_EQUIPMENT_ERROR,
MM_MOBILE_EQUIPMENT_ERROR_SIM_FAILURE,
"Couldn't get SIM lock status after %u retries",
- MAX_RETRIES);
+ get_max_retries (self));
g_object_unref (task);
return;
}
@@ -454,8 +474,8 @@
g_assert (ctx->pin_check_timeout_id == 0);
MM_IFACE_MODEM_GET_INTERFACE (self)->load_unlock_required (
self,
- (ctx->retries == MAX_RETRIES), /* last_attempt? */
- (GAsyncReadyCallback)load_unlock_required_ready,
+ (ctx->retries >= get_max_retries (self)), /* last_attempt? */
+ (GAsyncReadyCallback) load_unlock_required_ready,
task);
}