From dfc0f8ebfd6a4a698af6cf784ba749ecdcb05e7e Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 13 Sep 2024 12:49:39 +0000 Subject: 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: [1726567756.430308] [modem0] [operation 22] default - enable: scheduled [1726567756.430806] [modem0] [operation 22] default - enable: lock acquired [1726567756.623746] [modem0] [operation 23] default - set-initial-eps-bearer-settings: scheduled [1726567756.751743] [modem0] [operation 22] default - enable: lock released [1726567756.752027] [modem0] [operation 23] default - set-initial-eps-bearer-settings: lock acquired [1726567756.823739] [modem0] [operation 24] default - disable: scheduled [1726567757.049581] [modem0] [operation 25] default - enable: scheduled [1726567757.250165] [modem0] [operation 26] default - set-power-state: scheduled [1726567757.450518] [modem0] [operation 27] default - enable: scheduled [1726567757.676362] [modem0] [operation 28] override - disabling: override requested - no new operations will be allowed [1726567757.678792] [modem0] [operation 24] default - disable: aborted early [1726567757.679866] [modem0] [operation 25] default - enable: aborted early [1726567757.680157] [modem0] [operation 26] default - set-power-state: aborted early [1726567757.680496] [modem0] [operation 27] default - enable: aborted early [1726567759.695780] [modem0] [operation 23] default - set-initial-eps-bearer-settings: lock released [1726567759.695935] [modem0] [operation 28] override - disabling: lock acquired [1726567759.872196] [modem0] [operation 28] override - disabling: lock released --- src/mm-base-modem.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/mm-base-modem.c') 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); } -- cgit v1.2.3-70-g09d2