[mpp]: fixup for the deadlock in decoding

When the input stream is full, it may happen:
1. Both mTheadHal(hal) and mThreadCodec(parser) is waiting
 a signal;
2. The previous task is not ready in parser;
3. A task is in idle and the other is done is the tasks group.

If the parser has finished the checking on the task is done but
has not enter into wait condition state yet, then the hal thread
can't wake the parser later.

Change-Id: I3b30e40bc1de7c5ca6d401084929cfd57ca00546
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
This commit is contained in:
Randy Li
2017-08-01 16:43:48 +08:00
committed by Herman Chen
parent e6ade9b712
commit c8394f0203

View File

@@ -101,7 +101,9 @@ static MPP_RET check_task_wait(MppDec *dec, DecTask *task)
if (task->wait.task_hnd || if (task->wait.task_hnd ||
task->wait.mpp_pkt_in || task->wait.mpp_pkt_in ||
task->wait.prev_task || /* Re-check */
(task->wait.prev_task &&
!hal_task_check_empty(dec->tasks, TASK_PROC_DONE)) ||
task->wait.info_change || task->wait.info_change ||
task->wait.dec_pic_buf) task->wait.dec_pic_buf)
return MPP_NOK; return MPP_NOK;
@@ -606,6 +608,7 @@ void *mpp_dec_hal_thread(void *data)
{ {
Mpp *mpp = (Mpp*)data; Mpp *mpp = (Mpp*)data;
MppThread *hal = mpp->mThreadHal; MppThread *hal = mpp->mThreadHal;
MppThread *parser = mpp->mThreadCodec;
MppDec *dec = mpp->mDec; MppDec *dec = mpp->mDec;
HalTaskGroup tasks = dec->tasks; HalTaskGroup tasks = dec->tasks;
MppBufSlots frame_slots = dec->frame_slots; MppBufSlots frame_slots = dec->frame_slots;
@@ -677,7 +680,11 @@ void *mpp_dec_hal_thread(void *data)
mpp_buf_slot_clr_flag(packet_slots, task_dec->input, mpp_buf_slot_clr_flag(packet_slots, task_dec->input,
SLOT_HAL_INPUT); SLOT_HAL_INPUT);
// TODO: may have risk here /*
* TODO: Locking the parser thread will prevent it fetching a
* new task. I wish there be a better way here.
*/
parser->lock();
hal_task_hnd_set_status(task, TASK_PROC_DONE); hal_task_hnd_set_status(task, TASK_PROC_DONE);
task = NULL; task = NULL;
if (dec->parser_fast_mode) { if (dec->parser_fast_mode) {
@@ -687,6 +694,7 @@ void *mpp_dec_hal_thread(void *data)
} }
} }
mpp->mThreadCodec->signal(); mpp->mThreadCodec->signal();
parser->unlock();
mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT); mpp_buf_slot_clr_flag(frame_slots, task_dec->output, SLOT_HAL_OUTPUT);
for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) { for (RK_U32 i = 0; i < MPP_ARRAY_ELEMS(task_dec->refer); i++) {