@@ -177,29 +177,20 @@ void vdec_msg_queue_update_ube_wptr(struct vdec_msg_queue *msg_queue, uint64_t u
177177
178178bool vdec_msg_queue_wait_lat_buf_full (struct vdec_msg_queue * msg_queue )
179179{
180- struct vdec_lat_buf * buf , * tmp ;
181- struct list_head * list_core [3 ];
182- struct vdec_msg_queue_ctx * core_ctx ;
183- int ret , i , in_core_count = 0 , count = 0 ;
180+ int ret ;
184181 long timeout_jiff ;
185182
186- core_ctx = & msg_queue -> ctx -> dev -> msg_queue_core_ctx ;
187- spin_lock (& core_ctx -> ready_lock );
188- list_for_each_entry_safe (buf , tmp , & core_ctx -> ready_queue , core_list ) {
189- if (buf && buf -> ctx == msg_queue -> ctx ) {
190- list_core [in_core_count ++ ] = & buf -> core_list ;
191- list_del (& buf -> core_list );
192- }
193- }
194-
195- for (i = 0 ; i < in_core_count ; i ++ ) {
196- list_add (list_core [in_core_count - (1 + i )], & core_ctx -> ready_queue );
197- queue_work (msg_queue -> ctx -> dev -> core_workqueue , & msg_queue -> core_work );
183+ if (atomic_read (& msg_queue -> lat_list_cnt ) == NUM_BUFFER_COUNT ) {
184+ mtk_v4l2_debug (3 , "wait buf full: list(%d %d) ready_num:%d status:%d" ,
185+ atomic_read (& msg_queue -> lat_list_cnt ),
186+ atomic_read (& msg_queue -> core_list_cnt ),
187+ msg_queue -> lat_ctx .ready_num ,
188+ msg_queue -> status );
189+ return true;
198190 }
199- spin_unlock (& core_ctx -> ready_lock );
200191
201192 timeout_jiff = msecs_to_jiffies (1000 * (NUM_BUFFER_COUNT + 2 ));
202- ret = wait_event_timeout (msg_queue -> ctx -> msg_queue . core_dec_done ,
193+ ret = wait_event_timeout (msg_queue -> core_dec_done ,
203194 msg_queue -> lat_ctx .ready_num == NUM_BUFFER_COUNT ,
204195 timeout_jiff );
205196 if (ret ) {
@@ -208,18 +199,9 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue *msg_queue)
208199 return true;
209200 }
210201
211- spin_lock (& core_ctx -> ready_lock );
212- list_for_each_entry_safe (buf , tmp , & core_ctx -> ready_queue , core_list ) {
213- if (buf && buf -> ctx == msg_queue -> ctx ) {
214- count ++ ;
215- list_del (& buf -> core_list );
216- }
217- }
218- spin_unlock (& core_ctx -> ready_lock );
219-
220- mtk_v4l2_err ("failed with lat buf isn't full: list(%d %d) count:%d" ,
202+ mtk_v4l2_err ("failed with lat buf isn't full: list(%d %d)" ,
221203 atomic_read (& msg_queue -> lat_list_cnt ),
222- atomic_read (& msg_queue -> core_list_cnt ), count );
204+ atomic_read (& msg_queue -> core_list_cnt ));
223205
224206 return false;
225207}
@@ -247,6 +229,8 @@ void vdec_msg_queue_deinit(struct vdec_msg_queue *msg_queue,
247229
248230 kfree (lat_buf -> private_data );
249231 }
232+
233+ cancel_work_sync (& msg_queue -> core_work );
250234}
251235
252236static void vdec_msg_queue_core_work (struct work_struct * work )
@@ -258,11 +242,11 @@ static void vdec_msg_queue_core_work(struct work_struct *work)
258242 struct mtk_vcodec_dev * dev = ctx -> dev ;
259243 struct vdec_lat_buf * lat_buf ;
260244
261- spin_lock (& ctx -> dev -> msg_queue_core_ctx .ready_lock );
245+ spin_lock (& msg_queue -> core_ctx .ready_lock );
262246 ctx -> msg_queue .status &= ~CONTEXT_LIST_QUEUED ;
263- spin_unlock (& ctx -> dev -> msg_queue_core_ctx .ready_lock );
247+ spin_unlock (& msg_queue -> core_ctx .ready_lock );
264248
265- lat_buf = vdec_msg_queue_dqbuf (& dev -> msg_queue_core_ctx );
249+ lat_buf = vdec_msg_queue_dqbuf (& msg_queue -> core_ctx );
266250 if (!lat_buf )
267251 return ;
268252
@@ -276,12 +260,11 @@ static void vdec_msg_queue_core_work(struct work_struct *work)
276260 mtk_vcodec_dec_disable_hardware (ctx , MTK_VDEC_CORE );
277261 vdec_msg_queue_qbuf (& ctx -> msg_queue .lat_ctx , lat_buf );
278262
279- wake_up_all (& ctx -> msg_queue .core_dec_done );
280263 if (!(ctx -> msg_queue .status & CONTEXT_LIST_QUEUED ) &&
281264 atomic_read (& msg_queue -> core_list_cnt )) {
282- spin_lock (& ctx -> dev -> msg_queue_core_ctx .ready_lock );
265+ spin_lock (& msg_queue -> core_ctx .ready_lock );
283266 ctx -> msg_queue .status |= CONTEXT_LIST_QUEUED ;
284- spin_unlock (& ctx -> dev -> msg_queue_core_ctx .ready_lock );
267+ spin_unlock (& msg_queue -> core_ctx .ready_lock );
285268 queue_work (ctx -> dev -> core_workqueue , & msg_queue -> core_work );
286269 }
287270}
@@ -297,8 +280,8 @@ int vdec_msg_queue_init(struct vdec_msg_queue *msg_queue,
297280 if (msg_queue -> wdma_addr .size )
298281 return 0 ;
299282
300- msg_queue -> ctx = ctx ;
301283 vdec_msg_queue_init_ctx (& msg_queue -> lat_ctx , MTK_VDEC_LAT0 );
284+ vdec_msg_queue_init_ctx (& msg_queue -> core_ctx , MTK_VDEC_CORE );
302285 INIT_WORK (& msg_queue -> core_work , vdec_msg_queue_core_work );
303286
304287 atomic_set (& msg_queue -> lat_list_cnt , 0 );
0 commit comments