From 30e4577b4d7f044810126157c0c34967ef03aacd Mon Sep 17 00:00:00 2001 From: Filip Pokryvka Date: Wed, 4 Mar 2026 10:54:58 +0100 Subject: [PATCH] base-modem: make max timeouts configurable via udev rule Add the ID_MM_MAX_TIMEOUTS udev tag to allow users and system administrators to configure the maximum number of consecutive command timeouts before a modem is invalidated and re-probed, on a per-device basis. The tag accepts an integer value >= 0, where 0 disables the timeout monitoring feature entirely. If not set, the existing default of 10 consecutive timeouts is used. This is needed for some older modems which become unresponsive during consecutive data traffic, but come back alive when traffic is lower. These modems have no further firmware updates available. This follows the same pattern as other udev-configurable device properties like ID_MM_MAX_MULTIPLEXED_LINKS. Signed-off-by: Filip Pokryvka --- include/ModemManager-tags.h | 16 ++++++++++++++++ src/mm-base-modem.c | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/ModemManager-tags.h b/include/ModemManager-tags.h index 59c31f12..6f74cf55 100644 --- a/include/ModemManager-tags.h +++ b/include/ModemManager-tags.h @@ -350,6 +350,22 @@ */ #define ID_MM_AT_NETWORK_TIME_BROKEN "ID_MM_AT_NETWORK_TIME_BROKEN" +/** + * ID_MM_MAX_TIMEOUTS: + * + * This is a device-specific tag that allows users to specify the maximum number + * of consecutive command timeouts allowed before the modem is marked as invalid + * and re-probed. + * + * An integer value greater or equal than 0 must be given. The value 0 in this + * tag completely disables the timeout monitoring feature. + * + * If not given, the default value of 10 consecutive timeouts is used. + * + * Since: 1.26 + */ +#define ID_MM_MAX_TIMEOUTS "ID_MM_MAX_TIMEOUTS" + /* * The following symbols are deprecated. We don't add them to -compat * because this -tags file is not really part of the installed API. diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index 224320f6..2ff45d4d 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -446,6 +446,17 @@ base_modem_internal_grab_port (MMBaseModem *self, #endif } + /* Check if a custom max timeouts value is set via udev */ + if (mm_kernel_device_has_global_property (kernel_device, ID_MM_MAX_TIMEOUTS)) { + guint max_timeouts; + + max_timeouts = mm_kernel_device_get_global_property_as_int (kernel_device, ID_MM_MAX_TIMEOUTS); + if (max_timeouts != self->priv->max_timeouts) { + mm_obj_dbg (self, "max timeouts overridden via udev: %u", max_timeouts); + self->priv->max_timeouts = max_timeouts; + } + } + if (port_monitoring) { if (self->priv->max_timeouts > 0) g_signal_connect (port,