* [PATCH] mailbox: mtk-cmdq: Fix runtime PM leak in cmdq_mbox_flush()
@ 2026-09-17 9:39 Wentao Liang
2026-10-12 1:36 ` Jassi Brar
0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 9:39 UTC (permalink / raw)
To: angelogioacchino.delregno
Cc: bibby.hsieh, ck.hu, jassisinghbrar, linux-arm-kernel,
linux-kernel, linux-mediatek, matthias.bgg, Wentao Liang, stable
pm_runtime_get_sync() leaves the runtime PM usage counter incremented
even when it fails, but cmdq_mbox_flush() returns the error without
dropping it. The same happens when the GCE thread does not drain in
time and the function bails out with -EFAULT.
Undo the reference on both error paths.
Fixes: b0524f7c9635 ("mailbox: mediatek: implement flush function")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index eadd340f8fee..07a8c2382c93 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -565,8 +565,10 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
int ret;
ret = pm_runtime_get_sync(cmdq->mbox.dev);
- if (ret < 0)
+ if (ret < 0) {
+ pm_runtime_put_noidle(cmdq->mbox.dev);
return ret;
+ }
spin_lock_irqsave(&thread->chan->lock, flags);
if (list_empty(&thread->task_busy_list))
@@ -603,6 +605,9 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
dev_err(cmdq->mbox.dev, "Fail to wait GCE thread 0x%x done\n",
(u32)(thread->base - cmdq->base));
+ pm_runtime_mark_last_busy(cmdq->mbox.dev);
+ pm_runtime_put_autosuspend(cmdq->mbox.dev);
+
return -EFAULT;
}
pm_runtime_mark_last_busy(cmdq->mbox.dev);
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] mailbox: mtk-cmdq: Fix runtime PM leak in cmdq_mbox_flush()
2026-09-17 9:39 [PATCH] mailbox: mtk-cmdq: Fix runtime PM leak in cmdq_mbox_flush() Wentao Liang
@ 2026-10-12 1:36 ` Jassi Brar
0 siblings, 0 replies; 2+ messages in thread
From: Jassi Brar @ 2026-10-12 1:36 UTC (permalink / raw)
To: Wentao Liang
Cc: angelogioacchino.delregno, bibby.hsieh, ck.hu, linux-arm-kernel,
linux-kernel, linux-mediatek, matthias.bgg, stable
On Thu, Sep 17, 2026 at 4:39 AM Wentao Liang <vulab@iscas.ac.cn> wrote:
>
> pm_runtime_get_sync() leaves the runtime PM usage counter incremented
> even when it fails, but cmdq_mbox_flush() returns the error without
> dropping it. The same happens when the GCE thread does not drain in
> time and the function bails out with -EFAULT.
>
> Undo the reference on both error paths.
>
> Fixes: b0524f7c9635 ("mailbox: mediatek: implement flush function")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
> drivers/mailbox/mtk-cmdq-mailbox.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index eadd340f8fee..07a8c2382c93 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -565,8 +565,10 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
> int ret;
>
> ret = pm_runtime_get_sync(cmdq->mbox.dev);
> - if (ret < 0)
> + if (ret < 0) {
> + pm_runtime_put_noidle(cmdq->mbox.dev);
> return ret;
> + }
>
> spin_lock_irqsave(&thread->chan->lock, flags);
> if (list_empty(&thread->task_busy_list))
> @@ -603,6 +605,9 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)
> dev_err(cmdq->mbox.dev, "Fail to wait GCE thread 0x%x done\n",
> (u32)(thread->base - cmdq->base));
>
> + pm_runtime_mark_last_busy(cmdq->mbox.dev);
> + pm_runtime_put_autosuspend(cmdq->mbox.dev);
> +
> return -EFAULT;
> }
> pm_runtime_mark_last_busy(cmdq->mbox.dev);
> --
> 2.34.1
>
Applied to mailbox/for-next
Thanks
Jassi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-12 1:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-17 9:39 [PATCH] mailbox: mtk-cmdq: Fix runtime PM leak in cmdq_mbox_flush() Wentao Liang
2026-10-12 1:36 ` Jassi Brar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®