[PATCH 2/2] mailbox: mtk-cmdq: Move pm_runimte_get and put to mbox_chan_ops API

Jason-JH Lin (林睿祥) Jason-JH.Lin at mediatek.com
Wed Jul 3 09:41:41 PDT 2024


On Thu, 2024-06-27 at 22:40 -0500, Jassi Brar wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On Wed, Jun 26, 2024 at 4:32 AM Jason-JH Lin (林睿祥)
> <Jason-JH.Lin at mediatek.com> wrote:
> > >
> > > The idea is that
> > > 1) If the gap between transfers on a busy channel is ~10ms or
> > > more.  And ..
> > > 2) The silence on the mailbox channel is multiple of 100ms. And
> ...
> >
> > The mailbox channel would not be always busy and the gap is not
> > consistent as well.
> > For example, display driver calls mbox_send_message() every ~16ms
> while
> > UI is updating in 60fps.
> > If UI dose not update, display driver won't call
> mbox_send_message(),
> > so user may not has the gap and the silence like this.
> >
> From your logs, send_diff only increases from 16ms if the UI is not
> updating. Which makes it more prudent to release the channel.
> 
> The user needs the channel for mbox_send_message, while actual power
> saving comes from cmdq_runtime_suspend/resume.
> So for your target usage pattern, trace mbox_send_message() ,
> cmdq_runtime_resume() and cmdq_runtime_suspend() and compare the
> timestamped logs with and without this patchset.
> 
[snip]

I realized that we have 2 cmdq drivers:
display uses 10320000.mailbox and imgsys uses 10330000.mailbox

I added diff logs in cmdq_runtime_resume(), cmdq_runtime_suspend()
and cmdq_mbox_send_data().

Here is the log of 10320000.mailbox:
// CMDQ probe
[    4.288408] mtk_cmdq 10320000.mailbox: IRQ=279++++++++++++++
// Show boot logo
[    9.177741] cmdq_runtime_resume: resume_diff=9177 ms
[    9.698045] cmdq_mbox_send_data: send_diff=14 ms
// Show UI     
[   15.620525] cmdq_mbox_send_data: send_diff=5922 ms
[   15.652041] cmdq_mbox_send_data: send_diff=31 ms
[   15.681308] cmdq_mbox_send_data: send_diff=29 ms
[   16.276090] cmdq_mbox_send_data: send_diff=594 ms
[   16.355256] cmdq_mbox_send_data: send_diff=79 ms
...            
[   35.013395] cmdq_mbox_send_data: send_diff=16 ms
[   35.030301] cmdq_mbox_send_data: send_diff=16 ms
[   35.047002] cmdq_mbox_send_data: send_diff=16 ms
[   35.068360] cmdq_mbox_send_data: send_diff=21 ms
// Open camera APP
[   37.291937] cmdq_mbox_send_data: send_diff=2223 ms
[   37.884435] cmdq_mbox_send_data: send_diff=592 ms
[   37.905703] cmdq_mbox_send_data: send_diff=21 ms
[   37.928599] cmdq_mbox_send_data: send_diff=22 ms
...
[   41.396577] cmdq_mbox_send_data: send_diff=16 ms
[   41.413107] cmdq_mbox_send_data: send_diff=16 ms
[   42.440862] cmdq_mbox_send_data: send_diff=1027 ms
[   42.647045] cmdq_mbox_send_data: send_diff=206 ms
// Close camera APP
[   89.940631] cmdq_mbox_send_data: send_diff=47293 ms
[  106.704928] cmdq_mbox_send_data: send_diff=16764 ms
...
[  113.130841] cmdq_mbox_send_data: send_diff=211 ms
// push power key to disable panel
[  113.281999] cmdq_runtime_suspend: R/S_diff=104104 ms
// push power key to enable panel
[  131.287190] cmdq_runtime_resume: resume_diff=122109 ms


Here is the log of 10330000.mailbox:
// CMDQ probe
[    4.290404] mtk_cmdq 10330000.mailbox: IRQ=280++++++++++++++
// Open camera APP
[   36.174867] BUG: sleeping function called from invalid context at
drivers/base/power/runtime.c:1164
[   36.183942] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid:
95, name: kworker/u17:0
[   36.192383] preempt_count: 1, expected: 0
[   36.196395] RCU nest depth: 0, expected: 0
[   36.200489] INFO: lockdep is turned off.
[   36.204405] irq event stamp: 16
[   36.238636] CPU: 2 PID: 95 Comm: kworker/u17:0 Not tainted
[   36.251508] Hardware name: Google Ciri sku0/unprovisioned board (DT)
[   36.257864] Workqueue: imgsys_runner imgsys_runner_func
[   36.263107] Call trace:
[   36.265555]  dump_backtrace+0x100/0x120
[   36.269400]  show_stack+0x20/0x2c
[   36.272722]  dump_stack_lvl+0x84/0xb4
[   36.276390]  dump_stack+0x18/0x44
[   36.279706]  __might_resched+0x204/0x214
[   36.283631]  __might_sleep+0x50/0x80
[   36.287209]  __pm_runtime_resume+0x48/0xbc
[   36.291316]  cmdq_mbox_send_data+0x84/0x43c
[   36.295510]  msg_submit+0x84/0x104
[   36.298919]  mbox_send_message+0xb8/0x124
[   36.302934]  imgsys_cmdq_sendtask+0x6b0/0x990
[   36.307300]  imgsys_runner_func+0x44/0x78
[   36.311318]  process_one_work+0x274/0x574
[   36.315336]  worker_thread+0x240/0x3f0
[   36.319093]  kthread+0xfc/0x11c
[   36.322242]  ret_from_fork+0x10/0x20
[   36.325989] cmdq_runtime_resume: resume_diff=36325 ms
[   36.342235] cmdq_mbox_send_data: send_diff=167 ms
[   36.366714] cmdq_mbox_send_data: send_diff=24 ms
[   36.382882] cmdq_mbox_send_data: send_diff=16 ms
[   36.399512] cmdq_mbox_send_data: send_diff=16 ms
...
[   42.817244] cmdq_mbox_send_data: send_diff=16 ms
[   42.844891] cmdq_mbox_send_data: send_diff=27 ms
[   42.856340] cmdq_mbox_send_data: send_diff=11 ms
[   42.856364] cmdq_mbox_send_data: send_diff=0 ms
[   42.856384] cmdq_mbox_send_data: send_diff=0 ms
[   42.856410] cmdq_mbox_send_data: send_diff=0 ms
[   42.856431] cmdq_mbox_send_data: send_diff=0 ms
[   42.856458] cmdq_mbox_send_data: send_diff=0 ms
[   42.856482] cmdq_mbox_send_data: send_diff=0 ms
[   42.985695] cmdq_mbox_send_data: send_diff=129 ms
[   42.992017] cmdq_runtime_suspend: R/S_diff=6666 ms

Regards,
Jason-JH.Lin


More information about the linux-arm-kernel mailing list