From 4cdda05e9d57c6a142b8d0741458e89b294a86d2 Mon Sep 17 00:00:00 2001 From: Arun Kumar Neelakantam Date: Fri, 31 May 2019 12:23:12 +0530 Subject: [PATCH 1/2] soc: qcom: qmi_interface: Release mutex lock before return Mutex lock not released before function return in failure case. Add mutex unlock in failure case. CRs-Fixed: 2463072 Change-Id: I68b23364e8cb1001c0a65b1b831fd3b68894e1a9 Signed-off-by: Arun Kumar Neelakantam --- drivers/soc/qcom/qmi_interface.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c index 810bd1246673..e325165c380a 100644 --- a/drivers/soc/qcom/qmi_interface.c +++ b/drivers/soc/qcom/qmi_interface.c @@ -463,6 +463,7 @@ static void qmi_handle_net_reset(struct qmi_handle *qmi) /* Already qmi_handle_release() started */ if (!qmi->sock) { sock_release(sock); + mutex_unlock(&qmi->sock_lock); return; } sock_release(qmi->sock); From 3bf90d6d2686268b18e2cf4cec50afd09c3b40d5 Mon Sep 17 00:00:00 2001 From: Arun Kumar Neelakantam Date: Fri, 14 Jun 2019 14:15:29 +0530 Subject: [PATCH 2/2] soc: qcom: qmi_interface: Remove ineffective mutex lock from txn struct The same QMI transaction data is synchronized using two mutex locks. Remove ineffective transaction mutex lock because it is always covered by QMI txn_lock with same purpose. CRs-Fixed: 2470638 Change-Id: If53e006436c77d572b2d69507e1593e3d57e1cd4 Signed-off-by: Arun Kumar Neelakantam --- drivers/soc/qcom/qmi_interface.c | 19 ++----------------- include/linux/soc/qcom/qmi.h | 2 -- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/soc/qcom/qmi_interface.c b/drivers/soc/qcom/qmi_interface.c index e325165c380a..7bfb414148a1 100644 --- a/drivers/soc/qcom/qmi_interface.c +++ b/drivers/soc/qcom/qmi_interface.c @@ -311,7 +311,6 @@ int qmi_txn_init(struct qmi_handle *qmi, struct qmi_txn *txn, memset(txn, 0, sizeof(*txn)); - mutex_init(&txn->lock); init_completion(&txn->completion); txn->qmi = qmi; txn->ei = ei; @@ -347,17 +346,12 @@ int qmi_txn_wait(struct qmi_txn *txn, unsigned long timeout) ret = wait_for_completion_timeout(&txn->completion, timeout); - mutex_lock(&txn->lock); if (txn->result == -ENETRESET) { - mutex_unlock(&txn->lock); return txn->result; } - mutex_unlock(&txn->lock); mutex_lock(&qmi->txn_lock); - mutex_lock(&txn->lock); idr_remove(&qmi->txns, txn->id); - mutex_unlock(&txn->lock); mutex_unlock(&qmi->txn_lock); if (ret == 0) @@ -376,9 +370,7 @@ void qmi_txn_cancel(struct qmi_txn *txn) struct qmi_handle *qmi = txn->qmi; mutex_lock(&qmi->txn_lock); - mutex_lock(&txn->lock); idr_remove(&qmi->txns, txn->id); - mutex_unlock(&txn->lock); mutex_unlock(&qmi->txn_lock); } EXPORT_SYMBOL(qmi_txn_cancel); @@ -508,10 +500,6 @@ static void qmi_handle_message(struct qmi_handle *qmi, mutex_unlock(&qmi->txn_lock); return; } - - mutex_lock(&txn->lock); - mutex_unlock(&qmi->txn_lock); - if (txn->dest && txn->ei) { ret = qmi_decode_message(buf, len, txn->ei, txn->dest); if (ret < 0) @@ -519,11 +507,10 @@ static void qmi_handle_message(struct qmi_handle *qmi, txn->result = ret; complete(&txn->completion); - } else { + } else { qmi_invoke_handler(qmi, sq, txn, buf, len); } - - mutex_unlock(&txn->lock); + mutex_unlock(&qmi->txn_lock); } else { /* Create a txn based on the txn_id of the incoming message */ memset(&tmp_txn, 0, sizeof(tmp_txn)); @@ -736,11 +723,9 @@ void qmi_handle_release(struct qmi_handle *qmi) mutex_lock(&qmi->txn_lock); idr_for_each_entry(&qmi->txns, txn, txn_id) { - mutex_lock(&txn->lock); idr_remove(&qmi->txns, txn->id); txn->result = -ENETRESET; complete(&txn->completion); - mutex_unlock(&txn->lock); } mutex_unlock(&qmi->txn_lock); idr_destroy(&qmi->txns); diff --git a/include/linux/soc/qcom/qmi.h b/include/linux/soc/qcom/qmi.h index 1a8c91482460..6e8694e78dff 100644 --- a/include/linux/soc/qcom/qmi.h +++ b/include/linux/soc/qcom/qmi.h @@ -158,7 +158,6 @@ struct qmi_ops { * struct qmi_txn - transaction context * @qmi: QMI handle this transaction is associated with * @id: transaction id - * @lock: for synchronization between handler and waiter of messages * @completion: completion object as the transaction receives a response * @result: result code for the completed transaction * @ei: description of the QMI encoded response (optional) @@ -169,7 +168,6 @@ struct qmi_txn { u16 id; - struct mutex lock; struct completion completion; int result;