Browse Source

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 <jean.thomas@wifirst.fr>
Jean Thomas 4 months ago
parent
commit
c3488b831c
1 changed files with 32 additions and 0 deletions
  1. 32 0
      dev.c

+ 32 - 0
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;