mbim-proxy listening to systemd suspend/resume events
Giacinto Cifelli
gciofono at gmail.com
Sun Sep 13 18:53:00 UTC 2020
Hi Bjørn,
thank you for your views.
On Sun, Sep 13, 2020 at 6:44 PM Bjørn Mork <bjorn at mork.no> wrote:
> Giacinto Cifelli <gciofono at gmail.com> writes:
> > On Sun, Sep 13, 2020 at 10:56 AM Bjørn Mork <bjorn at mork.no> wrote:
> >> Aleksander Morgado <aleksander at aleksander.es> writes:
> >>
> >> > 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.
> >>
> >> Won't that disconnect all IP sessions as a side effect? I can imagine
> >> use cases where that's unwanted.
> >>
> >
> > This patch is for host suspended, which drops the USB VBUS line
>
> That's not always true. There is no such requirement. And some hosts
> can be confgured to keep VBUS always on.
>
> > (ie:
> > disconnects). At least I have not seen any application/controller that
> > keeps the line up.
> > And when it is re-connected on resume, then the device is re-enumerated
> and
> > all PDNs are inevitably lost.
> >
> >
> >> IMHO, the host should (and do) suspend the USB bus, but not touch any
> >> higher level stuff unless explicitly configured to do so. This will
> >> allow a powered modem to maintain active connections, so that the host
> >> can resume them when it wakes up.
> >>
> >
> > It doesn't work if VBUS goes down (USB suspend/resume transit on VBUS,
> not
> > on the data lines).
>
> No, USB suspend is a data line thingy. We do that all the time with
> autosuspend, even with active connections if the modem supports remote
> wakeup.
>
I stand corrected on this. Thanks.
> And it does.
> > This strategy would work seamlessly on plain RS232/422 lines, thou. But
> in
> > that case no MBIM.
>
> FWIW, I just tested this since you made me unsure of myself :-)
>
> It has been a while since the last time I tested. None of my laptops
> have been able to keep the internal modem slot powered, so it's not a
> feature I am able to use for real. In fact, I don't think I've ever
> tested it with MBIM before, since my previous test most likely was
> before the cdc_mbim driver was written. But I know it worked fine with
> qmi_wwan a very long time ago.
>
> Anyway, I just tried now with an EM7565 in MBIM mode, connected to an
> external USB port on my laptop (Thinkpad X1 4th gen) using a USB3
> adapter and cable. This did not work... The device is reset when the
> host resumes.
>
> So I dug out my old laptop (Thinkpad X301), which is the one I use for
> the previous test. And it worked with the modem in MBIM mode too.
> Connected, logged into a remote server over ssh with TCPKeepAlive=no,
> suspended the laptop, resumed it, and watched the ssh connection still
> being alive.
>
> What didn't work so well was ModemManager forgetting all about the modem
> on resume, and "discovering" it as a new modem. So the active
> connection was not unmanaged after resume.
>
> But suspending and resuming with an active MBIM session does definitely
> work, given the right conditions. So I think we should rather try to
> fix the current issues, and not add more problems.
>
Let me highlight that Aleksander gives it as an option.
And from your tests and what I saw out in the field, it looks like it is
the right default.
You have to hit just the right set of conditions to make it work, and this
not even considering the points below.
> Note that a device doesn't have to draw much power in this state. The
> USB controller is suspended, and the radio can also be suspended most of
> the time. This is actually the same when the host is alive too, as long
> as there is no traffic. Whether the host cpu is suspended or not is
> pretty irrelevant to the device.
>
This is a bit beside the point, interesting nevertheless.
The modems, especially the higher LTE categories, are in general
self-powered.
As for the power effectively consumed, it depends.
If it is a moving application, it must do location updates and cell
reselections as the tracking area changes, and this consumes quite some
power because it is done (almost by definition) at the cell edge.
It has to listen to paging messages for SMS and incoming voice calls (even
if nobody will answer them).
The network can configure a DRX to keep the modem in low-power longer, but
there is a limit, especially for voice-supporting devices, not to ring too
much time later the remote part starts the call.
There is the option about going in airplane mode, but here there isn't
really any reason to keep the modem powered.
Most modems even have an IRQ line to wakeup the application (as a backup
for remote wakeup when the USB is disconnected), and this is additional
processing.
As for the frequency of local events, MM configures the MBIM modems for
signal quality reporting, and this happens every 5 seconds per MBIM
specification.
> >> Killing connections on suspend and reconnecting on resume is sub-optimal
> >> behaviour. It breaks all established tcp sessions unless you have a
> >> static address. Completely unnecessary.
> >>
> >
> > From a device point of view, the application asks for notifications, and
> > then doesn't read them.
> > It is forced to buffer them, and the buffer is limited.
>
> The device knows the USB connection is suspended. It should not attempt
> to send any USB data when this happens. This is the same on the host
> side. We kill URBs before suspending.
>
> There is no obligation to buffer everything on the device. That would
> not scale at all. The device can and should drop anything it cannot
> deliver in a timely manner, whether that is a notification for the host
> or incoming data packets from the network.
>
As I have mentioned above, several modems are configured for remote wakeup
of the host.
This is the only way to wakeup some applications remotely.
And so it must keep the buffer that awakens the host.
You could say that after a timeout it could be discarded, but what is a
sensible timeout?
Some applications do switch off completely, and so take a few seconds to
respond, and in the meanwhile additional data comes in the buffer.
> >> I hate all sort of "bring down networking" on suspend. It just makes
> >> suspend pointless. You might as well power off then.
> >>
> >
> > Power off has a much higher cost in terms of reboot of the host and the
> > device.
> > Re-establishing the PDNs is fast if the modem is already registered.
>
> It's fast, but usually associated with a new dynamic ip address, which
> means that you lose all existing tcp sessions. To me, that's the
> highest cost of a reboot.
>
> Ok, if you want to argue that this is broken by those networks that
> can't even keep your address stable, then I have to agree. The ever
> changing address on mobile networks makes this much harder than
> necessary.
>
so, again, in a perfect world everything would work, but out there these
cases are all to consider.
What is more, all mobile applications must already have procedures to
recover from a severed connection (also non-mobile good code actually, but
it isn't a primary concern sometimes, as some lines are highly reliable).
> It is inconvenient for the high-level, for sure, but some applications
> stay
> > suspended for days. It also costs resources on the remote side to keep
> > unused TCP connection structures in memory.
>
> Whatever. That's how tcp works. You can suspend it just fine until
> someone comes along and breaks it with a lot of assumptions. Stupid
> stateful firewalls are another part of this. But don't get me started
> on that one :-)
>
Yes, these TCP issues were known already at the time of Stevens' TCP/IP
illustrated. And nothing has improved there.
But there is memory reserved in the final host. If a connection is never
released, then in case of change of IP address of the client, or any other
problem, this will be kept forever.
Over time, the memory of the server would get clogged by these vestigial
connections. Or something bad would happen in case of collision due to
re-assigned IP addresses.
Bottom line: for practical reasons, there must be a keepalive or a timeout.
Giacinto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libmbim-devel/attachments/20200913/02563910/attachment-0001.htm>
More information about the libmbim-devel
mailing list