[PATCH] mailbox: mtk-cmdq: Fix CURR and END addr for task insert case

Jason-JH Lin posted 1 patch 1 week, 4 days ago
drivers/mailbox/mtk-cmdq-mailbox.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] mailbox: mtk-cmdq: Fix CURR and END addr for task insert case
Posted by Jason-JH Lin 1 week, 4 days ago
Fix CURR and END address calculation for inserting a cmdq task into the
task list by using cmdq_reg_shift_addr() for proper address converting.
This ensures both CURR and END addresses are set correctly when
enabling the thread.

Fixes: a195c7ccfb7a ("mailbox: mtk-cmdq: Refine DMA address handling for the command buffer")
Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index d7c6b38888a3..547a10a8fad3 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -493,14 +493,14 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)
 		if (curr_pa == end_pa - CMDQ_INST_SIZE ||
 		    curr_pa == end_pa) {
 			/* set to this task directly */
-			writel(task->pa_base >> cmdq->pdata->shift,
-			       thread->base + CMDQ_THR_CURR_ADDR);
+			gce_addr = cmdq_convert_gce_addr(task->pa_base, cmdq->pdata);
+			writel(gce_addr, thread->base + CMDQ_THR_CURR_ADDR);
 		} else {
 			cmdq_task_insert_into_thread(task);
 			smp_mb(); /* modify jump before enable thread */
 		}
-		writel((task->pa_base + pkt->cmd_buf_size) >> cmdq->pdata->shift,
-		       thread->base + CMDQ_THR_END_ADDR);
+		gce_addr = cmdq_convert_gce_addr(task->pa_base + pkt->cmd_buf_size, cmdq->pdata);
+		writel(gce_addr, thread->base + CMDQ_THR_END_ADDR);
 		cmdq_thread_resume(thread);
 	}
 	list_move_tail(&task->list_entry, &thread->task_busy_list);
-- 
2.43.0
Re: [PATCH] mailbox: mtk-cmdq: Fix CURR and END addr for task insert case
Posted by Jassi Brar 5 days, 3 hours ago
On Mon, Mar 23, 2026 at 4:07 AM Jason-JH Lin <jason-jh.lin@mediatek.com> wrote:
>
> Fix CURR and END address calculation for inserting a cmdq task into the
> task list by using cmdq_reg_shift_addr() for proper address converting.
> This ensures both CURR and END addresses are set correctly when
> enabling the thread.
>
> Fixes: a195c7ccfb7a ("mailbox: mtk-cmdq: Refine DMA address handling for the command buffer")
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/mailbox/mtk-cmdq-mailbox.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
> index d7c6b38888a3..547a10a8fad3 100644
> --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> @@ -493,14 +493,14 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)
>                 if (curr_pa == end_pa - CMDQ_INST_SIZE ||
>                     curr_pa == end_pa) {
>                         /* set to this task directly */
> -                       writel(task->pa_base >> cmdq->pdata->shift,
> -                              thread->base + CMDQ_THR_CURR_ADDR);
> +                       gce_addr = cmdq_convert_gce_addr(task->pa_base, cmdq->pdata);
> +                       writel(gce_addr, thread->base + CMDQ_THR_CURR_ADDR);
>                 } else {
>                         cmdq_task_insert_into_thread(task);
>                         smp_mb(); /* modify jump before enable thread */
>                 }
> -               writel((task->pa_base + pkt->cmd_buf_size) >> cmdq->pdata->shift,
> -                      thread->base + CMDQ_THR_END_ADDR);
> +               gce_addr = cmdq_convert_gce_addr(task->pa_base + pkt->cmd_buf_size, cmdq->pdata);
> +               writel(gce_addr, thread->base + CMDQ_THR_END_ADDR);
>                 cmdq_thread_resume(thread);
>         }
>         list_move_tail(&task->list_entry, &thread->task_busy_list);
> --
> 2.43.0
>
Applied to mailbox/for-next
Thanks
Jassi