[PATCH v7 12/20] soc: mediatek: Add programming flow for unsupported subsys ID hardware

Jason-JH Lin (林睿祥) Jason-JH.Lin at mediatek.com
Mon Oct 13 02:22:42 PDT 2025


On Thu, 2025-10-09 at 13:41 +0200, AngeloGioacchino Del Regno wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> 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
> 

Thanks! I'll fix this.

> 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 :-)
> 

OK, I'll add more comment for this and other client drivers.

/*
 * Only MMIO access, no need to check mminfra_offset.
 *
 * All GCEs support writing register PA with mask without subsys,
 * but this requires extra GCE instructions to convert the PA into
 * a format that GCE can handle, which is less performance than
 * directly using subsys. Therefore, when subsys is available,
 * we prefer to use subsys for writing register PA.
 */

Regards,
Jason-JH Lin

> after which
> 
> Reviewed-by: AngeloGioacchino Del Regno
> <angelogioacchino.delregno at collabora.com>



More information about the Linux-mediatek mailing list