mbim-proxy listening to systemd suspend/resume events
Aleksander Morgado
aleksander at aleksander.es
Sun Sep 13 07:01:03 UTC 2020
Hey all,
The mbim-proxy takes care of the lifecycle of the MBIM session opened
with the device. When the first proxy client arrives and attempts to
talk to a device, the proxy opens the MBIM session and keeps it open
for as long as the device is around. This means that, even if there
are not clients connected to the proxy, the MBIM session is kept
opened with the device.
The forced open session is to avoid needing to open and close the
session all the time e.g. if only mbimcli is being used, as mbimcli
acts as a proxy client only during a single request, unlike other
clients like ModemManager that are clients connected to the proxy
during the whole MM process runtime.
Keeping the MBIM session open like this introduces problems in some
modules (e.g. Cinterion mPLS62-w) when the host system goes to suspend
and the modem device is kept powered externally. Under this scenario,
the MBIM device attempts to send MBIM notifications via USB to the
host, but these are never read, and the device may end up crashing.
This is something that could obviously be fixed in the side of the
device, but it is also something we can avoid in the host side, by
making sure all MBIM sessions between host and device are brought down
on suspend, and brought up again automatically on resume.
I've prepared a branch to implement this logic and it looks like it
works very well to avoid the crashes with the mPLS62-w:
https://gitlab.freedesktop.org/mobile-broadband/libmbim/-/merge_requests/31
The optional systemd suspend/resume event monitoring can be explicitly
requested in configure with --with-systemd-suspend-resume=yes; and
otherwise it will be automatically enabled if the corresponding
systemd libraries are detected in the system. ModemManager already
supports this same feature, and so a setup using ModemManager with
suspend/resume support can safely use the setup also in
libmbim/mbim-proxy. Both logics complement each other, they don't
collide.
If instead of closing the sessions on suspend we attempted to close
the session any time there were no clients connected to the proxy
(something I also thought about), we would be breaking the mbimcli
--no-open=TRID and --no-close operations, so that is not something we
should be doing :/
What does everyone think? Comments?
--
Aleksander
https://aleksander.es
More information about the libmbim-devel
mailing list