From 5059b812fc23531136825a5c879758539a4f5962 Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Sat, 11 Jan 2025 14:40:34 +0100 Subject: [PATCH] intel: XMM7360: RPC and AT port interlocking We have to avoid sending RPC and AT commands at the same time (even thought they are sent via different serial ports) since apparently this modems does not like it. It also looks like this modem does not like to receive a RPC command soon after an AT one, since such RPC commands sometimes fail to generate any response. Prevent this problem by delaying a RPC command if there was an AT command completed recently. The sufficient time gap was determined experimentally, but 300 ms seems to be enough. RPC commands are relatively rare so this should not be a performance issue. Otherwise we often never get any response to RPC calls if AT command happens to be sent at the same time. Signed-off-by: Maciej S. Szmigiero --- src/plugins/intel/mm-broadband-modem-xmm7360.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/plugins/intel/mm-broadband-modem-xmm7360.c b/src/plugins/intel/mm-broadband-modem-xmm7360.c index a4357079..f50e9408 100644 --- a/src/plugins/intel/mm-broadband-modem-xmm7360.c +++ b/src/plugins/intel/mm-broadband-modem-xmm7360.c @@ -36,6 +36,7 @@ #include "mm-broadband-modem-xmm7360.h" #include "mm-broadband-modem-xmm7360-rpc.h" +#include "mm-port-scheduler-rr.h" #include "mm-port-serial-xmmrpc-xmm7360.h" #include "mm-bearer-xmm7360.h" #include "mm-sim-xmm7360.h" @@ -1108,6 +1109,8 @@ initialization_started (MMBroadbandModem *modem, MMBroadbandModemXmm7360 *self = MM_BROADBAND_MODEM_XMM7360 (modem); InitializationStartedContext *ctx; GTask *task; + MMPortSerialAt *at_port; + g_autoptr(MMPortScheduler) sched = NULL; task = g_task_new (self, NULL, @@ -1120,6 +1123,14 @@ initialization_started (MMBroadbandModem *modem, ctx->timeout_id = 0; g_task_set_task_data (task, ctx, (GDestroyNotify)initialization_started_context_free); + at_port = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)); + if (!at_port) { + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_NOT_INITIALIZED, + "no primary AT port"); + g_object_unref (task); + return; + } + /* Open XMMRPC port for initialization */ if (!mm_port_serial_open (MM_PORT_SERIAL (ctx->port), &error)) { g_prefix_error (&error, "Couldn't open XMMRPC port during initialization: "); @@ -1134,6 +1145,13 @@ initialization_started (MMBroadbandModem *modem, task, NULL); + g_object_get (G_OBJECT (ctx->port), MM_PORT_SERIAL_SCHEDULER, &sched, NULL); + g_object_set (sched, + MM_PORT_SCHEDULER_RR_INTER_PORT_DELAY, + 300, + NULL); + g_object_set (G_OBJECT (at_port), MM_PORT_SERIAL_SCHEDULER, sched, NULL); + mm_obj_dbg (self, "running init sequence..."); mm_broadband_modem_xmm7360_rpc_sequence_full (MM_BROADBAND_MODEM_XMM7360 (self), ctx->port,