[PATCH v7 12/20] soc: mediatek: Add programming flow for unsupported subsys ID hardware
AngeloGioacchino Del Regno
angelogioacchino.delregno at collabora.com
Thu Oct 9 04:41:28 PDT 2025
Il 27/08/25 13:37, Jason-JH Lin ha scritto:
> To support hardware without subsys IDs on new SoCs, add a programming
> flow that checks whether the subsys ID is valid.
>
> If the subsys ID is valid, the flow will call cmdq_pkt_write_subsys()
> and cmdq_pkt_write_mask_subsys() instead of the original
> cmdq_pkt_write() and cmdq_pkt_write_mask().
>
> If the subsys ID is invalid, the flow will call cmdq_pkt_write_pa() and
> cmdq_pkt_write_mask_pa() to achieve the same functionality.
>
> Signed-off-by: Jason-JH Lin <jason-jh.lin at mediatek.com>
> ---
> drivers/soc/mediatek/mtk-mmsys.c | 12 +++++++++---
> drivers/soc/mediatek/mtk-mutex.c | 8 ++++++--
> 2 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
> index bb4639ca0b8c..0c324846e334 100644
> --- a/drivers/soc/mediatek/mtk-mmsys.c
> +++ b/drivers/soc/mediatek/mtk-mmsys.c
> @@ -167,9 +167,15 @@ static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask,
> u32 tmp;
>
> if (mmsys->cmdq_base.size && cmdq_pkt) {
> - ret = cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys,
> - mmsys->cmdq_base.offset + offset, val,
> - mask);
> + offset += mmsys->cmdq_base.offset;
> + if (mmsys->cmdq_base.subsys != CMDQ_SUBSYS_INVALID)
> + ret = cmdq_pkt_write_mask_subsys(cmdq_pkt, mmsys->cmdq_base.subsys,
> + mmsys->cmdq_base.pa_base, offset,
> + val, mask);
> + else /* only MMIO access, no need to check mminfro_offset */
nit: fix typo -> mminfra_offset
and also it would be nice if you could also say in a comment that all GCEs support
write_mask_pa() without subsys, but it is less performant - so for the platforms
that do support it, we prefer using it.
Of course that has to be properly reworded, but that's the idea anyway :-)
after which
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
> + ret = cmdq_pkt_write_mask_pa(cmdq_pkt, mmsys->cmdq_base.subsys,
> + mmsys->cmdq_base.pa_base, offset, val, mask);
> +
> if (ret)
> pr_debug("CMDQ unavailable: using CPU write\n");
> else
> diff --git a/drivers/soc/mediatek/mtk-mutex.c b/drivers/soc/mediatek/mtk-mutex.c
> index 38179e8cd98f..9b22d7e09d99 100644
> --- a/drivers/soc/mediatek/mtk-mutex.c
> +++ b/drivers/soc/mediatek/mtk-mutex.c
> @@ -990,6 +990,7 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt)
> struct mtk_mutex_ctx *mtx = container_of(mutex, struct mtk_mutex_ctx,
> mutex[mutex->id]);
> struct cmdq_pkt *cmdq_pkt = (struct cmdq_pkt *)pkt;
> + dma_addr_t en_addr = mtx->addr + DISP_REG_MUTEX_EN(mutex->id);
>
> WARN_ON(&mtx->mutex[mutex->id] != mutex);
>
> @@ -998,8 +999,11 @@ int mtk_mutex_enable_by_cmdq(struct mtk_mutex *mutex, void *pkt)
> return -ENODEV;
> }
>
> - cmdq_pkt_write(cmdq_pkt, mtx->cmdq_reg.subsys,
> - mtx->addr + DISP_REG_MUTEX_EN(mutex->id), 1);
> + if (mtx->cmdq_reg.subsys != CMDQ_SUBSYS_INVALID)
> + cmdq_pkt_write_subsys(cmdq_pkt, mtx->cmdq_reg.subsys, en_addr, en_addr, 1);
> + else /* only MMIO access, no need to check mminfro_offset */
> + cmdq_pkt_write_pa(cmdq_pkt, mtx->cmdq_reg.subsys, en_addr, en_addr, 1);
> +
> return 0;
> }
> EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq);
More information about the Linux-mediatek
mailing list