Kaynağa Gözat

msm: camera: isp: Optimize number of buf done callbacks

ISP context supports handling one composite group per IRQ callback. Use
this capability to reduce number of callbacks per IRQ.

CRs-Fixed: 2977031
Change-Id: I514e3e8f8f4b5998b98f2c2c6131e322231dacad
Signed-off-by: Anand Ravi <[email protected]>
Anand Ravi 4 yıl önce
ebeveyn
işleme
0364ef7135

+ 24 - 21
drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

@@ -11562,28 +11562,36 @@ static int cam_ife_hw_mgr_handle_hw_buf_done(
 	void                                *ctx,
 	void                                *evt_info)
 {
-	cam_hw_event_cb_func                 ife_hwr_irq_wm_done_cb;
-	struct cam_ife_hw_mgr_ctx           *ife_hw_mgr_ctx = ctx;
-	struct cam_isp_hw_done_event_data    buf_done_event_data = {0};
-	struct cam_isp_hw_event_info        *event_info = evt_info;
-	int32_t                              rc = 0;
+	cam_hw_event_cb_func                   ife_hwr_irq_wm_done_cb;
+	struct cam_ife_hw_mgr_ctx             *ife_hw_mgr_ctx = ctx;
+	struct cam_isp_hw_done_event_data      buf_done_event_data = {0};
+	struct cam_isp_hw_compdone_event_info *event_info = evt_info;
+	int32_t                                rc = 0, i;
 
 	ife_hwr_irq_wm_done_cb = ife_hw_mgr_ctx->common.event_cb;
 
-	buf_done_event_data.num_handles = 1;
-	buf_done_event_data.resource_handle[0] = event_info->res_id;
-	buf_done_event_data.last_consumed_addr[0] =
-		event_info->reg_val;
+	buf_done_event_data.num_handles = event_info->num_res;
 
-	if (cam_ife_hw_mgr_is_sfe_rdi_for_fetch(event_info->res_id)) {
-		rc = cam_ife_hw_mgr_check_rdi_scratch_buf_done(
-			ife_hw_mgr_ctx->ctx_index,
-			ife_hw_mgr_ctx->sfe_info.scratch_config,
-			event_info->res_id, event_info->reg_val);
-		if (rc)
-			goto end;
+	for (i = 0; i < event_info->num_res; i++) {
+		buf_done_event_data.resource_handle[i] = event_info->res_id[i];
+		buf_done_event_data.last_consumed_addr[i] = event_info->last_consumed_addr[i];
+
+		CAM_DBG(CAM_ISP, "Buf done for %s: %d res_id: 0x%x last consumed addr: 0x%x",
+		((event_info->hw_type == CAM_ISP_HW_TYPE_SFE) ? "SFE" : "IFE"),
+		event_info->hw_idx, event_info->res_id[i], event_info->last_consumed_addr[i]);
+
+		if (cam_ife_hw_mgr_is_sfe_rdi_for_fetch(event_info->res_id[i])) {
+			rc = cam_ife_hw_mgr_check_rdi_scratch_buf_done(
+				ife_hw_mgr_ctx->ctx_index,
+				ife_hw_mgr_ctx->sfe_info.scratch_config,
+				event_info->res_id[i],
+				event_info->last_consumed_addr[i]);
+			if (rc)
+				goto end;
+		}
 	}
 
+
 	if (atomic_read(&ife_hw_mgr_ctx->overflow_pending))
 		return 0;
 
@@ -11594,11 +11602,6 @@ static int cam_ife_hw_mgr_handle_hw_buf_done(
 	}
 
 end:
-	CAM_DBG(CAM_ISP,
-		"Buf done for %s: %d res_id: 0x%x last consumed addr: 0x%x",
-		((event_info->hw_type == CAM_ISP_HW_TYPE_SFE) ? "SFE" : "IFE"),
-		event_info->hw_idx, event_info->res_id, event_info->reg_val);
-
 	return 0;
 }
 

+ 23 - 0
drivers/cam_isp/isp_hw_mgr/isp_hw/include/cam_isp_hw.h

@@ -13,6 +13,7 @@
 #include "cam_irq_controller.h"
 #include "cam_hw_intf.h"
 #include "cam_cdm_intf_api.h"
+#include "cam_hw_mgr_intf.h"
 
 /* Maximum length of tag while dumping */
 #define CAM_ISP_HW_DUMP_TAG_MAX_LEN 32
@@ -256,6 +257,28 @@ struct cam_isp_hw_event_info {
 	uint32_t                       in_core_type;
 };
 
+/**
+ * struct cam_isp_hw_compdone_event_info:
+ *
+ * @brief:              Structure to pass bufdone event details to hw mgr
+ *
+ * @res_type:           Type of IFE/SFE resource
+ * @hw_idx:             IFE/SFE hw index
+ * @num_res:            Number of valid resource IDs in this event
+ * @hw_type:            Hw Type sending the event (IFE or SFE)
+ * @res_id:             Resource IDs to report buf dones
+ * @last_consumed_addr: Last consumed addr for resource ID at that index
+ *
+ */
+struct cam_isp_hw_compdone_event_info {
+	enum cam_isp_resource_type     res_type;
+	uint32_t                       hw_idx;
+	uint32_t                       hw_type;
+	uint32_t num_res;
+	uint32_t res_id[CAM_NUM_OUT_PER_COMP_IRQ_MAX];
+	uint32_t last_consumed_addr[CAM_NUM_OUT_PER_COMP_IRQ_MAX];
+};
+
 /*
  * struct cam_isp_hw_cmd_buf_update:
  *

+ 9 - 8
drivers/cam_isp/isp_hw_mgr/isp_hw/sfe_hw/sfe_bus/cam_sfe_bus_wr.c

@@ -1688,7 +1688,7 @@ static int cam_sfe_bus_handle_sfe_out_done_bottom_half(
 	struct cam_isp_resource_node           *sfe_out = handler_priv;
 	struct cam_sfe_bus_wr_out_data         *rsrc_data = sfe_out->res_priv;
 	struct cam_sfe_bus_wr_irq_evt_payload  *evt_payload = evt_payload_priv;
-	struct cam_isp_hw_event_info            evt_info;
+	struct cam_isp_hw_compdone_event_info    evt_info = {0};
 	void                                   *ctx = NULL;
 	uint32_t                       out_list[CAM_SFE_BUS_SFE_OUT_MAX];
 
@@ -1711,16 +1711,17 @@ static int cam_sfe_bus_handle_sfe_out_done_bottom_half(
 
 		rc = cam_sfe_bus_get_comp_sfe_out_res_id_list(
 			comp_mask, out_list, &num_out);
+		evt_info.num_res = num_out;
 		for (i = 0; i < num_out; i++) {
-			evt_info.res_id = out_list[i];
-			 cam_sfe_bus_get_last_consumed_addr(
+			evt_info.res_id[i] = out_list[i];
+			cam_sfe_bus_get_last_consumed_addr(
 				rsrc_data->bus_priv,
-				evt_info.res_id, &val);
-			evt_info.reg_val = val;
-			if (rsrc_data->common_data->event_cb)
-				rsrc_data->common_data->event_cb(ctx, evt_id,
-					(void *)&evt_info);
+				evt_info.res_id[i], &val);
+			evt_info.last_consumed_addr[i] = val;
 		}
+		if (rsrc_data->common_data->event_cb)
+			rsrc_data->common_data->event_cb(ctx, evt_id,
+				(void *)&evt_info);
 		break;
 	default:
 		break;

+ 8 - 9
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver2.c

@@ -2419,7 +2419,7 @@ static int cam_vfe_bus_handle_vfe_out_done_bottom_half(
 	int rc = -EINVAL;
 	struct cam_isp_resource_node             *vfe_out = handler_priv;
 	struct cam_vfe_bus_ver2_vfe_out_data     *rsrc_data = vfe_out->res_priv;
-	struct cam_isp_hw_event_info              evt_info;
+	struct cam_isp_hw_compdone_event_info      evt_info = {0};
 	void                                     *ctx = NULL;
 	uint32_t                                  evt_id = 0;
 	uint32_t                                  comp_mask = 0;
@@ -2452,18 +2452,17 @@ static int cam_vfe_bus_handle_vfe_out_done_bottom_half(
 		if (rsrc_data->comp_grp) {
 			cam_vfe_bus_get_comp_vfe_out_res_id_list(
 				comp_mask, out_list, &num_out);
+			evt_info.num_res = num_out;
 			for (i = 0; i < num_out; i++) {
-				evt_info.res_id = out_list[i];
-				if (rsrc_data->common_data->event_cb)
-					rsrc_data->common_data->event_cb(ctx,
-						evt_id, (void *)&evt_info);
+				evt_info.res_id[i] = out_list[i];
 			}
 		} else {
-			evt_info.res_id = vfe_out->res_id;
-			if (rsrc_data->common_data->event_cb)
-				rsrc_data->common_data->event_cb(ctx, evt_id,
-					(void *)&evt_info);
+			evt_info.num_res = 1;
+			evt_info.res_id[0] = vfe_out->res_id;
 		}
+		if (rsrc_data->common_data->event_cb)
+			rsrc_data->common_data->event_cb(ctx,
+				evt_id, (void *)&evt_info);
 		break;
 	default:
 		break;

+ 16 - 15
drivers/cam_isp/isp_hw_mgr/isp_hw/vfe_hw/vfe_bus/cam_vfe_bus_ver3.c

@@ -2357,15 +2357,15 @@ static int cam_vfe_bus_ver3_handle_vfe_out_done_bottom_half(
 	void                *handler_priv,
 	void                *evt_payload_priv)
 {
-	int                                   rc = -EINVAL, num_out = 0, i = 0;
-	struct cam_isp_resource_node         *vfe_out = handler_priv;
-	struct cam_vfe_bus_ver3_vfe_out_data *rsrc_data = vfe_out->res_priv;
-	struct cam_vfe_bus_irq_evt_payload   *evt_payload = evt_payload_priv;
-	struct cam_isp_hw_event_info          evt_info;
-	void                                 *ctx = NULL;
-	uint32_t                              evt_id = 0;
-	uint64_t                              comp_mask = 0;
-	uint32_t                         out_list[CAM_VFE_BUS_VER3_VFE_OUT_MAX];
+	int                                    rc = -EINVAL, num_out = 0, i = 0;
+	struct cam_isp_resource_node          *vfe_out = handler_priv;
+	struct cam_vfe_bus_ver3_vfe_out_data  *rsrc_data = vfe_out->res_priv;
+	struct cam_vfe_bus_irq_evt_payload    *evt_payload = evt_payload_priv;
+	struct cam_isp_hw_compdone_event_info  evt_info = {0};
+	void                                  *ctx = NULL;
+	uint32_t                               evt_id = 0;
+	uint64_t                               comp_mask = 0;
+	uint32_t                               out_list[CAM_VFE_BUS_VER3_VFE_OUT_MAX];
 
 	rc = cam_vfe_bus_ver3_handle_comp_done_bottom_half(
 		rsrc_data->comp_grp, evt_payload_priv, &comp_mask);
@@ -2386,16 +2386,17 @@ static int cam_vfe_bus_ver3_handle_vfe_out_done_bottom_half(
 
 		rc = cam_vfe_bus_ver3_get_comp_vfe_out_res_id_list(
 			comp_mask, out_list, &num_out);
+		evt_info.num_res = num_out;
 		for (i = 0; i < num_out; i++) {
-			evt_info.res_id = out_list[i];
-			evt_info.reg_val =
+			evt_info.res_id[i] = out_list[i];
+			evt_info.last_consumed_addr[i] =
 				cam_vfe_bus_ver3_get_last_consumed_addr(
 				rsrc_data->bus_priv,
-				evt_info.res_id);
-			if (rsrc_data->common_data->event_cb)
-				rsrc_data->common_data->event_cb(ctx, evt_id,
-					(void *)&evt_info);
+				evt_info.res_id[i]);
 		}
+		if (rsrc_data->common_data->event_cb)
+			rsrc_data->common_data->event_cb(ctx, evt_id,
+				(void *)&evt_info);
 		break;
 	default:
 		break;