aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksandermj@chromium.org>2024-09-13 12:49:39 +0000
committerAleksander Morgado <aleksandermj@chromium.org>2024-09-30 11:07:11 +0000
commitdfc0f8ebfd6a4a698af6cf784ba749ecdcb05e7e (patch)
tree1cb3fffcf7ffec61746b6c89275cc554351b7449 /src
parent0aef4c422f5f686741f8943f479ff8d43b751f3d (diff)
base-modem: override disable operations done before modem object removal
If we are going to inhibit the modem or fully reprobe it after a SIM switch event, we should forbid further operations done with the modem object. This logic can be tested by queing different operations one after the other, and then adding a last device inhibition ("override" operation) that should trigger the early abort of all non-running operations, e.g.: mmcli -m a -e & sleep 0.2 mmcli -m a --3gpp-set-initial-eps-bearer-settings="apn=internet,ip-type=ipv4v6,force=true" & sleep 0.2 mmcli -m a -d & sleep 0.2 mmcli -m a -e & sleep 0.2 mmcli -m a --set-power-state-low & sleep 0.2 mmcli -m a -e & sleep 0.2 mmcli -m a --inhibit This previous sequence produces MM logs as follows: <dbg> [1726567756.430308] [modem0] [operation 22] default - enable: scheduled <dbg> [1726567756.430806] [modem0] [operation 22] default - enable: lock acquired <dbg> [1726567756.623746] [modem0] [operation 23] default - set-initial-eps-bearer-settings: scheduled <dbg> [1726567756.751743] [modem0] [operation 22] default - enable: lock released <dbg> [1726567756.752027] [modem0] [operation 23] default - set-initial-eps-bearer-settings: lock acquired <dbg> [1726567756.823739] [modem0] [operation 24] default - disable: scheduled <dbg> [1726567757.049581] [modem0] [operation 25] default - enable: scheduled <dbg> [1726567757.250165] [modem0] [operation 26] default - set-power-state: scheduled <dbg> [1726567757.450518] [modem0] [operation 27] default - enable: scheduled <dbg> [1726567757.676362] [modem0] [operation 28] override - disabling: override requested - no new operations will be allowed <dbg> [1726567757.678792] [modem0] [operation 24] default - disable: aborted early <dbg> [1726567757.679866] [modem0] [operation 25] default - enable: aborted early <dbg> [1726567757.680157] [modem0] [operation 26] default - set-power-state: aborted early <dbg> [1726567757.680496] [modem0] [operation 27] default - enable: aborted early <dbg> [1726567759.695780] [modem0] [operation 23] default - set-initial-eps-bearer-settings: lock released <dbg> [1726567759.695935] [modem0] [operation 28] override - disabling: lock acquired <dbg> [1726567759.872196] [modem0] [operation 28] override - disabling: lock released
Diffstat (limited to 'src')
-rw-r--r--src/mm-base-manager.c1
-rw-r--r--src/mm-base-modem.c26
-rw-r--r--src/mm-base-modem.h16
-rw-r--r--src/mm-device.c5
-rw-r--r--src/mm-iface-modem.c6
5 files changed, 36 insertions, 18 deletions
diff --git a/src/mm-base-manager.c b/src/mm-base-manager.c
index 449b74df..6e7542b5 100644
--- a/src/mm-base-manager.c
+++ b/src/mm-base-manager.c
@@ -963,6 +963,7 @@ foreach_disable (gpointer key,
mm_base_modem_disable (modem,
MM_BASE_MODEM_OPERATION_LOCK_REQUIRED,
+ MM_BASE_MODEM_OPERATION_PRIORITY_OVERRIDE,
(GAsyncReadyCallback)shutdown_disable_ready,
ctx);
}
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c
index 6348af33..b6023039 100644
--- a/src/mm-base-modem.c
+++ b/src/mm-base-modem.c
@@ -808,11 +808,12 @@ lock_before_state_operation_ready (MMBaseModem *self,
}
static void
-state_operation (MMBaseModem *self,
- StateOperationType operation_type,
- MMBaseModemOperationLock operation_lock,
- GAsyncReadyCallback callback,
- gpointer user_data)
+state_operation (MMBaseModem *self,
+ StateOperationType operation_type,
+ MMBaseModemOperationLock operation_lock,
+ MMBaseModemOperationPriority operation_priority,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GTask *task;
StateOperationContext *ctx;
@@ -871,7 +872,7 @@ state_operation (MMBaseModem *self,
g_assert (operation_lock == MM_BASE_MODEM_OPERATION_LOCK_REQUIRED);
mm_base_modem_operation_lock (self,
- MM_BASE_MODEM_OPERATION_PRIORITY_DEFAULT,
+ operation_priority,
operation_description,
(GAsyncReadyCallback) lock_before_state_operation_ready,
task);
@@ -898,6 +899,7 @@ mm_base_modem_sync (MMBaseModem *self,
state_operation (self,
STATE_OPERATION_TYPE_SYNC,
operation_lock,
+ MM_BASE_MODEM_OPERATION_PRIORITY_DEFAULT,
callback,
user_data);
}
@@ -915,14 +917,16 @@ mm_base_modem_disable_finish (MMBaseModem *self,
}
void
-mm_base_modem_disable (MMBaseModem *self,
- MMBaseModemOperationLock operation_lock,
- GAsyncReadyCallback callback,
- gpointer user_data)
+mm_base_modem_disable (MMBaseModem *self,
+ MMBaseModemOperationLock operation_lock,
+ MMBaseModemOperationPriority operation_priority,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
state_operation (self,
STATE_OPERATION_TYPE_DISABLE,
operation_lock,
+ operation_priority,
callback,
user_data);
}
@@ -946,6 +950,7 @@ mm_base_modem_enable (MMBaseModem *self,
state_operation (self,
STATE_OPERATION_TYPE_ENABLE,
operation_lock,
+ MM_BASE_MODEM_OPERATION_PRIORITY_DEFAULT,
callback,
user_data);
}
@@ -969,6 +974,7 @@ mm_base_modem_initialize (MMBaseModem *self,
state_operation (self,
STATE_OPERATION_TYPE_INITIALIZE,
operation_lock,
+ MM_BASE_MODEM_OPERATION_PRIORITY_DEFAULT,
callback,
user_data);
}
diff --git a/src/mm-base-modem.h b/src/mm-base-modem.h
index a02bdf4c..aab195ac 100644
--- a/src/mm-base-modem.h
+++ b/src/mm-base-modem.h
@@ -230,6 +230,7 @@ gboolean mm_base_modem_authorize_finish (MMBaseModem *self,
/* Operation lock support */
typedef enum { /*< underscore_name=mm_base_modem_operation_priority >*/
+ MM_BASE_MODEM_OPERATION_PRIORITY_UNKNOWN,
/* Default operations are scheduled at the end of the list of pending
* operations */
MM_BASE_MODEM_OPERATION_PRIORITY_DEFAULT,
@@ -285,13 +286,14 @@ gboolean mm_base_modem_enable_finish (MMBaseModem *self,
GAsyncResult *res,
GError **error);
-void mm_base_modem_disable (MMBaseModem *self,
- MMBaseModemOperationLock operation_lock,
- GAsyncReadyCallback callback,
- gpointer user_data);
-gboolean mm_base_modem_disable_finish (MMBaseModem *self,
- GAsyncResult *res,
- GError **error);
+void mm_base_modem_disable (MMBaseModem *self,
+ MMBaseModemOperationLock operation_lock,
+ MMBaseModemOperationPriority priority,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+gboolean mm_base_modem_disable_finish (MMBaseModem *self,
+ GAsyncResult *res,
+ GError **error);
#if defined WITH_SUSPEND_RESUME
void mm_base_modem_sync (MMBaseModem *self,
diff --git a/src/mm-device.c b/src/mm-device.c
index 40b2039c..62cba0fd 100644
--- a/src/mm-device.c
+++ b/src/mm-device.c
@@ -748,9 +748,12 @@ mm_device_inhibit (MMDevice *self,
g_assert (!self->priv->inhibited);
self->priv->inhibited = TRUE;
- /* Make sure modem is disabled while inhibited */
+ /* Make sure modem is disabled while inhibited. This operation requests
+ * an exclusive lock marked as override, so the modem object will not
+ * allow any additional lock request any more. */
mm_base_modem_disable (self->priv->modem,
MM_BASE_MODEM_OPERATION_LOCK_REQUIRED,
+ MM_BASE_MODEM_OPERATION_PRIORITY_OVERRIDE,
(GAsyncReadyCallback)inhibit_disable_ready,
task);
}
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 5e98261e..ff285dee 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -343,9 +343,13 @@ mm_iface_modem_process_sim_event (MMIfaceModem *self)
if (MM_IFACE_MODEM_GET_IFACE (self)->cleanup_sim_hot_swap)
MM_IFACE_MODEM_GET_IFACE (self)->cleanup_sim_hot_swap (self);
+ /* Make sure modem is disabled before reprobing. This operation requests
+ * an exclusive lock marked as override, so the modem object will not
+ * allow any additional lock request any more. */
mm_base_modem_set_reprobe (MM_BASE_MODEM (self), TRUE);
mm_base_modem_disable (MM_BASE_MODEM (self),
MM_BASE_MODEM_OPERATION_LOCK_REQUIRED,
+ MM_BASE_MODEM_OPERATION_PRIORITY_OVERRIDE,
(GAsyncReadyCallback) after_sim_event_disable_ready,
NULL);
}
@@ -2341,6 +2345,7 @@ handle_enable_auth_ready (MMBaseModem *self,
mm_obj_info (self, "processing user request to disable modem...");
mm_base_modem_disable (self,
MM_BASE_MODEM_OPERATION_LOCK_ALREADY_ACQUIRED,
+ MM_BASE_MODEM_OPERATION_PRIORITY_UNKNOWN,
(GAsyncReadyCallback)enable_ready,
ctx);
}
@@ -2424,6 +2429,7 @@ disable_after_low (MMIfaceModem *self,
mm_obj_info (self, "automatically disable modem after low-power mode...");
mm_base_modem_disable (MM_BASE_MODEM (self),
MM_BASE_MODEM_OPERATION_LOCK_ALREADY_ACQUIRED,
+ MM_BASE_MODEM_OPERATION_PRIORITY_UNKNOWN,
(GAsyncReadyCallback)disable_after_low_ready,
ctx);
}