uqmi: add timeout parameter
Working with Quectel EM12 LTE-module, we observe
regular stalls of the QMI interface which cause
a request issued by uqmi to hang forever.
Most reproducibly this happens after the device
has been power-cycled and left untouched for a
while (~ 60s+). Most of the time the very first
QMI request fails, since it is not responded by
the module. This is the strace from such a run
(from --get-pin-status):
open("/dev/cdc-wdm0", O_RDWR|O_EXCL|O_NOCTTY|O_NONBLOCK|O_LARGEFILE) = 6
fcntl64(6, F_GETFL) = 0x10802 (flags O_RDWR|O_NONBLOCK|O_LARGEFILE)
fcntl64(6, F_SETFL, O_RDWR|O_NONBLOCK|O_LARGEFILE) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN|EPOLLRDHUP|EPOLLET, {u32=
268567076, u64=
1153486808202346496}}) = 0
write(6, "\1\17\0\0\0\0\0\1\"\0\4\0\1\1\0\2", 16) = 16
clock_gettime(CLOCK_MONOTONIC, {tv_sec=95, tv_nsec=
583444789}) = 0
clock_gettime(CLOCK_MONOTONIC, {tv_sec=95, tv_nsec=
583770264}) = 0
epoll_pwait(3,
[ hang forever ]
After killing the blocked uqmi process, the next
request works as expected.
We don't know whether this is a device FW issue
(we use the latest EM12GPAR01A15M4G) or whether
the device enters some undocumented power-save
mode after idling for some time.
This patch extends uqmi with a timeout option
(-t, --timeout <ms>) which if set terminates a
request after the given amount of msecs. In
our usecase it provides a means of preventing
infinitively stuck QMI requests. Since we
observe the issue only for the very first
request after cold-boot, we use a dummy access
early in qmi.sh, e.g.
uqmi -d /dev/cdc-wdm0 --get-pin-status -t 3000 >/dev/null 2>&1
This ensures the QMI interface is un-stuck in
case it entered the stall-state observed. The
change is intentionally not included in this
commit, since you don't need it if it works
for you.
Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>