Merge d733f3f0364ce613955257b15a6008639b23d392 on remote branch

Change-Id: Id83226c74c8af50c623ac82a3d9e76b99fbb0f23
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index 379d2c7..ea42d39 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -9761,6 +9761,9 @@
 	ipa3_ctx->buff_above_thresh_for_coal_pipe_notified = false;
 	ipa3_ctx->buff_below_thresh_for_def_pipe_notified = false;
 	ipa3_ctx->buff_below_thresh_for_coal_pipe_notified = false;
+	ipa3_ctx->buff_above_thresh_for_ll_pipe_notified = false;
+	ipa3_ctx->buff_below_thresh_for_ll_pipe_notified = false;
+	ipa3_ctx->free_page_task_scheduled = false;
 
 	mutex_init(&ipa3_ctx->app_clock_vote.mutex);
 	ipa3_ctx->is_modem_up = false;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c
index 44a9fef..79d675d 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c
@@ -1555,6 +1555,9 @@
 		"num_buff_below_thresh_for_def_pipe_notified=%u\n"
 		"num_buff_above_thresh_for_coal_pipe_notified=%u\n"
 		"num_buff_below_thresh_for_coal_pipe_notified=%u\n"
+		"num_buff_above_thresh_for_ll_pipe_notified=%u\n"
+		"num_buff_below_thresh_for_ll_pipe_notified=%u\n"
+		"num_free_page_task_scheduled=%u\n"
 		"pipe_setup_fail_cnt=%u\n"
 		"ttl_count=%u\n",
 		ipa3_ctx->stats.tx_sw_pkts,
@@ -1583,6 +1586,9 @@
 		atomic_read(&ipa3_ctx->stats.num_buff_below_thresh_for_def_pipe_notified),
 		atomic_read(&ipa3_ctx->stats.num_buff_above_thresh_for_coal_pipe_notified),
 		atomic_read(&ipa3_ctx->stats.num_buff_below_thresh_for_coal_pipe_notified),
+		atomic_read(&ipa3_ctx->stats.num_buff_above_thresh_for_ll_pipe_notified),
+		atomic_read(&ipa3_ctx->stats.num_buff_below_thresh_for_ll_pipe_notified),
+		atomic_read(&ipa3_ctx->stats.num_free_page_task_scheduled),
 		ipa3_ctx->stats.pipe_setup_fail_cnt,
 		ipa3_ctx->stats.ttl_cnt
 		);
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
index d01884d..366c7ac 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
@@ -1264,6 +1264,7 @@
 		list_splice(&temp_head, &sys->page_recycle_repl->page_repl_head);
 		ipa3_ctx->stats.page_recycle_cnt_in_tasklet += found_free_page;
 		IPADBG_LOW("found free pages count = %d\n", found_free_page);
+		ipa3_ctx->free_page_task_scheduled = false;
 		atomic_set(&sys->common_sys->page_avilable, 1);
 	}
 	spin_unlock_bh(&sys->common_sys->spinlock);
@@ -2669,6 +2670,21 @@
 		atomic_set(&sys->common_sys->page_avilable, 0);
 		tasklet_schedule(&sys->common_sys->tasklet_find_freepage);
 		++ipa3_ctx->stats.num_sort_tasklet_sched[stats_i];
+		spin_lock(&ipa3_ctx->notifier_lock);
+		if(ipa3_ctx->ipa_rmnet_notifier_enabled &&
+		   !ipa3_ctx->free_page_task_scheduled) {
+				atomic_inc(&ipa3_ctx->stats.num_free_page_task_scheduled);
+				if (stats_i ==2) {
+					raw_notifier_call_chain(ipa3_ctx->ipa_rmnet_notifier_list_internal,
+					FREE_PAGE_TASK_SCHEDULED_LL, &sys->common_sys->napi_sort_page_thrshld_cnt);
+				}
+				else {
+					raw_notifier_call_chain(ipa3_ctx->ipa_rmnet_notifier_list_internal,
+						FREE_PAGE_TASK_SCHEDULED, &sys->common_sys->napi_sort_page_thrshld_cnt);
+				}
+				ipa3_ctx->free_page_task_scheduled = true;
+			}
+			spin_unlock(&ipa3_ctx->notifier_lock);
 	}
 	return NULL;
 }
@@ -2710,7 +2726,7 @@
 	return 0;
 }
 
-static void ipa3_replenish_rx_page_recycle(struct ipa3_sys_context *sys)
+ static void ipa3_replenish_rx_page_recycle(struct ipa3_sys_context *sys)
 {
 	struct ipa3_rx_pkt_wrapper *rx_pkt;
 	int ret;
@@ -2844,8 +2860,19 @@
 			IPA_STATS_INC_CNT(ipa3_ctx->stats.lan_rx_empty);
 		else if (sys->ep->client == IPA_CLIENT_APPS_LAN_COAL_CONS)
 			IPA_STATS_INC_CNT(ipa3_ctx->stats.lan_rx_empty_coal);
-		else if (sys->ep->client == IPA_CLIENT_APPS_WAN_LOW_LAT_DATA_CONS)
+		else if (sys->ep->client == IPA_CLIENT_APPS_WAN_LOW_LAT_DATA_CONS) {
 			IPA_STATS_INC_CNT(ipa3_ctx->stats.rmnet_ll_rx_empty);
+			spin_lock(&ipa3_ctx->notifier_lock);
+			if (ipa3_ctx->ipa_rmnet_notifier_enabled
+				&& !ipa3_ctx->buff_below_thresh_for_ll_pipe_notified) {
+				atomic_inc(&ipa3_ctx->stats.num_buff_below_thresh_for_ll_pipe_notified);
+				raw_notifier_call_chain(ipa3_ctx->ipa_rmnet_notifier_list_internal,
+					BUFF_BELOW_LOW_THRESHOLD_FOR_LL_PIPE, &rx_len_cached);
+				ipa3_ctx->buff_above_thresh_for_ll_pipe_notified = false;
+				ipa3_ctx->buff_below_thresh_for_ll_pipe_notified = true;
+			}
+			spin_unlock(&ipa3_ctx->notifier_lock);
+		}
 		else
 			WARN_ON(1);
 	}
