@@ -60,6 +60,32 @@ static const char *__cam_isp_evt_val_to_type(
6060 }
6161}
6262
63+ static inline void __cam_isp_ctx_move_req_to_free_list (
64+ struct cam_context * ctx , struct cam_ctx_request * req )
65+ {
66+ struct cam_isp_ctx_req * req_isp ;
67+ struct cam_kmd_buf_info * kmd_cmd_buff_info ;
68+ int32_t handle ;
69+
70+ if (!req || !ctx ) {
71+ CAM_ERR (CAM_ISP , "Invalid args" );
72+ return ;
73+ }
74+
75+ req_isp = (struct cam_isp_ctx_req * ) req -> req_priv ;
76+ kmd_cmd_buff_info = & (req_isp -> hw_update_data .kmd_cmd_buff_info );
77+ handle = kmd_cmd_buff_info -> handle ;
78+
79+ CAM_DBG (CAM_ISP ,
80+ "Free req id: %lld, ctx_idx: %u, link: 0x%x" ,
81+ req -> request_id , ctx -> ctx_id , ctx -> link_hdl );
82+
83+ if (handle > 0 )
84+ cam_mem_put_kref (handle );
85+
86+ list_add_tail (& req -> list , & ctx -> free_req_list );
87+ }
88+
6389static void __cam_isp_ctx_update_event_record (
6490 struct cam_isp_context * ctx_isp ,
6591 enum cam_isp_ctx_event event ,
@@ -511,7 +537,7 @@ static int __cam_isp_ctx_enqueue_init_request(
511537
512538 req_old -> request_id = req -> request_id ;
513539
514- list_add_tail ( & req -> list , & ctx -> free_req_list );
540+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
515541 }
516542 } else {
517543 CAM_WARN (CAM_ISP ,
@@ -842,7 +868,7 @@ static int __cam_isp_ctx_handle_buf_done_for_req_list(
842868 CAM_SYNC_STATE_SIGNALED_ERROR ,
843869 CAM_SYNC_ISP_EVENT_BUBBLE );
844870
845- list_add_tail ( & req -> list , & ctx -> free_req_list );
871+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
846872 CAM_DBG (CAM_REQ ,
847873 "Move active request %lld to free list(cnt = %d) [flushed], ctx %u" ,
848874 buf_done_req_id , ctx_isp -> active_req_cnt ,
@@ -865,7 +891,7 @@ static int __cam_isp_ctx_handle_buf_done_for_req_list(
865891 }
866892 }
867893 list_del_init (& req -> list );
868- list_add_tail ( & req -> list , & ctx -> free_req_list );
894+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
869895 req_isp -> reapply = false;
870896 req_isp -> cdm_reset_before_apply = false;
871897 req_isp -> num_acked = 0 ;
@@ -1818,7 +1844,7 @@ static int __cam_isp_ctx_reg_upd_in_applied_state(
18181844 CAM_ISP_CTX_EVENT_RUP , req );
18191845 } else {
18201846 /* no io config, so the request is completed. */
1821- list_add_tail ( & req -> list , & ctx -> free_req_list );
1847+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
18221848 CAM_DBG (CAM_ISP ,
18231849 "move active request %lld to free list(cnt = %d), ctx %u" ,
18241850 req -> request_id , ctx_isp -> active_req_cnt , ctx -> ctx_id );
@@ -2105,7 +2131,7 @@ static int __cam_isp_ctx_reg_upd_in_sof(struct cam_isp_context *ctx_isp,
21052131 list_del_init (& req -> list );
21062132 req_isp = (struct cam_isp_ctx_req * ) req -> req_priv ;
21072133 if (req_isp -> num_fence_map_out == req_isp -> num_acked )
2108- list_add_tail ( & req -> list , & ctx -> free_req_list );
2134+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
21092135 else
21102136 CAM_ERR (CAM_ISP ,
21112137 "receive rup in unexpected state" );
@@ -2622,7 +2648,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
26222648 }
26232649 }
26242650 list_del_init (& req -> list );
2625- list_add_tail ( & req -> list , & ctx -> free_req_list );
2651+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
26262652 ctx_isp -> active_req_cnt -- ;
26272653 } else {
26282654 found = 1 ;
@@ -2654,7 +2680,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
26542680 }
26552681 }
26562682 list_del_init (& req -> list );
2657- list_add_tail ( & req -> list , & ctx -> free_req_list );
2683+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
26582684 ctx_isp -> active_req_cnt -- ;
26592685 } else {
26602686 found = 1 ;
@@ -2717,7 +2743,7 @@ static int __cam_isp_ctx_handle_error(struct cam_isp_context *ctx_isp,
27172743 req_isp -> fence_map_out [i ].sync_id = -1 ;
27182744 }
27192745 list_del_init (& req -> list );
2720- list_add_tail ( & req -> list , & ctx -> free_req_list );
2746+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
27212747
27222748 } while (req -> request_id < ctx_isp -> last_applied_req_id );
27232749
@@ -2926,7 +2952,7 @@ static int __cam_isp_ctx_fs2_reg_upd_in_sof(struct cam_isp_context *ctx_isp,
29262952 list_del_init (& req -> list );
29272953 req_isp = (struct cam_isp_ctx_req * ) req -> req_priv ;
29282954 if (req_isp -> num_fence_map_out == req_isp -> num_acked )
2929- list_add_tail ( & req -> list , & ctx -> free_req_list );
2955+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
29302956 else
29312957 CAM_ERR (CAM_ISP ,
29322958 "receive rup in unexpected state" );
@@ -2966,7 +2992,7 @@ static int __cam_isp_ctx_fs2_reg_upd_in_applied_state(
29662992 req -> request_id , ctx_isp -> active_req_cnt );
29672993 } else {
29682994 /* no io config, so the request is completed. */
2969- list_add_tail ( & req -> list , & ctx -> free_req_list );
2995+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
29702996 }
29712997
29722998 /*
@@ -3745,7 +3771,7 @@ static int __cam_isp_ctx_flush_req(struct cam_context *ctx,
37453771 req_isp -> reapply = false;
37463772 req_isp -> cdm_reset_before_apply = false;
37473773 list_del_init (& req -> list );
3748- list_add_tail ( & req -> list , & ctx -> free_req_list );
3774+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
37493775 }
37503776
37513777 return 0 ;
@@ -4283,7 +4309,7 @@ static int __cam_isp_ctx_rdi_only_sof_in_bubble_state(
42834309 CAM_SYNC_STATE_SIGNALED_ERROR ,
42844310 CAM_SYNC_ISP_EVENT_BUBBLE );
42854311 }
4286- list_add_tail ( & req -> list , & ctx -> free_req_list );
4312+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
42874313 ctx_isp -> active_req_cnt -- ;
42884314 }
42894315
@@ -4375,7 +4401,7 @@ static int __cam_isp_ctx_rdi_only_reg_upd_in_bubble_applied_state(
43754401 request_id = req -> request_id ;
43764402 } else {
43774403 /* no io config, so the request is completed. */
4378- list_add_tail ( & req -> list , & ctx -> free_req_list );
4404+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
43794405 CAM_DBG (CAM_ISP ,
43804406 "move active req %lld to free list(cnt=%d)" ,
43814407 req -> request_id , ctx_isp -> active_req_cnt );
@@ -4456,7 +4482,7 @@ static int __cam_isp_ctx_rdi_only_reg_upd_in_applied_state(
44564482 CAM_ISP_CTX_EVENT_RUP , req );
44574483 } else {
44584484 /* no io config, so the request is completed. */
4459- list_add_tail ( & req -> list , & ctx -> free_req_list );
4485+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
44604486 CAM_DBG (CAM_ISP ,
44614487 "move active request %lld to free list(cnt = %d), ctx %u" ,
44624488 req -> request_id , ctx_isp -> active_req_cnt , ctx -> ctx_id );
@@ -4956,7 +4982,7 @@ static int __cam_isp_ctx_config_dev_in_top_state(
49564982 }
49574983free_req :
49584984 spin_lock_bh (& ctx -> lock );
4959- list_add_tail ( & req -> list , & ctx -> free_req_list );
4985+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
49604986 spin_unlock_bh (& ctx -> lock );
49614987
49624988 cam_mem_put_cpu_buf ((int32_t ) cmd -> packet_handle );
@@ -5673,7 +5699,7 @@ static int __cam_isp_ctx_start_dev_in_ready(struct cam_context *ctx,
56735699 list_del_init (& req -> list );
56745700
56755701 if (ctx_isp -> offline_context && !req_isp -> num_fence_map_out ) {
5676- list_add_tail ( & req -> list , & ctx -> free_req_list );
5702+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
56775703 atomic_set (& ctx_isp -> rxd_epoch , 1 );
56785704 CAM_DBG (CAM_REQ ,
56795705 "Move pending req: %lld to free list(cnt: %d) offline ctx %u" ,
@@ -5792,7 +5818,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
57925818 CAM_SYNC_STATE_SIGNALED_CANCEL ,
57935819 CAM_SYNC_ISP_EVENT_HW_STOP );
57945820 }
5795- list_add_tail ( & req -> list , & ctx -> free_req_list );
5821+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
57965822 }
57975823
57985824 while (!list_empty (& ctx -> wait_req_list )) {
@@ -5809,7 +5835,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
58095835 CAM_SYNC_STATE_SIGNALED_CANCEL ,
58105836 CAM_SYNC_ISP_EVENT_HW_STOP );
58115837 }
5812- list_add_tail ( & req -> list , & ctx -> free_req_list );
5838+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
58135839 }
58145840
58155841 while (!list_empty (& ctx -> active_req_list )) {
@@ -5826,7 +5852,7 @@ static int __cam_isp_ctx_stop_dev_in_activated_unlock(
58265852 CAM_SYNC_STATE_SIGNALED_CANCEL ,
58275853 CAM_SYNC_ISP_EVENT_HW_STOP );
58285854 }
5829- list_add_tail ( & req -> list , & ctx -> free_req_list );
5855+ __cam_isp_ctx_move_req_to_free_list ( ctx , req );
58305856 }
58315857
58325858 ctx_isp -> frame_id = 0 ;
0 commit comments