service: don't SIGTERM the QMI/MBIM proxies together with the daemon

The qmi-proxy/mbim-proxy processes spawned by the daemon live in the
service's cgroup, so with the default KillMode=control-group systemd
sends SIGTERM to them at the same time as to the daemon on every unit
stop. The proxy exits immediately, tearing the control channel from
under the daemon while it is still disabling the modems:

    <msg> caught signal, shutting down...
    <msg> [modem0] state changed (connected -> disabling)
    <msg> [modem0] port 'cdc-wdm0' no longer controllable, reprobing
    <wrn> [/dev/cdc-wdm0] MBIM error: Device must be open to send commands
    <wrn> shutdown failed: timeout waiting for sleep preparation to complete

The consequences of losing the proxy mid-shutdown:
 - the modem disable/disconnect never reaches the device, so an MBIM
   session with an active bearer is left open in the firmware (observed
   to occasionally wedge the MBIM function of a Sierra EM7565 until a
   firmware reset);
 - the port teardown stalls waiting on the dead proxy until the
   shutdown timeout, so stopping the unit always takes the full
   MAX_SHUTDOWN_TIME_SECS instead of a second or two;
 - the port invalidation triggers the device reprobe path in the middle
   of the shutdown.

With KillMode=mixed only the daemon receives SIGTERM; the proxies
survive long enough for a clean disconnect and MBIM/QMI close, and
whatever remains in the cgroup afterwards (an idle, stateless proxy) is
killed when the unit finally stops.

Signed-off-by: Semyon Maryasin <simeon@maryasin.name>
This commit is contained in:
Semyon Maryasin
2026-09-22 12:31:25 -05:00
committed by Dan Williams
parent efb6a9833e
commit 225e66fea9
+1
View File
@@ -10,6 +10,7 @@ BusName=org.freedesktop.ModemManager1
ExecStart=@sbindir@/ModemManager
StandardError=null
Restart=on-abort
KillMode=mixed
CapabilityBoundingSet=CAP_SYS_ADMIN CAP_NET_ADMIN
ProtectSystem=true
ProtectHome=true