Parcourir la source

msm: ipa3: Add hw_type_index to ipa3_context

Caching hw_type_index in ipa3_context in ipa3_pre_init.

Change-Id: Iab6e801165db7c1fcb4cc6a4c0dc5cbc83052e94
Acked-by: Eliad Ben Yishay <[email protected]>
Signed-off-by: Amir Levy <[email protected]>
Amir Levy il y a 4 ans
Parent
commit
e42bd3284e

+ 1 - 0
drivers/platform/msm/ipa/ipa_v3/ipa.c

@@ -6653,6 +6653,7 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
 	ipa3_ctx->ipa_wrapper_base = resource_p->ipa_mem_base;
 	ipa3_ctx->ipa_wrapper_size = resource_p->ipa_mem_size;
 	ipa3_ctx->ipa_hw_type = resource_p->ipa_hw_type;
+	ipa3_ctx->hw_type_index = ipa3_get_hw_type_index();
 	ipa3_ctx->ipa3_hw_mode = resource_p->ipa3_hw_mode;
 	ipa3_ctx->platform_type = resource_p->platform_type;
 	ipa3_ctx->use_ipa_teth_bridge = resource_p->use_ipa_teth_bridge;

+ 4 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_i.h

@@ -1857,6 +1857,7 @@ struct ipa3_app_clock_vote {
  * @disconnect_lock: protects LAN_CONS packet receive notification CB
  * @ipa3_active_clients: structure for reference counting connected IPA clients
  * @ipa_hw_type: type of IPA HW type (e.g. IPA 1.0, IPA 1.1 etc')
+ * @ipa_hw_type_index: index of IPA HW type (e.g. IPA_4_0, IPA_4_0_MHI etc')
  * @ipa3_hw_mode: mode of IPA HW mode (e.g. Normal, Virtual or over PCIe)
  * @use_ipa_teth_bridge: use tethering bridge driver
  * @modem_cfg_emb_pipe_flt: modem configure embedded pipe filtering rules
@@ -1975,6 +1976,7 @@ struct ipa3_context {
 	struct mutex msg_wlan_client_lock;
 	wait_queue_head_t msg_waitq;
 	enum ipa_hw_type ipa_hw_type;
+	u8 hw_type_index;
 	enum ipa3_hw_mode ipa3_hw_mode;
 	enum ipa3_platform_type platform_type;
 	bool ipa_config_is_mhi;
@@ -2878,6 +2880,8 @@ bool ipa3_get_qmap_pipe_enable(void);
 
 /* internal functions */
 
+u8 ipa3_get_hw_type_index(void);
+
 int ipa3_bind_api_controller(enum ipa_hw_type ipa_hw_type,
 	struct ipa_api_controller *api_ctrl);
 

+ 34 - 16
drivers/platform/msm/ipa/ipa_v3/ipa_utils.c

@@ -3913,7 +3913,7 @@ int ipa3_resume_resource(enum ipa_rm_resource_name resource)
  *
  * Return value: HW type index
  */
-static u8 ipa3_get_hw_type_index(void)
+u8 ipa3_get_hw_type_index(void)
 {
 	u8 hw_type_index;
 
@@ -4171,7 +4171,7 @@ static void ipa3_cfg_qsb(void)
 	struct ipahal_reg_qsb_max_reads max_reads = { 0 };
 	struct ipahal_reg_qsb_max_writes max_writes = { 0 };
 
-	hw_type_idx = ipa3_get_hw_type_index();
+	hw_type_idx = ipa3_ctx->hw_type_index;
 
 	/*
 	 * Read the register values before writing to them to ensure
@@ -4340,7 +4340,9 @@ int ipa3_init_hw(void)
 int ipa3_get_ep_mapping(enum ipa_client_type client)
 {
 	int ipa_ep_idx;
-	u8 hw_idx = ipa3_get_hw_type_index();
+	u8 hw_idx;
+
+	hw_idx = ipa3_ctx->hw_type_index;
 
 	if (client >= IPA_CLIENT_MAX || client < 0) {
 		IPAERR_RL("Bad client number! client =%d\n", client);
@@ -4369,15 +4371,18 @@ const struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info
 	(enum ipa_client_type client)
 {
 	int ep_idx;
+	u8 hw_idx;
+
+	hw_idx = ipa3_ctx->hw_type_index;
 
 	ep_idx = ipa3_get_ep_mapping(client);
 	if (ep_idx == IPA_EP_NOT_ALLOCATED)
 		return NULL;
 
-	if (!ipa3_ep_mapping[ipa3_get_hw_type_index()][client].valid)
+	if (!ipa3_ep_mapping[hw_idx][client].valid)
 		return NULL;
 
-	return &(ipa3_ep_mapping[ipa3_get_hw_type_index()]
+	return &(ipa3_ep_mapping[hw_idx]
 		[client].ipa_gsi_ep_info);
 }
 
@@ -4389,15 +4394,19 @@ const struct ipa_gsi_ep_config *ipa3_get_gsi_ep_info
  */
 int ipa_get_ep_group(enum ipa_client_type client)
 {
+	u8 hw_idx;
+
+	hw_idx = ipa3_ctx->hw_type_index;
+
 	if (client >= IPA_CLIENT_MAX || client < 0) {
 		IPAERR("Bad client number! client =%d\n", client);
 		return -EINVAL;
 	}
 
-	if (!ipa3_ep_mapping[ipa3_get_hw_type_index()][client].valid)
+	if (!ipa3_ep_mapping[hw_idx][client].valid)
 		return -EINVAL;
 
-	return ipa3_ep_mapping[ipa3_get_hw_type_index()][client].group_num;
+	return ipa3_ep_mapping[hw_idx][client].group_num;
 }
 
 /**
@@ -4408,15 +4417,19 @@ int ipa_get_ep_group(enum ipa_client_type client)
  */
 u8 ipa3_get_qmb_master_sel(enum ipa_client_type client)
 {
+	u8 hw_idx;
+
+	hw_idx = ipa3_ctx->hw_type_index;
+
 	if (client >= IPA_CLIENT_MAX || client < 0) {
 		IPAERR("Bad client number! client =%d\n", client);
 		return -EINVAL;
 	}
 
-	if (!ipa3_ep_mapping[ipa3_get_hw_type_index()][client].valid)
+	if (!ipa3_ep_mapping[hw_idx][client].valid)
 		return -EINVAL;
 
-	return ipa3_ep_mapping[ipa3_get_hw_type_index()]
+	return ipa3_ep_mapping[hw_idx]
 		[client].qmb_master_sel;
 }
 
@@ -4550,10 +4563,13 @@ enum ipa_client_type ipa3_get_client_mapping(int pipe_idx)
 enum ipa_client_type ipa3_get_client_by_pipe(int pipe_idx)
 {
 	int j = 0;
+	u8 hw_type_idx;
+
+	hw_type_idx = ipa3_ctx->hw_type_index;
 
 	for (j = 0; j < IPA_CLIENT_MAX; j++) {
 		const struct ipa_ep_configuration *iec_ptr =
-			&(ipa3_ep_mapping[ipa3_get_hw_type_index()][j]);
+			&(ipa3_ep_mapping[hw_type_idx][j]);
 		if (iec_ptr->valid &&
 		    iec_ptr->ipa_gsi_ep_info.ipa_ep_num == pipe_idx)
 			break;
@@ -4573,11 +4589,12 @@ enum ipa_client_type ipa3_get_client_by_pipe(int pipe_idx)
 void ipa_init_ep_flt_bitmap(void)
 {
 	enum ipa_client_type cl;
-	u8 hw_idx = ipa3_get_hw_type_index();
+	u8 hw_idx;
 	u32 bitmap;
 	u32 pipe_num;
 	const struct ipa_gsi_ep_config *gsi_ep_ptr;
 
+	hw_idx = ipa3_ctx->hw_type_index;
 	bitmap = 0;
 	if (ipa3_ctx->ep_flt_bitmap) {
 		WARN_ON(1);
@@ -4657,7 +4674,7 @@ int ipa3_cfg_ep_seq(u32 clnt_hdl, const struct ipa_ep_cfg_seq *seq_cfg)
 	if (seq_cfg->set_dynamic)
 		type = seq_cfg->seq_type;
 	else
-		type = ipa3_ep_mapping[ipa3_get_hw_type_index()]
+		type = ipa3_ep_mapping[ipa3_ctx->hw_type_index]
 			[ipa3_ctx->ep[clnt_hdl].client].sequencer_type;
 
 	if (type != IPA_DPS_HPS_SEQ_TYPE_INVALID) {
@@ -7414,7 +7431,7 @@ static void ipa3_write_rsrc_grp_type_reg(int group_index,
 {
 	u8 hw_type_idx;
 
-	hw_type_idx = ipa3_get_hw_type_index();
+	hw_type_idx = ipa3_ctx->hw_type_index;
 
 	switch (hw_type_idx) {
 	case IPA_3_0:
@@ -7730,7 +7747,7 @@ static void ipa3_configure_rx_hps_clients(int depth,
 	struct ipahal_reg_rx_hps_clients val;
 	u8 hw_type_idx;
 
-	hw_type_idx = ipa3_get_hw_type_index();
+	hw_type_idx = ipa3_ctx->hw_type_index;
 
 	for (i = 0 ; i < max_clnt_in_depth ; i++) {
 		if (min)
@@ -7762,7 +7779,7 @@ static void ipa3_configure_rx_hps_weight(void)
 	struct ipahal_reg_rx_hps_weights val;
 	u8 hw_type_idx;
 
-	hw_type_idx = ipa3_get_hw_type_index();
+	hw_type_idx = ipa3_ctx->hw_type_index;
 
 	val.hps_queue_weight_0 =
 			ipa3_rsrc_rx_grp_hps_weight_config
@@ -7829,7 +7846,8 @@ void ipa3_set_resorce_groups_min_max_limits(void)
 
 	IPADBG("ENTER\n");
 
-	hw_type_idx = ipa3_get_hw_type_index();
+	hw_type_idx = ipa3_ctx->hw_type_index;
+
 	switch (hw_type_idx) {
 	case IPA_3_0:
 		src_rsrc_type_max = IPA_v3_0_RSRC_GRP_TYPE_SRC_MAX;