video: rockchip: mpp: fix rkvenc2 run crash issue

Calling an interface containing mutex lock after
schedule_preempt_disabled caused the problem.

Call trace:
 dump_backtrace+0xf4/0x118
 show_stack+0x18/0x24
 dump_stack_lvl+0x60/0x7c
 dump_stack+0x18/0x3c
 __schedule_bug+0x6c/0x8c
 __schedule+0x64c/0x9cc
 schedule+0x7c/0xe8
 schedule_preempt_disabled+0x24/0x40
 __mutex_lock+0x224/0xdac
 __mutex_lock_slowpath+0x14/0x24
 mutex_lock+0x40/0xec
 clk_get_rate+0x50/0x134
 rkvenc_run+0x4ec/0x728 [rk_vcodec]
 mpp_task_worker_default+0x2b4/0x494 [rk_vcodec]
 kthread_worker_fn+0x10c/0x244
 kthread+0x104/0x1d4
 ret_from_fork+0x10/0x20

Fixes: ca7fd65693 ("video: rockchip: mpp: rkvenc2: optimize iommu fault handle")
Signed-off-by: Yandong Lin <yandong.lin@rock-chips.com>
Change-Id: I1bceea441495a1c6c94776a648601d670b7a29d2
This commit is contained in:
Yandong Lin
2023-11-06 16:03:36 +08:00
committed by Tao Huang
parent 59cc6c2107
commit d9794ef01e

View File

@@ -1246,11 +1246,6 @@ static int rkvenc_run(struct mpp_dev *mpp, struct mpp_task *mpp_task)
/* init current task */
mpp->cur_task = mpp_task;
mpp_task_run_begin(mpp_task, timing_en, MPP_WORK_TIMEOUT_DELAY);
/* Flush the register before the start the device */
wmb();
/*
* reconfig timeout threshold.
* bit0-bit23,x1024 core clk cycles
@@ -1258,6 +1253,11 @@ static int rkvenc_run(struct mpp_dev *mpp, struct mpp_task *mpp_task)
timeout_thd = mpp_read(mpp, RKVENC_WDG) & 0xff000000;
timeout_thd |= TIMEOUT_MS * clk_get_rate(enc->core_clk_info.clk) / 1024000;
mpp_write(mpp, RKVENC_WDG, timeout_thd);
mpp_task_run_begin(mpp_task, timing_en, MPP_WORK_TIMEOUT_DELAY);
/* Flush the register before the start the device */
wmb();
mpp_write(mpp, enc->hw_info->enc_start_base, start_val);
mpp_task_run_end(mpp_task, timing_en);