Bladeren bron

msm: camera: isp: Update the resource reserve logic

Based on HW team's recommendation, we should restrict to 1:1
mapping in between IFE and SFE hw index. This change makes
sure IFE acquire resource from the hw idx what SFE has
acquired.

CRs-Fixed: 3618217
Change-Id: I493f3519887a3a214e23cf8e70d2a1550213ee84
Signed-off-by: Depeng Shao <[email protected]>
Depeng Shao 1 jaar geleden
bovenliggende
commit
83c35b72f0
1 gewijzigde bestanden met toevoegingen van 187 en 262 verwijderingen
  1. 187 262
      drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

+ 187 - 262
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -2811,51 +2811,33 @@ static int cam_convert_res_id_to_hw_path(int res_id, int csid_res_id)
 }
 
 static int cam_ife_hw_mgr_acquire_sfe_hw(
-	bool                                use_lower_idx,
-	struct cam_ife_hw_mgr_ctx          *ife_ctx,
-	struct cam_sfe_acquire_args        *sfe_acquire)
+	bool                          is_right_hw,
+	struct cam_ife_hw_mgr_ctx    *ife_ctx,
+	struct cam_sfe_acquire_args  *sfe_acquire)
 {
-	int i, rc = -EINVAL;
+	int rc = -EINVAL;
+	uint32_t hw_idx;
 	struct cam_hw_intf    *hw_intf = NULL;
 	struct cam_ife_hw_mgr *ife_hw_mgr = ife_ctx->hw_mgr;
 
-	/* Use lower index for RDIs in case of dual */
-	if ((ife_ctx->flags.is_fe_enabled) || (use_lower_idx)) {
-		for (i = 0; i < CAM_SFE_HW_NUM_MAX; i++) {
-			if (!ife_hw_mgr->sfe_devices[i])
-				continue;
+	if (is_right_hw)
+		hw_idx = ife_ctx->right_hw_idx;
+	else
+		hw_idx = ife_ctx->left_hw_idx;
 
-			hw_intf = ife_hw_mgr->sfe_devices[i]->hw_intf;
-			rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-					sfe_acquire,
-					sizeof(struct cam_sfe_acquire_args));
-			if (rc) {
-				CAM_DBG(CAM_ISP,
-					"Can not acquire SFE HW: %d for res: %d ctx_idx: %u",
-					i, sfe_acquire->sfe_in.res_id, ife_ctx->ctx_index);
-				continue;
-			} else {
-				break;
-			}
-		}
-	} else {
-		for (i = CAM_SFE_HW_NUM_MAX - 1; i >= 0; i--) {
-			if (!ife_hw_mgr->sfe_devices[i])
-				continue;
+	if ((hw_idx >= CAM_SFE_HW_NUM_MAX) || !ife_hw_mgr->sfe_devices[hw_idx]) {
+		CAM_ERR(CAM_ISP, "the hw index:%d is wrong");
+		return -EINVAL;
+	}
 
-			hw_intf = ife_hw_mgr->sfe_devices[i]->hw_intf;
-			rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-					sfe_acquire,
-					sizeof(struct cam_sfe_acquire_args));
-			if (rc) {
-				CAM_DBG(CAM_ISP,
-					"Can not acquire SFE HW: %d for res: %d ctx_idx: %u",
-					i, sfe_acquire->sfe_in.res_id, ife_ctx->ctx_index);
-				continue;
-			} else {
-				break;
-			}
-		}
+	hw_intf = ife_hw_mgr->sfe_devices[hw_idx]->hw_intf;
+	rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+		sfe_acquire,
+		sizeof(struct cam_sfe_acquire_args));
+	if (rc) {
+		CAM_DBG(CAM_ISP,
+			"Can not acquire SFE HW: %d for res: %d ctx_idx: %u",
+			hw_idx, sfe_acquire->sfe_in.res_id, ife_ctx->ctx_index);
 	}
 
 	return rc;
