Public bug reported:

Description: Ubuntu 24.04.4 LTS
Release: 24.04

Package version (apt-cache policy):
 linux-image-6.8.0-1006-mtk:
  Installed: 6.8.0-1006.6
 linux-mtk:
  Installed: 6.8.0.1006.6
  Candidate: 6.8.0.1007.7
       500 https://ppa.launchpadcontent.net/baoshan-team/baoshan-release/ubuntu 
noble/main arm64 Packages

Also present in 6.8.0-1007.7 (current release in the baoshan-
team/baoshan-release PPA): the stock mtk-mdp3 module in 1007.7 has the
same srcversion (E4875CBE0AFC043DF84A94F) as in 1006.6, i.e. the driver
source is unchanged and the bug is still there.

Expected:
Concurrent V4L2 M2M jobs on the MDP keep running at the source frame rate (25 
fps per stream). A job waiting in mdp_alg_process() starts as soon as the 
previous ALG job has been released.

What happened instead:
All MDP M2M contexts stop together for 2.00-2.06 s (the wait_event_timeout in 
mdp_alg_process()) while the hardware is idle, then catch up in a burst. No 
error is logged.

Hardware: 
MediaTek Genio 720 EVK (MT8391), Ubuntu 24.04 Genio image 20260506

Symptom: 
With several V4L2 M2M contexts on the MDP (/dev/video* "mtk-mdp3:m2m") running 
at the same time, every context periodically stops for 2.00-2.06 s and then 
catches up in a burst. It happens about once a minute with 3 streams and 7–17 
times per 5 minutes with 4. 

Reproduce:
Run 3-4 of these pipelines concurrently (MJPEG 1280x720 at 25 fps sources):

... ! jpegparse ! v4l2jpegdec ! v4l2convert !
video/x-raw,format=BGR,width=640,height=640 ! fakesink

Trace v4l2:v4l2_dqbuf for the MDP device: CAPTURE dequeues stop for
about 2 s on all contexts at once, with OUTPUT buffers queued and
CAPTURE buffers free. The GCE (mtk_cmdq) interrupts also stop, so the
hardware is idle.

Root cause:
(drivers/media/platform/mediatek/mdp3/mdp_alg_core.c) mdp_alg_process() waits 
for job_count[MDP_CMDQ_USER_ALG] to reach zero:
wait_event_timeout(callback_wq, !atomic_read(&job_count[ALG]), 2 * HZ);

cmdq_release_work() calls mdp_m2m_process_done() first, which frees the m2m 
slot, and decrements job_count afterwards. It never calls 
wake_up(&mdp->callback_wq). A job started from another context's QBUF in that 
window (about 50 µs) reads a count of 1, sleeps, is never woken, and runs only 
when the 2 s timeout expires, at which point the condition is true, so no error 
is logged. 
The sibling mdp_cmdq_release_work() in mtk-mdp3-cmdq.c does call wake_up(). 
Confirmed with kernel stacks (thread in D state in mdp_alg_process for 2.02 s) 
and function tracing of cmdq_release_work / mdp_m2m_process_done / 
mdp_alg_process across 18 stalls.


Fix

--- a/drivers/media/platform/mediatek/mdp3/mdp_alg_core.c
+++ b/drivers/media/platform/mediatek/mdp3/mdp_alg_core.c
@@ static void cmdq_release_work(struct mdp_alg_cmdq *cmd)
        atomic_dec(&mdp->job_count[MDP_CMDQ_USER_ALG]);
+       wake_up(&mdp->callback_wq);

Verification (module rebuilt from tag Ubuntu-mtk-6.8.0-1006.6 with only
this change)

4 concurrent streams for 300 s: 0 gaps over 200 ms on the MDP.
Application with 4 camera streams has 99.9 fps total. Stock gives
74.8-90.8 fps with windows down to 5 fps.

** Affects: linux-mtk (Ubuntu)
     Importance: Undecided
         Status: New

** Patch added: "0001-mdp3-wake-alg-waiters.patch"
   
https://bugs.launchpad.net/bugs/2173864/+attachment/6016688/+files/0001-mdp3-wake-alg-waiters.patch

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2173864

Title:
  mtk-mdp3: missing wake_up() in ALG cmdq_release_work() stalls all M2M
  jobs for 2 s

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-mtk/+bug/2173864/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to