Bläddra i källkod

msm: ipa: optimize the spearhead stats mips consumption

Removed stats ioctls which are not relevant when pipes are not
connected yet.

Change-Id: I59891e07d4fb116e7a1fb8475e2aefae1cb799c6
Signed-off-by: Michael Adisumarta <[email protected]>
Michael Adisumarta 3 år sedan
förälder
incheckning
34e8dbc749

+ 1 - 0
drivers/platform/msm/ipa/ipa_common_i.h

@@ -894,6 +894,7 @@ int ipa_set_pkt_init_ex_hdr_ofst(
   struct ipa_pkt_init_ex_hdr_ofst_set *lookup, bool proc_ctx);
 
 /* IPA stats pm functions */
+int ipa_pm_get_scaling_bw_levels(struct ipa_lnx_clock_stats *clock_stats);
 int ipa_pm_get_aggregated_throughput(void);
 int ipa_pm_get_current_clk_vote(void);
 bool ipa_get_pm_client_stats_filled(struct pm_client_stats *pm_stats_ptr,

+ 4 - 48
drivers/platform/msm/ipa/ipa_v3/ipa_client.c

@@ -802,21 +802,10 @@ EXPORT_SYMBOL(ipa3_set_usb_max_packet_size);
 int ipa3_get_usb_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
 {
 	int i;
-	int ipa_ep_idx_tx, ipa_ep_idx_rx;
 
-	ipa_ep_idx_tx = ipa3_get_ep_mapping(IPA_CLIENT_USB_CONS);
-	ipa_ep_idx_rx = ipa3_get_ep_mapping(IPA_CLIENT_USB_PROD);
-
-	if ((ipa_ep_idx_tx == -1) || (ipa_ep_idx_rx == -1) ||
-		!ipa3_ctx->ep[ipa_ep_idx_tx].valid ||
-		!ipa3_ctx->ep[ipa_ep_idx_rx].valid) {
+	if (!ipa3_ctx->usb_ctx.dbg_stats.uc_dbg_stats_mmio)
 		return -EINVAL;
-	}
 
-	if (!ipa3_ctx->usb_ctx.dbg_stats.uc_dbg_stats_mmio) {
-		IPAERR("bad parms NULL usb_gsi_stats_mmio\n");
-		return -EINVAL;
-	}
 	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 	for (i = 0; i < MAX_USB_CHANNELS; i++) {
 		stats->u.ring[i].ringFull = ioread32(
@@ -2072,21 +2061,10 @@ static void ipa3_get_gsi_ring_stats(struct IpaHwRingStats_t *ring,
 int ipa3_get_aqc_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
 {
 	int i;
-	int ipa_ep_idx_tx, ipa_ep_idx_rx;
 
-	ipa_ep_idx_tx = ipa3_get_ep_mapping(IPA_CLIENT_AQC_ETHERNET_CONS);
-	ipa_ep_idx_rx = ipa3_get_ep_mapping(IPA_CLIENT_AQC_ETHERNET_PROD);
-
-	if ((ipa_ep_idx_tx == -1) || (ipa_ep_idx_rx == -1) ||
-		!ipa3_ctx->ep[ipa_ep_idx_tx].valid ||
-		!ipa3_ctx->ep[ipa_ep_idx_rx].valid) {
+	if (!ipa3_ctx->aqc_ctx.dbg_stats.uc_dbg_stats_mmio)
 		return -EINVAL;
-	}
 
-	if (!ipa3_ctx->aqc_ctx.dbg_stats.uc_dbg_stats_mmio) {
-		IPAERR("bad parms NULL aqc_gsi_stats_mmio\n");
-		return -EINVAL;
-	}
 	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 	for (i = 0; i < MAX_AQC_CHANNELS; i++) {
 		ipa3_get_gsi_ring_stats(stats->u.ring + i,
@@ -2110,21 +2088,10 @@ int ipa3_get_aqc_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
 int ipa3_get_ntn_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
 {
 	int i;
-	int ipa_ep_idx_tx, ipa_ep_idx_rx;
 
-	ipa_ep_idx_tx = ipa3_get_ep_mapping(IPA_CLIENT_ETHERNET_CONS);
-	ipa_ep_idx_rx = ipa3_get_ep_mapping(IPA_CLIENT_ETHERNET_PROD);
-
-	if ((ipa_ep_idx_tx == -1) || (ipa_ep_idx_rx == -1) ||
-		!ipa3_ctx->ep[ipa_ep_idx_tx].valid ||
-		!ipa3_ctx->ep[ipa_ep_idx_rx].valid) {
+	if (!ipa3_ctx->ntn_ctx.dbg_stats.uc_dbg_stats_mmio)
 		return -EINVAL;
-	}
 
-	if (!ipa3_ctx->ntn_ctx.dbg_stats.uc_dbg_stats_mmio) {
-		IPAERR("bad parms NULL ntn_gsi_stats_mmio\n");
-		return -EINVAL;
-	}
 	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 	for (i = 0; i < MAX_NTN_CHANNELS; i++) {
 		ipa3_get_gsi_ring_stats(stats->u.ring + i,
@@ -2149,21 +2116,10 @@ int ipa3_get_rtk_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
 {
 	int i;
 	u64 low, high;
-	int ipa_ep_idx_tx, ipa_ep_idx_rx;
 
-	ipa_ep_idx_tx = ipa3_get_ep_mapping(IPA_CLIENT_RTK_ETHERNET_CONS);
-	ipa_ep_idx_rx = ipa3_get_ep_mapping(IPA_CLIENT_RTK_ETHERNET_PROD);
-
-	if ((ipa_ep_idx_tx == -1) || (ipa_ep_idx_rx == -1) ||
-		!ipa3_ctx->ep[ipa_ep_idx_tx].valid ||
-		!ipa3_ctx->ep[ipa_ep_idx_rx].valid) {
+	if (!ipa3_ctx->rtk_ctx.dbg_stats.uc_dbg_stats_mmio)
 		return -EINVAL;
-	}
 
-	if (!ipa3_ctx->rtk_ctx.dbg_stats.uc_dbg_stats_mmio) {
-		IPAERR("bad parms NULL eth_gsi_stats_mmio\n");
-		return -EINVAL;
-	}
 	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 	for (i = 0; i < MAX_RTK_CHANNELS; i++) {
 		ipa3_get_gsi_ring_stats(&stats->u.rtk[i].commStats,

+ 15 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_pm.c

@@ -1458,6 +1458,21 @@ int ipa_pm_exceptions_stat(char *buf, int size)
 	return cnt;
 }
 
+int ipa_pm_get_scaling_bw_levels(struct ipa_lnx_clock_stats *clock_stats)
+{
+	struct clk_scaling_db *clk;
+
+	if (ipa_pm_ctx) {
+		clk = &ipa_pm_ctx->clk_scaling;
+		if (clk->threshold_size >= 3) {
+			clock_stats->scale_thresh_svs = clk->current_threshold[0];
+			clock_stats->scale_thresh_nom = clk->current_threshold[1];
+			clock_stats->scale_thresh_tur = clk->current_threshold[2];
+			return 0;
+		} else return -EINVAL;
+	} else return -EINVAL;
+}
+
 int ipa_pm_get_aggregated_throughput(void)
 {
 	if (ipa_pm_ctx)

+ 37 - 27
drivers/platform/msm/ipa/ipa_v3/ipa_stats.c

@@ -402,16 +402,12 @@ static int ipa_get_clock_stats(unsigned long arg)
 	clock_stats = (struct ipa_lnx_clock_stats *) memdup_user((
 		const void __user *)arg, alloc_size);
 	if (IS_ERR(clock_stats)) {
-		IPA_STATS_ERR("copy from user failed");
+		IPA_STATS_ERR("copy from user failed\n");
 		return -ENOMEM;
 	}
 
-	clock_stats->scale_thresh_svs =
-		ipa3_ctx->ctrl->clock_scaling_bw_threshold_svs;
-	clock_stats->scale_thresh_nom =
-		ipa3_ctx->ctrl->clock_scaling_bw_threshold_nominal;
-	clock_stats->scale_thresh_tur =
-		ipa3_ctx->ctrl->clock_scaling_bw_threshold_turbo;
+	if(ipa_pm_get_scaling_bw_levels(clock_stats))
+		IPA_STATS_ERR("Couldn't get scaling bw levels\n");
 	clock_stats->aggr_bw =
 		ipa_pm_get_aggregated_throughput();
 	clock_stats->curr_clk_vote = ipa_pm_get_current_clk_vote();
@@ -955,6 +951,7 @@ static int ipa_get_eth_inst_stats(unsigned long arg)
 							sizeof(struct ipa_lnx_gsi_rx_debug_stats)) +
 							(instance_ptr->num_pipes *
 							sizeof(struct ipa_lnx_pipe_info)));
+						continue;
 					}
 				} else {
 					if(ipa3_get_aqc_gsi_stats(&stats)) {
@@ -967,6 +964,7 @@ static int ipa_get_eth_inst_stats(unsigned long arg)
 							sizeof(struct ipa_lnx_gsi_rx_debug_stats)) +
 							(instance_ptr->num_pipes *
 							sizeof(struct ipa_lnx_pipe_info)));
+						continue;
 					}
 				}
 
@@ -1012,6 +1010,7 @@ static int ipa_get_eth_inst_stats(unsigned long arg)
 						sizeof(struct ipa_lnx_gsi_rx_debug_stats)) +
 						(instance_ptr->num_pipes *
 						sizeof(struct ipa_lnx_pipe_info)));
+					continue;
 				}
 				client_type = IPA_CLIENT_RTK_ETHERNET_CONS;
 				instance_ptr->pm_bandwidth =
@@ -1390,6 +1389,7 @@ static int ipa_get_mhip_inst_stats(unsigned long arg)
 				(instance_ptr->gsi_debug_stats.num_rx_instances *
 					sizeof(struct ipa_lnx_gsi_rx_debug_stats)) +
 				(instance_ptr->num_pipes * sizeof(struct ipa_lnx_pipe_info)));
+			continue;
 		}
 
 		tx_instance_ptr = (struct ipa_lnx_gsi_tx_debug_stats *)((
@@ -1505,6 +1505,7 @@ static int ipa_stats_get_alloc_info(unsigned long arg)
 	int i = 0;
 	int j, k;
 	int holb_drop_stats_num_pipes = 0;
+	int ipa_ep_idx_tx, ipa_ep_idx_rx;
 	int ipa_client_type;
 	int reg_idx;
 	int index;
@@ -1546,31 +1547,39 @@ static int ipa_stats_get_alloc_info(unsigned long arg)
 
 	/* For WLAN instance */
 	if (ipa_lnx_agent_ctx.log_type_mask & SPRHD_IPA_LOG_TYPE_WLAN_STATS) {
-		ipa_lnx_agent_ctx.alloc_info.num_wlan_instances = 1;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_pipes = 2;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_tx_instances = 1;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_rx_instances = 1;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].pipes_client_type[0]
-			= IPA_CLIENT_WLAN2_CONS;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].pipes_client_type[1]
-			= IPA_CLIENT_WLAN2_PROD;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].tx_inst_client_type[0]
-			= IPA_CLIENT_WLAN2_CONS;
-		ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].rx_inst_client_type[0]
-			= IPA_CLIENT_WLAN2_PROD;
-		if(ipa_wdi_is_tx1_used() == 1) {
-			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_tx_instances++;
-			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_pipes++;
-			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[
-				0].pipes_client_type[2] = IPA_CLIENT_WLAN2_CONS1;
-			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[
-				0].tx_inst_client_type[1] = IPA_CLIENT_WLAN2_CONS1;
+		ipa_ep_idx_tx = ipa3_get_ep_mapping(IPA_CLIENT_WLAN2_CONS);
+		ipa_ep_idx_rx = ipa3_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);
+		if ((ipa_ep_idx_tx == -1) || (ipa_ep_idx_rx == -1) ||
+			!ipa3_ctx->ep[ipa_ep_idx_tx].valid ||
+			!ipa3_ctx->ep[ipa_ep_idx_rx].valid) {
+			ipa_lnx_agent_ctx.alloc_info.num_wlan_instances = 0;
+		} else {
+			ipa_lnx_agent_ctx.alloc_info.num_wlan_instances = 1;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_pipes = 2;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_tx_instances = 1;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_rx_instances = 1;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].pipes_client_type[0]
+				= IPA_CLIENT_WLAN2_CONS;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].pipes_client_type[1]
+				= IPA_CLIENT_WLAN2_PROD;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].tx_inst_client_type[0]
+				= IPA_CLIENT_WLAN2_CONS;
+			ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].rx_inst_client_type[0]
+				= IPA_CLIENT_WLAN2_PROD;
+			if(ipa_wdi_is_tx1_used() == 1) {
+				ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_tx_instances++;
+				ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[0].num_pipes++;
+				ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[
+					0].pipes_client_type[2] = IPA_CLIENT_WLAN2_CONS1;
+				ipa_lnx_agent_ctx.alloc_info.wlan_inst_info[
+					0].tx_inst_client_type[1] = IPA_CLIENT_WLAN2_CONS1;
+		}
 		}
 	}
 
 	/* For ETH instance */
 	if (ipa_lnx_agent_ctx.log_type_mask & SPRHD_IPA_LOG_TYPE_ETH_STATS) {
-		ipa_lnx_agent_ctx.alloc_info.num_eth_instances = IPA_ETH_INST_ID_MAX;
+		ipa_lnx_agent_ctx.alloc_info.num_eth_instances = 0;
 		for (i = 0; i < IPA_ETH_INST_ID_MAX; i++) {
 			ipa_lnx_agent_ctx.alloc_info.eth_inst_info[i].num_pipes = 0;
 			ipa_lnx_agent_ctx.alloc_info.eth_inst_info[i].num_pipes = 0;
@@ -1609,6 +1618,7 @@ static int ipa_stats_get_alloc_info(unsigned long arg)
 					}
 					ipa_lnx_agent_ctx.alloc_info.eth_inst_info[
 						i].pipes_client_type[(k*2) + 1] = ipa_client_type;
+					ipa_lnx_agent_ctx.alloc_info.num_eth_instances++;
 					k++;
 				}
 			}

