From: Jean Thomas Date: Tue, 5 Dec 2023 10:12:38 +0000 (+0100) Subject: uqmi: cancel all requests on SYNC indication reception X-Git-Url: http://git.openwrt.org/?p=project%2Fuqmi.git;a=commitdiff_plain;h=c3488b831ce6285c8107704156b9b8ed7d59deb3 uqmi: cancel all requests on SYNC indication reception A SYNC indication might be sent by the modem on boot as a first response, in order to indicate that all Client IDs have been deallocated. Upon reception of this indication, cancel all current requests, as they will never be answered. Signed-off-by: Jean Thomas --- diff --git a/dev.c b/dev.c index 2d1597c..031b0c0 100644 --- a/dev.c +++ b/dev.c @@ -76,6 +76,20 @@ static bool qmi_message_is_response(struct qmi_msg *msg) return false; } +static bool qmi_message_is_indication(struct qmi_msg *msg) +{ + if (msg->qmux.service == QMI_SERVICE_CTL) { + if (msg->flags & QMI_CTL_FLAG_INDICATION) + return true; + } + else { + if (msg->flags & QMI_SERVICE_FLAG_INDICATION) + return true; + } + + return false; +} + static void __qmi_request_complete(struct qmi_dev *qmi, struct qmi_request *req, struct qmi_msg *msg) { void *tlv_buf; @@ -110,6 +124,24 @@ static void qmi_process_msg(struct qmi_dev *qmi, struct qmi_msg *msg) struct qmi_request *req; uint16_t tid; + if (qmi_message_is_indication(msg)) { + if (msg->qmux.service == QMI_SERVICE_CTL) { + struct qmi_msg sync_msg = {0}; + qmi_set_ctl_sync_request(&sync_msg); + /* A SYNC indication might be sent on boot in order to indicate + * that all Client IDs have been deallocated by the modem: + * cancel all requests, as they will not be answered. */ + if (msg->ctl.message == sync_msg.ctl.message) { + while (!list_empty(&qmi->req)) { + req = list_first_entry(&qmi->req, struct qmi_request, list); + qmi_request_cancel(qmi, req); + } + } + } + + return; + } + if (!qmi_message_is_response(msg)) return;