]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction
authorJason-JH Lin <jason-jh.lin@mediatek.com>
Fri, 31 Oct 2025 15:56:30 +0000 (23:56 +0800)
committerAngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Mon, 19 Jan 2026 11:57:44 +0000 (12:57 +0100)
Add the cmdq_mbox_priv structure to store the private data of GCE,
such as the shift bits of the physical address. Then, include the
cmdq_mbox_priv structure within the cmdq_pkt structure.

This allows CMDQ users to utilize the private data in cmdq_pkt to
generate GCE instructions when needed. Additionally, having
cmdq_mbox_priv makes it easier to expand and reference other GCE
private data in the future.

Add cmdq_get_mbox_priv() for CMDQ users to get all the private data
into the cmdq_mbox_priv of the cmdq_pkt.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Acked-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
drivers/mailbox/mtk-cmdq-mailbox.c
include/linux/mailbox/mtk-cmdq-mailbox.h

index 5791f80f995ab98f751cd3e1a5c1dee7b6b1a786..95e8a5331b7cf37c3bbcd319fe33d1246627135c 100644 (file)
@@ -104,6 +104,14 @@ static inline dma_addr_t cmdq_revert_gce_addr(u32 addr, const struct gce_plat *p
        return (dma_addr_t)addr << pdata->shift;
 }
 
+void cmdq_get_mbox_priv(struct mbox_chan *chan, struct cmdq_mbox_priv *priv)
+{
+       struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);
+
+       priv->shift_pa = cmdq->pdata->shift;
+}
+EXPORT_SYMBOL(cmdq_get_mbox_priv);
+
 u8 cmdq_get_shift_pa(struct mbox_chan *chan)
 {
        struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);
index e1555e06e7e55e9d74fa583669ef7d8cf00b571d..73b70be4a8a755186084fbd6e1ea7116feebfdf4 100644 (file)
@@ -70,13 +70,31 @@ struct cmdq_cb_data {
        struct cmdq_pkt         *pkt;
 };
 
+struct cmdq_mbox_priv {
+       u8 shift_pa;
+};
+
 struct cmdq_pkt {
        void                    *va_base;
        dma_addr_t              pa_base;
        size_t                  cmd_buf_size; /* command occupied size */
        size_t                  buf_size; /* real buffer size */
+       struct cmdq_mbox_priv   priv; /* for generating instruction */
 };
 
+/**
+ * cmdq_get_mbox_priv() - get the private data of mailbox channel
+ * @chan: mailbox channel
+ * @priv: pointer to store the private data of mailbox channel
+ *
+ * While generating the GCE instruction to command buffer, the private data
+ * of GCE hardware may need to be referenced, such as the shift bits of
+ * physical address.
+ *
+ * This function should be called before generating the GCE instruction.
+ */
+void cmdq_get_mbox_priv(struct mbox_chan *chan, struct cmdq_mbox_priv *priv);
+
 /**
  * cmdq_get_shift_pa() - get the shift bits of physical address
  * @chan: mailbox channel