+ 1 - 13
drivers/platform/msm/ipa/ipa_v3/ipa_wdi3_i.c

@@ -1205,21 +1205,9 @@ exit:
 int ipa3_get_wdi3_gsi_stats(struct ipa_uc_dbg_ring_stats *stats)
 {
 	int i;
-	int ipa_ep_idx_tx, ipa_ep_idx_rx;
 
-	ipa_ep_idx_tx = ipa3_get_ep_mapping(IPA_CLIENT_WLAN2_CONS);
-	ipa_ep_idx_rx = ipa3_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);
-
-	if ((ipa_ep_idx_tx == -1) || (ipa_ep_idx_rx == -1) ||
-		!ipa3_ctx->ep[ipa_ep_idx_tx].valid ||
-		!ipa3_ctx->ep[ipa_ep_idx_rx].valid) {
+	if (!ipa3_ctx->wdi3_ctx.dbg_stats.uc_dbg_stats_mmio)
 		return -EINVAL;
-	}
-
-	if (!ipa3_ctx->wdi3_ctx.dbg_stats.uc_dbg_stats_mmio) {
-		IPAERR("bad NULL parms for wdi3_gsi_stats\n");
-		return -EINVAL;
-	}
 
 	IPA_ACTIVE_CLIENTS_INC_SIMPLE();
 	for (i = 0; i < MAX_WDI3_CHANNELS; i++) {