* [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers
@ 2026-12-01 11:23 Jason-JH Lin
2026-12-01 15:22 ` Roman Vivchar
2026-12-02 4:15 ` Fei Shao
0 siblings, 2 replies; 4+ messages in thread
From: Jason-JH Lin @ 2026-12-01 11:23 UTC (permalink / raw)
To: Chun-Kuang Hu, AngeloGioacchino Del Regno, Matthias Brugger
Cc: Jassi Brar, Jason-JH Lin, Paul-PL Chen, Zi-Hao Huang, Olivia Wen,
Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
linux-kernel, linux-mediatek, linux-arm-kernel, stable
From: Jason-jh Lin <jason-jh.lin@mediatek.com>
cmdq_pkt_write_pa() and cmdq_pkt_write_mask_pa() build the WRITE_S
target address as SPR << 16 | (arg & ~BIT(1)), but only load the SPR
with CMDQ_ADDR_HIGH(pa_base) and pass only the register offset as the
WRITE_S argument. When pa_base is not 64K aligned, its low 16 bits are
lost and the write lands at (pa_base & ~0xffff) + offset, while the
packet still runs to EOC without error.
Fold pa_base + offset into both halves, so the SPR gets
CMDQ_ADDR_HIGH(pa_base + offset) and the WRITE_S argument gets
CMDQ_ADDR_LOW(pa_base + offset).
Fixes: 40dc5bbad63b ("soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID")
Cc: stable@vger.kernel.org
Signed-off-by: Jason-jh Lin <jason-jh.lin@mediatek.com>
---
drivers/soc/mediatek/mtk-cmdq-helper.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index fb82f2a85a21..99d5750b6dc4 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -247,11 +247,12 @@ int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/, u32 pa_base,
{
int err;
- err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base));
+ err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base + offset));
if (err < 0)
return err;
- return cmdq_pkt_write_s_value(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_LOW(offset), value);
+ return cmdq_pkt_write_s_value(pkt, CMDQ_THR_SPR_IDX0,
+ CMDQ_ADDR_LOW(pa_base + offset), value);
}
EXPORT_SYMBOL(cmdq_pkt_write_pa);
@@ -284,12 +285,12 @@ int cmdq_pkt_write_mask_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/, u32 pa_ba
{
int err;
- err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base));
+ err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base + offset));
if (err < 0)
return err;
return cmdq_pkt_write_s_mask_value(pkt, CMDQ_THR_SPR_IDX0,
- CMDQ_ADDR_LOW(offset), value, mask);
+ CMDQ_ADDR_LOW(pa_base + offset), value, mask);
}
EXPORT_SYMBOL(cmdq_pkt_write_mask_pa);
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers
2026-12-01 11:23 [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers Jason-JH Lin
@ 2026-12-01 15:22 ` Roman Vivchar
2026-12-02 4:15 ` Fei Shao
1 sibling, 0 replies; 4+ messages in thread
From: Roman Vivchar @ 2026-12-01 15:22 UTC (permalink / raw)
To: Jason-JH Lin
Cc: Chun-Kuang Hu, AngeloGioacchino Del Regno, Matthias Brugger,
Project_Global_Chrome_Upstream_Group, Jassi Brar, linux-kernel,
Zi-Hao Huang, Olivia Wen, Paul-PL Chen, linux-mediatek, stable,
Chen-yu Tsai, linux-arm-kernel
Hi,
On Tuesday, December 1st, 2026 at 1:25 PM, Jason-JH Lin <jason-jh.lin@mediatek.com> wrote:
> From: Jason-jh Lin <jason-jh.lin@mediatek.com>
>
> cmdq_pkt_write_pa() and cmdq_pkt_write_mask_pa() build the WRITE_S
> target address as SPR << 16 | (arg & ~BIT(1)), but only load the SPR
> with CMDQ_ADDR_HIGH(pa_base) and pass only the register offset as the
> WRITE_S argument. When pa_base is not 64K aligned, its low 16 bits are
> lost and the write lands at (pa_base & ~0xffff) + offset, while the
> packet still runs to EOC without error.
>
> Fold pa_base + offset into both halves, so the SPR gets
> CMDQ_ADDR_HIGH(pa_base + offset) and the WRITE_S argument gets
> CMDQ_ADDR_LOW(pa_base + offset).
>
> Fixes: 40dc5bbad63b ("soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jason-jh Lin <jason-jh.lin@mediatek.com>
> ---
Reviewed-by: Roman Vivchar <rva333@protonmail.com>
Best regards,
Roman
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers
2026-12-01 11:23 [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers Jason-JH Lin
2026-12-01 15:22 ` Roman Vivchar
@ 2026-12-02 4:15 ` Fei Shao
2026-12-02 10:01 ` Jason-JH Lin (林睿祥)
1 sibling, 1 reply; 4+ messages in thread
From: Fei Shao @ 2026-12-02 4:15 UTC (permalink / raw)
To: Jason-JH Lin
Cc: Chun-Kuang Hu, AngeloGioacchino Del Regno, Matthias Brugger,
Jassi Brar, Paul-PL Chen, Zi-Hao Huang, Olivia Wen, Chen-yu Tsai,
Project_Global_Chrome_Upstream_Group, linux-kernel,
linux-mediatek, linux-arm-kernel, stable
On Tue, Dec 1, 2026 at 7:25 PM Jason-JH Lin <jason-jh.lin@mediatek.com> wrote:
>
> From: Jason-jh Lin <jason-jh.lin@mediatek.com>
>
> cmdq_pkt_write_pa() and cmdq_pkt_write_mask_pa() build the WRITE_S
> target address as SPR << 16 | (arg & ~BIT(1)), but only load the SPR
> with CMDQ_ADDR_HIGH(pa_base) and pass only the register offset as the
> WRITE_S argument. When pa_base is not 64K aligned, its low 16 bits are
> lost and the write lands at (pa_base & ~0xffff) + offset, while the
> packet still runs to EOC without error.
>
> Fold pa_base + offset into both halves, so the SPR gets
> CMDQ_ADDR_HIGH(pa_base + offset) and the WRITE_S argument gets
> CMDQ_ADDR_LOW(pa_base + offset).
>
> Fixes: 40dc5bbad63b ("soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID")
> Cc: stable@vger.kernel.org
> Signed-off-by: Jason-jh Lin <jason-jh.lin@mediatek.com>
> ---
> drivers/soc/mediatek/mtk-cmdq-helper.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
Reviewed-by: Fei Shao <fshao@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers
2026-12-02 4:15 ` Fei Shao
@ 2026-12-02 10:01 ` Jason-JH Lin (林睿祥)
0 siblings, 0 replies; 4+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2026-12-02 10:01 UTC (permalink / raw)
To: fshao, rva333
Cc: linux-kernel, chunkuang.hu, Project_Global_Chrome_Upstream_Group,
AngeloGioacchino Del Regno,
Zi-hao Huang (黃梓豪),
Paul-pl Chen (陳柏霖),
jassisinghbrar, wenst, matthias.bgg, linux-mediatek,
Olivia Wen (温倩苓),
stable, linux-arm-kernel
On Wed, 2026-12-02 at 12:15 +0800, Fei Shao wrote:
> On Tue, Dec 1, 2026 at 7:25 PM Jason-JH Lin
> <jason-jh.lin@mediatek.com> wrote:
> >
> > From: Jason-jh Lin <jason-jh.lin@mediatek.com>
> >
> > cmdq_pkt_write_pa() and cmdq_pkt_write_mask_pa() build the WRITE_S
> > target address as SPR << 16 | (arg & ~BIT(1)), but only load the
> > SPR
> > with CMDQ_ADDR_HIGH(pa_base) and pass only the register offset as
> > the
> > WRITE_S argument. When pa_base is not 64K aligned, its low 16 bits
> > are
> > lost and the write lands at (pa_base & ~0xffff) + offset, while the
> > packet still runs to EOC without error.
> >
> > Fold pa_base + offset into both halves, so the SPR gets
> > CMDQ_ADDR_HIGH(pa_base + offset) and the WRITE_S argument gets
> > CMDQ_ADDR_LOW(pa_base + offset).
> >
> > Fixes: 40dc5bbad63b ("soc: mediatek: mtk-cmdq: Extend
> > cmdq_pkt_write API for SoCs without subsys ID")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Jason-jh Lin <jason-jh.lin@mediatek.com>
> > ---
> > drivers/soc/mediatek/mtk-cmdq-helper.c | 9 +++++----
> > 1 file changed, 5 insertions(+), 4 deletions(-)
>
> Reviewed-by: Fei Shao <fshao@chromium.org>
Hi Fei, Roman,
Thank you for the reviews.
However, I found that callers already do the same thing on their side.
MDP3:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=307673410774d5708232d05a977f047c03e2a4bb
SOC:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=004361f01625fda9f6d4009d0dc5a59e32b7be7d
DDP(not applied):
https://patchwork.kernel.org/project/linux-mediatek/patch/20260325035836.2110757-4-jason-jh.lin@mediatek.com/
Base on the definition to this API, pa_base means the pure base address
of hardware MMIO.
I think the concept of this patch is correct, but I need to modify the
usage for all callers.
I'll send v2 including the callers parts.
If you have any suggestions. Please let me know. Thanks!
Regards,
Jason-JH Lin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-12-02 10:01 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 11:23 [PATCH 1/1] soc: mediatek: mtk-cmdq: Fold the PA low half in write_pa helpers Jason-JH Lin
2026-12-01 15:22 ` Roman Vivchar
2026-12-02 4:15 ` Fei Shao
2026-12-02 10:01 ` Jason-JH Lin (林睿祥)
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®