From 4fbb1700efdee1ce0e6ed27e7ca777d65148dfda Mon Sep 17 00:00:00 2001 From: Vikram Sharma Date: Mon, 18 Oct 2021 13:15:15 +0530 Subject: [PATCH 1/5] msm: camera: ope: Increase max bl limit and max stripe to process MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Increase “OPE_MAX_CDM_BLS” to 32 from 24 and MAX_STRIPES to 64 from 48 to process 108M frame. CRs-Fixed: 3082993 Change-Id: I9e3631cc86c5e10e4e2020d4a9b2264ea282e437 Signed-off-by: Vikram Sharma --- drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h | 2 +- include/uapi/camera/media/cam_ope.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h index f6206f0c8bf0..a90cd56abc42 100644 --- a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h +++ b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h @@ -50,7 +50,7 @@ #define OPE_CMDS OPE_MAX_CMD_BUFS #define CAM_MAX_IN_RES 8 -#define OPE_MAX_CDM_BLS 24 +#define OPE_MAX_CDM_BLS 32 #define CAM_OPE_MAX_PER_PATH_VOTES 6 #define CAM_OPE_BW_CONFIG_UNKNOWN 0 diff --git a/include/uapi/camera/media/cam_ope.h b/include/uapi/camera/media/cam_ope.h index d9badbcdff3d..b6a9a41d8dfe 100644 --- a/include/uapi/camera/media/cam_ope.h +++ b/include/uapi/camera/media/cam_ope.h @@ -73,7 +73,7 @@ #define OPE_MAX_IO_BUFS (OPE_OUT_RES_MAX + OPE_IN_RES_MAX) #define OPE_MAX_PASS 1 #define OPE_MAX_PLANES 2 -#define OPE_MAX_STRIPES 48 +#define OPE_MAX_STRIPES 64 #define OPE_MAX_BATCH_SIZE 16 /** From 8eeacc770c200536caebed42081da9705cbff566 Mon Sep 17 00:00:00 2001 From: Alok Chauhan Date: Fri, 19 Nov 2021 12:25:48 +0530 Subject: [PATCH 2/5] msm: camera: ope: Update request timeout for NRT/RT context Currently the ope request timeout value for RT and NRT context are same. In some usecases, NRT request processing takes more time. Hence, initialize the RT and NRT request timeout value separately. CRs-Fixed: 3082993 Change-Id: I17e86d26403fb21cdff518a81dee7a19c865144e Signed-off-by: Alok Chauhan --- drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c | 18 +++++++++++------- drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c index 978160a6a6ac..6057ec7b5cc1 100644 --- a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c +++ b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c @@ -624,8 +624,8 @@ static bool cam_ope_check_req_delay(struct cam_ope_ctx *ctx_data, ts.tv_nsec); if (ts_ns - req_time < - ((OPE_REQUEST_TIMEOUT - - OPE_REQUEST_TIMEOUT / 10) * 1000000)) { + ((ctx_data->req_timer_timeout - + ctx_data->req_timer_timeout / 10) * 1000000)) { CAM_INFO(CAM_OPE, "ctx: %d, ts_ns : %llu", ctx_data->ctx_id, ts_ns); cam_ope_req_timer_reset(ctx_data); @@ -848,7 +848,7 @@ static int cam_ope_start_req_timer(struct cam_ope_ctx *ctx_data) int rc = 0; rc = crm_timer_init(&ctx_data->req_watch_dog, - OPE_REQUEST_TIMEOUT, ctx_data, &cam_ope_req_timer_cb); + ctx_data->req_timer_timeout, ctx_data, &cam_ope_req_timer_cb); if (rc) CAM_ERR(CAM_OPE, "Failed to start timer"); @@ -2626,11 +2626,15 @@ static int cam_ope_mgr_acquire_hw(void *hw_priv, void *hw_acquire_args) goto end; } strlcpy(cdm_acquire->identifier, "ope", sizeof("ope")); - if (ctx->ope_acquire.dev_type == OPE_DEV_TYPE_OPE_RT) + if (ctx->ope_acquire.dev_type == OPE_DEV_TYPE_OPE_RT) { cdm_acquire->priority = CAM_CDM_BL_FIFO_3; + ctx->req_timer_timeout = OPE_REQUEST_RT_TIMEOUT; + } else if (ctx->ope_acquire.dev_type == - OPE_DEV_TYPE_OPE_NRT) + OPE_DEV_TYPE_OPE_NRT) { cdm_acquire->priority = CAM_CDM_BL_FIFO_0; + ctx->req_timer_timeout = OPE_REQUEST_NRT_TIMEOUT; + } else goto free_cdm_acquire; @@ -3300,7 +3304,7 @@ static int cam_ope_mgr_prepare_hw_update(void *hw_priv, CAM_DBG(CAM_REQ, "req_id= %llu ctx_id= %d lrt=%llu", packet->header.request_id, ctx_data->ctx_id, ctx_data->last_req_time); - cam_ope_req_timer_modify(ctx_data, OPE_REQUEST_TIMEOUT); + cam_ope_req_timer_modify(ctx_data, ctx_data->req_timer_timeout); set_bit(request_idx, ctx_data->bitmap); mutex_unlock(&ctx_data->ctx_mutex); @@ -3620,7 +3624,7 @@ static int cam_ope_mgr_hw_dump(void *hw_priv, void *hw_dump_args) cur_ts = ktime_to_timespec64(cur_time); req_ts = ktime_to_timespec64(ctx_data->req_list[idx]->submit_timestamp); - if (diff < (OPE_REQUEST_TIMEOUT * 1000)) { + if (diff < (ctx_data->req_timer_timeout * 1000)) { CAM_INFO(CAM_OPE, "No Error req %llu %ld:%06ld %ld:%06ld", dump_args->request_id, req_ts.tv_sec, diff --git a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h index f6206f0c8bf0..247b6b0f0abe 100644 --- a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h +++ b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.h @@ -60,7 +60,8 @@ #define CLK_HW_MAX 0x1 #define OPE_DEVICE_IDLE_TIMEOUT 400 -#define OPE_REQUEST_TIMEOUT 200 +#define OPE_REQUEST_RT_TIMEOUT 200 +#define OPE_REQUEST_NRT_TIMEOUT 400 /** * struct cam_ope_clk_bw_request_v2 @@ -447,6 +448,7 @@ struct cam_ope_cdm { * @clk_watch_dog: Clock watchdog * @clk_watch_dog_reset_counter: Reset counter * @last_flush_req: last flush req for this ctx + * @req_timer_timeout: req timer timeout value */ struct cam_ope_ctx { void *context_priv; @@ -470,6 +472,7 @@ struct cam_ope_ctx { uint32_t clk_watch_dog_reset_counter; uint64_t last_flush_req; bool pf_mid_found; + uint64_t req_timer_timeout; }; /** From c6de9ec432f31ae0713fb068e3cd1ef2b40d9722 Mon Sep 17 00:00:00 2001 From: Tejas Prajapati Date: Wed, 24 Nov 2021 10:50:39 +0530 Subject: [PATCH 3/5] msm: camera: isp: Add eof notification for rdi only context For RDI only context EOF is not notified; it should be notified, for the corner case if the flash is configured to apply at EOF then it will block apply for ISP on SOF as well until the EOF is notified, this change adds EOF notification. CRs-Fixed: 3091241 Change-Id: If6d974d092d640d9def89bbcf7a88fba0d85579b Signed-off-by: Tejas Prajapati --- drivers/cam_isp/cam_isp_context.c | 10 +++++----- drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c | 8 ++++++++ drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c | 6 ++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/cam_isp/cam_isp_context.c b/drivers/cam_isp/cam_isp_context.c index 9992e6261956..f3d454914204 100644 --- a/drivers/cam_isp/cam_isp_context.c +++ b/drivers/cam_isp/cam_isp_context.c @@ -4315,7 +4315,7 @@ static struct cam_isp_ctx_irq_ops __cam_isp_ctx_rdi_only_sof_in_top_state, __cam_isp_ctx_reg_upd_in_sof, NULL, - NULL, + __cam_isp_ctx_notify_eof_in_activated_state, NULL, }, }, @@ -4326,7 +4326,7 @@ static struct cam_isp_ctx_irq_ops __cam_isp_ctx_rdi_only_sof_in_applied_state, NULL, NULL, - NULL, + __cam_isp_ctx_notify_eof_in_activated_state, __cam_isp_ctx_buf_done_in_applied, }, }, @@ -4337,7 +4337,7 @@ static struct cam_isp_ctx_irq_ops __cam_isp_ctx_rdi_only_sof_in_top_state, NULL, NULL, - NULL, + __cam_isp_ctx_notify_eof_in_activated_state, __cam_isp_ctx_buf_done_in_epoch, }, }, @@ -4348,7 +4348,7 @@ static struct cam_isp_ctx_irq_ops __cam_isp_ctx_rdi_only_sof_in_bubble_state, __cam_isp_ctx_rdi_only_reg_upd_in_bubble_state, NULL, - NULL, + __cam_isp_ctx_notify_eof_in_activated_state, __cam_isp_ctx_buf_done_in_bubble, }, }, @@ -4359,7 +4359,7 @@ static struct cam_isp_ctx_irq_ops __cam_isp_ctx_rdi_only_sof_in_bubble_applied, __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state, NULL, - NULL, + __cam_isp_ctx_notify_eof_in_activated_state, __cam_isp_ctx_buf_done_in_bubble_applied, }, }, diff --git a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c index 487f1eda3457..8af790e2d3b2 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_ife_hw_mgr.c @@ -7990,6 +7990,14 @@ static int cam_ife_hw_mgr_handle_hw_eof( case CAM_ISP_HW_VFE_IN_RDI1: case CAM_ISP_HW_VFE_IN_RDI2: case CAM_ISP_HW_VFE_IN_RDI3: + if (!ife_hw_mgr_ctx->is_rdi_only_context) + break; + if (atomic_read(&ife_hw_mgr_ctx->overflow_pending)) + break; + ife_hw_irq_eof_cb(ife_hw_mgr_ctx->common.cb_priv, + CAM_ISP_HW_EVENT_EOF, (void *)&eof_done_event_data); + break; + case CAM_ISP_HW_VFE_IN_PDLIB: case CAM_ISP_HW_VFE_IN_LCR: break; diff --git a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c index 4b33439c44f3..aa6e8c15aa8e 100644 --- a/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c +++ b/drivers/cam_isp/isp_hw_mgr/cam_tfe_hw_mgr.c @@ -5649,6 +5649,12 @@ static int cam_tfe_hw_mgr_handle_hw_eof( case CAM_ISP_HW_TFE_IN_RDI0: case CAM_ISP_HW_TFE_IN_RDI1: case CAM_ISP_HW_TFE_IN_RDI2: + if (!tfe_hw_mgr_ctx->is_rdi_only_context) + break; + if (atomic_read(&tfe_hw_mgr_ctx->overflow_pending)) + break; + tfe_hw_irq_eof_cb(tfe_hw_mgr_ctx->common.cb_priv, + CAM_ISP_HW_EVENT_EOF, (void *)&eof_done_event_data); break; default: From 4856f7a40a673e60987482c62492946e48445e36 Mon Sep 17 00:00:00 2001 From: Tejas Prajapati Date: Mon, 20 Dec 2021 14:44:36 +0530 Subject: [PATCH 4/5] msm: camera: reqmgr: check if link handle is correctly passed Instead of the link handle if the dev handle is passed for dumping the request information, this can lead to accessing invalid data structure. To avodi accessing invalid data structure based on the dev handle, first check if the link handle passed in IOCTL is matchting with looked up link handle. CRs-Fixed: 3097336 Change-Id: I815457ff96e3b26fe9fa886bd984d53d209e4edb Signed-off-by: Tejas Prajapati --- drivers/cam_req_mgr/cam_req_mgr_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cam_req_mgr/cam_req_mgr_core.c b/drivers/cam_req_mgr/cam_req_mgr_core.c index 05e6fdb90381..ac04553899a2 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_core.c +++ b/drivers/cam_req_mgr/cam_req_mgr_core.c @@ -4542,7 +4542,7 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req) link = (struct cam_req_mgr_core_link *) cam_get_device_priv(dump_req->link_hdl); - if (!link) { + if (!link || link->link_hdl != dump_req->link_hdl) { CAM_DBG(CAM_CRM, "link ptr NULL %x", dump_req->link_hdl); rc = -EINVAL; goto end; From deb0914ed40c4149d42454f2fbe4bf14b2dc4eb8 Mon Sep 17 00:00:00 2001 From: Alok Chauhan Date: Tue, 28 Dec 2021 11:46:46 +0530 Subject: [PATCH 5/5] msm: camera: ope: Fix for 32-bit kernel Use div_u64 to do 64-bit division. CRs-Fixed: 3099898 Change-Id: I405461ea02d0ec668cb7be764543a9a16bd1c3e6 Signed-off-by: Alok Chauhan Signed-off-by: Nirmal Abraham --- drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c index 6057ec7b5cc1..b76f97a7461c 100644 --- a/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c +++ b/drivers/cam_ope/ope_hw_mgr/cam_ope_hw_mgr.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2017-2021, The Linux Foundation. All rights reserved. + * Copyright (c) 2017-2022, The Linux Foundation. All rights reserved. */ #include @@ -19,6 +19,7 @@ #include #include #include +#include #include "cam_sync_api.h" #include "cam_packet_util.h" @@ -625,7 +626,7 @@ static bool cam_ope_check_req_delay(struct cam_ope_ctx *ctx_data, if (ts_ns - req_time < ((ctx_data->req_timer_timeout - - ctx_data->req_timer_timeout / 10) * 1000000)) { + div_u64(ctx_data->req_timer_timeout, 10)) * 1000000)) { CAM_INFO(CAM_OPE, "ctx: %d, ts_ns : %llu", ctx_data->ctx_id, ts_ns); cam_ope_req_timer_reset(ctx_data);