msm: ipa: update IPA driver to the tip of msm-4.4 kernel

The commit contains changes from the following original commits:
commit c114fe5555d0 ("msm: ipa: fix potential race condition ioctls")
commit c6d606203352 ("msm: ipa: WDI2.0: hotspot offload using WDI 2.0
interface")
commit 634732c1bb02 ("msm: ipa3: fix GSI ring DMA allocation
parameters")
commit 915354544a81 ("msm: ipa3: Fix timeout period of IPA resource add
dependency")
commit a1e8c020b542 ("msm: ipa3: Fix wrong parameter to xdci release
function")
commit bd09eb993a1a ("msm: ipa: fix skb recycle logic")
commit b2c8a0dbe6c8 ("msm: ipa: fix memory leak on QMI")
commit c4fddbc45db0 ("msm: ipa: mhi: add perf vote")
commit 7bd2a476f7d8 ("msm: ipa: Allocate memory on send message")
commit b544de499e55 ("msm: ipa3: increase SSR tag timeout")
commit 15dc347f5272 ("msm: ipa3: hal: change FnR prints to low")
commit b0756920f39f ("msm: ipa: unlock WLAN doorbell register access")
commit 0dfb2feb3e79 ("msm: ipa: Recycle wan buffer")
commit 1966a333f80b ("mam: ipa: always add default flt rule at the
end")
commit 9ba1638c4bdb ("msm: ipa3: change FnR prints to low")
commit 8b81dd70999c ("msm: ipa3: fix benign prints on ipa3_usb_init")
commit d51f2f62e4bc ("msm: ipa3: Add specific logs to improve debugging
capabilities")
commit 21fab3e70330 ("msm: ipa: fix mutex_lock with task->state !=
RUNNING")
commit bdb22900877b ("msm: ipa3: Do not wait for IPA DMA_TASK H/W
ACK for GSI")
commit fc5f71883677 ("msm: ipa: fix reference count in rm")
commit cd5f5121db9a ("msm: ipa: update wan pool size on napi enable")
commit 7e079d086ffe ("msm: ipa: Remove obsolete IOMMU domain
attribute")
commit 38b227b0c22f ("msm: ipa: Add guard around nat entries read")
commit 9dc2df841d20 ("msm: ipa: fix static analysis sign issue")
commit 3ce1ef220c57 ("msm: ipa3: add check on qmi-client handler")
commit 5334ff493a3f ("msm: ipa: Fix ipa ready cb return value")

All of these changes come to complete the initial IPA driver snapshot:
commit 9659e593c80a ("msm: ipa: initial commit of IPA driver")

Change-Id: Iad2c7633eb15393202d5ba8b3209363442410160
Signed-off-by: Gidon Studinski <gidons@codeaurora.org>
Signed-off-by: Amir Levy <alevy@codeaurora.org>
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c b/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
index 32c5004..b9f5755 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
@@ -358,6 +358,11 @@
 	return result;
 }
 
+static void ipa3_send_msg_free(void *buff, u32 len, u32 type)
+{
+	kfree(buff);
+}
+
 /**
  * ipa3_send_msg() - Send "message" from kernel client to IPA driver
  * @meta: [in] message meta-data
@@ -377,6 +382,7 @@
 		  ipa_msg_free_fn callback)
 {
 	struct ipa3_push_msg *msg;
+	void *data = NULL;
 
 	if (meta == NULL || (buff == NULL && callback != NULL) ||
 	    (buff != NULL && callback == NULL)) {
@@ -397,8 +403,17 @@
 	}
 
 	msg->meta = *meta;
-	msg->buff = buff;
-	msg->callback = callback;
+	if (meta->msg_len > 0 && buff) {
+		data = kmalloc(meta->msg_len, GFP_KERNEL);
+		if (data == NULL) {
+			IPAERR("fail to alloc data container\n");
+			kfree(msg);
+			return -ENOMEM;
+		}
+		memcpy(data, buff, meta->msg_len);
+		msg->buff = data;
+		msg->callback = ipa3_send_msg_free;
+	}
 
 	mutex_lock(&ipa3_ctx->msg_lock);
 	list_add_tail(&msg->link, &ipa3_ctx->msg_list);
@@ -406,6 +421,8 @@
 	IPA_STATS_INC_CNT(ipa3_ctx->stats.msg_w[meta->msg_type]);
 
 	wake_up(&ipa3_ctx->msg_waitq);
+	if (buff)
+		callback(buff, meta->msg_len, meta->msg_type);
 
 	return 0;
 }
@@ -511,12 +528,12 @@
 	start = buf;
 
 	while (1) {
+		mutex_lock(&ipa3_ctx->msg_lock);
+		locked = 1;
 		prepare_to_wait(&ipa3_ctx->msg_waitq,
 				&wait,
 				TASK_INTERRUPTIBLE);
 
-		mutex_lock(&ipa3_ctx->msg_lock);
-		locked = 1;
 		if (!list_empty(&ipa3_ctx->msg_list)) {
 			msg = list_first_entry(&ipa3_ctx->msg_list,
 					struct ipa3_push_msg, link);