Quick suspend/resume
This issue is used to investigate, discuss and implement a quick suspend/resume in ModemManager, used for modems which are never powered down or suspended while the host can suspend such as the PinePhone with a Quectel EG25-G modem.
Problem
ModemManager needs to be in sync with the internal modem state such as registered network, access technology, etc. even when the host is suspended. Therefore, ModemManager removes the modem before suspending and adds it again when the userspace resumes. This takes several seconds which results into missing calls and texts on the PinePhone since the caller already ends up in voicemail before the phone starts to ring. This problem is also highlighted in #194.
Partial solution
Disabling the suspend/resume hooks in ModemManager avoids this problem and is implemented with !433 (merged) and !436 (merged). While this works in 95% of the cases perfectly, disabling these hooks makes it possible that ModemManager is out of sync with the internal modem state. A possible issue (see log below) can be a network bearer that is no longer valid because the modem lost network reception or switched to a different network. In order to cover these cases, we need to have a synchronization hook when the host's userspace resumes.
[2543]: [/dev/cdc-wdm0] Sent message...
<<<<<< RAW:
<<<<<< length = 20
<<<<<< data = 01:13:00:00:01:12:00:A5:00:24:00:07:00:01:04:00:C0:00:00:00
[2543]: [/dev/cdc-wdm0] Sent generic request (translated)...
<<<<<< QMUX:
<<<<<< length = 19
<<<<<< flags = 0x00
<<<<<< service = "wds"
<<<<<< client = 18
<<<<<< QMI:
<<<<<< flags = "none"
<<<<<< transaction = 165
<<<<<< tlv_length = 7
<<<<<< message = "Get Packet Statistics" (0x0024)
<<<<<< TLV:
<<<<<< type = "Mask" (0x01)
<<<<<< length = 4
<<<<<< value = C0:00:00:00
<<<<<< translated = tx-bytes-ok, rx-bytes-ok
[2543]: [/dev/cdc-wdm0] Received message...
<<<<<< RAW:
<<<<<< length = 42
<<<<<< data = 01:29:00:80:01:12:02:A5:00:24:00:1D:00:02:04:00:01:00:0F:00:1B:08:00:00:00:00:00:00:00:00:00:1C:08:00:00:00:00:00:00:00:00:00
[2543]: [/dev/cdc-wdm0] Received generic response (translated)...
<<<<<< QMUX:
<<<<<< length = 41
<<<<<< flags = 0x80
<<<<<< service = "wds"
<<<<<< client = 18
<<<<<< QMI:
<<<<<< flags = "response"
<<<<<< transaction = 165
<<<<<< tlv_length = 29
<<<<<< message = "Get Packet Statistics" (0x0024)
<<<<<< TLV:
<<<<<< type = "Result" (0x02)
<<<<<< length = 4
<<<<<< value = 01:00:0F:00
<<<<<< translated = FAILURE: OutOfCall
<<<<<< TLV:
<<<<<< type = "Last Call Tx Bytes Ok" (0x1b)
<<<<<< length = 8
<<<<<< value = 00:00:00:00:00:00:00:00
<<<<<< translated = 0
<<<<<< TLV:
<<<<<< type = "Last Call Rx Bytes Ok" (0x1c)
<<<<<< length = 8
<<<<<< value = 00:00:00:00:00:00:00:00
<<<<<< translated = 0
[2543]: <warn> [1613488089.907489] [modem1/bearer3] reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
See https://gitlab.com/postmarketOS/pmaports/-/merge_requests/1931 and https://gitlab.com/mobian1/devices/eg25-manager/-/merge_requests/5 for such cases.
TODO
-
Which things needs to be synchronized on resume? -
How can we synchronize the modem with a minimum or no impact on the resume time? -
Because modems differ a lot, do we need modem specific suspend/resume hooks? -
Implement new hooks in ModemManager
Feel free to comment on this issue if you have any suggestion :)