@@ -2866,7 +2848,6 @@ static int cam_ife_hw_mgr_acquire_res_sfe_src_util(
 	struct cam_isp_in_port_generic_info *in_port,
 	struct cam_isp_hw_mgr_res           *csid_res,
 	struct cam_sfe_acquire_args         *sfe_acquire,
-	bool                                 is_rdi,
 	uint32_t                            *acquired_hw_id,
 	uint32_t                            *acquired_hw_path)
 {
@@ -2898,9 +2879,7 @@ static int cam_ife_hw_mgr_acquire_res_sfe_src_util(
 	sfe_src_res->use_wm_pack = csid_res->use_wm_pack;
 
 	for (i = sfe_src_res->is_dual_isp; i >= 0; i--) {
-		rc = cam_ife_hw_mgr_acquire_sfe_hw(
-			((is_rdi) && (!sfe_src_res->is_dual_isp) &&
-			(ife_ctx->flags.is_dual)),
+		rc = cam_ife_hw_mgr_acquire_sfe_hw(i,
 			ife_ctx, sfe_acquire);
 
 		if (rc || !sfe_acquire->sfe_in.rsrc_node) {
@@ -2956,7 +2935,6 @@ static int cam_ife_hw_mgr_acquire_res_sfe_src(
 	int                                  rc = -1;
 	struct cam_sfe_acquire_args          sfe_acquire;
 	struct cam_isp_hw_mgr_res           *csid_res;
-	bool                                 is_rdi = false;
 	long                                 sfe_required_res = 0;
 	uint32_t                             sfe_acquired_res = 0;
 	uint32_t                             sfe_res_id = 0;
@@ -3023,26 +3001,9 @@ static int cam_ife_hw_mgr_acquire_res_sfe_src(
 		sfe_res_id = ffs(sfe_required_res) - 1;
 		clear_bit(sfe_res_id, &sfe_required_res);
 
-		switch (sfe_res_id) {
-		case CAM_ISP_HW_SFE_IN_PIX:
-			is_rdi = false;
-			break;
-		case CAM_ISP_HW_SFE_IN_RDI0:
-		case CAM_ISP_HW_SFE_IN_RDI1:
-		case CAM_ISP_HW_SFE_IN_RDI2:
-		case CAM_ISP_HW_SFE_IN_RDI3:
-		case CAM_ISP_HW_SFE_IN_RDI4:
-			is_rdi = true;
-			break;
-		default:
-			CAM_ERR(CAM_ISP, "Wrong CSID Path Resource ID: %u ctx_idx: %u",
-				sfe_res_id, ife_ctx->ctx_index);
-			goto err;
-		}
-
 		sfe_acquire.sfe_in.res_id = sfe_res_id;
 		rc = cam_ife_hw_mgr_acquire_res_sfe_src_util(ife_ctx, in_port,
-			csid_res_map[sfe_res_id], &sfe_acquire, is_rdi,
+			csid_res_map[sfe_res_id], &sfe_acquire,
 			acquired_hw_id, acquired_hw_path);
 		if (rc)
 			goto err;
@@ -3085,6 +3046,9 @@ static bool cam_ife_mgr_check_can_use_lite(
 		goto end;
 	}
 
+	if (ife_ctx->flags.is_fe_enabled || ife_ctx->flags.dsp_enabled)
+		can_use_lite = false;
+
 	CAM_DBG(CAM_ISP,
 		"in_port lite hint %d, rdi_only: %d can_use_lite: %d res_id: %u ctx_idx: %u",
 		csid_acquire->in_port->can_use_lite,
@@ -3099,19 +3063,23 @@ static int cam_ife_hw_mgr_acquire_res_ife_bus_rd(
 	struct cam_ife_hw_mgr_ctx                  *ife_ctx,
 	struct cam_isp_in_port_generic_info        *in_port)
 {
-	int                                         rc = -EINVAL, j;
-	int                                         i = CAM_ISP_HW_SPLIT_LEFT;
-	struct cam_vfe_acquire_args                 vfe_acquire;
-	struct cam_isp_hw_mgr_res                  *ife_bus_rd_res;
-	struct cam_hw_intf                         *hw_intf;
-	struct cam_ife_hw_mgr                      *ife_hw_mgr;
+	int                          i, rc = -EINVAL;
+	struct cam_vfe_acquire_args  vfe_acquire;
+	struct cam_isp_hw_mgr_res   *ife_bus_rd_res;
+	struct cam_hw_intf          *hw_intf;
+	struct cam_ife_hw_mgr       *ife_hw_mgr;
 
 	ife_hw_mgr = ife_ctx->hw_mgr;
 
+	if (!ife_hw_mgr->ife_devices[ife_ctx->left_hw_idx]) {
+		CAM_ERR(CAM_ISP, "ife_devices[%d] is NULL", ife_ctx->left_hw_idx);
+		return -ENODEV;
+	}
+
 	rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list, &ife_bus_rd_res);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "No more free hw mgr resource, ctx_idx: %u", ife_ctx->ctx_index);
-		goto end;
+		return -ENODEV;
 	}
 
 	vfe_acquire.rsrc_type = CAM_ISP_RESOURCE_VFE_BUS_RD;
@@ -3125,64 +3093,87 @@ static int cam_ife_hw_mgr_acquire_res_ife_bus_rd(
 	vfe_acquire.vfe_bus_rd.res_id = CAM_ISP_HW_VFE_IN_RD;
 	vfe_acquire.vfe_bus_rd.unpacker_fmt = in_port->fe_unpacker_fmt;
 
-	for (j = 0; j < CAM_IFE_HW_NUM_MAX; j++) {
-		if (!ife_hw_mgr->ife_devices[j])
-			continue;
-
-		hw_intf = ife_hw_mgr->ife_devices[j]->hw_intf;
-		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-			&vfe_acquire, sizeof(struct cam_vfe_acquire_args));
+	if (ife_ctx->left_hw_idx >= CAM_IFE_HW_NUM_MAX) {
+		if (in_port->ife_rd_count) {
+			for (i = CAM_IFE_HW_NUM_MAX - 1; i >= 0; i--) {
+				if (!ife_hw_mgr->ife_devices[i])
+					continue;
 
-		if (!rc) {
-			ife_bus_rd_res->hw_res[i] =
-				vfe_acquire.vfe_bus_rd.rsrc_node;
+				hw_intf = ife_hw_mgr->ife_devices[i]->hw_intf;
+				if (ife_hw_mgr->ife_dev_caps[hw_intf->hw_idx].is_lite)
+					continue;
 
-			CAM_DBG(CAM_ISP, "Acquired VFE:%d BUS RD for LEFT, ctx_idx: %u",
-				j, ife_ctx->ctx_index);
-			break;
+				vfe_acquire.vfe_bus_rd.rsrc_node = NULL;
+				rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+					&vfe_acquire, sizeof(struct cam_vfe_acquire_args));
+				if (!rc && vfe_acquire.vfe_bus_rd.rsrc_node)
+					goto acquire_successful;
+				else
+					CAM_ERR(CAM_ISP,
+						"IFE[%d] acquire failed (rc=%d), ctx_idx: %u",
+						i, rc, ife_ctx->ctx_index);
+			}
+			CAM_ERR(CAM_ISP, "Can't find free IFE for ctx_idx: %u",
+				ife_ctx->ctx_index);
+			goto put_res;
+		} else {
+			rc = -ENODEV;
+			CAM_ERR(CAM_ISP,
+				"The acquired hw idx %d is invalid and it isn't FE usecase",
+				ife_ctx->left_hw_idx);
+			goto put_res;
 		}
 	}
 
-	if (j == CAM_IFE_HW_NUM_MAX || !vfe_acquire.vfe_bus_rd.rsrc_node) {
+	if (!ife_hw_mgr->ife_devices[ife_ctx->left_hw_idx]) {
+		CAM_ERR(CAM_ISP, "IFE device %d is NULL.",
+			ife_ctx->left_hw_idx);
+		goto put_res;
+	}
+
+	hw_intf = ife_hw_mgr->ife_devices[ife_ctx->left_hw_idx]->hw_intf;
+	rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+		&vfe_acquire, sizeof(struct cam_vfe_acquire_args));
+
+	if (rc || !vfe_acquire.vfe_bus_rd.rsrc_node) {
+		rc = -ENODEV;
 		CAM_ERR(CAM_ISP, "Failed to acquire VFE:%d BUS RD for LEFT, ctx_idx: %u",
-			j, ife_ctx->ctx_index);
+			ife_ctx->left_hw_idx, ife_ctx->ctx_index);
 		goto put_res;
 	}
 
+acquire_successful:
+	ife_bus_rd_res->hw_res[CAM_ISP_HW_SPLIT_LEFT] =
+		vfe_acquire.vfe_bus_rd.rsrc_node;
+
+	CAM_DBG(CAM_ISP, "Acquired VFE:%d BUS RD for LEFT, ctx_idx: %u",
+		ife_ctx->left_hw_idx, ife_ctx->ctx_index);
+
+	ife_ctx->left_hw_idx = hw_intf->hw_idx;
 	ife_bus_rd_res->res_type = vfe_acquire.rsrc_type;
 	ife_bus_rd_res->res_id = vfe_acquire.vfe_in.res_id;
 	ife_bus_rd_res->is_dual_isp = (uint32_t)ife_ctx->flags.is_dual;
 	cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_in_rd, &ife_bus_rd_res);
 
 	if (ife_ctx->flags.is_dual) {
-		for (j = 0; j < CAM_IFE_HW_NUM_MAX; j++) {
-			if (!ife_hw_mgr->ife_devices[j])
-				continue;
-
-			if (j == ife_bus_rd_res->hw_res[i]->hw_intf->hw_idx)
-				continue;
-
-			hw_intf = ife_hw_mgr->ife_devices[j]->hw_intf;
-			rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-				&vfe_acquire,
-				sizeof(struct cam_vfe_acquire_args));
+		if (!ife_hw_mgr->ife_devices[ife_ctx->right_hw_idx]) {
+			CAM_ERR(CAM_ISP, "ife_devices[%d] is NULL", ife_ctx->right_hw_idx);
+			goto put_res;
+		}
 
-			if (!rc) {
-				ife_bus_rd_res->hw_res[++i] =
-					vfe_acquire.vfe_bus_rd.rsrc_node;
+		hw_intf = ife_hw_mgr->ife_devices[ife_ctx->right_hw_idx]->hw_intf;
+		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+			&vfe_acquire,
+			sizeof(struct cam_vfe_acquire_args));
 
-				CAM_DBG(CAM_ISP,
-					"Acquired VFE:%d BUS RD for RIGHT, ctx: %u",
-					j, ife_ctx->ctx_index);
-				break;
-			}
-		}
+		if (!rc && vfe_acquire.vfe_bus_rd.rsrc_node) {
+			ife_bus_rd_res->hw_res[CAM_ISP_HW_SPLIT_RIGHT] =
+				vfe_acquire.vfe_bus_rd.rsrc_node;
+			ife_ctx->right_hw_idx = hw_intf->hw_idx;
 
-		if (j == CAM_IFE_HW_NUM_MAX ||
-			!vfe_acquire.vfe_bus_rd.rsrc_node) {
-			CAM_ERR(CAM_ISP, "Failed to acquire VFE:%d BUS RD for RIGHT, ctx: %u",
-				j, ife_ctx->ctx_index);
-			goto end;
+			CAM_DBG(CAM_ISP,
+				"Acquired VFE:%d BUS RD for RIGHT, ctx: %u",
+				ife_ctx->right_hw_idx, ife_ctx->ctx_index);
 		}
 	}
 
@@ -3190,7 +3181,6 @@ static int cam_ife_hw_mgr_acquire_res_ife_bus_rd(
 
 put_res:
 	cam_ife_hw_mgr_put_res(&ife_ctx->free_res_list, &ife_bus_rd_res);
-end:
 	return rc;
 }
 
@@ -3199,18 +3189,17 @@ static int cam_ife_hw_mgr_acquire_sfe_bus_rd(
 	struct cam_isp_in_port_generic_info *in_port)
 {
 	int rc = -1, i;
-	uint32_t acquired_cnt = CAM_ISP_HW_SPLIT_LEFT;
 	struct cam_sfe_acquire_args           sfe_acquire;
 	struct cam_ife_hw_mgr                *ife_hw_mgr;
 	struct cam_hw_intf                   *hw_intf;
-	struct cam_isp_hw_mgr_res            *sfe_rd_res, *sfe_res_iterator;
+	struct cam_isp_hw_mgr_res            *sfe_rd_res;
 
 	ife_hw_mgr = ife_ctx->hw_mgr;
 
 	rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list, &sfe_rd_res);
 	if (rc) {
 		CAM_ERR(CAM_ISP, "No more free hw mgr resource, ctx_idx: %u", ife_ctx->ctx_index);
-		goto err;
+		return rc;
 	}
 
 	if (!cam_ife_hw_mgr_is_sfe_rd_res(in_port->sfe_in_path_type)) {
@@ -3234,73 +3223,51 @@ static int cam_ife_hw_mgr_acquire_sfe_bus_rd(
 	sfe_acquire.sfe_rd.res_id = in_port->sfe_in_path_type;
 	sfe_acquire.sfe_rd.secure_mode = in_port->secure_mode;
 
-	list_for_each_entry(sfe_res_iterator, &ife_ctx->res_list_ife_in_rd,
-		list) {
-		for (i = 0; i < CAM_ISP_HW_SPLIT_MAX; i++) {
-			if (!sfe_res_iterator->hw_res[i])
-				continue;
-
-			/* Check for secure */
-			if (sfe_res_iterator->is_secure != in_port->secure_mode)
-				continue;
+	if (ife_ctx->left_hw_idx >= CAM_SFE_HW_NUM_MAX) {
+		if (in_port->ife_rd_count) {
+			for (i = 0; i < CAM_SFE_HW_NUM_MAX; i++) {
+				if (!ife_hw_mgr->sfe_devices[i])
+					continue;
 
-			hw_intf = sfe_res_iterator->hw_res[i]->hw_intf;
-			rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-				&sfe_acquire, sizeof(sfe_acquire));
-			if (rc) {
-				CAM_DBG(CAM_ISP,
-					"No SFE RD rsrc: 0x%x from hw: %u ctx_idx: %u",
-					in_port->sfe_in_path_type,
-					hw_intf->hw_idx, ife_ctx->ctx_index);
-				continue;
+				hw_intf = ife_hw_mgr->sfe_devices[i]->hw_intf;
+				rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+					&sfe_acquire, sizeof(struct cam_sfe_acquire_args));
+				if (rc)
+					continue;
+				else
+					break;
 			}
-
-		sfe_rd_res->hw_res[acquired_cnt++] =
-				sfe_acquire.sfe_rd.rsrc_node;
-
-			CAM_DBG(CAM_ISP,
-				"ctx_idx: %u acquired from old SFE(%s): %u path: 0x%x successfully",
-				ife_ctx->ctx_index, (i == 0) ? "left" : "right",
-				hw_intf->hw_idx, in_port->sfe_in_path_type);
-
-			/* With SFE the below condition should never be met */
-			if ((in_port->usage_type) && (acquired_cnt == 1))
-				continue;
-
-			if (acquired_cnt)
-				goto acquire_successful;
+		} else {
+			rc = -ENODEV;
+			CAM_ERR(CAM_ISP,
+				"The acquired hw idx %d is invalid and it isn't FE usecase",
+				ife_ctx->left_hw_idx);
+			goto put_res;
+		}
+	} else {
+		if (!ife_hw_mgr->sfe_devices[ife_ctx->left_hw_idx]) {
+			rc = -ENODEV;
+			CAM_ERR(CAM_ISP, "No valid sfe devices for idx:%d",
+				ife_ctx->left_hw_idx);
+			goto put_res;
 		}
-	}
-
-	/*
-	 * SFEx can be connected to any CSID/IFE in
-	 * single/dual use cases hence always iterating
-	 * from 0 to HW max. IFE also will reserve from lower idx
-	 * as well since SFE works with FULL IFEs only
-	 */
-	for (i = 0; i < CAM_SFE_HW_NUM_MAX; i++) {
-		if (!ife_hw_mgr->sfe_devices[i])
-			continue;
 
-		hw_intf = ife_hw_mgr->sfe_devices[i]->hw_intf;
+		hw_intf = ife_hw_mgr->sfe_devices[ife_ctx->left_hw_idx]->hw_intf;
 		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
 			&sfe_acquire, sizeof(struct cam_sfe_acquire_args));
-		if (rc)
-			continue;
-		else
-			break;
 	}
 
 	if (!sfe_acquire.sfe_rd.rsrc_node || rc) {
+		rc = -ENODEV;
 		CAM_ERR(CAM_ISP,
 			"Failed to acquire SFE RD: 0x%x, ctx_idx: %u",
 			in_port->sfe_in_path_type, ife_ctx->ctx_index);
 		goto put_res;
 	}
 
-	sfe_rd_res->hw_res[acquired_cnt++] = sfe_acquire.sfe_rd.rsrc_node;
+	sfe_rd_res->hw_res[CAM_ISP_HW_SPLIT_LEFT] = sfe_acquire.sfe_rd.rsrc_node;
+	ife_ctx->left_hw_idx = hw_intf->hw_idx;
 
-acquire_successful:
 	CAM_DBG(CAM_ISP,
 		"SFE RD left [%u] acquired success for path: %u is_dual: %d res: %s res_id: 0x%x ctx_idx: %u",
 		sfe_rd_res->hw_res[0]->hw_intf->hw_idx, in_port->sfe_in_path_type,
@@ -3313,43 +3280,9 @@ acquire_successful:
 	sfe_rd_res->is_secure = in_port->secure_mode;
 	cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_in_rd, &sfe_rd_res);
 
-	/* DUAL SFE for Fetch engine - unused for now */
-	if (in_port->usage_type && acquired_cnt == 1) {
-		sfe_acquire.sfe_rd.rsrc_node = NULL;
-		for (i = 0; i < CAM_SFE_HW_NUM_MAX; i++) {
-			if (!ife_hw_mgr->sfe_devices[i])
-				continue;
-
-			if (i == sfe_rd_res->hw_res[0]->hw_intf->hw_idx)
-				continue;
-
-			hw_intf = ife_hw_mgr->sfe_devices[i]->hw_intf;
-			rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-				&sfe_acquire, sizeof(sfe_acquire));
-			if (rc)
-				continue;
-			else
-				break;
-		}
-
-		if (!sfe_acquire.sfe_rd.rsrc_node || rc) {
-			CAM_ERR(CAM_ISP,
-				"Can not acquire SFE RD right resource, ctx_idx: %u",
-				ife_ctx->ctx_index);
-			goto err;
-		}
-
-		sfe_rd_res->hw_res[1] = sfe_acquire.sfe_rd.rsrc_node;
-		CAM_DBG(CAM_ISP,
-			"SFE right [%u] acquire success for res: 0x%x ctx_idx: %u",
-			sfe_rd_res->hw_res[1]->hw_intf->hw_idx, in_port->sfe_in_path_type,
-			ife_ctx->ctx_index);
-	}
-
 	return 0;
 put_res:
 	cam_ife_hw_mgr_put_res(&ife_ctx->free_res_list, &sfe_rd_res);
-err:
 	return rc;
 }
 
@@ -3359,12 +3292,19 @@ static int cam_ife_hw_mgr_acquire_ife_src_for_sfe(
 	bool acquire_lcr, uint32_t *acquired_hw_id,
 	uint32_t *acquired_hw_path)
 {
-	int rc = -1, i;
+	int rc = -1;
 	struct cam_vfe_acquire_args                 vfe_acquire;
 	struct cam_isp_hw_mgr_res                  *ife_src_res;
 	struct cam_hw_intf                         *hw_intf = NULL;
 	struct cam_ife_hw_mgr                      *ife_hw_mgr;
 
+	if ((ife_ctx->left_hw_idx >= CAM_SFE_HW_NUM_MAX) ||
+		(ife_ctx->flags.is_dual && (ife_ctx->right_hw_idx >= CAM_SFE_HW_NUM_MAX))) {
+		CAM_ERR(CAM_ISP, "the hw index:[%d - %d] is wrong",
+			ife_ctx->left_hw_idx, ife_ctx->right_hw_idx);
+		goto end;
+	}
+
 	ife_hw_mgr = ife_ctx->hw_mgr;
 	rc = cam_ife_hw_mgr_get_res(&ife_ctx->free_res_list,
 		&ife_src_res);
@@ -3406,40 +3346,29 @@ static int cam_ife_hw_mgr_acquire_ife_src_for_sfe(
 	vfe_acquire.vfe_in.is_dual =
 		(uint32_t)ife_ctx->flags.is_dual;
 
-
 	ife_src_res->res_type = vfe_acquire.rsrc_type;
 	ife_src_res->res_id = vfe_acquire.vfe_in.res_id;
 	ife_src_res->is_dual_isp = (uint32_t)ife_ctx->flags.is_dual;
-	for (i =  0; i < CAM_IFE_HW_NUM_MAX; i++) {
-		if (!ife_hw_mgr->ife_devices[i])
-			continue;
 
-		if (i != ife_ctx->left_hw_idx)
-			continue;
-
-		hw_intf = ife_hw_mgr->ife_devices[i]->hw_intf;
-		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-			&vfe_acquire,
-			sizeof(struct cam_vfe_acquire_args));
-		if (rc)
-			continue;
-		else
-			break;
-	}
+	hw_intf = ife_hw_mgr->ife_devices[ife_ctx->left_hw_idx]->hw_intf;
+	rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+		&vfe_acquire,
+		sizeof(struct cam_vfe_acquire_args));
 
-	if (i == CAM_IFE_HW_NUM_MAX || rc ||
-			!vfe_acquire.vfe_in.rsrc_node) {
+	if (rc || !vfe_acquire.vfe_in.rsrc_node) {
 		CAM_ERR(CAM_ISP, "Unable to acquire LEFT IFE res: %d ctx_idx: %u",
 			vfe_acquire.vfe_in.res_id, ife_ctx->ctx_index);
-		return -EAGAIN;
+		rc = -EINVAL;
+		goto put_res;
 	}
 
-	ife_src_res->hw_res[0] = vfe_acquire.vfe_in.rsrc_node;
+	ife_src_res->hw_res[CAM_ISP_HW_SPLIT_LEFT] = vfe_acquire.vfe_in.rsrc_node;
 	cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_src,
 		&ife_src_res);
 
 	*acquired_hw_id |= cam_convert_hw_idx_to_ife_hw_num(hw_intf->hw_idx);
-	acquired_hw_path[0] |= cam_convert_res_id_to_hw_path(ife_src_res->hw_res[0]->res_id, -1);
+	acquired_hw_path[0] |= cam_convert_res_id_to_hw_path(
+		ife_src_res->hw_res[CAM_ISP_HW_SPLIT_LEFT]->res_id, -1);
 
 	CAM_DBG(CAM_ISP,
 		"acquire success LEFT IFE: %d res type: 0x%x res: %s res id: 0x%x ctx_idx: %u",
@@ -3454,39 +3383,24 @@ static int cam_ife_hw_mgr_acquire_ife_src_for_sfe(
 			CAM_ISP_HW_SYNC_SLAVE;
 		vfe_acquire.vfe_in.dual_hw_idx =
 			ife_ctx->left_hw_idx;
-		for (i = 0; i < CAM_IFE_HW_NUM_MAX; i++) {
-			if (!ife_hw_mgr->ife_devices[i])
-				continue;
-
-			if (i == ife_src_res->hw_res[0]->hw_intf->hw_idx)
-				continue;
 
-			if (i != ife_ctx->right_hw_idx)
-				continue;
-
-			hw_intf = ife_hw_mgr->ife_devices[i]->hw_intf;
-			rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
-				&vfe_acquire,
-				sizeof(struct cam_vfe_acquire_args));
-			if (rc)
-				continue;
-			else
-				break;
-		}
+		hw_intf = ife_hw_mgr->ife_devices[ife_ctx->right_hw_idx]->hw_intf;
+		rc = hw_intf->hw_ops.reserve(hw_intf->hw_priv,
+			&vfe_acquire,
+			sizeof(struct cam_vfe_acquire_args));
 
-		if (i == CAM_IFE_HW_NUM_MAX || rc ||
-				!vfe_acquire.vfe_in.rsrc_node) {
+		if (rc || !vfe_acquire.vfe_in.rsrc_node) {
 			CAM_ERR(CAM_ISP, "Unable to acquire right IFE res: %u, ctx_idx: %u",
 				vfe_acquire.vfe_in.res_id, ife_ctx->ctx_index);
-			rc = -EAGAIN;
-			goto end;
+			rc = -EINVAL;
+			goto put_res;
 		}
 
-		ife_src_res->hw_res[1] = vfe_acquire.vfe_in.rsrc_node;
+		ife_src_res->hw_res[CAM_ISP_HW_SPLIT_RIGHT] = vfe_acquire.vfe_in.rsrc_node;
 		*acquired_hw_id |=
 			cam_convert_hw_idx_to_ife_hw_num(hw_intf->hw_idx);
 		acquired_hw_path[1] |= cam_convert_res_id_to_hw_path(
-			ife_src_res->hw_res[0]->res_id, -1);
+			ife_src_res->hw_res[CAM_ISP_HW_SPLIT_RIGHT]->res_id, -1);
 		CAM_DBG(CAM_ISP,
 			"acquire success RIGHT IFE: %u res type: 0x%x res: %s res id: 0x%x ctx_idx: %u",
 			hw_intf->hw_idx,
@@ -3497,6 +3411,8 @@ static int cam_ife_hw_mgr_acquire_ife_src_for_sfe(
 
 	return 0;
 
+put_res:
+	cam_ife_hw_mgr_put_res(&ife_ctx->free_res_list, &ife_src_res);
 end:
 	/* release resource at the entry function */
 	return rc;
@@ -3699,11 +3615,11 @@ static int cam_ife_hw_mgr_acquire_csid_hw(
 		return -EINVAL;
 	}
 
-	if (ife_ctx->flags.is_fe_enabled || ife_ctx->flags.dsp_enabled)
-		is_start_lower_idx =  true;
-
 	ife_hw_mgr = ife_ctx->hw_mgr;
 
+	if (ife_ctx->ctx_type == CAM_IFE_CTX_TYPE_SFE)
+		is_start_lower_idx =  true;
+
 	if (in_port->num_out_res)
 		out_port = &(in_port->data[0]);
 
@@ -4815,6 +4731,8 @@ static int cam_ife_hw_mgr_acquire_offline_res_csid(
 		goto put_res;
 	}
 
+	csid_res->hw_res[CAM_ISP_HW_SPLIT_LEFT] = csid_acquire.node_res;
+
 	if (!ife_ctx->buf_done_controller && csid_acquire.buf_done_controller)
 		ife_ctx->buf_done_controller = csid_acquire.buf_done_controller;
 
@@ -4824,6 +4742,7 @@ static int cam_ife_hw_mgr_acquire_offline_res_csid(
 	csid_res->is_dual_isp = 0;
 	csid_res->hw_res[0] = csid_acquire.node_res;
 	csid_res->hw_res[1] = NULL;
+	ife_ctx->left_hw_idx = csid_acquire.node_res->hw_intf->hw_idx;
 	cam_ife_hw_mgr_put_res(&ife_ctx->res_list_ife_csid, &csid_res);
 
 	return 0;
@@ -5032,21 +4951,6 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
 		return -EINVAL;
 	}
 
-	if (in_port->ife_rd_count) {
-		if (ife_ctx->ctx_type == CAM_IFE_CTX_TYPE_SFE)
-			rc = cam_ife_hw_mgr_acquire_sfe_bus_rd(
-				ife_ctx, in_port);
-		else
-			rc = cam_ife_hw_mgr_acquire_res_ife_bus_rd(
-				ife_ctx, in_port);
-		if (rc) {
-			CAM_ERR(CAM_ISP, "Acquire %s BUS RD resource Failed, ctx_idx: %u",
-				(ife_ctx->ctx_type ==
-				CAM_IFE_CTX_TYPE_SFE) ? "SFE" : "IFE", ife_ctx->ctx_index);
-			goto err;
-		}
-	}
-
 	/* get ife csid IPP resource */
 	if (cam_ife_hw_mgr_is_need_csid_ipp(ife_ctx, in_port)) {
 		rc = cam_ife_hw_mgr_acquire_res_ife_csid_pxl(ife_ctx,
@@ -5092,6 +4996,25 @@ static int cam_ife_mgr_acquire_hw_for_ctx(
 		}
 	}
 
+	CAM_DBG(CAM_ISP, "Acquired CSID resource, is_dual:%s left_hw_idx:%d right_hw_idx:%d",
+		CAM_BOOL_TO_YESNO(ife_ctx->flags.is_dual),
+		ife_ctx->left_hw_idx, ife_ctx->right_hw_idx);
+
+	if (in_port->ife_rd_count) {
+		if (ife_ctx->ctx_type == CAM_IFE_CTX_TYPE_SFE)
+			rc = cam_ife_hw_mgr_acquire_sfe_bus_rd(
+				ife_ctx, in_port);
+		else
+			rc = cam_ife_hw_mgr_acquire_res_ife_bus_rd(
+				ife_ctx, in_port);
+		if (rc) {
+			CAM_ERR(CAM_ISP, "Acquire %s BUS RD resource Failed, ctx_idx: %u",
+				(ife_ctx->ctx_type ==
+				CAM_IFE_CTX_TYPE_SFE) ? "SFE" : "IFE", ife_ctx->ctx_index);
+			goto err;
+		}
+	}
+
 	/* try acquire RDI for SFE cases without RDI out ports,
 	 * this is specifically for targets having RDI as input
 	 * to SFE IPP
@@ -5671,6 +5594,8 @@ static int cam_ife_mgr_acquire_hw(void *hw_mgr_priv, void *acquire_hw_args)
 	ife_ctx->drv_path_idle_en = 0;
 	ife_ctx->res_list_ife_out = NULL;
 	ife_ctx->res_list_sfe_out = NULL;
+	ife_ctx->left_hw_idx = CAM_IFE_CSID_HW_NUM_MAX;
+	ife_ctx->right_hw_idx = CAM_IFE_CSID_HW_NUM_MAX;
 
 	acquire_hw_info = (struct cam_isp_acquire_hw_info *) acquire_args->acquire_info;