[PATCH 03/15] soc: mediatek: Support GCE thread loop
CK Hu (胡俊光)
ck.hu at mediatek.com
Tue Aug 29 19:15:07 PDT 2023
Hi, Hsiao-chien:
On Wed, 2023-08-23 at 23:13 +0800, Hsiao Chien Sung wrote:
> Add a new API to create GCE thread loop by
> appending a command at the end of CMDQ packet
> to jump to the head of it.
>
> Signed-off-by: Hsiao Chien Sung <shawn.sung at mediatek.com>
> ---
> drivers/soc/mediatek/mtk-cmdq-helper.c | 30
> ++++++++++++++++++++++++++
> include/linux/soc/mediatek/mtk-cmdq.h | 2 ++
> 2 files changed, 32 insertions(+)
>
> diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c
> b/drivers/soc/mediatek/mtk-cmdq-helper.c
> index c1837a468267..7d503d491c0d 100644
> --- a/drivers/soc/mediatek/mtk-cmdq-helper.c
> +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
> @@ -430,6 +430,9 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt)
> int err;
> struct cmdq_client *client = (struct cmdq_client *)pkt->cl;
>
> + dma_sync_single_for_device(client->chan->mbox->dev, pkt-
> >pa_base,
> + pkt->cmd_buf_size, DMA_TO_DEVICE);
This function has been called by client driver, so drop this.
Regards,
CK
> +
> err = mbox_send_message(client->chan, pkt);
> if (err < 0)
> return err;
> @@ -440,4 +443,31 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt)
> }
> EXPORT_SYMBOL(cmdq_pkt_flush_async);
>
> +int cmdq_pkt_finalize_loop(struct cmdq_pkt *pkt)
> +{
> + struct cmdq_instruction inst = { {0} };
> + int err;
> + u8 shift_pa = 0;
> +
> + shift_pa = cmdq_get_shift_pa(((struct cmdq_client *)pkt->cl)-
> >chan);
> +
> + /* insert EOC and generate IRQ for command iteration */
> + inst.op = CMDQ_CODE_EOC;
> + inst.value = CMDQ_EOC_IRQ_EN;
> + err = cmdq_pkt_append_command(pkt, inst);
> + if (err < 0)
> + return err;
> +
> + /* jump to head of the packet */
> + inst.op = CMDQ_CODE_JUMP;
> + inst.offset = CMDQ_JUMP_RELATIVE;
> + inst.value = pkt->pa_base >> shift_pa;
> + err = cmdq_pkt_append_command(pkt, inst);
> +
> + pkt->loop = true;
> +
> + return err;
> +}
> +EXPORT_SYMBOL(cmdq_pkt_finalize_loop);
> +
> MODULE_LICENSE("GPL v2");
> diff --git a/include/linux/soc/mediatek/mtk-cmdq.h
> b/include/linux/soc/mediatek/mtk-cmdq.h
> index 3eb95ef34c6c..4c30f891d924 100644
> --- a/include/linux/soc/mediatek/mtk-cmdq.h
> +++ b/include/linux/soc/mediatek/mtk-cmdq.h
> @@ -273,6 +273,8 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt,
> dma_addr_t addr);
> */
> int cmdq_pkt_finalize(struct cmdq_pkt *pkt);
>
> +int cmdq_pkt_finalize_loop(struct cmdq_pkt *pkt);
> +
> /**
> * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute
> the CMDQ
> * packet and call back at the end of done
> packet
More information about the Linux-mediatek
mailing list