video: rockchip: mpp: rkvenc2: Fix async msg issue

H.264 encoder will send the task request and wait result in async way.
The task process will be like:
send task 1
send task 2
wait task 1
send task 3
wait task 2
Then the msgs struct will carry the latest task rather than the task in
the pending queue. And free the wrong task structure.

Error log:
[  387.742800][ T1983] list_add corruption. prev->next should be next (ffffff8114ced948), but was ffffff8152228028. (prev=ffffff8152228028).
[  387.742819][ T1983] ------------[ cut here ]------------
[  387.742822][ T1983] kernel BUG at lib/list_debug.c:28!
[  387.742827][ T1983] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[  387.762394][ T1983] Modules linked in: rk_vcodec
[  387.762403][ T1983] CPU: 5 PID: 1983 Comm: mpp_h264e_1982 Not tainted 5.10.66 #103
[  387.762404][ T1983] Hardware name: Rockchip RK3588 EVB1 LP4 V10 Board (DT)
[  387.762408][ T1983] pstate: 60400009 (nZCv daif +PAN -UAO -TCO BTYPE=--)
[  387.762415][ T1983] pc : __list_add_valid+0x94/0x98
[  387.762417][ T1983] lr : __list_add_valid+0x94/0x98
[  387.762419][ T1983] sp : ffffffc018f2bce0
[  387.762421][ T1983] x29: ffffffc018f2bce0 x28: ffffff8114ced948
[  387.762424][ T1983] x27: ffffff8152228028 x26: ffffff8152228028
[  387.762427][ T1983] x25: ffffff8114ced880 x24: ffffff817888a080
[  387.762429][ T1983] x23: ffffff8152228000 x22: ffffff817888a080
[  387.762432][ T1983] x21: ffffffc018f2bd58 x20: ffffff8114ced880
[  387.762435][ T1983] x19: ffffffc018f2bd58 x18: ffffffc018ecd040
[  387.762437][ T1983] x17: 0000000000000000 x16: 00000000000000d8
[  387.762440][ T1983] x15: 0000000000000004 x14: 0000000000003fff
[  387.762443][ T1983] x13: ffffffc011f0cf78 x12: 0000000000000003
[  387.762445][ T1983] x11: 00000000ffffbfff x10: 00000000ffffffff
[  387.762448][ T1983] x9 : 07e69d051dac6800 x8 : 07e69d051dac6800
[  387.762451][ T1983] x7 : 727028202e383230 x6 : ffffffc0120ee318
[  387.762454][ T1983] x5 : ffffffffffffffff x4 : 0000000000000000
[  387.762457][ T1983] x3 : ffffffc011bc4854 x2 : 0000000000000000
[  387.762459][ T1983] x1 : 0000000000000001 x0 : 0000000000000075
[  387.762462][ T1983] Call trace:
[  387.762465][ T1983]  __list_add_valid+0x94/0x98
[  387.762507][ T1983]  mpp_msgs_trigger+0x15c/0x1f0 [rk_vcodec]
[  387.762542][ T1983]  mpp_dev_ioctl+0x4b8/0x5d8 [rk_vcodec]
[  387.762563][ T1983]  __arm64_sys_ioctl+0x94/0xd0
[  387.764333][ T1983]  el0_svc_common+0xc0/0x23c
[  387.764335][ T1983]  do_el0_svc+0x28/0x88
[  387.764339][ T1983]  el0_svc+0x14/0x24
[  387.764342][ T1983]  el0_sync_handler+0x88/0xec
[  387.764344][ T1983]  el0_sync+0x1a8/0x1c0
[  387.764349][ T1983]
[  387.764349][ T1983] PC: 0xffffffc01059b608:

Signed-off-by: Herman Chen <herman.chen@rock-chips.com>
Change-Id: Id55b3b66726a526bca68594ab9a86cc58c265945
This commit is contained in:
Herman Chen
2022-03-12 10:44:59 +08:00
committed by Tao Huang
parent 2094d714b6
commit b5267d2417

View File

@@ -1524,13 +1524,12 @@ static void rkvenc2_task_pop_pending(struct mpp_task *task)
}
static int rkvenc2_task_default_process(struct mpp_dev *mpp,
struct mpp_task_msgs *msgs)
struct mpp_task *task)
{
struct mpp_task *task = msgs->task;
int ret = 0;
if (mpp->dev_ops && mpp->dev_ops->result)
ret = mpp->dev_ops->result(mpp, task, msgs);
ret = mpp->dev_ops->result(mpp, task, NULL);
mpp_debug_func(DEBUG_TASK_INFO, "kref_read %d, ret %d\n",
kref_read(&task->ref), ret);
@@ -1584,7 +1583,7 @@ task_done_ret:
msecs_to_jiffies(RKVENC2_WAIT_TIMEOUT_DELAY));
if (ret > 0)
return rkvenc2_task_default_process(mpp, msgs);
return rkvenc2_task_default_process(mpp, task);
rkvenc2_task_timeout_process(session, task);
return ret;