msm: camera: req_mgr: CRM Code refactoring

Due to major changes in CRM code, refactoring CRM
kernel driver code. Fix apply threshold calculation logic.

CRs-Fixed: 2783209
Change-Id: I08ba6c89b0d4f0e982c017bab4226a569327f861
Signed-off-by: Ayush Kumar <ayushkr@codeaurora.org>
This commit is contained in:
Ayush Kumar
2021-06-17 01:27:28 +05:30
parent c6903209f2
commit e8e814eda9
6 changed files with 551 additions and 551 deletions

View File

@@ -581,6 +581,7 @@ static int __cam_isp_ctx_enqueue_init_request(
req_isp_new->hw_update_data.frame_header_res_id; req_isp_new->hw_update_data.frame_header_res_id;
req_isp_old->hw_update_data.frame_header_cpu_addr = req_isp_old->hw_update_data.frame_header_cpu_addr =
hw_update_data->frame_header_cpu_addr; hw_update_data->frame_header_cpu_addr;
req_isp_old->hw_update_data.fps = req_isp_new->hw_update_data.fps;
req_old->request_id = req->request_id; req_old->request_id = req->request_id;
@@ -1118,10 +1119,8 @@ static int __cam_isp_ctx_handle_buf_done_for_request(
CAM_DBG(CAM_ISP, "req %lld, reset sync id 0x%x ctx %u", CAM_DBG(CAM_ISP, "req %lld, reset sync id 0x%x ctx %u",
req->request_id, req->request_id,
req_isp->fence_map_out[j].sync_id, ctx->ctx_id); req_isp->fence_map_out[j].sync_id, ctx->ctx_id);
if (!rc) { if (!rc)
req_isp->num_acked++; req_isp->num_acked++;
req_isp->fence_map_out[j].sync_id = -1;
}
if ((ctx_isp->use_frame_header_ts) && if ((ctx_isp->use_frame_header_ts) &&
(req_isp->hw_update_data.frame_header_res_id == (req_isp->hw_update_data.frame_header_res_id ==
@@ -1975,14 +1974,14 @@ notify_only:
req = list_first_entry(&ctx->active_req_list, req = list_first_entry(&ctx->active_req_list,
struct cam_ctx_request, list); struct cam_ctx_request, list);
req_isp = (struct cam_isp_ctx_req *) req->req_priv; req_isp = (struct cam_isp_ctx_req *) req->req_priv;
notify.fps = req_isp->hw_update_data.fps; if (req_isp->hw_update_data.fps != -1)
} else { ctx_isp->fps = req_isp->hw_update_data.fps;
notify.fps = 0;
} }
notify.fps = ctx_isp->fps;
ctx->ctx_crm_intf->notify_trigger(&notify); ctx->ctx_crm_intf->notify_trigger(&notify);
CAM_DBG(CAM_ISP, "Notify CRM SOF frame %lld ctx %u", CAM_DBG(CAM_ISP, "Notify CRM SOF frame %lld ctx %u fps %d",
ctx_isp->frame_id, ctx->ctx_id); ctx_isp->frame_id, ctx->ctx_id, ctx_isp->fps);
} }
list_for_each_entry(req, &ctx->active_req_list, list) { list_for_each_entry(req, &ctx->active_req_list, list) {
@@ -2213,8 +2212,6 @@ static int __cam_isp_ctx_epoch_in_applied(struct cam_isp_context *ctx_isp,
req->request_id, ctx->ctx_id); req->request_id, ctx->ctx_id);
rc = ctx->ctx_crm_intf->notify_err(&notify); rc = ctx->ctx_crm_intf->notify_err(&notify);
CAM_DBG(CAM_CRM, "Need bubble recovery %d", rc);
if (rc) { if (rc) {
req_isp->bubble_detected = false; req_isp->bubble_detected = false;
req_isp->reapply = false; req_isp->reapply = false;
@@ -4043,6 +4040,7 @@ static struct cam_ctx_ops
.notify_frame_skip = .notify_frame_skip =
__cam_isp_ctx_apply_default_req_settings, __cam_isp_ctx_apply_default_req_settings,
.change_state = __cam_isp_ctx_change_substate, .change_state = __cam_isp_ctx_change_substate,
.signal_buf_done = __cam_isp_ctx_signal_buf_done,
}, },
.irq_ops = NULL, .irq_ops = NULL,
}, },
@@ -4979,6 +4977,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
cfg.num_out_map_entries = 0; cfg.num_out_map_entries = 0;
cfg.num_in_map_entries = 0; cfg.num_in_map_entries = 0;
req_isp->hw_update_data.fps = -1; req_isp->hw_update_data.fps = -1;
req_isp->hw_update_data.packet = packet;
CAM_DBG(CAM_ISP, "try to prepare config packet......"); CAM_DBG(CAM_ISP, "try to prepare config packet......");
@@ -4997,7 +4996,6 @@ static int __cam_isp_ctx_config_dev_in_top_state(
req_isp->num_deferred_acks = 0; req_isp->num_deferred_acks = 0;
req_isp->bubble_detected = false; req_isp->bubble_detected = false;
req_isp->cdm_reset_before_apply = false; req_isp->cdm_reset_before_apply = false;
req_isp->hw_update_data.packet = packet;
atomic_set(&req_isp->buf_done_ready, INIT_BUF_DONE); atomic_set(&req_isp->buf_done_ready, INIT_BUF_DONE);
for (i = 0; i < req_isp->num_fence_map_out; i++) { for (i = 0; i < req_isp->num_fence_map_out; i++) {
@@ -5908,6 +5906,7 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
ctx_isp->active_req_cnt = 0; ctx_isp->active_req_cnt = 0;
ctx_isp->reported_req_id = 0; ctx_isp->reported_req_id = 0;
ctx_isp->bubble_frame_cnt = 0; ctx_isp->bubble_frame_cnt = 0;
ctx_isp->fps = req_isp->hw_update_data.fps;
ctx_isp->substate_activated = ctx_isp->rdi_only_context ? ctx_isp->substate_activated = ctx_isp->rdi_only_context ?
CAM_ISP_CTX_ACTIVATED_APPLIED : CAM_ISP_CTX_ACTIVATED_APPLIED :
(req_isp->num_fence_map_out) ? CAM_ISP_CTX_ACTIVATED_EPOCH : (req_isp->num_fence_map_out) ? CAM_ISP_CTX_ACTIVATED_EPOCH :
@@ -6089,6 +6088,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
ctx_isp->last_applied_req_id = 0; ctx_isp->last_applied_req_id = 0;
ctx_isp->req_info.last_bufdone_req_id = 0; ctx_isp->req_info.last_bufdone_req_id = 0;
ctx_isp->bubble_frame_cnt = 0; ctx_isp->bubble_frame_cnt = 0;
ctx_isp->fps = -1;
atomic_set(&ctx_isp->process_bubble, 0); atomic_set(&ctx_isp->process_bubble, 0);
atomic_set(&ctx_isp->rxd_epoch, 0); atomic_set(&ctx_isp->rxd_epoch, 0);
atomic64_set(&ctx_isp->state_monitor_head, -1); atomic64_set(&ctx_isp->state_monitor_head, -1);

View File

@@ -8815,11 +8815,12 @@ static int cam_isp_packet_generic_blob_handler(void *user_data,
prepare_hw_data = (struct cam_isp_prepare_hw_update_data *) prepare_hw_data = (struct cam_isp_prepare_hw_update_data *)
prepare->priv; prepare->priv;
if (fps_config->fps) { if (fps_config->fps)
prepare_hw_data->fps = fps_config->fps; prepare_hw_data->fps = fps_config->fps;
CAM_DBG(CAM_ISP, "FPS value %u", fps_config->fps); CAM_DBG(CAM_ISP, "FPS value %u ctx %d req id %lld",
} else fps_config->fps, ife_mgr_ctx->ctx_index,
CAM_WARN(CAM_ISP, "FPS value 0"); prepare_hw_data->packet->header.request_id);
} }
break; break;
default: default:

File diff suppressed because it is too large Load Diff

View File

@@ -264,7 +264,6 @@ struct cam_req_mgr_req_tbl {
* @recover : if user enabled recovery for this request. * @recover : if user enabled recovery for this request.
* @req_id : mask tracking which all devices have request ready * @req_id : mask tracking which all devices have request ready
* @sync_mode : Modified sync mode in which req id in this slot has to applied * @sync_mode : Modified sync mode in which req id in this slot has to applied
* @real_sync_mode : Actual sync mode in which req id in this slot has to applied
* @additional_timeout : Adjusted watchdog timeout value associated with * @additional_timeout : Adjusted watchdog timeout value associated with
* this request * this request
*/ */
@@ -275,7 +274,6 @@ struct cam_req_mgr_slot {
int32_t recover; int32_t recover;
int64_t req_id; int64_t req_id;
int32_t sync_mode; int32_t sync_mode;
int32_t real_sync_mode;
int32_t additional_timeout; int32_t additional_timeout;
}; };
@@ -334,6 +332,48 @@ struct cam_req_mgr_connected_device {
void *parent; void *parent;
}; };
/**
* struct cam_req_mgr_sof_time
* - Frame sof time in ns
* @csid_timestamp_ns : CSID SOF timestamp value
* @prev_csid_timestamp_ns : Previous CSID SOF timestamp value
* @boottime_ns : SOF Boottime value
* @last_sof_trigger_jiffies : Record the jiffies of last sof trigger jiffies
*/
struct cam_req_mgr_sof_time {
uint64_t boottime_ns;
uint64_t csid_timestamp_ns;
uint64_t prev_csid_timestamp_ns;
uint64_t last_sof_trigger_jiffies;
};
/**
* struct cam_req_mgr_sync_data
* - Sync link data and properties
* @num_sync_link : total number of sync links
* @sync_link : array of pointer to the sync link for synchronization
* @initial_sync_req : The initial req which is required to sync with the
* other link
* @modified_init_sync_req : Modified initial req which is required to sync
* with the other link
* @sync_link_sof_skip : flag determines if a pkt is not available for a given
* frame in a particular link skip corresponding
* frame in sync link as well.
* @sync_frame_id : current frame id of sync link
* @sof_time : sof timing value in different format
* @is_sync_req : flag used for deciding sync and non-sync
*/
struct cam_req_mgr_sync_data {
int32_t num_sync_link;
struct cam_req_mgr_core_link *sync_link[MAXIMUM_LINKS_PER_SESSION];
int64_t initial_sync_req;
int64_t modified_init_sync_req;
bool sync_link_sof_skip;
uint64_t sync_frame_id;
struct cam_req_mgr_sof_time sof_time;
bool is_sync_req;
};
/** /**
* struct cam_req_mgr_core_link * struct cam_req_mgr_core_link
* - Link Properties * - Link Properties
@@ -357,11 +397,7 @@ struct cam_req_mgr_connected_device {
* @parent : pvt data - link's parent is session * @parent : pvt data - link's parent is session
* @lock : mutex lock to guard link data operations * @lock : mutex lock to guard link data operations
* @link_state_spin_lock : spin lock to protect link state variable * @link_state_spin_lock : spin lock to protect link state variable
* @sync_link : array of pointer to the sync link for synchronization * @sync_data : sync data datails needed in sync mode
* @num_sync_link : total number of sync links
* @sync_link_sof_skip : flag determines if a pkt is not available for a given
* frame in a particular link skip corresponding
* frame in sync link as well.
* @open_req_cnt : Counter to keep track of open requests that are yet * @open_req_cnt : Counter to keep track of open requests that are yet
* to be serviced in the kernel. * to be serviced in the kernel.
* @last_flush_id : Last request to flush * @last_flush_id : Last request to flush
@@ -370,29 +406,20 @@ struct cam_req_mgr_connected_device {
* is assigned as master * is assigned as master
* @initial_skip : Flag to determine if initial req need to skip for * @initial_skip : Flag to determine if initial req need to skip for
* diff pd * diff pd
* @is_sync_req : flag used for deciding sync and non-sync
* @in_msync_mode : Flag to determine if a link is in master-slave mode * @in_msync_mode : Flag to determine if a link is in master-slave mode
* @initial_sync_req : The initial req which is required to sync with the
* other link
* @modified_init_sync_req : Modified initial req which is required to sync
* with the other link
* @retry_cnt : Counter that tracks number of attempts to apply * @retry_cnt : Counter that tracks number of attempts to apply
* the same req * the same req
* @is_shutdown : Flag to indicate if link needs to be disconnected * @is_shutdown : Flag to indicate if link needs to be disconnected
* as part of shutdown. * as part of shutdown.
* @sof_timestamp_value : SOF timestamp value
* @prev_sof_timestamp : Previous SOF timestamp value
* @dual_trigger : Links needs to wait for two triggers prior to * @dual_trigger : Links needs to wait for two triggers prior to
* applying the settings * applying the settings
* @trigger_cnt : trigger count value per device initiating the trigger * @trigger_cnt : trigger count value per device initiating the trigger
* @eof_event_cnt : Atomic variable to track the number of EOF requests * @eof_event_cnt : Atomic variable to track the number of EOF requests
* @skip_init_frame : skip initial frames crm_wd_timer validation in the * @skip_init_frame : skip initial frames crm_wd_timer validation in the
* case of long exposure use case * case of long exposure use case
* @last_sof_trigger_jiffies : Record the jiffies of last sof trigger jiffies
* @wq_congestion : Indicates if WQ congestion is detected or not * @wq_congestion : Indicates if WQ congestion is detected or not
* @activate_seq : sequence in which link is activated * @activate_seq : sequence in which link is activated
* @frame_id : current frame id * @frame_id : current frame id
* @sync_frame_id : current frame id of sync link
* @bubble_skip : req to skip on bubble * @bubble_skip : req to skip on bubble
* @num_isp_dev : number of isp dev in a link * @num_isp_dev : number of isp dev in a link
* @retry_threshold : number of times to retry apply on increased threshold * @retry_threshold : number of times to retry apply on increased threshold
@@ -413,38 +440,27 @@ struct cam_req_mgr_core_link {
void *parent; void *parent;
struct mutex lock; struct mutex lock;
spinlock_t link_state_spin_lock; spinlock_t link_state_spin_lock;
struct cam_req_mgr_core_link *sync_link[ struct cam_req_mgr_sync_data sync_data;
MAXIMUM_LINKS_PER_SESSION];
int32_t num_sync_link;
bool sync_link_sof_skip;
uint32_t open_req_cnt; uint32_t open_req_cnt;
uint32_t last_flush_id; uint32_t last_flush_id;
atomic_t is_used; atomic_t is_used;
bool is_master; bool is_master;
uint32_t initial_skip; uint32_t initial_skip;
bool is_sync_req;
bool in_msync_mode; bool in_msync_mode;
int64_t initial_sync_req;
int64_t modified_init_sync_req;
uint32_t retry_cnt; uint32_t retry_cnt;
bool is_shutdown; bool is_shutdown;
uint64_t sof_boottime;
uint64_t sof_timestamp;
uint64_t prev_sof_timestamp;
bool dual_trigger; bool dual_trigger;
uint32_t trigger_cnt[CAM_REQ_MGR_MAX_TRIGGERS][CAM_TRIGGER_MAX_POINTS]; uint32_t trigger_cnt[CAM_REQ_MGR_MAX_TRIGGERS][CAM_TRIGGER_MAX_POINTS];
atomic_t eof_event_cnt; atomic_t eof_event_cnt;
bool skip_init_frame; bool skip_init_frame;
uint64_t last_sof_trigger_jiffies;
bool wq_congestion; bool wq_congestion;
int32_t activate_seq; int32_t activate_seq;
uint64_t frame_id; uint64_t frame_id;
uint64_t sync_frame_id;
int32_t bubble_skip; int32_t bubble_skip;
bool skip_sync_apply; bool skip_sync_apply;
uint32_t num_isp_dev; uint32_t num_isp_dev;
uint32_t retry_threshold; uint32_t retry_threshold;
uint32_t fps; int32_t fps;
}; };
/** /**

View File

@@ -254,7 +254,7 @@ struct cam_req_mgr_trigger_notify {
uint64_t sof_boottime; uint64_t sof_boottime;
uint64_t req_id; uint64_t req_id;
int32_t trigger_id; int32_t trigger_id;
uint32_t fps; int32_t fps;
}; };
/** /**

View File

@@ -82,9 +82,13 @@
* @CAM_REQ_MGR_SYNC_MODE_NO_SYNC: Req mgr will apply non-sync mode for this * @CAM_REQ_MGR_SYNC_MODE_NO_SYNC: Req mgr will apply non-sync mode for this
* request. * request.
* @CAM_REQ_MGR_SYNC_MODE_SYNC: Req mgr will apply sync mode for this request. * @CAM_REQ_MGR_SYNC_MODE_SYNC: Req mgr will apply sync mode for this request.
* @CAM_REQ_MGR_SYNC_MODE_TRANSITION_SYNC: Req mgr will apply transition sync
* mode for this request. Only first few request before sync mode will apply
* transition sync mode.
*/ */
#define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0 #define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0
#define CAM_REQ_MGR_SYNC_MODE_SYNC 1 #define CAM_REQ_MGR_SYNC_MODE_SYNC 1
#define CAM_REQ_MGR_SYNC_MODE_TRANSITION_SYNC 2
/** /**
* struct cam_req_mgr_event_data * struct cam_req_mgr_event_data