@@ -2873,6 +2900,17 @@
 				ipa3_ctx->buff_below_thresh_for_coal_pipe_notified = false;
 			}
 			spin_unlock(&ipa3_ctx->notifier_lock);
+		} else if (sys->ep->client == IPA_CLIENT_APPS_WAN_LOW_LAT_DATA_CONS) {
+			spin_lock(&ipa3_ctx->notifier_lock);
+			if(ipa3_ctx->ipa_rmnet_notifier_enabled &&
+				!ipa3_ctx->buff_above_thresh_for_ll_pipe_notified) {
+				atomic_inc(&ipa3_ctx->stats.num_buff_above_thresh_for_ll_pipe_notified);
+				raw_notifier_call_chain(ipa3_ctx->ipa_rmnet_notifier_list_internal,
+					BUFF_ABOVE_HIGH_THRESHOLD_FOR_LL_PIPE, &rx_len_cached);
+				ipa3_ctx->buff_above_thresh_for_ll_pipe_notified = true;
+				ipa3_ctx->buff_below_thresh_for_ll_pipe_notified = false;
+			}
+			spin_unlock(&ipa3_ctx->notifier_lock);
 		}
 	}
 
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
index a8ed84a..4b8355d 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
@@ -1626,6 +1626,9 @@
 	atomic_t num_buff_above_thresh_for_coal_pipe_notified;
 	atomic_t num_buff_below_thresh_for_def_pipe_notified;
 	atomic_t num_buff_below_thresh_for_coal_pipe_notified;
+	atomic_t num_buff_above_thresh_for_ll_pipe_notified;
+	atomic_t num_buff_below_thresh_for_ll_pipe_notified;
+	atomic_t num_free_page_task_scheduled;
 	struct lan_coal_stats coal;
 	u64 num_sort_tasklet_sched[3];
 	u64 num_of_times_wq_reschd;
@@ -2483,8 +2486,11 @@
 	bool ipa_rmnet_notifier_enabled;
 	bool buff_above_thresh_for_def_pipe_notified;
 	bool buff_above_thresh_for_coal_pipe_notified;
+	bool buff_above_thresh_for_ll_pipe_notified;
 	bool buff_below_thresh_for_def_pipe_notified;
 	bool buff_below_thresh_for_coal_pipe_notified;
+	bool buff_below_thresh_for_ll_pipe_notified;
+	bool free_page_task_scheduled;
 	u8 mhi_ctrl_state;
 	struct ipa_mem_buffer uc_act_tbl;
 	bool uc_act_tbl_valid;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_odl.c b/drivers/platform/msm/ipa/ipa_v3/ipa_odl.c
index 2123327..c50b3ea 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_odl.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_odl.c
@@ -483,6 +483,12 @@
 		IPAERR("adpl pipe not configured\n");
 		return;
 	}
+
+	if(!ipa3_odl_ctx->odl_state.odl_ep_setup) {
+		IPAERR("adpl pipe setup not done\n");
+		return;
+	}
+
 	if (ipa3_odl_ctx->odl_state.odl_open)
 		ipa_odl_opened = true;
 
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c b/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c
index eb61f70..df73f52 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_qmi_service.c
@@ -1767,7 +1767,8 @@
 	/* Initialize modem IPA-driver */
 	IPAWANDBG("send ipa3_qmi_init_modem_send_sync_msg to modem\n");
 	rc = ipa3_qmi_init_modem_send_sync_msg();
-	if ((rc == -ENETRESET) || (rc == -ENODEV) || (rc == -ECONNRESET)) {
+	if ((rc == -ENETRESET) || (rc == -ENODEV) || (rc == -ECONNRESET) ||
+		atomic_read(&ipa3_ctx->is_ssr)) {
 		IPAWANERR(
 		"ipa3_qmi_init_modem_send_sync_msg failed due to SSR!\n");
 		/* Cleanup when ipa3_wwan_remove is called */
@@ -2605,6 +2606,7 @@
 void ipa3_qmi_init(void)
 {
 	mutex_init(&ipa3_qmi_lock);
+	nat_move_qmi_disabled = true;
 }
 
 void ipa3_qmi_cleanup(void)
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c
index f24ce9b..55286b5 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_fltrt.c
@@ -4711,12 +4711,12 @@
 		if (!IPA_IS_RULE_EQ_VALID(i))
 			continue;
 
-		if (eq_bits & IPA_GET_RULE_EQ_BIT_PTRN(eq_bitfield[i])) {
+		if (eq_bits & IPA_GET_RULE_EQ_BIT_PTRN(i)) {
 			IPAHAL_ERR("more than eq with same bit. eq=%d\n", i);
 			WARN_ON(1);
 			return -EFAULT;
 		}
-		eq_bits |= IPA_GET_RULE_EQ_BIT_PTRN(eq_bitfield[i]);
+		eq_bits |= IPA_GET_RULE_EQ_BIT_PTRN(i);
 	}
 
 	mem = &ipahal_ctx->empty_fltrt_tbl;