qcom-soc: ModemManager respects invalid uim state from DMS service
On some devices using qcom-soc (such as msm8916 devices) there is a chance of modem reporting State: 'not-present'
via DMS even if the uim is present and application on it is selected:
$ sudo qmicli -pd /dev/modem --dms-uim-get-state
[/dev/modem] UIM state retrieved:
State: 'not-present'
$ sudo qmicli -pd /dev/modem --uim-get-card-status
[/dev/modem] Successfully got card status
Provisioning applications:
Primary GW: slot '1', application '1'
Primary 1X: session doesn't exist
Secondary GW: session doesn't exist
Secondary 1X: session doesn't exist
Slot [1]:
Card state: 'present'
UPIN state: 'not-initialized'
UPIN retries: '0'
UPUK retries: '0'
Application [1]:
Application type: 'usim (2)'
Application state: 'pin1-or-upin-pin-required'
Application ID:
... snip ...
$ ModemManager -V
ModemManager 1.17.900
This seem to happen when the uim-change-provisioning-session
call is made right after modem has started and is, sadly, very hard to consistently reproduce. I assume it's some race condition in the modem firmware since the issue usually disappears if one adds a small delay after the modem processor start before interacting with it.
Problem is that MM prefers to use DMS call result as an indication of the UIM presence so the modem is unusable when such thing happens (MM thinks there is no sim available).
ModemManager code actually already can use the new UIM service calls for the devices that don't support the old ones and patching those checks "resolves" the issue:
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/blob/master/src/mm-broadband-modem-qmi.c#L888-889
https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/blob/master/src/mm-broadband-modem-qmi.c#L1164-1166
To reproduce the issue one can try to restart rmtfs
service (which is responsible for starting the modem core) and select the session right after that. On postmarketOS edge running sudo service rmtfs restart
will also restart the msm-modem-uim-selection
service giving the same result (though I'm unable to reproduce the issue this way right now)