diff options
author | Aleksander Morgado <aleksandermj@chromium.org> | 2022-12-15 21:09:30 +0000 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2022-12-18 21:52:51 +0000 |
commit | 455c4860915b194c654abb6cd49bcbb483ec650b (patch) | |
tree | 4ca9912163d96e179a8217bce576ef0d1b3cc0b8 /src/mm-base-modem.c | |
parent | 2a1851536c3c096ab4e3f26ebe6671b946e665be (diff) |
port: define new generic 'removed' signal
This signal indicates that the port is no longer accessible. Unlike a
udev port removal event, this indication may happen even if the port
is still exposed by the system.
It is designed to detect protocol proxy crashes, and so when such
event is detected by the modem, a full reprobe of the device will be
done to start from scratch the protocol management operations.
Diffstat (limited to 'src/mm-base-modem.c')
-rw-r--r-- | src/mm-base-modem.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index cf304fe9..64361654 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -147,6 +147,18 @@ mm_base_modem_get_dbus_id (MMBaseModem *self) /******************************************************************************/ static void +port_removed_cb (MMPort *port, + MMBaseModem *self) +{ + /* We have to do a full re-probe here because simply reopening the device + * and restarting proxy would leave us without proper notifications. */ + mm_obj_msg (self, "port '%s' no longer controllable, reprobing", + mm_port_get_device (MM_PORT (port))); + self->priv->reprobe = TRUE; + g_cancellable_cancel (self->priv->cancellable); +} + +static void port_timed_out_cb (MMPort *port, guint n_consecutive_timeouts, MMBaseModem *self) @@ -322,6 +334,7 @@ base_modem_internal_grab_port (MMBaseModem *self, const gchar *subsys; const gchar *name; g_autofree gchar *key = NULL; + gboolean port_monitoring = FALSE; subsys = mm_kernel_device_get_subsystem (kernel_device); name = mm_kernel_device_get_name (kernel_device); @@ -362,35 +375,37 @@ base_modem_internal_grab_port (MMBaseModem *self, return NULL; } - /* Setup consecutive timeout watcher in all control ports */ - if (self->priv->max_timeouts > 0) { - gboolean timeout_monitoring = FALSE; - - if (MM_IS_PORT_SERIAL_AT (port)) { - mm_obj_dbg (port, "timeout monitoring enabled in AT port"); - timeout_monitoring = TRUE; - } else if (MM_IS_PORT_SERIAL_QCDM (port)) { - mm_obj_dbg (port, "timeout monitoring enabled in QCDM port"); - timeout_monitoring = TRUE; - } + /* Setup consecutive ports and removal watchers in all control ports */ + if (MM_IS_PORT_SERIAL_AT (port)) { + mm_obj_dbg (port, "port monitoring enabled in AT port"); + port_monitoring = TRUE; + } else if (MM_IS_PORT_SERIAL_QCDM (port)) { + mm_obj_dbg (port, "port monitoring enabled in QCDM port"); + port_monitoring = TRUE; + } #if defined WITH_QMI - else if (MM_IS_PORT_QMI (port)) { - mm_obj_dbg (port, "timeout monitoring enabled in QMI port"); - timeout_monitoring = TRUE; - } + else if (MM_IS_PORT_QMI (port)) { + mm_obj_dbg (port, "port monitoring enabled in QMI port"); + port_monitoring = TRUE; + } #endif #if defined WITH_MBIM - else if (MM_IS_PORT_MBIM (port)) { - mm_obj_dbg (port, "timeout monitoring enabled in MBIM port"); - timeout_monitoring = TRUE; - } + else if (MM_IS_PORT_MBIM (port)) { + mm_obj_dbg (port, "port monitoring enabled in MBIM port"); + port_monitoring = TRUE; + } #endif - if (timeout_monitoring) + if (port_monitoring) { + if (self->priv->max_timeouts > 0) g_signal_connect (port, MM_PORT_SIGNAL_TIMED_OUT, G_CALLBACK (port_timed_out_cb), self); + g_signal_connect (port, + MM_PORT_SIGNAL_REMOVED, + G_CALLBACK (port_removed_cb), + self); } /* Store kernel device */ @@ -1748,6 +1763,7 @@ cleanup_modem_port (MMBaseModem *self, /* Cleanup on all control ports */ g_signal_handlers_disconnect_by_func (port, port_timed_out_cb, self); + g_signal_handlers_disconnect_by_func (port, port_removed_cb, self); #if defined WITH_MBIM /* We need to close the MBIM port cleanly when disposing the modem object */ |