Skip to content

Commit 1c55b1b

Browse files
author
Ravikishore Pampana
committed
msm: camera: isp: Handle wait and active list during flush all
If umd issues flush all, isp driver need to make sure that wait and active list requests also flushed and corresponding buffer fences needed to returned. For active and wait list flush, ife hardware need to stop at frame boundary and release the fences. Ife hardware need to reset to make sure that vfe bus write master fifos are cleared. Start the ife hardware after reset and set the isp context state to sof. Change-Id: Ibc57e64fbcef07de13520f2b9e4cc37c7c62bb37 Signed-off-by: Ravikishore Pampana <[email protected]>
1 parent f22ad65 commit 1c55b1b

File tree

4 files changed

+119
-18
lines changed

4 files changed

+119
-18
lines changed

drivers/media/platform/msm/camera/cam_core/cam_hw_mgr_intf.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@ struct cam_hw_dump_pf_args {
262262
bool *mem_found;
263263
};
264264

265+
/**
266+
* struct cam_hw_reset_args -hw reset arguments
267+
*
268+
* @ctxt_to_hw_map: HW context from the acquire
269+
*
270+
*/
271+
struct cam_hw_reset_args {
272+
void *ctxt_to_hw_map;
273+
};
274+
265275
/* enum cam_hw_mgr_command - Hardware manager command type */
266276
enum cam_hw_mgr_command {
267277
CAM_HW_MGR_CMD_INTERNAL,
@@ -313,6 +323,7 @@ struct cam_hw_cmd_args {
313323
* @hw_open: Function pointer for HW init
314324
* @hw_close: Function pointer for HW deinit
315325
* @hw_flush: Function pointer for HW flush
326+
* @hw_reset: Function pointer for HW reset
316327
*
317328
*/
318329
struct cam_hw_mgr_intf {
@@ -333,6 +344,7 @@ struct cam_hw_mgr_intf {
333344
int (*hw_open)(void *hw_priv, void *fw_download_args);
334345
int (*hw_close)(void *hw_priv, void *hw_close_args);
335346
int (*hw_flush)(void *hw_priv, void *hw_flush_args);
347+
int (*hw_reset)(void *hw_priv, void *hw_reset_args);
336348
};
337349

338350
#endif /* _CAM_HW_MGR_INTF_H_ */

drivers/media/platform/msm/camera/cam_isp/cam_isp_context.c

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,16 +1922,19 @@ static int __cam_isp_ctx_flush_req_in_top_state(
19221922
struct cam_req_mgr_flush_request *flush_req)
19231923
{
19241924
int rc = 0;
1925-
struct cam_isp_context *ctx_isp;
1926-
1927-
ctx_isp = (struct cam_isp_context *) ctx->ctx_priv;
1925+
struct cam_isp_context *ctx_isp =
1926+
(struct cam_isp_context *) ctx->ctx_priv;
1927+
struct cam_isp_stop_args stop_isp;
1928+
struct cam_hw_stop_args stop_args;
1929+
struct cam_isp_start_args start_isp;
1930+
struct cam_hw_reset_args reset_args;
19281931
if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
1929-
CAM_INFO(CAM_ISP, "Last request id to flush is %lld",
1930-
flush_req->req_id);
1932+
CAM_INFO(CAM_ISP, "ctx id:%d Last request id to flush is %lld",
1933+
ctx->ctx_id, flush_req->req_id);
19311934
ctx->last_flush_req = flush_req->req_id;
19321935
}
19331936

1934-
CAM_DBG(CAM_ISP, "try to flush pending list");
1937+
CAM_DBG(CAM_ISP, "ctx id:%d try to flush pending list", ctx->ctx_id);
19351938
spin_lock_bh(&ctx->lock);
19361939
rc = __cam_isp_ctx_flush_req(ctx, &ctx->pending_req_list, flush_req);
19371940

@@ -1954,6 +1957,57 @@ static int __cam_isp_ctx_flush_req_in_top_state(
19541957
spin_unlock_bh(&ctx->lock);
19551958

19561959
atomic_set(&ctx_isp->process_bubble, 0);
1960+
if (flush_req->type == CAM_REQ_MGR_FLUSH_TYPE_ALL) {
1961+
/* if active and wait list are empty, return */
1962+
spin_lock_bh(&ctx->lock);
1963+
if ((list_empty(&ctx->wait_req_list)) &&
1964+
(list_empty(&ctx->active_req_list))) {
1965+
spin_unlock_bh(&ctx->lock);
1966+
CAM_DBG(CAM_ISP, "ctx id:%d active,wait list are empty",
1967+
ctx->ctx_id);
1968+
goto end;
1969+
}
1970+
spin_unlock_bh(&ctx->lock);
1971+
1972+
/* Stop hw first before active list flush */
1973+
CAM_DBG(CAM_ISP, "ctx id:%d try to stop hw", ctx->ctx_id);
1974+
stop_args.ctxt_to_hw_map = ctx_isp->hw_ctx;
1975+
stop_isp.hw_stop_cmd = CAM_ISP_HW_STOP_AT_FRAME_BOUNDARY;
1976+
stop_isp.stop_only = true;
1977+
stop_args.args = (void *)&stop_isp;
1978+
ctx->hw_mgr_intf->hw_stop(ctx->hw_mgr_intf->hw_mgr_priv,
1979+
&stop_args);
1980+
1981+
spin_lock_bh(&ctx->lock);
1982+
CAM_DBG(CAM_ISP, "try to flush wait list");
1983+
rc = __cam_isp_ctx_flush_req(ctx, &ctx->wait_req_list,
1984+
flush_req);
1985+
CAM_DBG(CAM_ISP, "try to flush active list");
1986+
rc = __cam_isp_ctx_flush_req(ctx, &ctx->active_req_list,
1987+
flush_req);
1988+
ctx_isp->active_req_cnt = 0;
1989+
spin_unlock_bh(&ctx->lock);
1990+
1991+
CAM_DBG(CAM_ISP, "try to reset hw");
1992+
/* Reset hw */
1993+
reset_args.ctxt_to_hw_map = ctx_isp->hw_ctx;
1994+
rc = ctx->hw_mgr_intf->hw_reset(ctx->hw_mgr_intf->hw_mgr_priv,
1995+
&reset_args);
1996+
if (rc)
1997+
goto end;
1998+
1999+
CAM_DBG(CAM_ISP, "ctx id%d try to start hw", ctx->ctx_id);
2000+
/* Start hw */
2001+
start_isp.hw_config.ctxt_to_hw_map = ctx_isp->hw_ctx;
2002+
start_isp.start_only = true;
2003+
start_isp.hw_config.priv = NULL;
2004+
2005+
rc = ctx->hw_mgr_intf->hw_start(ctx->hw_mgr_intf->hw_mgr_priv,
2006+
&start_isp);
2007+
}
2008+
2009+
end:
2010+
ctx_isp->substate_activated = CAM_ISP_CTX_ACTIVATED_SOF;
19572011
return rc;
19582012
}
19592013

drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2572,6 +2572,11 @@ static int cam_ife_mgr_pause_hw(struct cam_ife_hw_mgr_ctx *ctx)
25722572
return cam_ife_mgr_bw_control(ctx, CAM_VFE_BW_CONTROL_EXCLUDE);
25732573
}
25742574

2575+
static int cam_ife_mgr_resume_hw(struct cam_ife_hw_mgr_ctx *ctx)
2576+
{
2577+
return cam_ife_mgr_bw_control(ctx, CAM_VFE_BW_CONTROL_INCLUDE);
2578+
}
2579+
25752580
/* entry function: stop_hw */
25762581
static int cam_ife_mgr_stop_hw(void *hw_mgr_priv, void *stop_hw_args)
25772582
{
@@ -2925,6 +2930,9 @@ static int cam_ife_mgr_start_hw(void *hw_mgr_priv, void *start_hw_args)
29252930

29262931
CAM_DBG(CAM_ISP, "START IFE OUT ... in ctx id:%d",
29272932
ctx->ctx_index);
2933+
if (start_isp->start_only)
2934+
cam_ife_mgr_resume_hw(ctx);
2935+
29282936
/* start the IFE out devices */
29292937
for (i = 0; i < CAM_IFE_HW_OUT_RES_MAX; i++) {
29302938
rc = cam_ife_hw_mgr_start_hw_res(
@@ -3025,6 +3033,44 @@ static int cam_ife_mgr_write(void *hw_mgr_priv, void *write_args)
30253033
return -EPERM;
30263034
}
30273035

3036+
static int cam_ife_mgr_reset(void *hw_mgr_priv, void *hw_reset_args)
3037+
{
3038+
struct cam_ife_hw_mgr *hw_mgr = hw_mgr_priv;
3039+
struct cam_hw_reset_args *reset_args = hw_reset_args;
3040+
struct cam_ife_hw_mgr_ctx *ctx;
3041+
struct cam_ife_hw_mgr_res *hw_mgr_res;
3042+
uint32_t i;
3043+
int rc = 0;
3044+
3045+
if (!hw_mgr_priv || !hw_reset_args) {
3046+
CAM_ERR(CAM_ISP, "Invalid arguments");
3047+
return -EINVAL;
3048+
}
3049+
3050+
ctx = (struct cam_ife_hw_mgr_ctx *)reset_args->ctxt_to_hw_map;
3051+
if (!ctx || !ctx->ctx_in_use) {
3052+
CAM_ERR(CAM_ISP, "Invalid context is used");
3053+
return -EPERM;
3054+
}
3055+
3056+
CAM_DBG(CAM_ISP, "reset csid and vfe hw");
3057+
list_for_each_entry(hw_mgr_res, &ctx->res_list_ife_csid,
3058+
list) {
3059+
rc = cam_ife_hw_mgr_reset_csid_res(hw_mgr_res);
3060+
if (rc) {
3061+
CAM_ERR(CAM_ISP, "Failed RESET (%d) rc:%d",
3062+
hw_mgr_res->res_id, rc);
3063+
goto end;
3064+
}
3065+
}
3066+
3067+
for (i = 0; i < ctx->num_base; i++)
3068+
rc = cam_ife_mgr_reset_vfe_hw(hw_mgr, ctx->base[i].idx);
3069+
3070+
end:
3071+
return rc;
3072+
}
3073+
30283074
static int cam_ife_mgr_release_hw(void *hw_mgr_priv,
30293075
void *release_hw_args)
30303076
{
@@ -4025,10 +4071,6 @@ static int cam_ife_mgr_prepare_hw_update(void *hw_mgr_priv,
40254071
return rc;
40264072
}
40274073

4028-
static int cam_ife_mgr_resume_hw(struct cam_ife_hw_mgr_ctx *ctx)
4029-
{
4030-
return cam_ife_mgr_bw_control(ctx, CAM_VFE_BW_CONTROL_INCLUDE);
4031-
}
40324074

40334075
static int cam_ife_mgr_sof_irq_debug(
40344076
struct cam_ife_hw_mgr_ctx *ctx,
@@ -5852,6 +5894,7 @@ int cam_ife_hw_mgr_init(struct cam_hw_mgr_intf *hw_mgr_intf, int *iommu_hdl)
58525894
hw_mgr_intf->hw_prepare_update = cam_ife_mgr_prepare_hw_update;
58535895
hw_mgr_intf->hw_config = cam_ife_mgr_config_hw;
58545896
hw_mgr_intf->hw_cmd = cam_ife_mgr_cmd;
5897+
hw_mgr_intf->hw_reset = cam_ife_mgr_reset;
58555898

58565899
if (iommu_hdl)
58575900
*iommu_hdl = g_ife_hw_mgr.mgr_common.img_iommu_hdl;

drivers/media/platform/msm/camera/cam_isp/isp_hw_mgr/isp_hw/ife_csid_hw/cam_ife_csid_core.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,6 @@ static int cam_ife_csid_path_reset(struct cam_ife_csid_hw *csid_hw,
566566
init_completion(complete);
567567
reset_strb_val = csid_reg->cmn_reg->path_rst_stb_all;
568568

569-
/* Enable the Test gen before reset */
570-
cam_io_w_mb(1, csid_hw->hw_info->soc_info.reg_map[0].mem_base +
571-
csid_reg->tpg_reg->csid_tpg_ctrl_addr);
572-
573569
/* Reset the corresponding ife csid path */
574570
cam_io_w_mb(reset_strb_val, soc_info->reg_map[0].mem_base +
575571
reset_strb_addr);
@@ -584,10 +580,6 @@ static int cam_ife_csid_path_reset(struct cam_ife_csid_hw *csid_hw,
584580
rc = -ETIMEDOUT;
585581
}
586582

587-
/* Disable Test Gen after reset*/
588-
cam_io_w_mb(0, soc_info->reg_map[0].mem_base +
589-
csid_reg->tpg_reg->csid_tpg_ctrl_addr);
590-
591583
end:
592584
return rc;
593585

0 commit comments

Comments
 (0)