On Thu, 2025-03-06 at 10:47 +0100, AngeloGioacchino Del Regno wrote: > > External email : Please do not click links or open attachments until > you have verified the sender or the content. > > > Il 18/02/25 06:41, 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 > > invalid, the flow will call 2 alternative CMDQ APIs: > > cmdq_pkt_assign() and cmdq_pkt_write_s_value() to achieve the same > > functionality. > > > > Signed-off-by: Jason-JH Lin <jason-jh.lin@xxxxxxxxxxxx> > > Reviewed-by: CK Hu <ck.hu@xxxxxxxxxxxx> > > --- > > drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 33 > > ++++++++++++++++++++----- > > 1 file changed, 27 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c > > b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c > > index edc6417639e6..219d67735a54 100644 > > --- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c > > +++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c > > @@ -66,14 +66,37 @@ struct mtk_ddp_comp_dev { > > struct cmdq_client_reg cmdq_reg; > > }; > > > > +#if IS_REACHABLE(CONFIG_MTK_CMDQ) > > +static void mtk_ddp_write_cmdq_pkt(struct cmdq_pkt *cmdq_pkt, > > struct cmdq_client_reg *cmdq_reg, > > + unsigned int offset, unsigned int > > value, unsigned int mask) > > +{ > > + offset += cmdq_reg->offset; > > + > > + if (cmdq_reg->subsys != CMDQ_SUBSYS_INVALID) { > > + if (mask == GENMASK(31, 0)) > > + cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys, > > offset, value); > > + else > > + cmdq_pkt_write_mask(cmdq_pkt, cmdq_reg- > > >subsys, offset, value, mask); > > Sorry but this is pointless, really... > > Function cmdq_pkt_write_mask() in mtk-cmdq-helper is doing: > > if (mask != GENMASK(31, 0)) { > err = cmdq_pkt_mask(pkt, mask); > if (err < 0) > return err; > > offset_mask |= CMDQ_WRITE_ENABLE_MASK; > } > return cmdq_pkt_write(pkt, subsys, offset_mask, value); > > here you're doing the exact inverse check. > Oh, I didn't notice that it was redundant. Thanks. > At this point you can just do: > > static int mtk_ddp_write_cmdq_pkt(struct cmdq_pkt *cmdq_pkt, struct > cmdq_client_reg > *cmdq_reg, > u16 offset, u32 value, u32 mask) > { > u16 gce_offset = cmdq_reg->offset + offset; > > if (cmdq_reg->subsys != CMDQ_SUBSYS_INVALID) > return cmdq_pkt_write_mask(pkt, cmdq_reg->subsys, > gce_offset, value, mask); > > return cmdq_pkt_write_mask_pa(cmdq_pkt, cmdq_reg->pa_base, > gce_offset, value, mask); > } > I'll change like this, Thanks! Regards, Jason-JH Lin > Cheers, > Angelo