mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v8 00/20] Add GCE support for MT8196
@ 2025-10-17  6:44 Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header " Jason-JH Lin
                   ` (20 more replies)
  0 siblings, 21 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media, Jason-jh Lin

From: Jason-jh Lin <jason-jh.lin@mediatek.corp-partner.google.com>

This patch series adds support for the MediaTek MT8196 SoC in the CMDQ
driver and related subsystems. The changes include adding compatible
names and iommus property, updating driver data to accommodate hardware
changes, and modifying the usage of CMDQ APIs to support non-subsys ID
hardware.

---
Change in v8:
1. Use function pointer to select the correct CMDQ APIs when checking
   subsys is support for the HW component.

Change in v7:
1. Rename cmdq_reg_shift_addr() and cmdq_reg_revert_addr() to 
   cmdq_convert_gce_addr() and cmdq_revert_gce_addr().
2. Change cmdq_vm_toggle to cmdq_vm_init().

Change in v6:
1. Move the removal patches to the end of series.
2. Fix build error for cmdq_pkt_jump_rel_temp patch.

Change in RESEND v5:
1. Separate the removal of cmdq_get_shift_pa() from [PATCH v5 03/19] to a
   single patch [PATCH RESEND v5 10/20].

Change in v5:
1. Rebase on tag: next-20250424 + patch [1].
2. Split adding driver data for MT8196 patch to 3 independent patch
   and add more detail commit message to each patch.
3. Refine passing shift_pa as the parameter in API to storing it into
   the cmdq_pkt.
4. Refine DMA address potential issue in cmdq mailbox driver.
5. Change the mminfra_offset related mbox API to passing it by cmdq_pkt.
6. Add new cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() APIs to
   replace the cmdq_pkt_write().

[1] mailbox: mtk-cmdq: Refine GCE_GCTL_VALUE setting
- https://patchwork.kernel.org/project/linux-mediatek/patch/20250421035650.441383-1-jason-jh.lin@mediatek.com/

Change in v4:
1. Remove dt-binding header and add a gce header in dts folder.
2. Remove dot in sign-off name.
3. Change addr type from u32 to dma_addr_t for cmdq_reg_shift_addr() and
   cmdq_reg_revert_addr().

Change in v3:
1. Merge 2 dt-bindings pathes together and add more detail commit message.
2. Change type u32 to phys_addr_t for pa_base of struct cmdq_client_reg.
3. Remove cmdq_subsys_is_valid() and subsys_num in CMDQ driver.
4. Add CMDQ_SUBSYS_INVALID to check subsys instead of using
   cmdq_subsys_is_invalid().
5. Make use of CMDQ_THR_SPR0 define to the parameter of CMDQ APIs.
6. Rebase on the new MACRO in mtk-mdp3-comp.h.

Change in v2:
1. Remove the constant and fix warning in dt-bindings.
2. Remove the pa_base parameter of CMDQ APIs and related modification.
3. Move subsys checking to client drivers and use 2 alternative
   CMDQ APIs to achieve the same functionality.

---

Jason-JH Lin (20):
  arm64: dts: mediatek: Add GCE header for MT8196
  mailbox: mtk-cmdq: Refine DMA address handling for the command buffer
  mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating
    instruction
  soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in cmdq_pkt_create()
  soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for removing
    shift_pa
  mailbox: mtk-cmdq: Add GCE hardware virtualization configuration
  mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM
    transaction
  mailbox: mtk-cmdq: Add driver data to support for MT8196
  soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without
    subsys ID support
  soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without
    subsys ID
  soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM
    addresses
  soc: mediatek: Use reg_write function pointer for subsys ID
    compatibility
  drm/mediatek:Use reg_write function pointer for subsys ID
    compatibility
  media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change
  media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to
    cmdq_pkt_jump_rel_temp()
  soc: mediatek: mtk-cmdq: Remove shift_pa parameter from
    cmdq_pkt_jump()
  media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa
  soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and
    cmdq_pkt_jump_rel_temp()
  soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and
    cmdq_pkt_write_mask()
  mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa()

 arch/arm64/boot/dts/mediatek/mt8196-gce.h     | 612 ++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c       |  12 +-
 drivers/mailbox/mtk-cmdq-mailbox.c            | 113 +++-
 .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c    |   6 +-
 .../platform/mediatek/mdp3/mtk-mdp3-comp.h    |   6 +-
 .../platform/mediatek/mdp3/mtk-mdp3-core.c    |   2 -
 .../platform/mediatek/mdp3/mtk-mdp3-core.h    |   1 -
 drivers/soc/mediatek/mtk-cmdq-helper.c        |  82 ++-
 drivers/soc/mediatek/mtk-mmsys.c              |   8 +-
 drivers/soc/mediatek/mtk-mutex.c              |   5 +-
 include/linux/mailbox/mtk-cmdq-mailbox.h      |  19 +-
 include/linux/soc/mediatek/mtk-cmdq.h         |  87 ++-
 12 files changed, 879 insertions(+), 74 deletions(-)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8196-gce.h

-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header for MT8196
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20  9:46   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 02/20] mailbox: mtk-cmdq: Refine DMA address handling for the command buffer Jason-JH Lin
                   ` (19 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Add GCE header define for GCE Thread Priority and GCE Event IDs
that used in the MT8196 dtsi.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 arch/arm64/boot/dts/mediatek/mt8196-gce.h | 612 ++++++++++++++++++++++
 1 file changed, 612 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8196-gce.h

diff --git a/arch/arm64/boot/dts/mediatek/mt8196-gce.h b/arch/arm64/boot/dts/mediatek/mt8196-gce.h
new file mode 100644
index 000000000000..457dc73aeed3
--- /dev/null
+++ b/arch/arm64/boot/dts/mediatek/mt8196-gce.h
@@ -0,0 +1,612 @@
+/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */
+/*
+ * Copyright (c) 2025 MediaTek Inc.
+ *
+ */
+
+#ifndef __DTS_GCE_MT8196_H
+#define __DTS_GCE_MT8196_H
+
+/* GCE Thread Priority
+ * The GCE core has multiple GCE threads, each of which can independently
+ * execute its own sequence of instructions.
+ * However, the GCE threads on the same core cannot run in parallel.
+ * Different GCE threads can determine thread priority based on the scenario,
+ * thereby serving different user needs.
+ *
+ * Low priority thread is executed when no high priority thread is active.
+ * Same priority thread is scheduled by round robin.
+ */
+#define CMDQ_THR_PRIO_LOWEST	0
+#define CMDQ_THR_PRIO_1		1
+#define CMDQ_THR_PRIO_2		2
+#define CMDQ_THR_PRIO_3		3
+#define CMDQ_THR_PRIO_4		4
+#define CMDQ_THR_PRIO_5		5
+#define CMDQ_THR_PRIO_6		6
+#define CMDQ_THR_PRIO_HIGHEST	7
+
+/*
+ * GCE0 Hardware Event IDs
+ * Different SoCs will have varying numbers of hardware event signals,
+ * which are sent from the corresponding hardware to the GCE.
+ * Each hardware event signal corresponds to an event ID in the GCE.
+ * The CMDQ driver can use the following event ID definitions to allow
+ * the client driver to use wait and clear APIs provided by CMDQ, enabling
+ * the GCE to execute operations in the instructions for that event ID.
+ *
+ * The event IDs of GCE0 are mainly used by display hardware.
+ */
+/* CMDQ_EVENT_DISP0_STREAM_SOF0 ~ 15: 0 ~ 15 */
+#define CMDQ_EVENT_DISP0_STREAM_SOF(n)						(0 + (n))
+/* CMDQ_EVENT_DISP0_FRAME_DONE_SEL0 ~ 15: 16 ~ 31 */
+#define CMDQ_EVENT_DISP0_FRAME_DONE_SEL(n)					(16 + (n))
+#define CMDQ_EVENT_DISP0_DISP_WDMA0_TARGET_LINE_END_ENG_EVENT			32
+#define CMDQ_EVENT_DISP0_DISP_WDMA0_SW_RST_DONE_ENG_EVENT			33
+#define CMDQ_EVENT_DISP0_DISP_POSTMASK1_RST_DONE_ENG_EVENT			34
+#define CMDQ_EVENT_DISP0_DISP_POSTMASK0_RST_DONE_ENG_EVENT			35
+#define CMDQ_EVENT_DISP0_DISP_MUTEX0_TIMEOUT_ENG_EVENT				36
+/* CMDQ_EVENT_DISP0_DISP_MUTEX0_REG_UPDATE_ENG_EVENT0 ~ 15: 37 ~ 52 */
+#define CMDQ_EVENT_DISP0_DISP_MUTEX0_REG_UPDATE_ENG_EVENT(n)			(37 + (n))
+#define CMDQ_EVENT_DISP0_DISP_MUTEX0_GET_RELEASE_ENG_EVENT			53
+#define CMDQ_EVENT_DISP0_DISP_MDP_RDMA0_SW_RST_DONE_ENG_EVENT			54
+/* CMDQ_EVENT_DISP1_STREAM_SOF0 ~ 15: 55 ~ 70 */
+#define CMDQ_EVENT_DISP1_STREAM_SOF(n)						(55 + (n))
+/* CMDQ_EVENT_DISP1_FRAME_DONE_SEL0 ~ 15: 71 ~ 86 */
+#define CMDQ_EVENT_DISP1_FRAME_DONE_SEL(n)					(71 + (n))
+/* CMDQ_EVENT_DISP1_STREAM_DONE_ENG_EVENT0 ~ 15: 87 ~ 102 */
+#define CMDQ_EVENT_DISP1_STREAM_DONE_ENG_EVENT(n)				(87 + (n))
+/* CMDQ_EVENT_DISP1_REG_UPDATE_DONE_ENG_EVENT0 ~ 15: 103 ~ 118 */
+#define CMDQ_EVENT_DISP1_REG_UPDATE_DONE_ENG_EVENT(n)				(103 + (n))
+#define CMDQ_EVENT_DISP1_OCIP_SUBSYS_SRAM_ISOINT_ENG_EVENT			119
+#define CMDQ_EVENT_DISP1_DISP_WDMA4_TARGET_LINE_END_ENG_EVENT			120
+#define CMDQ_EVENT_DISP1_DISP_WDMA4_SW_RST_DONE_ENG_EVENT			121
+#define CMDQ_EVENT_DISP1_DISP_WDMA3_TARGET_LINE_END_ENG_EVENT			122
+#define CMDQ_EVENT_DISP1_DISP_WDMA3_SW_RST_DONE_ENG_EVENT			123
+#define CMDQ_EVENT_DISP1_DISP_WDMA2_TARGET_LINE_END_ENG_EVENT			124
+#define CMDQ_EVENT_DISP1_DISP_WDMA2_SW_RST_DONE_ENG_EVENT			125
+#define CMDQ_EVENT_DISP1_DISP_WDMA1_TARGET_LINE_END_ENG_EVENT			126
+#define CMDQ_EVENT_DISP1_DISP_WDMA1_SW_RST_DONE_ENG_EVENT			127
+#define CMDQ_EVENT_DISP1_DISP_MUTEX0_TIMEOUT_ENG_EVENT				128
+#define CMDQ_EVENT_DISP1_DISP_MUTEX0_GET_RLZ_ENG_EVENT				129
+#define CMDQ_EVENT_DISP1_DISP_MDP_RDMA1_SW_RST_DONE_ENG_EVENT			130
+#define CMDQ_EVENT_DISP1_DISP_GDMA0_SW_RST_DONE_ENG_EVENT			131
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_VSYNC_START_ENG_EVENT		132
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_VSYNC_END_ENG_EVENT		133
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_VRR_VFP_LAST_SAFE_BLANK_ENG_EVENT	134
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_VFP_START_ENG_EVENT		135
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_VFP_LAST_LINE_ENG_EVENT		136
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_VDE_END_ENG_EVENT			137
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_TRIGGER_LOOP_CLR_ENG_EVENT	138
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_TARGET_LINE1_ENG_EVENT		139
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_INT_TG_TARGET_LINE0_ENG_EVENT		140
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_EXT_TG_VSYNC_START_ENG_EVENT		141
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_EXT_TG_VSYNC_END_ENG_EVENT		142
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_EXT_TG_VDE_START_ENG_EVENT		143
+#define CMDQ_EVENT_DISP1_DISP_DVO0_DVO_EXT_TG_VDE_END_ENG_EVENT			144
+/* CMDQ_EVENT_DISP1_DISP_DSI2_ENG_EVENT0 ~ 10: 145 ~ 155 */
+#define CMDQ_EVENT_DISP1_DISP_DSI2_ENG_EVENT(n)					(145 + (n))
+/* CMDQ_EVENT_DISP1_DISP_DSI1_ENG_EVENT0 ~ 21: 156 ~ 177 */
+#define CMDQ_EVENT_DISP1_DISP_DSI1_ENG_EVENT(n)					(156 + (n))
+/* CMDQ_EVENT_DISP1_DISP_DSI0_ENG_EVENT0 ~ 10: 178 ~ 188 */
+#define CMDQ_EVENT_DISP1_DISP_DSI0_ENG_EVENT(n)					(178 + (n))
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF1_VSYNC_START_ENG_EVENT			189
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF1_VSYNC_END_ENG_EVENT			190
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF1_VDE_START_ENG_EVENT			191
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF1_VDE_END_ENG_EVENT			192
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF1_TARGET_LINE_ENG_EVENT			193
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF0_VSYNC_START_ENG_EVENT			194
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF0_VSYNC_END_ENG_EVENT			195
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF0_VDE_START_ENG_EVENT			196
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF0_VDE_END_ENG_EVENT			197
+#define CMDQ_EVENT_DISP1_DISP_DP_INTF0_TARGET_LINE_ENG_EVENT			198
+/* CMDQ_EVENT_DISP1_BUF_UNDERRUN_ENG_EVENT0 ~ 10: 199 ~ 209 */
+#define CMDQ_EVENT_DISP1_BUF_UNDERRUN_ENG_EVENT(n)				(199 + (n))
+/* CMDQ_EVENT_MML0_STREAM_SOF0 ~ 15: 210 ~ 225 */
+#define CMDQ_EVENT_MML0_STREAM_SOF(n)						(210 + (n))
+/* CMDQ_EVENT_MML0_FRAME_DONE_SEL0 ~ 15: 226 ~ 241 */
+#define CMDQ_EVENT_MML0_FRAME_DONE_SEL(n)					(226 + (n))
+/* CMDQ_EVENT_MML0_REG_UPDATE_DONE_ENG_EVENT0 ~ 15: 242 ~ 257 */
+#define CMDQ_EVENT_MML0_REG_UPDATE_DONE_ENG_EVENT(n)				(242 + (n))
+#define CMDQ_EVENT_MML0_MDP_WROT2_SW_RST_DONE_ENG_EVENT				258
+#define CMDQ_EVENT_MML0_MDP_WROT1_SW_RST_DONE_ENG_EVENT				259
+#define CMDQ_EVENT_MML0_MDP_WROT0_SW_RST_DONE_ENG_EVENT				260
+#define CMDQ_EVENT_MML0_MDP_RROT0_SW_RST_DONE_ENG_EVENT				261
+#define CMDQ_EVENT_MML0_MDP_RDMA2_SW_RST_DONE_ENG_EVENT				262
+#define CMDQ_EVENT_MML0_MDP_RDMA1_SW_RST_DONE_ENG_EVENT				263
+#define CMDQ_EVENT_MML0_MDP_RDMA0_SW_RST_DONE_ENG_EVENT				264
+#define CMDQ_EVENT_MML0_MDP_MERGE0_SW_RST_DONE_ENG_EVENT			265
+#define CMDQ_EVENT_MML0_DISP_MUTEX0_TIMEOUT_ENG_EVENT				266
+#define CMDQ_EVENT_MML0_DISP_MUTEX0_GET_RLZ_ENG_EVENT				267
+/* CMDQ_EVENT_MML1_STREAM_SOF0 ~ 15: 268 ~ 283 */
+#define CMDQ_EVENT_MML1_STREAM_SOF(n)						(268 + (n))
+/* CMDQ_EVENT_MML1_FRAME_DONE_SEL0 ~ 15: 284 ~ 299 */
+#define CMDQ_EVENT_MML1_FRAME_DONE_SEL(n)					(284 + (n))
+/* CMDQ_EVENT_MML1_REG_UPDATE_DONE_ENG_EVENT0 ~ 15: 300 ~ 315 */
+#define CMDQ_EVENT_MML1_REG_UPDATE_DONE_ENG_EVENT0				(300 + (n))
+#define CMDQ_EVENT_MML1_MDP_WROT2_SW_RST_DONE_ENG_EVENT				316
+#define CMDQ_EVENT_MML1_MDP_WROT1_SW_RST_DONE_ENG_EVENT				317
+#define CMDQ_EVENT_MML1_MDP_WROT0_SW_RST_DONE_ENG_EVENT				318
+#define CMDQ_EVENT_MML1_MDP_RROT0_SW_RST_DONE_ENG_EVENT				319
+#define CMDQ_EVENT_MML1_MDP_RDMA2_SW_RST_DONE_ENG_EVENT				320
+#define CMDQ_EVENT_MML1_MDP_RDMA1_SW_RST_DONE_ENG_EVENT				321
+#define CMDQ_EVENT_MML1_MDP_RDMA0_SW_RST_DONE_ENG_EVENT				322
+#define CMDQ_EVENT_MML1_MDP_MERGE0_SW_RST_DONE_ENG_EVENT			323
+#define CMDQ_EVENT_MML1_DISP_MUTEX0_TIMEOUT_ENG_EVENT				324
+#define CMDQ_EVENT_MML1_DISP_MUTEX0_GET_RLZ_ENG_EVENT				325
+/* CMDQ_EVENT_OVL0_STREAM_SOF0 ~ 15: 326 ~ 341 */
+#define CMDQ_EVENT_OVL0_STREAM_SOF(n)						(326 + (n))
+/* CMDQ_EVENT_OVL0_FRAME_DONE_SEL0 ~ 15: 342 ~ 357 */
+#define CMDQ_EVENT_OVL0_FRAME_DONE_SEL(n)					(342 + (n))
+#define CMDQ_EVENT_OVL0_OVL_UFBC_WDMA0_TARGET_LINE_END_ENG_EVENT		358
+#define CMDQ_EVENT_OVL0_OVL_MUTEX0_TIMEOUT_ENG_EVENT				359
+/* CMDQ_EVENT_OVL0_OVL_MUTEX0_REG_UPDATE_DONE_ENG_EVENT0 ~ 15: 360 ~ 375 */
+#define CMDQ_EVENT_OVL0_OVL_MUTEX0_REG_UPDATE_DONE_ENG_EVENT(n)			(360 + (n))
+#define CMDQ_EVENT_OVL0_OVL_MUTEX0_GET_RELEASE_ENG_EVENT			376
+#define CMDQ_EVENT_OVL0_OVL_MDP_RDMA1_SW_RST_DONE_ENG_EVENT			377
+#define CMDQ_EVENT_OVL0_OVL_MDP_RDMA0_SW_RST_DONE_ENG_EVENT			378
+#define CMDQ_EVENT_OVL0_OVL_EXDMA9_FRAME_RESET_DONE_ENG_EVENT			379
+#define CMDQ_EVENT_OVL0_OVL_EXDMA8_FRAME_RESET_DONE_ENG_EVENT			380
+#define CMDQ_EVENT_OVL0_OVL_EXDMA7_FRAME_RESET_DONE_ENG_EVENT			381
+#define CMDQ_EVENT_OVL0_OVL_EXDMA6_FRAME_RESET_DONE_ENG_EVENT			382
+#define CMDQ_EVENT_OVL0_OVL_EXDMA5_FRAME_RESET_DONE_ENG_EVENT			383
+#define CMDQ_EVENT_OVL0_OVL_EXDMA4_FRAME_RESET_DONE_ENG_EVENT			384
+#define CMDQ_EVENT_OVL0_OVL_EXDMA3_FRAME_RESET_DONE_ENG_EVENT			385
+#define CMDQ_EVENT_OVL0_OVL_EXDMA2_FRAME_RESET_DONE_ENG_EVENT			386
+#define CMDQ_EVENT_OVL0_OVL_EXDMA1_FRAME_RESET_DONE_ENG_EVENT			387
+#define CMDQ_EVENT_OVL0_OVL_EXDMA0_FRAME_RESET_DONE_ENG_EVENT			388
+#define CMDQ_EVENT_OVL0_OVL_DISP_WDMA1_TARGET_LINE_END_ENG_EVENT		389
+#define CMDQ_EVENT_OVL0_OVL_DISP_WDMA1_SW_RST_DONE_END_ENG_EVENT		390
+#define CMDQ_EVENT_OVL0_OVL_DISP_WDMA0_TARGET_LINE_END_ENG_EVENT		391
+#define CMDQ_EVENT_OVL0_OVL_DISP_WDMA0_SW_RST_DONE_END_ENG_EVENT		392
+#define CMDQ_EVENT_OVL0_OVL_BWM0_FRAME_RESET_DONE_ENG_EVENT			393
+/* CMDQ_EVENT_OVL1_STREAM_SOF0 ~ 15: 394 ~ 409 */
+#define CMDQ_EVENT_OVL1_STREAM_SOF(n)						(394 + (n))
+/* CMDQ_EVENT_OVL1_FRAME_DONE_SEL0 ~ 15: 410 ~ 425 */
+#define CMDQ_EVENT_OVL1_FRAME_DONE_SEL(n)					(410 + (n))
+#define CMDQ_EVENT_OVL1_OVL_UFBC_WDMA0_TARGET_LINE_END_ENG_EVENT		426
+#define CMDQ_EVENT_OVL1_OVL_MUTEX0_TIMEOUT_ENG_EVENT				427
+/* CMDQ_EVENT_OVL1_OVL_MUTEX0_REG_UPDATE_DONE_ENG_EVENT0 ~ 15: 428 ~ 443 */
+#define CMDQ_EVENT_OVL1_OVL_MUTEX0_REG_UPDATE_DONE_ENG_EVENT(n)			(428 + (n))
+#define CMDQ_EVENT_OVL1_OVL_MUTEX0_GET_RELEASE_ENG_EVENT			444
+#define CMDQ_EVENT_OVL1_OVL_MDP_RDMA1_SW_RST_DONE_ENG_EVENT			445
+#define CMDQ_EVENT_OVL1_OVL_MDP_RDMA0_SW_RST_DONE_ENG_EVENT			446
+#define CMDQ_EVENT_OVL1_OVL_EXDMA9_FRAME_RESET_DONE_ENG_EVENT			447
+#define CMDQ_EVENT_OVL1_OVL_EXDMA8_FRAME_RESET_DONE_ENG_EVENT			448
+#define CMDQ_EVENT_OVL1_OVL_EXDMA7_FRAME_RESET_DONE_ENG_EVENT			449
+#define CMDQ_EVENT_OVL1_OVL_EXDMA6_FRAME_RESET_DONE_ENG_EVENT			450
+#define CMDQ_EVENT_OVL1_OVL_EXDMA5_FRAME_RESET_DONE_ENG_EVENT			451
+#define CMDQ_EVENT_OVL1_OVL_EXDMA4_FRAME_RESET_DONE_ENG_EVENT			452
+#define CMDQ_EVENT_OVL1_OVL_EXDMA3_FRAME_RESET_DONE_ENG_EVENT			453
+#define CMDQ_EVENT_OVL1_OVL_EXDMA2_FRAME_RESET_DONE_ENG_EVENT			454
+#define CMDQ_EVENT_OVL1_OVL_EXDMA1_FRAME_RESET_DONE_ENG_EVENT			455
+#define CMDQ_EVENT_OVL1_OVL_EXDMA0_FRAME_RESET_DONE_ENG_EVENT			456
+#define CMDQ_EVENT_OVL1_OVL_DISP_WDMA1_TARGET_LINE_END_ENG_EVENT		457
+#define CMDQ_EVENT_OVL1_OVL_DISP_WDMA1_SW_RST_DONE_END_ENG_EVENT		458
+#define CMDQ_EVENT_OVL1_OVL_DISP_WDMA0_TARGET_LINE_END_ENG_EVENT		459
+#define CMDQ_EVENT_OVL1_OVL_DISP_WDMA0_SW_RST_DONE_END_ENG_EVENT		460
+#define CMDQ_EVENT_OVL1_OVL_BWM0_FRAME_RESET_DONE_ENG_EVENT			461
+#define CMDQ_EVENT_DPC_DT_DONE0							462
+#define CMDQ_EVENT_DPC_DT_DONE1							463
+#define CMDQ_EVENT_DPC_DT_DONE2_0_MERGE						464
+#define CMDQ_EVENT_DPC_DT_DONE2_1_MERGE						465
+#define CMDQ_EVENT_DPC_DT_DONE2_2_MERGE						466
+#define CMDQ_EVENT_DPC_DT_DONE2_3_MERGE						467
+#define CMDQ_EVENT_DPC_DT_DONE3							468
+#define CMDQ_EVENT_DPC_DT_DONE4_MERGE						469
+#define CMDQ_EVENT_DPC_DT_DONE5							470
+#define CMDQ_EVENT_DPC_DT_DONE6_0_MERGE						471
+#define CMDQ_EVENT_DPC_DT_DONE6_1_MERGE						472
+#define CMDQ_EVENT_DPC_DT_DONE6_2_MERGE						473
+#define CMDQ_EVENT_DPC_DT_DONE6_3_MERGE						474
+#define CMDQ_EVENT_DPC_DT_DONE7							475
+#define CMDQ_EVENT_DPC_DT_DONE32_MERGE						476
+#define CMDQ_EVENT_DPC_DT_DONE33						477
+#define CMDQ_EVENT_DPC_DT_DONE34_0						478
+#define CMDQ_EVENT_DPC_DT_DONE35						479
+#define CMDQ_EVENT_DPC_DISP_SSYS_DT_ERR_ON_BEFORE_OFF				480
+#define CMDQ_EVENT_DPC_DISP_SSYS_DT_ERR_PRETE_BEFORE_ON				481
+#define CMDQ_EVENT_DPC_DISP_DVFS_DT_ERR_ON_BEFORE_OFF				482
+#define CMDQ_EVENT_DPC_DISP_DVFS_DT_ERR_PRETE_BEFORE_ON				483
+#define CMDQ_EVENT_DPC_DISP_SB_DT_ERR_ON_BEFORE_OFF				484
+#define CMDQ_EVENT_DPC_DISP_SB_DT_ERR_PRETE_BEFORE_ON				485
+#define CMDQ_EVENT_DPC_DISP_SW_CONFIG_WHEN_MTCMOS_OFF				486
+#define CMDQ_EVENT_DPC_MML_SSYS_DT_ERR_ON_BEFORE_OFF				487
+#define CMDQ_EVENT_DPC_MML_SSYS_DT_ERR_PRETE_BEFORE_ON				488
+#define CMDQ_EVENT_DPC_MML_DVFS_DT_ERR_ON_BEFORE_OFF				489
+#define CMDQ_EVENT_DPC_MML_DVFS_DT_ERR_PRETE_BEFORE_ON				490
+#define CMDQ_EVENT_DPC_MML_SB_DT_ERR_ON_BEFORE_OFF				491
+#define CMDQ_EVENT_DPC_MML_SB_DT_ERR_PRETE_BEFORE_ON				492
+#define CMDQ_EVENT_DPC_MML_SW_CONFIG_WHEN_MTCMOS_OFF				493
+/* CMDQ_EVENT_DPTX_DPTX_EVENT0 ~ 3: 494 ~ 497 */
+#define CMDQ_EVENT_DPTX_DPTX_EVENT(n)						(494 + (n))
+/* CMDQ_EVENT_EDPTX_EDPTX_EVENT0 ~ 1: 498 ~ 499 */
+#define CMDQ_EVENT_EDPTX_EDPTX_EVENT(n)						(498 + (n))
+
+#define CMDQ_EVENT_DSI0_TE_I_DSI0_TE_I						898
+#define CMDQ_EVENT_DSI1_TE_I_DSI1_TE_I						899
+#define CMDQ_EVENT_DSI2_TE_I_DSI2_TE_I						900
+/* CMDQ_EVENT_POWEREVENT_GCE_EVENT_SUBSYS_PWR_ACK0 ~ 23: 901 ~ 924 */
+#define CMDQ_EVENT_POWEREVENT_GCE_EVENT_SUBSYS_PWR_ACK(n)			(901 + (n))
+/* CMDQ_EVENT_GCE_EVENT_DPTX_GCE_EVENT_DPTX0 ~ 1: 925 ~ 926 */
+#define CMDQ_EVENT_GCE_EVENT_DPTX_GCE_EVENT_DPTX(n)				(925 + (n))
+/* CMDQ_EVENT_GCE_EVENT_DPTX_P1_GCE_EVENT_DPTX_P10 ~ 1: 927 ~ 928 */
+#define CMDQ_EVENT_GCE_EVENT_DPTX_P1_GCE_EVENT_DPTX_P1(n)			(927 + (n))
+/* CMDQ_EVENT_GCE_EVENT_EDPTX_GCE_EVENT_EDPTX0 ~ 1: 929 ~ 930 */
+#define CMDQ_EVENT_GCE_EVENT_EDPTX_GCE_EVENT_EDPTX(n)				(929 + (n))
+#define CMDQ_EVENT_DSI3_TE_I_DSI3_TE_I						931
+#define CMDQ_EVENT_SPI0_FINISH_EVENT_DSI4_TE_I					932
+#define CMDQ_EVENT_SPI0_EVENT_EVENT_DSI5_TE_I					933
+
+/*
+ * GCE1 Hardware Event IDs
+ * Different SoCs will have varying numbers of hardware event signals,
+ * which are sent from the corresponding hardware to the GCE.
+ * Each hardware event signal corresponds to an event ID in the GCE.
+ * The CMDQ driver can use the following event ID definitions to allow
+ * the client driver to use wait and clear APIs provided by CMDQ, enabling
+ * the GCE to execute operations in the instructions for that event ID.
+ *
+ * The event IDs of GCE1 are mainly used by non-display hardware.
+ */
+#define CMDQ_EVENT_VENC3_VENC_RESERVED						0
+#define CMDQ_EVENT_VENC3_VENC_FRAME_DONE					1
+#define CMDQ_EVENT_VENC3_VENC_PAUSE_DONE					2
+#define CMDQ_EVENT_VENC3_JPGENC_DONE						3
+#define CMDQ_EVENT_VENC3_VENC_MB_DONE						4
+#define CMDQ_EVENT_VENC3_VENC_128BYTE_DONE					5
+#define CMDQ_EVENT_VENC3_JPGDEC_DONE						6
+#define CMDQ_EVENT_VENC3_JPGDEC_C1_DONE						7
+#define CMDQ_EVENT_VENC3_JPGDEC_INSUFF_DONE					8
+#define CMDQ_EVENT_VENC3_JPGDEC_C1_INSUFF_DONE					9
+#define CMDQ_EVENT_VENC3_WP_2ND_STAGE_DONE					10
+#define CMDQ_EVENT_VENC3_WP_3RD_STAGE_DONE					11
+#define CMDQ_EVENT_VENC3_PPS_HEADER_DONE					12
+#define CMDQ_EVENT_VENC3_SPS_HEADER_DONE					13
+#define CMDQ_EVENT_VENC3_VPS_HEADER_DONE					14
+#define CMDQ_EVENT_VENC3_VENC_SLICE_DONE					15
+#define CMDQ_EVENT_VENC3_VENC_SOC_SLICE_DONE					16
+#define CMDQ_EVENT_VENC3_VENC_SOC_FRAME_DONE					17
+
+#define CMDQ_EVENT_VENC2_VENC_FRAME_DONE					33
+#define CMDQ_EVENT_VENC2_VENC_PAUSE_DONE					34
+#define CMDQ_EVENT_VENC2_JPGENC_DONE						35
+#define CMDQ_EVENT_VENC2_VENC_MB_DONE						36
+#define CMDQ_EVENT_VENC2_VENC_128BYTE_DONE					37
+#define CMDQ_EVENT_VENC2_JPGDEC_DONE						38
+#define CMDQ_EVENT_VENC2_JPGDEC_C1_DONE						39
+#define CMDQ_EVENT_VENC2_JPGDEC_INSUFF_DONE					40
+#define CMDQ_EVENT_VENC2_JPGDEC_C1_INSUFF_DONE					41
+#define CMDQ_EVENT_VENC2_WP_2ND_STAGE_DONE					42
+#define CMDQ_EVENT_VENC2_WP_3RD_STAGE_DONE					43
+#define CMDQ_EVENT_VENC2_PPS_HEADER_DONE					44
+#define CMDQ_EVENT_VENC2_SPS_HEADER_DONE					45
+#define CMDQ_EVENT_VENC2_VPS_HEADER_DONE					46
+#define CMDQ_EVENT_VENC2_VENC_SLICE_DONE					47
+#define CMDQ_EVENT_VENC2_VENC_SOC_SLICE_DONE					48
+#define CMDQ_EVENT_VENC2_VENC_SOC_FRAME_DONE					49
+
+#define CMDQ_EVENT_VENC1_VENC_FRAME_DONE					65
+#define CMDQ_EVENT_VENC1_VENC_PAUSE_DONE					66
+#define CMDQ_EVENT_VENC1_JPGENC_DONE						67
+#define CMDQ_EVENT_VENC1_VENC_MB_DONE						68
+#define CMDQ_EVENT_VENC1_VENC_128BYTE_DONE					69
+#define CMDQ_EVENT_VENC1_JPGDEC_DONE						70
+#define CMDQ_EVENT_VENC1_JPGDEC_C1_DONE						71
+#define CMDQ_EVENT_VENC1_JPGDEC_INSUFF_DONE					72
+#define CMDQ_EVENT_VENC1_JPGDEC_C1_INSUFF_DONE					73
+#define CMDQ_EVENT_VENC1_WP_2ND_STAGE_DONE					74
+#define CMDQ_EVENT_VENC1_WP_3RD_STAGE_DONE					75
+#define CMDQ_EVENT_VENC1_PPS_HEADER_DONE					76
+#define CMDQ_EVENT_VENC1_SPS_HEADER_DONE					77
+#define CMDQ_EVENT_VENC1_VPS_HEADER_DONE					78
+#define CMDQ_EVENT_VENC1_VENC_SLICE_DONE					79
+#define CMDQ_EVENT_VENC1_VENC_SOC_SLICE_DONE					80
+#define CMDQ_EVENT_VENC1_VENC_SOC_FRAME_DONE					81
+
+#define CMDQ_EVENT_VDEC1_VDEC_LINE_CNT_INT					192
+#define CMDQ_EVENT_VDEC1_VDEC_INT						193
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_2						194
+#define CMDQ_EVENT_VDEC1_VDEC_DEC_ERR						195
+#define CMDQ_EVENT_VDEC1_VDEC_BUSY_OVERFLOW					196
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_5						197
+#define CMDQ_EVENT_VDEC1_VDEC_INI_FETCH_RDY					198
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_7						199
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_8						200
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_9						201
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_10						202
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_11						203
+
+#define CMDQ_EVENT_VDEC1_VDEC_GCE_CNT_OP_THR					207
+
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_32						224
+#define CMDQ_EVENT_VDEC1_VDEC_LAT_INT						225
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_34						226
+#define CMDQ_EVENT_VDEC1_VDEC_LAT_DEC_ERR					227
+#define CMDQ_EVENT_VDEC1_VDEC_LAT_BUSY_OVERFLOW					228
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_37						229
+#define CMDQ_EVENT_VDEC1_VDEC_LAT_INI_FETCH_RDY					230
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_39						231
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_40						232
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_41						233
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_42						234
+#define CMDQ_EVENT_VDEC1_VDEC1_EVENT_43						235
+
+#define CMDQ_EVENT_VDEC1_VDEC_LAT_GCE_CNT_OP_THR				239
+
+#define CMDQ_EVENT_IMG_IMG_EVENT_0						256
+/* CMDQ_EVENT_IMG_TRAW0_CQ_THR_DONE_TRAW0_0 ~ 5: 257 ~  262 */
+#define CMDQ_EVENT_IMG_TRAW0_CQ_THR_DONE_TRAW0(n)				(257 + (n))
+#define CMDQ_EVENT_IMG_TRAW0_DMA_ERR_EVENT					263
+#define CMDQ_EVENT_IMG_TRAW0_DUMMY_0						264
+/* CMDQ_EVENT_IMG_TRAW1_CQ_THR_DONE_TRAW0_0 ~ 5: 265 ~ 270 */
+#define CMDQ_EVENT_IMG_TRAW1_CQ_THR_DONE_TRAW0(n)				(265 + (n))
+#define CMDQ_EVENT_IMG_TRAW1_DMA_ERR_EVENT					271
+#define CMDQ_EVENT_IMG_ADL_TILE_DONE_EVENT					272
+#define CMDQ_EVENT_IMG_ADLWR0_TILE_DONE_EVENT					273
+#define CMDQ_EVENT_IMG_ADLWR1_TILE_DONE_EVENT					274
+#define CMDQ_EVENT_IMG_IMGSYS_IPE_ME_DONE					275
+#define CMDQ_EVENT_IMG_IMGSYS_IPE_MMG_DONE					276
+/* CMDQ_EVENT_IMG_QOF_ACK_EVENT0 ~ 19: 277 ~ 296 */
+#define CMDQ_EVENT_IMG_QOF_ACK_EVENT(n)						(277 + (n))
+/* CMDQ_EVENT_IMG_QOF_ON_EVENT0 ~ 4: 297 ~ 301 */
+#define CMDQ_EVENT_IMG_QOF_ON_EVENT(n)						(297 + (n))
+/* CMDQ_EVENT_IMG_QOF_OFF_EVENT0 ~ 4: 302 ~ 306 */
+#define CMDQ_EVENT_IMG_QOF_OFF_EVENT(n)						(302 + (n))
+/* CMDQ_EVENT_IMG_QOF_SAVE_EVENT0 ~ 4: 307 ~ 311 */
+#define CMDQ_EVENT_IMG_QOF_SAVE_EVENT(n)					(307 + (n))
+/* CMDQ_EVENT_IMG_QOF_RESTORE_EVENT0 ~ 4: 312 ~ 316 */
+#define CMDQ_EVENT_IMG_QOF_RESTORE_EVENT(n)					(312 + (n))
+/* CMDQ_EVENT_IMG_DIP_CQ_THR_DONE_P20~5: 317 ~ 322 */
+#define CMDQ_EVENT_IMG_DIP_CQ_THR_DONE_P2(n)					(317 + (n))
+#define CMDQ_EVENT_IMG_DIP_DMA_ERR_EVENT					323
+#define CMDQ_EVENT_IMG_DIP_NR_DMA_ERR_EVENT					324
+#define CMDQ_EVENT_IMG_DIP_DUMMY_0						325
+#define CMDQ_EVENT_IMG_WPE_EIS_GCE_FRAME_DONE					326
+#define CMDQ_EVENT_IMG_WPE_EIS_DONE_SYNC_OUT					327
+/* CMDQ_EVENT_IMG_WPE_EIS_CQ_THR_DONE_P20 ~ 5: 328 ~ 333 */
+#define CMDQ_EVENT_IMG_WPE_EIS_CQ_THR_DONE_P2(n)				(328 + (n))
+/* CMDQ_EVENT_IMG_PQDIP_A_CQ_THR_DONE_P20 ~ 5: 334 ~ 339 */
+#define CMDQ_EVENT_IMG_PQDIP_A_CQ_THR_DONE_P2(n)				(334 + (n))
+#define CMDQ_EVENT_IMG_PQA_DMA_ERR_EVENT					340
+/* CMDQ_EVENT_IMG_WPE0_DUMMY0~2: 341 ~ 343 */
+#define CMDQ_EVENT_IMG_WPE0_DUMMY(n)						(341 + (n))
+#define CMDQ_EVENT_IMG_OMC_TNR_GCE_FRAME_DONE					344
+#define CMDQ_EVENT_IMG_OMC_TNR_DONE_SYNC_OUT					345
+/* CMDQ_EVENT_IMG_OMC_TNR_CQ_THR_DONE_P20 ~ 5: 346 ~ 351 */
+#define CMDQ_EVENT_IMG_OMC_TNR_CQ_THR_DONE_P2(n)				(346 + (n))
+/* CMDQ_EVENT_IMG_PQDIP_B_CQ_THR_DONE_P20 ~ 5: 352 ~ 357 */
+#define CMDQ_EVENT_IMG_PQDIP_B_CQ_THR_DONE_P2(n)				(352 + (n))
+#define CMDQ_EVENT_IMG_PQB_DMA_ERR_EVENT					358
+/* CMDQ_EVENT_IMG_WPE1_DUMMY0 ~ 2: 359 ~ 361 */
+#define CMDQ_EVENT_IMG_WPE1_DUMMY(n)						(359 + (n))
+#define CMDQ_EVENT_IMG_WPE_LITE_GCE_FRAME_DONE					362
+#define CMDQ_EVENT_IMG_WPE_LITE_DONE_SYNC_OUT					363
+/* CMDQ_EVENT_IMG_WPE_LITE_CQ_THR_DONE_P20 ~ 5: 364 ~ 369 */
+#define CMDQ_EVENT_IMG_WPE_LITE_CQ_THR_DONE_P2(n)				(364 + (n))
+#define CMDQ_EVENT_IMG_OMC_LITE_GCE_FRAME_DONE					370
+#define CMDQ_EVENT_IMG_OMC_LITE_DONE_SYNC_OUT					371
+/* CMDQ_EVENT_IMG_OMC_LITE_CQ_THR_DONE_P20 ~ 5: 372 ~ 377 */
+#define CMDQ_EVENT_IMG_OMC_LITE_CQ_THR_DONE_P2(n)				(372 + (n))
+/* CMDQ_EVENT_IMG_WPE2_DUMMY0 ~ 2: 378 ~ 380 */
+#define CMDQ_EVENT_IMG_WPE2_DUMMY(n)						(378 + (n))
+#define CMDQ_EVENT_IMG_IMGSYS_IPE_FDVT0_DONE					381
+#define CMDQ_EVENT_IMG_IMG_EVENT_126						382
+#define CMDQ_EVENT_IMG_IMG_EVENT_127						383
+#define CMDQ_EVENT_CAM_CAM_EVENT_0						384
+#define CMDQ_EVENT_CAM_CAM_SUBA_SW_PASS1_DONE					385
+#define CMDQ_EVENT_CAM_CAM_SUBB_SW_PASS1_DONE					386
+#define CMDQ_EVENT_CAM_CAM_SUBC_SW_PASS1_DONE					387
+#define CMDQ_EVENT_CAM_CAM_SUBA_TFMR_PASS1_DONE					388
+#define CMDQ_EVENT_CAM_CAM_SUBB_TFMR_PASS1_DONE					389
+#define CMDQ_EVENT_CAM_CAM_SUBC_TFMR_PASS1_DONE					390
+/* CMDQ_EVENT_CAM_CAMSV_A_SW_PASS1_DONE0 ~ 3: 391 ~ 394 */
+#define CMDQ_EVENT_CAM_CAMSV_A_SW_PASS1_DONE(n)					(391 + (n))
+/* CMDQ_EVENT_CAM_CAMSV_B_SW_PASS1_DONE0 ~ 3: 395 ~ 398 */
+#define CMDQ_EVENT_CAM_CAMSV_B_SW_PASS1_DONE(n)					(395 + (n))
+/* CMDQ_EVENT_CAM_CAMSV_C_SW_PASS1_DONE0 ~ 3: 399 + 402 */
+#define CMDQ_EVENT_CAM_CAMSV_C_SW_PASS1_DONE(n)					(399 + (n))
+/* CMDQ_EVENT_CAM_CAMSV_D_SW_PASS1_DONE0 ~ 3: 403 ~ 406 */
+#define CMDQ_EVENT_CAM_CAMSV_D_SW_PASS1_DONE(n)					(403 + (n))
+/* CMDQ_EVENT_CAM_CAMSV_E_SW_PASS1_DONE0 ~ 3: 407 ~ 409 */
+#define CMDQ_EVENT_CAM_CAMSV_E_SW_PASS1_DONE(n)					(407 + (n))
+/* CMDQ_EVENT_CAM_CAMSV_F_SW_PASS1_DONE0 ~ 3: 411 ~ 413 */
+#define CMDQ_EVENT_CAM_CAMSV_F_SW_PASS1_DONE(n)					(411 + (n))
+#define CMDQ_EVENT_CAM_MRAW0_SW_PASS1_DONE					415
+#define CMDQ_EVENT_CAM_MRAW1_SW_PASS1_DONE					416
+#define CMDQ_EVENT_CAM_MRAW2_SW_PASS1_DONE					417
+#define CMDQ_EVENT_CAM_MRAW3_SW_PASS1_DONE					418
+#define CMDQ_EVENT_CAM_UISP_SW_PASS1_DONE					419
+#define CMDQ_EVENT_CAM_TG_MRAW0_OUT_SOF						420
+#define CMDQ_EVENT_CAM_TG_MRAW1_OUT_SOF						421
+#define CMDQ_EVENT_CAM_TG_MRAW2_OUT_SOF						422
+#define CMDQ_EVENT_CAM_TG_MRAW3_OUT_SOF						423
+#define CMDQ_EVENT_CAM_PDA0_IRQO_EVENT_DONE_D1					424
+#define CMDQ_EVENT_CAM_PDA1_IRQO_EVENT_DONE_D1					425
+#define CMDQ_EVENT_CAM_DPE_DVP_CMQ_EVENT					426
+#define CMDQ_EVENT_CAM_DPE_DVS_CMQ_EVENT					427
+#define CMDQ_EVENT_CAM_DPE_DVFG_CMQ_EVENT					428
+#define CMDQ_EVENT_CAM_CAM_EVENT_45						429
+#define CMDQ_EVENT_CAM_CAM_EVENT_46						430
+#define CMDQ_EVENT_CAM_CAM_EVENT_47						431
+#define CMDQ_EVENT_CAM_CAM_EVENT_48						432
+/* CMDQ_EVENT_CAM_CAM_SUBA_TG_INT1 ~ 4: 433 ~ 436 */
+#define CMDQ_EVENT_CAM_CAM_SUBA_TG_INT(n)					(433 + (n) - 1)
+/* CMDQ_EVENT_CAM_CAM_SUBB_TG_INT1 ~ 4: 437 ~ 440 */
+#define CMDQ_EVENT_CAM_CAM_SUBB_TG_INT(n)					(437 + (n) - 1)
+/* CMDQ_EVENT_CAM_CAM_SUBC_TG_INT1 ~ 4: 441 ~ 444 */
+#define CMDQ_EVENT_CAM_CAM_SUBC_TG_INT(n)					(441 + (n) - 1)
+#define CMDQ_EVENT_CAM_RAW_O_SOF_SUBA						445
+#define CMDQ_EVENT_CAM_RAW_O_SOF_SUBB						446
+#define CMDQ_EVENT_CAM_RAW_O_SOF_SUBC						447
+#define CMDQ_EVENT_CAM_TFMR_RAW_O_SOF_SUBA					448
+#define CMDQ_EVENT_CAM_TFMR_RAW_O_SOF_SUBB					449
+#define CMDQ_EVENT_CAM_TFMR_RAW_O_SOF_SUBC					450
+#define CMDQ_EVENT_CAM_RAW_SEL_SOF_UISP						451
+#define CMDQ_EVENT_CAM_CAM_SUBA_RING_BUFFER_OVERFLOW_INT_IN			452
+#define CMDQ_EVENT_CAM_CAM_SUBB_RING_BUFFER_OVERFLOW_INT_IN			453
+#define CMDQ_EVENT_CAM_CAM_SUBC_RING_BUFFER_OVERFLOW_INT_IN			454
+#define CMDQ_EVENT_CAM_CAM_EVENT_71						455
+#define CMDQ_EVENT_CAM_ADL_WR_FRAME_DONE					456
+#define CMDQ_EVENT_CAM_ADL_RD_FRAME_DONE					457
+#define CMDQ_EVENT_CAM_QOF_RAWA_POWER_ON_EVENT					458
+#define CMDQ_EVENT_CAM_QOF_RAWB_POWER_ON_EVENT					459
+#define CMDQ_EVENT_CAM_QOF_RAWC_POWER_ON_EVENT					460
+#define CMDQ_EVENT_CAM_QOF_RAWA_POWER_OFF_EVENT					461
+#define CMDQ_EVENT_CAM_QOF_RAWB_POWER_OFF_EVENT					462
+#define CMDQ_EVENT_CAM_QOF_RAWC_POWER_OFF_EVENT					463
+#define CMDQ_EVENT_CAM_QOF_RAWA_SAVE_EVENT					464
+#define CMDQ_EVENT_CAM_QOF_RAWB_SAVE_EVENT					465
+#define CMDQ_EVENT_CAM_QOF_RAWC_SAVE_EVENT					466
+#define CMDQ_EVENT_CAM_QOF_RAWA_RESTORE_EVENT					467
+#define CMDQ_EVENT_CAM_QOF_RAWB_RESTORE_EVENT					468
+#define CMDQ_EVENT_CAM_QOF_RAWC_RESTORE_EVENT					469
+/* CMDQ_EVENT_CAM_QOF_CAM_EVENT0 ~ 11: 470 ~ 481 */
+#define CMDQ_EVENT_CAM_QOF_CAM_EVENT(n)						(470 + (n))
+/* CMDQ_EVENT_CAM_SENINF_CFG_DONE_EVENT0 ~ 11: 482 ~ 495 */
+#define CMDQ_EVENT_CAM_SENINF_CFG_DONE_EVENT(n)					(482 + (n))
+#define CMDQ_EVENT_CAM_CCU0_TO_GCE_NON_SEC_IRQ					496
+#define CMDQ_EVENT_CAM_CCU0_TO_GCE_SEC_IRQ					497
+#define CMDQ_EVENT_CAM_CCU0_TO_GCE_VM_IRQ					498
+#define CMDQ_EVENT_CAM_CCU0_TO_GCE_EXCH_VM_IRQ					499
+#define CMDQ_EVENT_CAM_CCU1_TO_GCE_NON_SEC_IRQ					500
+#define CMDQ_EVENT_CAM_CCU1_TO_GCE_SEC_IRQ					501
+#define CMDQ_EVENT_CAM_CCU1_TO_GCE_VM_IRQ					502
+#define CMDQ_EVENT_CAM_CCU1_TO_GCE_EXCH_VM_IRQ					503
+/* CMDQ_EVENT_CAM_I2C_CH2_EVENT0 ~ 4: 504 ~ 509 */
+#define CMDQ_EVENT_CAM_I2C_CH2_EVENT(n)						(504 + (n))
+#define CMDQ_EVENT_CAM_CAM_EVENT_125						509
+#define CMDQ_EVENT_CAM_CAM_EVENT_126						510
+#define CMDQ_EVENT_CAM_CAM_EVENT_127						511
+
+#define CMDQ_EVENT_SMI_EVENT_MMINFRA_SMI_MMSRAM_COMM_SMIASSER			898
+#define CMDQ_EVENT_SMI_EVENT_MMINFRA_SMI_MDP_COMM_SMIASSER			899
+#define CMDQ_EVENT_SMI_EVENT_MMINFRA_SMI_DISP_COMM_SMIASSER			900
+
+/*
+ * GCE Software Tokens
+ * Apart from the event IDs that are already bound to hardware event signals,
+ * the remaining event IDs can be used as software tokens.
+ * This allows the client driver to name and operate them independently,
+ * and their usage is the same as that of hardware events.
+ */
+/* Begin of GCE0 software token */
+/* Config thread notify trigger thread */
+#define CMDQ_SYNC_TOKEN_CONFIG_DIRTY			640
+/* Trigger thread notify config thread */
+#define CMDQ_SYNC_TOKEN_STREAM_EOF			641
+/* Block Trigger thread until the ESD check finishes */
+#define CMDQ_SYNC_TOKEN_ESD_EOF				642
+#define CMDQ_SYNC_TOKEN_STREAM_BLOCK			643
+/* Check CABC setup finish */
+#define CMDQ_SYNC_TOKEN_CABC_EOF			644
+/* VFP period token for Msync */
+#define CMDQ_SYNC_TOKEN_VFP_PERIOD			645
+/* Software sync token for dual display */
+#define CMDQ_SYNC_TOKEN_CONFIG_DIRTY_1			694
+#define CMDQ_SYNC_TOKEN_STREAM_EOF_1			695
+#define CMDQ_SYNC_TOKEN_ESD_EOF_1			696
+#define CMDQ_SYNC_TOKEN_STREAM_BLOCK_1			697
+#define CMDQ_SYNC_TOKEN_CABC_EOF_1			698
+
+/*
+ * GPR access tokens (for HW register backup)
+ * There are 15 32-bit GPR, form 3 GPR as a set
+ * (64-bit for address, 32-bit for value)
+ *
+ * CMDQ_SYNC_TOKEN_GPR_SET0 ~ 4: 700 ~ 704
+ */
+#define CMDQ_SYNC_TOKEN_GPR_SET(n)			(700 + (n))
+#define CMDQ_SYNC_TOKEN_TE_0				705
+#define CMDQ_SYNC_TOKEN_PREFETCH_TE_0			706
+#define CMDQ_SYNC_TOKEN_VIDLE_POWER_ON			707
+#define CMDQ_SYNC_TOKEN_CHECK_TRIGGER_MERGE		708
+
+/* Resource lock event to control resource in GCE thread */
+#define CMDQ_SYNC_RESOURCE_WROT0			710
+#define CMDQ_SYNC_RESOURCE_WROT1			711
+/* Hardware TRACE software token */
+#define CMDQ_SYNC_TOKEN_HW_TRACE_WAIT			712
+#define CMDQ_SYNC_TOKEN_HW_TRACE_LOCK			713
+/* Software sync token for dual display */
+#define CMDQ_SYNC_TOKEN_CONFIG_DIRTY_3			714
+#define CMDQ_SYNC_TOKEN_STREAM_EOF_3			715
+#define CMDQ_SYNC_TOKEN_ESD_EOF_3			716
+#define CMDQ_SYNC_TOKEN_STREAM_BLOCK_3			717
+#define CMDQ_SYNC_TOKEN_CABC_EOF_3			718
+/* End of GCE0 software token */
+
+/* Begin of GCE1 software token */
+/* CMDQ_SYNC_TOKEN_IMGSYS_POOL0 ~ 300: 512 ~ 812 */
+#define	CMDQ_SYNC_TOKEN_IMGSYS_POOL(n)			(512 + (n))
+/* ISP software token */
+#define CMDQ_SYNC_TOKEN_IMGSYS_WPE_EIS			813
+#define CMDQ_SYNC_TOKEN_IMGSYS_OMC_TNR			814
+#define CMDQ_SYNC_TOKEN_IMGSYS_WPE_LITE			815
+#define CMDQ_SYNC_TOKEN_IMGSYS_TRAW			816
+#define CMDQ_SYNC_TOKEN_IMGSYS_LTRAW			817
+#define CMDQ_SYNC_TOKEN_IMGSYS_XTRAW			818
+#define CMDQ_SYNC_TOKEN_IMGSYS_DIP			819
+#define CMDQ_SYNC_TOKEN_IMGSYS_PQDIP_A			820
+#define CMDQ_SYNC_TOKEN_IMGSYS_PQDIP_B			821
+#define CMDQ_SYNC_TOKEN_IPESYS_ME			822
+#define CMDQ_SYNC_TOKEN_APUSYS_APU			823
+#define CMDQ_SYNC_TOKEN_IMGSYS_VSS_TRAW			824
+#define CMDQ_SYNC_TOKEN_IMGSYS_VSS_LTRAW		825
+#define CMDQ_SYNC_TOKEN_IMGSYS_VSS_XTRAW		826
+#define CMDQ_SYNC_TOKEN_IMGSYS_VSS_DIP			827
+#define CMDQ_SYNC_TOKEN_IMGSYS_OMC_LITE			828
+/* IMG software token for QoS */
+#define CMDQ_SYNC_TOKEN_IMGSYS_QOS_LOCK			829
+/* IMG software token for Qof */
+#define CMDQ_SYNC_TOKEN_DIP_POWER_CTRL			830
+#define CMDQ_SYNC_TOKEN_DIP_TRIG_PWR_ON			831
+#define CMDQ_SYNC_TOKEN_DIP_PWR_ON			832
+#define CMDQ_SYNC_TOKEN_DIP_TRIG_PWR_OFF		833
+#define CMDQ_SYNC_TOKEN_DIP_PWR_OFF			834
+#define CMDQ_SYNC_TOKEN_DIP_PWR_HAND_SHAKE		835
+#define CMDQ_SYNC_TOKEN_TRAW_POWER_CTRL			836
+#define CMDQ_SYNC_TOKEN_TRAW_TRIG_PWR_ON		837
+#define CMDQ_SYNC_TOKEN_TRAW_PWR_ON			838
+#define CMDQ_SYNC_TOKEN_TRAW_TRIG_PWR_OFF		839
+#define CMDQ_SYNC_TOKEN_TRAW_PWR_OFF			840
+#define CMDQ_SYNC_TOKEN_TRAW_PWR_HAND_SHAKE		841
+/* End of GCE1 software token */
+
+/* Begin of common software token */
+/*
+ * Notify normal CMDQ there are some secure task done
+ * MUST NOT CHANGE, this token sync with secure world
+ */
+#define CMDQ_SYNC_SECURE_THR_EOF			940
+/* CMDQ use software token */
+#define CMDQ_SYNC_TOKEN_USER_0				941
+#define CMDQ_SYNC_TOKEN_USER_1				942
+#define CMDQ_SYNC_TOKEN_POLL_MONITOR			943
+#define CMDQ_SYNC_TOKEN_TPR_LOCK			942
+/* TZMP software token */
+#define CMDQ_SYNC_TOKEN_TZMP_DISP_WAIT			943
+#define CMDQ_SYNC_TOKEN_TZMP_DISP_SET			944
+#define CMDQ_SYNC_TOKEN_TZMP_ISP_WAIT			945
+#define CMDQ_SYNC_TOKEN_TZMP_ISP_SET			946
+#define CMDQ_SYNC_TOKEN_TZMP_AIE_WAIT			947
+#define CMDQ_SYNC_TOKEN_TZMP_AIE_SET			948
+#define CMDQ_SYNC_TOKEN_TZMP_ADL_WAIT			949
+#define CMDQ_SYNC_TOKEN_TZMP_ADL_SET			950
+/* PREBUILT software token */
+#define CMDQ_SYNC_TOKEN_PREBUILT_MDP_LOCK		951
+#define CMDQ_SYNC_TOKEN_PREBUILT_MML_LOCK		952
+#define CMDQ_SYNC_TOKEN_PREBUILT_VFMT_LOCK		953
+#define CMDQ_SYNC_TOKEN_PREBUILT_DISP_LOCK		954
+#define CMDQ_SYNC_TOKEN_DISP_VA_START			955
+#define CMDQ_SYNC_TOKEN_DISP_VA_END			956
+
+/*
+ * Event for GPR timer, used in sleep and poll with timeout
+ *
+ * CMDQ_TOKEN_GPR_TIMER_R0~15: 994 ~ 1009
+ */
+#define CMDQ_TOKEN_GPR_TIMER_R(n)			(994 + (n))
+/* End of common software token */
+
+#endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 02/20] mailbox: mtk-cmdq: Refine DMA address handling for the command buffer
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header " Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 03/20] mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction Jason-JH Lin
                   ` (18 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

GCE can only fetch the command buffer address from a 32-bit register.
Some SoCs support a 35-bit command buffer address for GCE, which
requires a right shift of 3 bits before setting the address into
the 32-bit register. A comment has been added to the header of
cmdq_get_shift_pa() to explain this requirement.

To prevent the GCE command buffer address from being DMA mapped beyond
its supported bit range, the DMA bit mask for the device is set during
initialization.

Additionally, to ensure the correct shift is applied when setting or
reading the register that stores the GCE command buffer address,
new APIs, cmdq_convert_gce_addr() and cmdq_revert_gce_addr(), have
been introduced for consistent operations on this register.

The variable type for the command buffer address has been standardized
to dma_addr_t to prevent handling issues caused by type mismatches.

Fixes: 0858fde496f8 ("mailbox: cmdq: variablize address shift in platform")
Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c       | 45 ++++++++++++++++--------
 include/linux/mailbox/mtk-cmdq-mailbox.h | 10 ++++++
 2 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 654a60f63756..5791f80f995a 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -92,6 +92,18 @@ struct gce_plat {
 	u32 gce_num;
 };
 
+static inline u32 cmdq_convert_gce_addr(dma_addr_t addr, const struct gce_plat *pdata)
+{
+	/* Convert DMA addr (PA or IOVA) to GCE readable addr */
+	return addr >> pdata->shift;
+}
+
+static inline dma_addr_t cmdq_revert_gce_addr(u32 addr, const struct gce_plat *pdata)
+{
+	/* Revert GCE readable addr to DMA addr (PA or IOVA) */
+	return (dma_addr_t)addr << pdata->shift;
+}
+
 u8 cmdq_get_shift_pa(struct mbox_chan *chan)
 {
 	struct cmdq *cmdq = container_of(chan->mbox, struct cmdq, mbox);
@@ -188,13 +200,12 @@ static void cmdq_task_insert_into_thread(struct cmdq_task *task)
 	struct cmdq_task *prev_task = list_last_entry(
 			&thread->task_busy_list, typeof(*task), list_entry);
 	u64 *prev_task_base = prev_task->pkt->va_base;
+	u32 gce_addr = cmdq_convert_gce_addr(task->pa_base, task->cmdq->pdata);
 
 	/* let previous task jump to this task */
 	dma_sync_single_for_cpu(dev, prev_task->pa_base,
 				prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
-	prev_task_base[CMDQ_NUM_CMD(prev_task->pkt) - 1] =
-		(u64)CMDQ_JUMP_BY_PA << 32 |
-		(task->pa_base >> task->cmdq->pdata->shift);
+	prev_task_base[CMDQ_NUM_CMD(prev_task->pkt) - 1] = (u64)CMDQ_JUMP_BY_PA << 32 | gce_addr;
 	dma_sync_single_for_device(dev, prev_task->pa_base,
 				   prev_task->pkt->cmd_buf_size, DMA_TO_DEVICE);
 
@@ -237,7 +248,8 @@ static void cmdq_thread_irq_handler(struct cmdq *cmdq,
 				    struct cmdq_thread *thread)
 {
 	struct cmdq_task *task, *tmp, *curr_task = NULL;
-	u32 curr_pa, irq_flag, task_end_pa;
+	u32 irq_flag, gce_addr;
+	dma_addr_t curr_pa, task_end_pa;
 	bool err;
 
 	irq_flag = readl(thread->base + CMDQ_THR_IRQ_STATUS);
@@ -259,7 +271,8 @@ static void cmdq_thread_irq_handler(struct cmdq *cmdq,
 	else
 		return;
 
-	curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR) << cmdq->pdata->shift;
+	gce_addr = readl(thread->base + CMDQ_THR_CURR_ADDR);
+	curr_pa = cmdq_revert_gce_addr(gce_addr, cmdq->pdata);
 
 	list_for_each_entry_safe(task, tmp, &thread->task_busy_list,
 				 list_entry) {
@@ -378,7 +391,8 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)
 	struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv;
 	struct cmdq *cmdq = dev_get_drvdata(chan->mbox->dev);
 	struct cmdq_task *task;
-	unsigned long curr_pa, end_pa;
+	u32 gce_addr;
+	dma_addr_t curr_pa, end_pa;
 
 	/* Client should not flush new tasks if suspended. */
 	WARN_ON(cmdq->suspended);
@@ -402,20 +416,20 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)
 		 */
 		WARN_ON(cmdq_thread_reset(cmdq, thread) < 0);
 
-		writel(task->pa_base >> cmdq->pdata->shift,
-		       thread->base + CMDQ_THR_CURR_ADDR);
-		writel((task->pa_base + pkt->cmd_buf_size) >> cmdq->pdata->shift,
-		       thread->base + CMDQ_THR_END_ADDR);
+		gce_addr = cmdq_convert_gce_addr(task->pa_base, cmdq->pdata);
+		writel(gce_addr, thread->base + CMDQ_THR_CURR_ADDR);
+		gce_addr = cmdq_convert_gce_addr(task->pa_base + pkt->cmd_buf_size, cmdq->pdata);
+		writel(gce_addr, thread->base + CMDQ_THR_END_ADDR);
 
 		writel(thread->priority, thread->base + CMDQ_THR_PRIORITY);
 		writel(CMDQ_THR_IRQ_EN, thread->base + CMDQ_THR_IRQ_ENABLE);
 		writel(CMDQ_THR_ENABLED, thread->base + CMDQ_THR_ENABLE_TASK);
 	} else {
 		WARN_ON(cmdq_thread_suspend(cmdq, thread) < 0);
-		curr_pa = readl(thread->base + CMDQ_THR_CURR_ADDR) <<
-			cmdq->pdata->shift;
-		end_pa = readl(thread->base + CMDQ_THR_END_ADDR) <<
-			cmdq->pdata->shift;
+		gce_addr = readl(thread->base + CMDQ_THR_CURR_ADDR);
+		curr_pa = cmdq_revert_gce_addr(gce_addr, cmdq->pdata);
+		gce_addr = readl(thread->base + CMDQ_THR_END_ADDR);
+		end_pa = cmdq_revert_gce_addr(gce_addr, cmdq->pdata);
 		/* check boundary */
 		if (curr_pa == end_pa - CMDQ_INST_SIZE ||
 		    curr_pa == end_pa) {
@@ -646,6 +660,9 @@ static int cmdq_probe(struct platform_device *pdev)
 	if (err)
 		return err;
 
+	dma_set_coherent_mask(dev,
+			      DMA_BIT_MASK(sizeof(u32) * BITS_PER_BYTE + cmdq->pdata->shift));
+
 	cmdq->mbox.dev = dev;
 	cmdq->mbox.chans = devm_kcalloc(dev, cmdq->pdata->thread_nr,
 					sizeof(*cmdq->mbox.chans), GFP_KERNEL);
diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h
index 4c1a91b07de3..e1555e06e7e5 100644
--- a/include/linux/mailbox/mtk-cmdq-mailbox.h
+++ b/include/linux/mailbox/mtk-cmdq-mailbox.h
@@ -77,6 +77,16 @@ struct cmdq_pkt {
 	size_t			buf_size; /* real buffer size */
 };
 
+/**
+ * cmdq_get_shift_pa() - get the shift bits of physical address
+ * @chan: mailbox channel
+ *
+ * GCE can only fetch the command buffer address from a 32-bit register.
+ * Some SOCs support more than 32-bit command buffer address for GCE, which
+ * requires some shift bits to make the address fit into the 32-bit register.
+ *
+ * Return: the shift bits of physical address
+ */
 u8 cmdq_get_shift_pa(struct mbox_chan *chan);
 
 #endif /* __MTK_CMDQ_MAILBOX_H__ */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 03/20] mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header " Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 02/20] mailbox: mtk-cmdq: Refine DMA address handling for the command buffer Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 04/20] soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in cmdq_pkt_create() Jason-JH Lin
                   ` (17 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

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>
---
 drivers/mailbox/mtk-cmdq-mailbox.c       |  8 ++++++++
 include/linux/mailbox/mtk-cmdq-mailbox.h | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 5791f80f995a..95e8a5331b7c 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -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);
diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h
index e1555e06e7e5..73b70be4a8a7 100644
--- a/include/linux/mailbox/mtk-cmdq-mailbox.h
+++ b/include/linux/mailbox/mtk-cmdq-mailbox.h
@@ -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
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 04/20] soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in cmdq_pkt_create()
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (2 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 03/20] mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 05/20] soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for removing shift_pa Jason-JH Lin
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Add cmdq_get_mbox_priv() in cmdq_pkt_create() to ensure getting private
data before generating GCE instructions.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index 455221e8de24..8feeaa320359 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -140,6 +140,7 @@ int cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *pkt, size_t siz
 	}
 
 	pkt->pa_base = dma_addr;
+	cmdq_get_mbox_priv(client->chan, &pkt->priv);
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 05/20] soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for removing shift_pa
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (3 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 04/20] soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in cmdq_pkt_create() Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 06/20] mailbox: mtk-cmdq: Add GCE hardware virtualization configuration Jason-JH Lin
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Since shift_pa will be stored into the cmdq_mobx_priv of cmdq_pkt, all
the shif_pa parameters in CMDQ helper APIs can be removed.

Add cmdq_pkt_jump_rel_temp() for the current users of cmdq_pkt_jump_rel(),
and then remove shift_pa after all users have migrated to the new APIs.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 include/linux/soc/mediatek/mtk-cmdq.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index 0c3906e8ad19..9b6d855cacb9 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -377,6 +377,24 @@ static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_
  */
 int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa);
 
+/**
+ * cmdq_pkt_jump_rel_temp() - Temporary wrapper for new CMDQ helper API
+ * @pkt:	the CMDQ packet
+ * @offset:	relative offset of target instruction buffer from current PC.
+ * @shift_pa:	[DEPRECATED] shift bits of physical address in CMDQ instruction.
+ *		This value is got by cmdq_get_shift_pa().
+ *
+ * This function is a temporary wrapper that was introduced only for ease of
+ * migration of the many users of the CMDQ API located in multiple kernel
+ * subsystems.
+ *
+ * This has to be removed after all users are migrated to the newer CMDQ API.
+ */
+static inline int cmdq_pkt_jump_rel_temp(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
+{
+	return cmdq_pkt_jump_rel(pkt, offset, shift_pa);
+}
+
 /**
  * cmdq_pkt_eoc() - Append EOC and ask GCE to generate an IRQ at end of execution
  * @pkt:	The CMDQ packet
@@ -506,6 +524,12 @@ static inline int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_p
 	return -EINVAL;
 }
 
+/* This wrapper has to be removed after all users migrated to jump_rel */
+static inline int cmdq_pkt_jump_rel_temp(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
+{
+	return -EIMVAL;
+}
+
 static inline int cmdq_pkt_eoc(struct cmdq_pkt *pkt)
 {
 	return -EINVAL;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 06/20] mailbox: mtk-cmdq: Add GCE hardware virtualization configuration
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (4 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 05/20] soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for removing shift_pa Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 07/20] mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM transaction Jason-JH Lin
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

The GCE hardware virtualization configuration supports the isolation of
GCE hardware resources across different OS environments. Each OS is
treated as a virtual machine (VM) for GCE purposes.
There are 6 VMs and 1 host VM. The host VM has main control over the
GCE virtualization settings for all VMs.

To properly access the GCE thread registers, it is necessary to
configure access permissions for specific GCE threads assigned to
different VMs.
Currently, since only the host VM is being used, it is required to
enable access permissions for all GCE threads for the host VM.

There are 2 VM configurations:
1. VM_ID_MAP
There are 4 registers to allocate 32 GCE threads across different VMs:
VM_ID_MAP0 for threads 0-9, VM_ID_MAP1 for threads 10-19,
VM_ID_MAP2 for threads 20-29, and VM_ID_MAP3 for threads 30-31.
Each thread has a 3-bit configuration, where setting all bits to 1
configures the thread for the host VM.

2. VM_CPR_GSIZE
It is used to allocate the CPR SRAM size to each VM. Each VM has 4-bit
configuration, where setting bit 0-3 to configures the size of host VM.
This setting must be configured before the VM configuration to prevent
resource leakage.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 48 ++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 95e8a5331b7c..a544108ddae7 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -43,6 +43,13 @@
 #define GCE_CTRL_BY_SW				GENMASK(2, 0)
 #define GCE_DDR_EN				GENMASK(18, 16)
 
+#define GCE_VM_ID_MAP(n)		(0x5018 + (n) / 10 * 4)
+#define GCE_VM_ID_MAP_THR_FLD_SHIFT(n)		((n) % 10 * 3)
+#define GCE_VM_ID_MAP_HOST_VM			GENMASK(2, 0)
+#define GCE_VM_CPR_GSIZE		0x50c4
+#define GCE_VM_CPR_GSIZE_FLD_SHIFT(vm_id)	((vm_id) * 4)
+#define GCE_VM_CPR_GSIZE_MAX			GENMASK(3, 0)
+
 #define CMDQ_THR_ACTIVE_SLOT_CYCLES	0x3200
 #define CMDQ_THR_ENABLED		0x1
 #define CMDQ_THR_DISABLED		0x0
@@ -89,6 +96,7 @@ struct gce_plat {
 	u8 shift;
 	bool control_by_sw;
 	bool sw_ddr_en;
+	bool gce_vm;
 	u32 gce_num;
 };
 
@@ -120,6 +128,45 @@ u8 cmdq_get_shift_pa(struct mbox_chan *chan)
 }
 EXPORT_SYMBOL(cmdq_get_shift_pa);
 
+static void cmdq_vm_init(struct cmdq *cmdq)
+{
+	int i;
+	u32 vm_cpr_gsize = 0, vm_id_map = 0;
+	u32 *vm_map = NULL;
+
+	if (!cmdq->pdata->gce_vm)
+		return;
+
+	vm_map = kcalloc(cmdq->pdata->thread_nr, sizeof(*vm_map), GFP_KERNEL);
+	if (!vm_map)
+		return;
+
+	/* only configure the max CPR SRAM size to host vm (vm_id = 0) currently */
+	vm_cpr_gsize = GCE_VM_CPR_GSIZE_MAX << GCE_VM_CPR_GSIZE_FLD_SHIFT(0);
+
+	/* set all thread mapping to host vm currently */
+	for (i = 0; i < cmdq->pdata->thread_nr; i++)
+		vm_map[i] = GCE_VM_ID_MAP_HOST_VM << GCE_VM_ID_MAP_THR_FLD_SHIFT(i);
+
+	/* set the amount of CPR SRAM to allocate to each VM */
+	writel(vm_cpr_gsize, cmdq->base + GCE_VM_CPR_GSIZE);
+
+	/* config CPR_GSIZE before setting VM_ID_MAP to avoid data leakage */
+	for (i = 0; i < cmdq->pdata->thread_nr; i++) {
+		vm_id_map |= vm_map[i];
+		/* config every 10 threads, e.g., thread id=0~9, 10~19, ..., into one register */
+		if ((i + 1) % 10 == 0) {
+			writel(vm_id_map, cmdq->base + GCE_VM_ID_MAP(i));
+			vm_id_map = 0;
+		}
+	}
+	/* config remaining threads settings */
+	if (cmdq->pdata->thread_nr % 10 != 0)
+		writel(vm_id_map, cmdq->base + GCE_VM_ID_MAP(cmdq->pdata->thread_nr - 1));
+
+	kfree(vm_map);
+}
+
 static void cmdq_gctl_value_toggle(struct cmdq *cmdq, bool ddr_enable)
 {
 	u32 val = cmdq->pdata->control_by_sw ? GCE_CTRL_BY_SW : 0;
@@ -164,6 +211,7 @@ static void cmdq_init(struct cmdq *cmdq)
 
 	WARN_ON(clk_bulk_enable(cmdq->pdata->gce_num, cmdq->clocks));
 
+	cmdq_vm_init(cmdq);
 	cmdq_gctl_value_toggle(cmdq, true);
 
 	writel(CMDQ_THR_ACTIVE_SLOT_CYCLES, cmdq->base + CMDQ_THR_SLOT_CYCLES);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 07/20] mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM transaction
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (5 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 06/20] mailbox: mtk-cmdq: Add GCE hardware virtualization configuration Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 08/20] mailbox: mtk-cmdq: Add driver data to support for MT8196 Jason-JH Lin
                   ` (13 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

The GCE in MT8196 is placed in MMINFRA and requires all addresses
in GCE instructions for DRAM transactions to be IOVA.

Due to MMIO, if the GCE needs to access a hardware register at
0x1000_0000, but the SMMU is also mapping a DRAM block at 0x1000_0000,
the MMINFRA will not know whether to write to the hardware register or
the DRAM.
To solve this, MMINFRA treats addresses greater than 2G as data paths
and those less than 2G as config paths because the DRAM start address
is currently at 2G (0x8000_0000). On the data path, MMINFRA remaps
DRAM addresses by subtracting 2G, allowing SMMU to map DRAM addresses
less than 2G.
For example, if the DRAM start address 0x8000_0000 is mapped to
IOVA=0x0, when GCE accesses IOVA=0x0, it must add a 2G offset to
the address in the GCE instruction. MMINFRA will then see it as a
data path (IOVA >= 2G) and subtract 2G, allowing GCE to access IOVA=0x0.

Since the MMINFRA remap subtracting 2G is done in hardware and cannot
be configured by software, the address of DRAM in GCE instruction must
always add 2G to ensure proper access. After that, the shift functions
do more than just shift addresses, so the APIs were renamed to
cmdq_convert_gce_addr() and cmdq_revert_gce_addr().

This 2G adjustment is referred to as mminfra_offset in the CMDQ driver.
CMDQ helper can get the mminfra_offset from the cmdq_mbox_priv of
cmdq_pkt and add the mminfra_offset to the DRAM address in GCE
instructions.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c       | 6 ++++--
 include/linux/mailbox/mtk-cmdq-mailbox.h | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index a544108ddae7..a9c06e4bbad4 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -94,6 +94,7 @@ struct cmdq {
 struct gce_plat {
 	u32 thread_nr;
 	u8 shift;
+	dma_addr_t mminfra_offset;
 	bool control_by_sw;
 	bool sw_ddr_en;
 	bool gce_vm;
@@ -103,13 +104,13 @@ struct gce_plat {
 static inline u32 cmdq_convert_gce_addr(dma_addr_t addr, const struct gce_plat *pdata)
 {
 	/* Convert DMA addr (PA or IOVA) to GCE readable addr */
-	return addr >> pdata->shift;
+	return (addr + pdata->mminfra_offset) >> pdata->shift;
 }
 
 static inline dma_addr_t cmdq_revert_gce_addr(u32 addr, const struct gce_plat *pdata)
 {
 	/* Revert GCE readable addr to DMA addr (PA or IOVA) */
-	return (dma_addr_t)addr << pdata->shift;
+	return ((dma_addr_t)addr << pdata->shift) - pdata->mminfra_offset;
 }
 
 void cmdq_get_mbox_priv(struct mbox_chan *chan, struct cmdq_mbox_priv *priv)
@@ -117,6 +118,7 @@ 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;
+	priv->mminfra_offset = cmdq->pdata->mminfra_offset;
 }
 EXPORT_SYMBOL(cmdq_get_mbox_priv);
 
diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h
index 73b70be4a8a7..07c1bfbdb8c4 100644
--- a/include/linux/mailbox/mtk-cmdq-mailbox.h
+++ b/include/linux/mailbox/mtk-cmdq-mailbox.h
@@ -72,6 +72,7 @@ struct cmdq_cb_data {
 
 struct cmdq_mbox_priv {
 	u8 shift_pa;
+	dma_addr_t mminfra_offset;
 };
 
 struct cmdq_pkt {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 08/20] mailbox: mtk-cmdq: Add driver data to support for MT8196
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (6 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 07/20] mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM transaction Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 09/20] soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without subsys ID support Jason-JH Lin
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media, CK Hu

MT8196 has 2 new hardware configuration compared with the previous SoC,
which correspond to the 2 new driver data:

1. mminfra_offset: For GCE data path control
   Since GCE has been moved into mminfra, GCE needs to append the
   mminfra offset to the DRAM address when accessing the DRAM.

2. gce_vm: For GCE hardware virtualization control
   Currently, the first version of the mt8196 mailbox controller only
   requires setting the VM-related registers to enable the permissions
   of a host VM.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index a9c06e4bbad4..1bf6984948ef 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -14,6 +14,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/sizes.h>
 #include <linux/mailbox_controller.h>
 #include <linux/mailbox/mtk-cmdq-mailbox.h>
 #include <linux/of.h>
@@ -840,6 +841,16 @@ static const struct gce_plat gce_plat_mt8195 = {
 	.gce_num = 2
 };
 
+static const struct gce_plat gce_plat_mt8196 = {
+	.thread_nr = 32,
+	.shift = 3,
+	.mminfra_offset = SZ_2G,
+	.control_by_sw = true,
+	.sw_ddr_en = true,
+	.gce_vm = true,
+	.gce_num = 2
+};
+
 static const struct of_device_id cmdq_of_ids[] = {
 	{.compatible = "mediatek,mt6779-gce", .data = (void *)&gce_plat_mt6779},
 	{.compatible = "mediatek,mt8173-gce", .data = (void *)&gce_plat_mt8173},
@@ -848,6 +859,7 @@ static const struct of_device_id cmdq_of_ids[] = {
 	{.compatible = "mediatek,mt8188-gce", .data = (void *)&gce_plat_mt8188},
 	{.compatible = "mediatek,mt8192-gce", .data = (void *)&gce_plat_mt8192},
 	{.compatible = "mediatek,mt8195-gce", .data = (void *)&gce_plat_mt8195},
+	{.compatible = "mediatek,mt8196-gce", .data = (void *)&gce_plat_mt8196},
 	{}
 };
 MODULE_DEVICE_TABLE(of, cmdq_of_ids);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 09/20] soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without subsys ID support
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (7 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 08/20] mailbox: mtk-cmdq: Add driver data to support for MT8196 Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID Jason-JH Lin
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

When GCE executes instructions, it typically locates the corresponding
hardware register using the subsys ID. For hardware that does not
support subsys ID, the subsys ID is set to an invalid value, and the
physical address must be used to generate GCE instructions.

The main advantage of using subsys ID is to reduce the number of
instructions. Without subsys ID, an additional `ASSIGN` instruction
is needed to assign the high bytes of the physical address, which can
impact performance if too many instructions are required. However, if
the hardware does not support subsys ID, using the physical address
is the only option to achieve the same functionality.

This commit adds a pa_base parsing flow to the cmdq_client_reg structure
to handle hardware without subsys ID support.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c | 16 ++++++++++++++--
 include/linux/soc/mediatek/mtk-cmdq.h  |  3 +++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index 8feeaa320359..80806fbeba91 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -8,6 +8,7 @@
 #include <linux/module.h>
 #include <linux/mailbox_controller.h>
 #include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/soc/mediatek/mtk-cmdq.h>
 
 #define CMDQ_WRITE_ENABLE_MASK	BIT(0)
@@ -60,20 +61,31 @@ int cmdq_dev_get_client_reg(struct device *dev,
 			    struct cmdq_client_reg *client_reg, int idx)
 {
 	struct of_phandle_args spec;
+	struct resource res;
 	int err;
 
 	if (!client_reg)
 		return -ENOENT;
 
+	err = of_address_to_resource(dev->of_node, 0, &res);
+	if (err) {
+		dev_err(dev, "Missing reg in %s node\n", dev->of_node->full_name);
+		return -EINVAL;
+	}
+	client_reg->pa_base = res.start;
+
 	err = of_parse_phandle_with_fixed_args(dev->of_node,
 					       "mediatek,gce-client-reg",
 					       3, idx, &spec);
 	if (err < 0) {
-		dev_warn(dev,
+		dev_dbg(dev,
 			"error %d can't parse gce-client-reg property (%d)",
 			err, idx);
 
-		return err;
+		/* make subsys invalid */
+		client_reg->subsys = CMDQ_SUBSYS_INVALID;
+
+		return 0;
 	}
 
 	client_reg->subsys = (u8)spec.args[0];
diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index 9b6d855cacb9..154d0511a0ad 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -23,6 +23,8 @@
 #define CMDQ_THR_SPR_IDX2	(2)
 #define CMDQ_THR_SPR_IDX3	(3)
 
+#define CMDQ_SUBSYS_INVALID	(U8_MAX)
+
 struct cmdq_pkt;
 
 enum cmdq_logic_op {
@@ -52,6 +54,7 @@ struct cmdq_operand {
 
 struct cmdq_client_reg {
 	u8 subsys;
+	phys_addr_t pa_base;
 	u16 offset;
 	u16 size;
 };
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (8 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 09/20] soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without subsys ID support Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 11/20] soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM addresses Jason-JH Lin
                   ` (10 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

This patch extends the cmdq_pkt_write API to support SoCs that do not
have subsys ID mapping by introducing new register write APIs:
- cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() replace
  cmdq_pkt_write()
- cmdq_pkt_write_mask_pa() and cmdq_pkt_write_mask_subsys() replace
  cmdq_pkt_write_mask()

To ensure consistent function pointer interfaces, both
cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() provide subsys and
pa_base parameters. This unifies how register writes are invoked,
regardless of whether subsys ID is supported by the device.

All GCEs support writing registers by PA (with mask) without subsys,
but this requires extra GCE instructions to convert the PA into a GCE
readable format, reducing performance compared to using subsys directly.
Therefore, subsys is preferred for register writes when available.

API documentation and function pointer declarations in cmdq_client_reg
have been updated. The original write APIs will be removed after all
CMDQ users transition to the new interfaces.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c | 54 +++++++++++++++++
 include/linux/soc/mediatek/mtk-cmdq.h  | 83 ++++++++++++++++++++++++++
 2 files changed, 137 insertions(+)

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index 80806fbeba91..a884e481efa6 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -85,6 +85,16 @@ int cmdq_dev_get_client_reg(struct device *dev,
 		/* make subsys invalid */
 		client_reg->subsys = CMDQ_SUBSYS_INVALID;
 
+		/*
+		 * 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.
+		 */
+		client_reg->reg_write = cmdq_pkt_write_pa;
+		client_reg->reg_write_mask = cmdq_pkt_write_mask_pa;
+
 		return 0;
 	}
 
@@ -93,6 +103,9 @@ int cmdq_dev_get_client_reg(struct device *dev,
 	client_reg->size = (u16)spec.args[2];
 	of_node_put(spec.np);
 
+	client_reg->reg_write = cmdq_pkt_write_subsys;
+	client_reg->reg_write_mask = cmdq_pkt_write_mask_subsys;
+
 	return 0;
 }
 EXPORT_SYMBOL(cmdq_dev_get_client_reg);
@@ -214,6 +227,26 @@ int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value)
 }
 EXPORT_SYMBOL(cmdq_pkt_write);
 
+int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/, u32 pa_base,
+		      u16 offset, u32 value)
+{
+	int err;
+
+	err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base));
+	if (err < 0)
+		return err;
+
+	return cmdq_pkt_write_s_value(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_LOW(offset), value);
+}
+EXPORT_SYMBOL(cmdq_pkt_write_pa);
+
+int cmdq_pkt_write_subsys(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base /*unused*/,
+			  u16 offset, u32 value)
+{
+	return cmdq_pkt_write(pkt, subsys, offset, value);
+}
+EXPORT_SYMBOL(cmdq_pkt_write_subsys);
+
 int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
 			u16 offset, u32 value, u32 mask)
 {
@@ -231,6 +264,27 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
 }
 EXPORT_SYMBOL(cmdq_pkt_write_mask);
 
+int cmdq_pkt_write_mask_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/, u32 pa_base,
+			   u16 offset, u32 value, u32 mask)
+{
+	int err;
+
+	err = cmdq_pkt_assign(pkt, CMDQ_THR_SPR_IDX0, CMDQ_ADDR_HIGH(pa_base));
+	if (err < 0)
+		return err;
+
+	return cmdq_pkt_write_s_mask_value(pkt, CMDQ_THR_SPR_IDX0,
+					   CMDQ_ADDR_LOW(offset), value, mask);
+}
+EXPORT_SYMBOL(cmdq_pkt_write_mask_pa);
+
+int cmdq_pkt_write_mask_subsys(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base /*unused*/,
+			       u16 offset, u32 value, u32 mask)
+{
+	return cmdq_pkt_write_mask(pkt, subsys, offset, value, mask);
+}
+EXPORT_SYMBOL(cmdq_pkt_write_mask_subsys);
+
 int cmdq_pkt_read_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx, u16 addr_low,
 		    u16 reg_idx)
 {
diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index 154d0511a0ad..f6dc43c036bd 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -57,6 +57,10 @@ struct cmdq_client_reg {
 	phys_addr_t pa_base;
 	u16 offset;
 	u16 size;
+	int (*reg_write)(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base,
+			 u16 offset, u32 value);
+	int (*reg_write_mask)(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base,
+			      u16 offset, u32 value, u32 mask);
 };
 
 struct cmdq_client {
@@ -124,6 +128,32 @@ void cmdq_pkt_destroy(struct cmdq_client *client, struct cmdq_pkt *pkt);
  */
 int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value);
 
+/**
+ * cmdq_pkt_write_pa() - append write command to the CMDQ packet with pa_base
+ * @pkt:	the CMDQ packet
+ * @subsys:	unused parameter
+ * @pa_base:	the physical address base of the hardware register
+ * @offset:	register offset from CMDQ sub system
+ * @value:	the specified target register value
+ *
+ * Return: 0 for success; else the error code is returned
+ */
+int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
+		      u32 pa_base, u16 offset, u32 value);
+
+/**
+ * cmdq_pkt_write_subsys() - append write command to the CMDQ packet with subsys
+ * @pkt:	the CMDQ packet
+ * @subsys:	the CMDQ sub system code
+ * @pa_base:	unused parameter
+ * @offset:	register offset from CMDQ sub system
+ * @value:	the specified target register value
+ *
+ * Return: 0 for success; else the error code is returned
+ */
+int cmdq_pkt_write_subsys(struct cmdq_pkt *pkt, u8 subsys,
+			  u32 pa_base /*unused*/, u16 offset, u32 value);
+
 /**
  * cmdq_pkt_write_mask() - append write command with mask to the CMDQ packet
  * @pkt:	the CMDQ packet
@@ -137,6 +167,34 @@ int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value);
 int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
 			u16 offset, u32 value, u32 mask);
 
+/**
+ * cmdq_pkt_write_mask_pa() - append write command with mask to the CMDQ packet with pa
+ * @pkt:	the CMDQ packet
+ * @subsys:	unused parameter
+ * @pa_base:	the physical address base of the hardware register
+ * @offset:	register offset from CMDQ sub system
+ * @value:	the specified target register value
+ * @mask:	the specified target register mask
+ *
+ * Return: 0 for success; else the error code is returned
+ */
+int cmdq_pkt_write_mask_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
+			   u32 pa_base, u16 offset, u32 value, u32 mask);
+
+/**
+ * cmdq_pkt_write_mask_subsys() - append write command with mask to the CMDQ packet with subsys
+ * @pkt:	the CMDQ packet
+ * @subsys:	the CMDQ sub system code
+ * @pa_base:	unused parameter
+ * @offset:	register offset from CMDQ sub system
+ * @value:	the specified target register value
+ * @mask:	the specified target register mask
+ *
+ * Return: 0 for success; else the error code is returned
+ */
+int cmdq_pkt_write_mask_subsys(struct cmdq_pkt *pkt, u8 subsys,
+			       u32 pa_base /*unused*/, u16 offset, u32 value, u32 mask);
+
 /*
  * cmdq_pkt_read_s() - append read_s command to the CMDQ packet
  * @pkt:	the CMDQ packet
@@ -439,12 +497,37 @@ static inline int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u3
 	return -ENOENT;
 }
 
+static inline int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
+				    u32 pa_base, u16 offset, u32 value)
+{
+	return -ENOENT;
+}
+
+static inline int cmdq_pkt_write_subsys(struct cmdq_pkt *pkt, u8 subsys,
+					u32 pa_base /*unused*/, u16 offset, u32 value)
+{
+	return -ENOENT;
+}
+
 static inline int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
 				      u16 offset, u32 value, u32 mask)
 {
 	return -ENOENT;
 }
 
+static inline int cmdq_pkt_write_mask_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
+					 u32 pa_base, u16 offset, u32 value, u32 mask)
+{
+	return -ENOENT;
+}
+
+static inline int cmdq_pkt_write_mask_subsys(struct cmdq_pkt *pkt, u8 subsys,
+					     u32 pa_base /*unused*/, u16 offset,
+					     u32 value, u32 mask)
+{
+	return -ENOENT;
+}
+
 static inline int cmdq_pkt_read_s(struct cmdq_pkt *pkt, u16 high_addr_reg_idx,
 				  u16 addr_low, u16 reg_idx)
 {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 11/20] soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM addresses
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (9 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 12/20] soc: mediatek: Use reg_write function pointer for subsys ID compatibility Jason-JH Lin
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Since GCE has been moved to MMINFRA in MT8196, all transactions from
MMINFRA to DRAM will have their addresses adjusted by subtracting a
mminfra_offset.

Therefore, the CMDQ helper driver needs to get the mminfra_offset value
of the SoC from cmdq_mbox_priv of cmdq_pkt and then add it to the DRAM
address when generating instructions to ensure GCE accesses the correct
DRAM address. CMDQ users can then call CMDQ helper APIs as usual.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index a884e481efa6..1b4d4a1e2984 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -372,6 +372,7 @@ int cmdq_pkt_mem_move(struct cmdq_pkt *pkt, dma_addr_t src_addr, dma_addr_t dst_
 	int ret;
 
 	/* read the value of src_addr into high_addr_reg_idx */
+	src_addr += pkt->priv.mminfra_offset;
 	ret = cmdq_pkt_assign(pkt, high_addr_reg_idx, CMDQ_ADDR_HIGH(src_addr));
 	if (ret < 0)
 		return ret;
@@ -380,6 +381,7 @@ int cmdq_pkt_mem_move(struct cmdq_pkt *pkt, dma_addr_t src_addr, dma_addr_t dst_
 		return ret;
 
 	/* write the value of value_reg_idx into dst_addr */
+	dst_addr += pkt->priv.mminfra_offset;
 	ret = cmdq_pkt_assign(pkt, high_addr_reg_idx, CMDQ_ADDR_HIGH(dst_addr));
 	if (ret < 0)
 		return ret;
@@ -505,7 +507,7 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32 value, u32 mas
 	inst.op = CMDQ_CODE_MASK;
 	inst.dst_t = CMDQ_REG_TYPE;
 	inst.sop = CMDQ_POLL_ADDR_GPR;
-	inst.value = addr;
+	inst.value = addr + pkt->priv.mminfra_offset;
 	ret = cmdq_pkt_append_command(pkt, inst);
 	if (ret < 0)
 		return ret;
@@ -565,7 +567,7 @@ int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
 	struct cmdq_instruction inst = {
 		.op = CMDQ_CODE_JUMP,
 		.offset = CMDQ_JUMP_ABSOLUTE,
-		.value = addr >> shift_pa
+		.value = (addr +  pkt->priv.mminfra_offset) >> pkt->priv.shift_pa
 	};
 	return cmdq_pkt_append_command(pkt, inst);
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 12/20] soc: mediatek: Use reg_write function pointer for subsys ID compatibility
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (10 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 11/20] soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM addresses Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-17  6:44 ` [PATCH v8 13/20] drm/mediatek:Use " Jason-JH Lin
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Switch to reg_write and reg_write_mask function pointers for register
access, enabling compatibility with platforms regardless of subsys ID
support.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
 drivers/soc/mediatek/mtk-mmsys.c | 8 +++++---
 drivers/soc/mediatek/mtk-mutex.c | 5 +++--
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-mmsys.c b/drivers/soc/mediatek/mtk-mmsys.c
index bb4639ca0b8c..5d3a9bbfda79 100644
--- a/drivers/soc/mediatek/mtk-mmsys.c
+++ b/drivers/soc/mediatek/mtk-mmsys.c
@@ -167,9 +167,11 @@ 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);
+		ret = mmsys->cmdq_base.reg_write_mask(cmdq_pkt,
+						      mmsys->cmdq_base.subsys,
+						      mmsys->cmdq_base.pa_base,
+						      mmsys->cmdq_base.offset + 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..bb42ad5ee8ca 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,8 @@ 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);
+	mtx->cmdq_reg.reg_write(cmdq_pkt, mtx->cmdq_reg.subsys, en_addr, en_addr, 1);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(mtk_mutex_enable_by_cmdq);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 13/20] drm/mediatek:Use reg_write function pointer for subsys ID compatibility
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (11 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 12/20] soc: mediatek: Use reg_write function pointer for subsys ID compatibility Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-28  5:47   ` CK Hu (胡俊光)
  2025-10-17  6:44 ` [PATCH v8 14/20] media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change Jason-JH Lin
                   ` (7 subsequent siblings)
  20 siblings, 2 replies; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Switch to reg_write and reg_write_mask function pointers for register
access, enabling compatibility with platforms regardless of subsys ID
support.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
index ac6620e10262..aa217fb11fd7 100644
--- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
+++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
@@ -72,8 +72,8 @@ void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
 {
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
 	if (cmdq_pkt)
-		cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
-			       cmdq_reg->offset + offset, value);
+		cmdq_reg->reg_write(cmdq_pkt, cmdq_reg->subsys, cmdq_reg->pa_base,
+				    cmdq_reg->offset + offset, value);
 	else
 #endif
 		writel(value, regs + offset);
@@ -85,8 +85,8 @@ void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
 {
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
 	if (cmdq_pkt)
-		cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
-			       cmdq_reg->offset + offset, value);
+		cmdq_reg->reg_write(cmdq_pkt, cmdq_reg->subsys, cmdq_reg->pa_base,
+				    cmdq_reg->offset + offset, value);
 	else
 #endif
 		writel_relaxed(value, regs + offset);
@@ -98,8 +98,8 @@ void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
 {
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
 	if (cmdq_pkt) {
-		cmdq_pkt_write_mask(cmdq_pkt, cmdq_reg->subsys,
-				    cmdq_reg->offset + offset, value, mask);
+		cmdq_reg->reg_write_mask(cmdq_pkt, cmdq_reg->subsys, cmdq_reg->pa_base,
+					 cmdq_reg->offset + offset, value, mask);
 	} else {
 #endif
 		u32 tmp = readl(regs + offset);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 14/20] media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (12 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 13/20] drm/mediatek:Use " Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 15/20] media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to cmdq_pkt_jump_rel_temp() Jason-JH Lin
                   ` (6 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Update CMDQ register writes to use subsys-aware APIs,
cmdq_pkt_write_subsys() and cmdq_pkt_write_mask_subsys().
This conforms to recent CMDQ API changes that split access by
subsys ID support.

Since all current MDP SoCs support subsys ID, and future MDP
deployments will not run on SoCs without subsys ID, only
subsys-specific API calls are needed. No logic for non-subsys ID
hardware is required.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 4 ++--
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index e5ccf673e152..d0b0b072f953 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -321,7 +321,7 @@ static int mdp_path_config_subfrm(struct mdp_cmdq_cmd *cmd,
 	/* Enable mux settings */
 	for (index = 0; index < ctrl->num_sets; index++) {
 		set = &ctrl->sets[index];
-		cmdq_pkt_write(&cmd->pkt, set->subsys_id, set->reg, set->value);
+		cmdq_pkt_write_subsys(&cmd->pkt, set->subsys_id, set->reg, set->reg, set->value);
 	}
 	/* Config sub-frame information */
 	for (index = (num_comp - 1); index >= 0; index--) {
@@ -376,7 +376,7 @@ static int mdp_path_config_subfrm(struct mdp_cmdq_cmd *cmd,
 	/* Disable mux settings */
 	for (index = 0; index < ctrl->num_sets; index++) {
 		set = &ctrl->sets[index];
-		cmdq_pkt_write(&cmd->pkt, set->subsys_id, set->reg, 0);
+		cmdq_pkt_write_subsys(&cmd->pkt, set->subsys_id, set->reg, set->reg, 0);
 	}
 
 	return 0;
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h
index 681906c16419..c6fc180950f2 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-comp.h
@@ -12,14 +12,14 @@
 #define MM_REG_WRITE_MASK(cmd, id, base, ofst, val, mask)	\
 do {								\
 	typeof(mask) (m) = (mask);				\
-	cmdq_pkt_write_mask(&((cmd)->pkt), id, (base) + (ofst),	\
-			    (val),				\
+	cmdq_pkt_write_mask_subsys(&((cmd)->pkt), (id), (base),	\
+				   (base) + (ofst), (val),	\
 		(((m) & (ofst##_MASK)) == (ofst##_MASK)) ?	\
 			(0xffffffff) : (m));			\
 } while (0)
 
 #define MM_REG_WRITE(cmd, id, base, ofst, val)			\
-	cmdq_pkt_write(&((cmd)->pkt), id, (base) + (ofst), (val))
+	cmdq_pkt_write_subsys(&((cmd)->pkt), (id), (base), (base) + (ofst), (val))
 
 #define MM_REG_WAIT(cmd, evt)					\
 do {								\
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 15/20] media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to cmdq_pkt_jump_rel_temp()
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (13 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 14/20] media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 16/20] soc: mediatek: mtk-cmdq: Remove shift_pa parameter from cmdq_pkt_jump() Jason-JH Lin
                   ` (5 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

To facilitate the removal of the shift_pa parameter from
cmdq_pkt_jump_rel(), current users of cmdq_pkt_jump_rel() need to
transition to using cmdq_pkt_jump_rel_temp() before the API change
is implemented.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index d0b0b072f953..5fc9263ccb78 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -628,7 +628,7 @@ static struct mdp_cmdq_cmd *mdp_cmdq_prepare(struct mdp_dev *mdp,
 		goto err_free_path;
 	}
 	cmdq_pkt_eoc(&cmd->pkt);
-	cmdq_pkt_jump_rel(&cmd->pkt, CMDQ_INST_SIZE, mdp->cmdq_shift_pa[pp_idx]);
+	cmdq_pkt_jump_rel_temp(&cmd->pkt, CMDQ_INST_SIZE, mdp->cmdq_shift_pa[pp_idx]);
 
 	for (i = 0; i < num_comp; i++) {
 		s32 inner_id = MDP_COMP_NONE;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 16/20] soc: mediatek: mtk-cmdq: Remove shift_pa parameter from cmdq_pkt_jump()
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (14 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 15/20] media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to cmdq_pkt_jump_rel_temp() Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 17/20] media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa Jason-JH Lin
                   ` (4 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Since shift_pa will be stored in the cmdq_mbox_priv structure within
cmdq_pkt, all shift_pa parameters in CMDQ helper APIs can be removed.

Remove the shift_pa parameters from cmdq_pkt_jump(), cmdq_pkt_jump_abs(),
and cmdq_pkt_jump_rel().

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c |  6 +++---
 include/linux/soc/mediatek/mtk-cmdq.h  | 20 ++++++++------------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index 1b4d4a1e2984..0ab87eb04614 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -562,7 +562,7 @@ int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value)
 }
 EXPORT_SYMBOL(cmdq_pkt_assign);
 
-int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
+int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr)
 {
 	struct cmdq_instruction inst = {
 		.op = CMDQ_CODE_JUMP,
@@ -573,11 +573,11 @@ int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
 }
 EXPORT_SYMBOL(cmdq_pkt_jump_abs);
 
-int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
+int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset)
 {
 	struct cmdq_instruction inst = {
 		.op = CMDQ_CODE_JUMP,
-		.value = (u32)offset >> shift_pa
+		.value = (u32)offset >> pkt->priv.shift_pa
 	};
 	return cmdq_pkt_append_command(pkt, inst);
 }
diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index f6dc43c036bd..af66410b06d1 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -411,17 +411,15 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32 value, u32 mas
  *			 contains more instruction.
  * @pkt:        the CMDQ packet
  * @addr:       absolute physical address of target instruction buffer
- * @shift_pa:	shift bits of physical address in CMDQ instruction. This value
- *		is got by cmdq_get_shift_pa().
  *
  * Return: 0 for success; else the error code is returned
  */
-int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa);
+int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr);
 
 /* This wrapper has to be removed after all users migrated to jump_abs */
-static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
+static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr)
 {
-	return cmdq_pkt_jump_abs(pkt, addr, shift_pa);
+	return cmdq_pkt_jump_abs(pkt, addr);
 }
 
 /**
@@ -431,12 +429,10 @@ static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_
  *			 target address should contains more instruction.
  * @pkt:	the CMDQ packet
  * @offset:	relative offset of target instruction buffer from current PC.
- * @shift_pa:	shift bits of physical address in CMDQ instruction. This value
- *		is got by cmdq_get_shift_pa().
  *
  * Return: 0 for success; else the error code is returned
  */
-int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa);
+int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset);
 
 /**
  * cmdq_pkt_jump_rel_temp() - Temporary wrapper for new CMDQ helper API
@@ -453,7 +449,7 @@ int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa);
  */
 static inline int cmdq_pkt_jump_rel_temp(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
 {
-	return cmdq_pkt_jump_rel(pkt, offset, shift_pa);
+	return cmdq_pkt_jump_rel(pkt, offset);
 }
 
 /**
@@ -595,17 +591,17 @@ static inline int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32
 	return -EINVAL;
 }
 
-static inline int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
+static inline int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr)
 {
 	return -EINVAL;
 }
 
-static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa)
+static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr)
 {
 	return -EINVAL;
 }
 
-static inline int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
+static inline int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset)
 {
 	return -EINVAL;
 }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 17/20] media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (15 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 16/20] soc: mediatek: mtk-cmdq: Remove shift_pa parameter from cmdq_pkt_jump() Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 18/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp() Jason-JH Lin
                   ` (3 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

With the removal of the shift_pa parameter, cmdq_pkt_jump_rel_temp()
can be replaced by the new cmdq_pkt_jump_rel() without shift_pa.

Then, remove the cmdq_shift_pa variable in the mdp_dev structure for
each mbox client.

Fixes: ade176534112 ("soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()")
Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 2 +-
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 2 --
 drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 -
 3 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
index 5fc9263ccb78..7da5424d7e62 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c
@@ -628,7 +628,7 @@ static struct mdp_cmdq_cmd *mdp_cmdq_prepare(struct mdp_dev *mdp,
 		goto err_free_path;
 	}
 	cmdq_pkt_eoc(&cmd->pkt);
-	cmdq_pkt_jump_rel_temp(&cmd->pkt, CMDQ_INST_SIZE, mdp->cmdq_shift_pa[pp_idx]);
+	cmdq_pkt_jump_rel(&cmd->pkt, CMDQ_INST_SIZE);
 
 	for (i = 0; i < num_comp; i++) {
 		s32 inner_id = MDP_COMP_NONE;
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
index 6559d72d5d42..4ac90f789062 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c
@@ -293,8 +293,6 @@ static int mdp_probe(struct platform_device *pdev)
 			ret = PTR_ERR(mdp->cmdq_clt[i]);
 			goto err_mbox_destroy;
 		}
-
-		mdp->cmdq_shift_pa[i] = cmdq_get_shift_pa(mdp->cmdq_clt[i]->chan);
 	}
 
 	init_waitqueue_head(&mdp->callback_wq);
diff --git a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
index 05cade1d098e..430251f63754 100644
--- a/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
+++ b/drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h
@@ -126,7 +126,6 @@ struct mdp_dev {
 	u32					id_count;
 	struct ida				mdp_ida;
 	struct cmdq_client			*cmdq_clt[MDP_PP_MAX];
-	u8					cmdq_shift_pa[MDP_PP_MAX];
 	wait_queue_head_t			callback_wq;
 
 	struct v4l2_device			v4l2_dev;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 18/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp()
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (16 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 17/20] media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 19/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and cmdq_pkt_write_mask() Jason-JH Lin
                   ` (2 subsequent siblings)
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Since all users have migrated to the new cmdq_pkt_jump* APIs without
shift_pa, the wrapper APIs cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp()
can be removed.

Fixes: ade176534112 ("soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()")
Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 include/linux/soc/mediatek/mtk-cmdq.h | 30 ---------------------------
 1 file changed, 30 deletions(-)

diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index af66410b06d1..140c70bb707c 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -416,12 +416,6 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32 value, u32 mas
  */
 int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr);
 
-/* This wrapper has to be removed after all users migrated to jump_abs */
-static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr)
-{
-	return cmdq_pkt_jump_abs(pkt, addr);
-}
-
 /**
  * cmdq_pkt_jump_rel() - Append jump command to the CMDQ packet, ask GCE
  *			 to execute an instruction that change current thread
@@ -434,24 +428,6 @@ static inline int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr)
  */
 int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset);
 
-/**
- * cmdq_pkt_jump_rel_temp() - Temporary wrapper for new CMDQ helper API
- * @pkt:	the CMDQ packet
- * @offset:	relative offset of target instruction buffer from current PC.
- * @shift_pa:	[DEPRECATED] shift bits of physical address in CMDQ instruction.
- *		This value is got by cmdq_get_shift_pa().
- *
- * This function is a temporary wrapper that was introduced only for ease of
- * migration of the many users of the CMDQ API located in multiple kernel
- * subsystems.
- *
- * This has to be removed after all users are migrated to the newer CMDQ API.
- */
-static inline int cmdq_pkt_jump_rel_temp(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
-{
-	return cmdq_pkt_jump_rel(pkt, offset);
-}
-
 /**
  * cmdq_pkt_eoc() - Append EOC and ask GCE to generate an IRQ at end of execution
  * @pkt:	The CMDQ packet
@@ -606,12 +582,6 @@ static inline int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset)
 	return -EINVAL;
 }
 
-/* This wrapper has to be removed after all users migrated to jump_rel */
-static inline int cmdq_pkt_jump_rel_temp(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa)
-{
-	return -EIMVAL;
-}
-
 static inline int cmdq_pkt_eoc(struct cmdq_pkt *pkt)
 {
 	return -EINVAL;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 19/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and cmdq_pkt_write_mask()
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (17 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 18/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp() Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-17  6:44 ` [PATCH v8 20/20] mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa() Jason-JH Lin
  2025-10-20 10:04 ` [PATCH v8 00/20] Add GCE support for MT8196 AngeloGioacchino Del Regno
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

The original cmdq_pkt_write() and cmdq_pkt_write_mask() only supported
generating GCE instructions with subsys ID. They have been replaced by
cmdq_pkt_write_pa(), cmdq_pkt_write_subsys(), cmdq_pkt_write_mask_pa()
and cmdq_pkt_write_mask_subsys().

These 2 functions can now be removed as they are no longer in use.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c | 49 ++++++++++----------------
 include/linux/soc/mediatek/mtk-cmdq.h  | 35 ------------------
 2 files changed, 18 insertions(+), 66 deletions(-)

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index 0ab87eb04614..880a69bae6d4 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -215,18 +215,6 @@ static int cmdq_pkt_mask(struct cmdq_pkt *pkt, u32 mask)
 	return cmdq_pkt_append_command(pkt, inst);
 }
 
-int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value)
-{
-	struct cmdq_instruction inst = {
-		.op = CMDQ_CODE_WRITE,
-		.value = value,
-		.offset = offset,
-		.subsys = subsys
-	};
-	return cmdq_pkt_append_command(pkt, inst);
-}
-EXPORT_SYMBOL(cmdq_pkt_write);
-
 int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/, u32 pa_base,
 		      u16 offset, u32 value)
 {
@@ -243,27 +231,16 @@ EXPORT_SYMBOL(cmdq_pkt_write_pa);
 int cmdq_pkt_write_subsys(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base /*unused*/,
 			  u16 offset, u32 value)
 {
-	return cmdq_pkt_write(pkt, subsys, offset, value);
+	struct cmdq_instruction inst = {
+		.op = CMDQ_CODE_WRITE,
+		.value = value,
+		.offset = offset,
+		.subsys = subsys
+	};
+	return cmdq_pkt_append_command(pkt, inst);
 }
 EXPORT_SYMBOL(cmdq_pkt_write_subsys);
 
-int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
-			u16 offset, u32 value, u32 mask)
-{
-	u16 offset_mask = offset;
-	int err;
-
-	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);
-}
-EXPORT_SYMBOL(cmdq_pkt_write_mask);
-
 int cmdq_pkt_write_mask_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/, u32 pa_base,
 			   u16 offset, u32 value, u32 mask)
 {
@@ -281,7 +258,17 @@ EXPORT_SYMBOL(cmdq_pkt_write_mask_pa);
 int cmdq_pkt_write_mask_subsys(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base /*unused*/,
 			       u16 offset, u32 value, u32 mask)
 {
-	return cmdq_pkt_write_mask(pkt, subsys, offset, value, mask);
+	u16 offset_mask = offset;
+	int err;
+
+	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_subsys(pkt, subsys, pa_base, offset_mask, value);
 }
 EXPORT_SYMBOL(cmdq_pkt_write_mask_subsys);
 
diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index 140c70bb707c..24a8c4102367 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -117,17 +117,6 @@ int cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *pkt, size_t siz
  */
 void cmdq_pkt_destroy(struct cmdq_client *client, struct cmdq_pkt *pkt);
 
-/**
- * cmdq_pkt_write() - append write command to the CMDQ packet
- * @pkt:	the CMDQ packet
- * @subsys:	the CMDQ sub system code
- * @offset:	register offset from CMDQ sub system
- * @value:	the specified target register value
- *
- * Return: 0 for success; else the error code is returned
- */
-int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value);
-
 /**
  * cmdq_pkt_write_pa() - append write command to the CMDQ packet with pa_base
  * @pkt:	the CMDQ packet
@@ -154,19 +143,6 @@ int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
 int cmdq_pkt_write_subsys(struct cmdq_pkt *pkt, u8 subsys,
 			  u32 pa_base /*unused*/, u16 offset, u32 value);
 
-/**
- * cmdq_pkt_write_mask() - append write command with mask to the CMDQ packet
- * @pkt:	the CMDQ packet
- * @subsys:	the CMDQ sub system code
- * @offset:	register offset from CMDQ sub system
- * @value:	the specified target register value
- * @mask:	the specified target register mask
- *
- * Return: 0 for success; else the error code is returned
- */
-int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
-			u16 offset, u32 value, u32 mask);
-
 /**
  * cmdq_pkt_write_mask_pa() - append write command with mask to the CMDQ packet with pa
  * @pkt:	the CMDQ packet
@@ -464,11 +440,6 @@ static inline int cmdq_pkt_create(struct cmdq_client *client, struct cmdq_pkt *p
 
 static inline void cmdq_pkt_destroy(struct cmdq_client *client, struct cmdq_pkt *pkt) { }
 
-static inline int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value)
-{
-	return -ENOENT;
-}
-
 static inline int cmdq_pkt_write_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
 				    u32 pa_base, u16 offset, u32 value)
 {
@@ -481,12 +452,6 @@ static inline int cmdq_pkt_write_subsys(struct cmdq_pkt *pkt, u8 subsys,
 	return -ENOENT;
 }
 
-static inline int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys,
-				      u16 offset, u32 value, u32 mask)
-{
-	return -ENOENT;
-}
-
 static inline int cmdq_pkt_write_mask_pa(struct cmdq_pkt *pkt, u8 subsys /*unused*/,
 					 u32 pa_base, u16 offset, u32 value, u32 mask)
 {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH v8 20/20] mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa()
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (18 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 19/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and cmdq_pkt_write_mask() Jason-JH Lin
@ 2025-10-17  6:44 ` Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-20 10:04 ` [PATCH v8 00/20] Add GCE support for MT8196 AngeloGioacchino Del Regno
  20 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin @ 2025-10-17  6:44 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jassi Brar,
	Chun-Kuang Hu, AngeloGioacchino Del Regno, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Jason-JH Lin, Nancy Lin,
	Singo Chang, Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang,
	Fei Shao, Chen-yu Tsai, Project_Global_Chrome_Upstream_Group,
	devicetree, linux-kernel, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-media

Since the mailbox driver data can be obtained using cmdq_get_mbox_priv()
and all CMDQ users have transitioned to cmdq_get_mbox_priv(),
cmdq_get_shift_pa() can be removed.

Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c       |  8 --------
 include/linux/mailbox/mtk-cmdq-mailbox.h | 12 ------------
 2 files changed, 20 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index 1bf6984948ef..81cd98fc9664 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -123,14 +123,6 @@ void cmdq_get_mbox_priv(struct mbox_chan *chan, struct cmdq_mbox_priv *priv)
 }
 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);
-
-	return cmdq->pdata->shift;
-}
-EXPORT_SYMBOL(cmdq_get_shift_pa);
-
 static void cmdq_vm_init(struct cmdq *cmdq)
 {
 	int i;
diff --git a/include/linux/mailbox/mtk-cmdq-mailbox.h b/include/linux/mailbox/mtk-cmdq-mailbox.h
index 07c1bfbdb8c4..a42b44d5fd49 100644
--- a/include/linux/mailbox/mtk-cmdq-mailbox.h
+++ b/include/linux/mailbox/mtk-cmdq-mailbox.h
@@ -96,16 +96,4 @@ struct cmdq_pkt {
  */
 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
- *
- * GCE can only fetch the command buffer address from a 32-bit register.
- * Some SOCs support more than 32-bit command buffer address for GCE, which
- * requires some shift bits to make the address fit into the 32-bit register.
- *
- * Return: the shift bits of physical address
- */
-u8 cmdq_get_shift_pa(struct mbox_chan *chan);
-
 #endif /* __MTK_CMDQ_MAILBOX_H__ */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header for MT8196
  2025-10-17  6:44 ` [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header " Jason-JH Lin
@ 2025-10-20  9:46   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20  9:46 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> Add GCE header define for GCE Thread Priority and GCE Event IDs
> that used in the MT8196 dtsi.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> ---
>   arch/arm64/boot/dts/mediatek/mt8196-gce.h | 612 ++++++++++++++++++++++
>   1 file changed, 612 insertions(+)
>   create mode 100644 arch/arm64/boot/dts/mediatek/mt8196-gce.h
> 
> diff --git a/arch/arm64/boot/dts/mediatek/mt8196-gce.h b/arch/arm64/boot/dts/mediatek/mt8196-gce.h
> new file mode 100644
> index 000000000000..457dc73aeed3
> --- /dev/null
> +++ b/arch/arm64/boot/dts/mediatek/mt8196-gce.h
> @@ -0,0 +1,612 @@
> +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */
> +/*
> + * Copyright (c) 2025 MediaTek Inc.
> + *
> + */
> +
> +#ifndef __DTS_GCE_MT8196_H
> +#define __DTS_GCE_MT8196_H
> +
> +/* GCE Thread Priority
> + * The GCE core has multiple GCE threads, each of which can independently
> + * execute its own sequence of instructions.
> + * However, the GCE threads on the same core cannot run in parallel.
> + * Different GCE threads can determine thread priority based on the scenario,
> + * thereby serving different user needs.
> + *
> + * Low priority thread is executed when no high priority thread is active.
> + * Same priority thread is scheduled by round robin.
> + */
> +#define CMDQ_THR_PRIO_LOWEST	0
> +#define CMDQ_THR_PRIO_1		1
> +#define CMDQ_THR_PRIO_2		2
> +#define CMDQ_THR_PRIO_3		3
> +#define CMDQ_THR_PRIO_4		4
> +#define CMDQ_THR_PRIO_5		5
> +#define CMDQ_THR_PRIO_6		6
> +#define CMDQ_THR_PRIO_HIGHEST	7
> +
> +/*
> + * GCE0 Hardware Event IDs
> + * Different SoCs will have varying numbers of hardware event signals,
> + * which are sent from the corresponding hardware to the GCE.
> + * Each hardware event signal corresponds to an event ID in the GCE.
> + * The CMDQ driver can use the following event ID definitions to allow
> + * the client driver to use wait and clear APIs provided by CMDQ, enabling
> + * the GCE to execute operations in the instructions for that event ID.
> + *
> + * The event IDs of GCE0 are mainly used by display hardware.

..snip..

> +/* CMDQ_EVENT_MML1_FRAME_DONE_SEL0 ~ 15: 284 ~ 299 */
> +#define CMDQ_EVENT_MML1_FRAME_DONE_SEL(n)					(284 + (n))
> +/* CMDQ_EVENT_MML1_REG_UPDATE_DONE_ENG_EVENT0 ~ 15: 300 ~ 315 */
> +#define CMDQ_EVENT_MML1_REG_UPDATE_DONE_ENG_EVENT0				(300 + (n))
                                                     ^^^^^
There's a typo here                                  (n)

Please fix, after which

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 20/20] mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa()
  2025-10-17  6:44 ` [PATCH v8 20/20] mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa() Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> Since the mailbox driver data can be obtained using cmdq_get_mbox_priv()
> and all CMDQ users have transitioned to cmdq_get_mbox_priv(),
> cmdq_get_shift_pa() can be removed.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 19/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and cmdq_pkt_write_mask()
  2025-10-17  6:44 ` [PATCH v8 19/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and cmdq_pkt_write_mask() Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> The original cmdq_pkt_write() and cmdq_pkt_write_mask() only supported
> generating GCE instructions with subsys ID. They have been replaced by
> cmdq_pkt_write_pa(), cmdq_pkt_write_subsys(), cmdq_pkt_write_mask_pa()
> and cmdq_pkt_write_mask_subsys().
> 
> These 2 functions can now be removed as they are no longer in use.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 18/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp()
  2025-10-17  6:44 ` [PATCH v8 18/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp() Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> Since all users have migrated to the new cmdq_pkt_jump* APIs without
> shift_pa, the wrapper APIs cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp()
> can be removed.
> 
> Fixes: ade176534112 ("soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()")
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 16/20] soc: mediatek: mtk-cmdq: Remove shift_pa parameter from cmdq_pkt_jump()
  2025-10-17  6:44 ` [PATCH v8 16/20] soc: mediatek: mtk-cmdq: Remove shift_pa parameter from cmdq_pkt_jump() Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> Since shift_pa will be stored in the cmdq_mbox_priv structure within
> cmdq_pkt, all shift_pa parameters in CMDQ helper APIs can be removed.
> 
> Remove the shift_pa parameters from cmdq_pkt_jump(), cmdq_pkt_jump_abs(),
> and cmdq_pkt_jump_rel().
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>


Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 17/20] media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa
  2025-10-17  6:44 ` [PATCH v8 17/20] media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> With the removal of the shift_pa parameter, cmdq_pkt_jump_rel_temp()
> can be replaced by the new cmdq_pkt_jump_rel() without shift_pa.
> 
> Then, remove the cmdq_shift_pa variable in the mdp_dev structure for
> each mbox client.
> 
> Fixes: ade176534112 ("soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()")
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 15/20] media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to cmdq_pkt_jump_rel_temp()
  2025-10-17  6:44 ` [PATCH v8 15/20] media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to cmdq_pkt_jump_rel_temp() Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> To facilitate the removal of the shift_pa parameter from
> cmdq_pkt_jump_rel(), current users of cmdq_pkt_jump_rel() need to
> transition to using cmdq_pkt_jump_rel_temp() before the API change
> is implemented.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 14/20] media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change
  2025-10-17  6:44 ` [PATCH v8 14/20] media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> Update CMDQ register writes to use subsys-aware APIs,
> cmdq_pkt_write_subsys() and cmdq_pkt_write_mask_subsys().
> This conforms to recent CMDQ API changes that split access by
> subsys ID support.
> 
> Since all current MDP SoCs support subsys ID, and future MDP
> deployments will not run on SoCs without subsys ID, only
> subsys-specific API calls are needed. No logic for non-subsys ID
> hardware is required.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 07/20] mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM transaction
  2025-10-17  6:44 ` [PATCH v8 07/20] mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM transaction Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> The GCE in MT8196 is placed in MMINFRA and requires all addresses
> in GCE instructions for DRAM transactions to be IOVA.
> 
> Due to MMIO, if the GCE needs to access a hardware register at
> 0x1000_0000, but the SMMU is also mapping a DRAM block at 0x1000_0000,
> the MMINFRA will not know whether to write to the hardware register or
> the DRAM.
> To solve this, MMINFRA treats addresses greater than 2G as data paths
> and those less than 2G as config paths because the DRAM start address
> is currently at 2G (0x8000_0000). On the data path, MMINFRA remaps
> DRAM addresses by subtracting 2G, allowing SMMU to map DRAM addresses
> less than 2G.
> For example, if the DRAM start address 0x8000_0000 is mapped to
> IOVA=0x0, when GCE accesses IOVA=0x0, it must add a 2G offset to
> the address in the GCE instruction. MMINFRA will then see it as a
> data path (IOVA >= 2G) and subtract 2G, allowing GCE to access IOVA=0x0.
> 
> Since the MMINFRA remap subtracting 2G is done in hardware and cannot
> be configured by software, the address of DRAM in GCE instruction must
> always add 2G to ensure proper access. After that, the shift functions
> do more than just shift addresses, so the APIs were renamed to
> cmdq_convert_gce_addr() and cmdq_revert_gce_addr().
> 
> This 2G adjustment is referred to as mminfra_offset in the CMDQ driver.
> CMDQ helper can get the mminfra_offset from the cmdq_mbox_priv of
> cmdq_pkt and add the mminfra_offset to the DRAM address in GCE
> instructions.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 13/20] drm/mediatek:Use reg_write function pointer for subsys ID compatibility
  2025-10-17  6:44 ` [PATCH v8 13/20] drm/mediatek:Use " Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-28  5:47   ` CK Hu (胡俊光)
  1 sibling, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> Switch to reg_write and reg_write_mask function pointers for register
> access, enabling compatibility with platforms regardless of subsys ID
> support.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 03/20] mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction
  2025-10-17  6:44 ` [PATCH v8 03/20] mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> 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>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 02/20] mailbox: mtk-cmdq: Refine DMA address handling for the command buffer
  2025-10-17  6:44 ` [PATCH v8 02/20] mailbox: mtk-cmdq: Refine DMA address handling for the command buffer Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> GCE can only fetch the command buffer address from a 32-bit register.
> Some SoCs support a 35-bit command buffer address for GCE, which
> requires a right shift of 3 bits before setting the address into
> the 32-bit register. A comment has been added to the header of
> cmdq_get_shift_pa() to explain this requirement.
> 
> To prevent the GCE command buffer address from being DMA mapped beyond
> its supported bit range, the DMA bit mask for the device is set during
> initialization.
> 
> Additionally, to ensure the correct shift is applied when setting or
> reading the register that stores the GCE command buffer address,
> new APIs, cmdq_convert_gce_addr() and cmdq_revert_gce_addr(), have
> been introduced for consistent operations on this register.
> 
> The variable type for the command buffer address has been standardized
> to dma_addr_t to prevent handling issues caused by type mismatches.
> 
> Fixes: 0858fde496f8 ("mailbox: cmdq: variablize address shift in platform")
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID
  2025-10-17  6:44 ` [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID Jason-JH Lin
@ 2025-10-20 10:04   ` AngeloGioacchino Del Regno
  2025-10-23  4:03     ` Jason-JH Lin (林睿祥)
  0 siblings, 1 reply; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> This patch extends the cmdq_pkt_write API to support SoCs that do not
> have subsys ID mapping by introducing new register write APIs:
> - cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() replace
>    cmdq_pkt_write()
> - cmdq_pkt_write_mask_pa() and cmdq_pkt_write_mask_subsys() replace
>    cmdq_pkt_write_mask()
> 
> To ensure consistent function pointer interfaces, both
> cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() provide subsys and
> pa_base parameters. This unifies how register writes are invoked,
> regardless of whether subsys ID is supported by the device.
> 
> All GCEs support writing registers by PA (with mask) without subsys,
> but this requires extra GCE instructions to convert the PA into a GCE
> readable format, reducing performance compared to using subsys directly.
> Therefore, subsys is preferred for register writes when available.
> 
> API documentation and function pointer declarations in cmdq_client_reg
> have been updated. The original write APIs will be removed after all
> CMDQ users transition to the new interfaces.
> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> ---
>   drivers/soc/mediatek/mtk-cmdq-helper.c | 54 +++++++++++++++++
>   include/linux/soc/mediatek/mtk-cmdq.h  | 83 ++++++++++++++++++++++++++
>   2 files changed, 137 insertions(+)
> 

> diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
> index 154d0511a0ad..f6dc43c036bd 100644
> --- a/include/linux/soc/mediatek/mtk-cmdq.h
> +++ b/include/linux/soc/mediatek/mtk-cmdq.h
> @@ -57,6 +57,10 @@ struct cmdq_client_reg {
>   	phys_addr_t pa_base;
>   	u16 offset;
>   	u16 size;
> +	int (*reg_write)(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base,
> +			 u16 offset, u32 value);

(*pkt_write)

> +	int (*reg_write_mask)(struct cmdq_pkt *pkt, u8 subsys, u32 pa_base,
> +			      u16 offset, u32 value, u32 mask);

(*pkt_write_mask)

those names make a lot more sense.

After applying the requested changes,

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

>   };

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 00/20] Add GCE support for MT8196
  2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
                   ` (19 preceding siblings ...)
  2025-10-17  6:44 ` [PATCH v8 20/20] mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa() Jason-JH Lin
@ 2025-10-20 10:04 ` AngeloGioacchino Del Regno
  2025-10-21 15:32   ` Jason-JH Lin (林睿祥)
  20 siblings, 1 reply; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-20 10:04 UTC (permalink / raw)
  To: Jason-JH Lin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Jassi Brar, Chun-Kuang Hu, Mauro Carvalho Chehab
  Cc: Matthias Brugger, Nicolas Dufresne, Nancy Lin, Singo Chang,
	Paul-PL Chen, Moudy Ho, Xiandong Wang, Sirius Wang, Fei Shao,
	Chen-yu Tsai, Project_Global_Chrome_Upstream_Group, devicetree,
	linux-kernel, dri-devel, linux-mediatek, linux-arm-kernel,
	linux-media, Jason-jh Lin

Il 17/10/25 08:44, Jason-JH Lin ha scritto:
> From: Jason-jh Lin <jason-jh.lin@mediatek.corp-partner.google.com>
> 
> This patch series adds support for the MediaTek MT8196 SoC in the CMDQ
> driver and related subsystems. The changes include adding compatible
> names and iommus property, updating driver data to accommodate hardware
> changes, and modifying the usage of CMDQ APIs to support non-subsys ID
> hardware.
> 

OK - after applying some last small changes as I pointed out in each patch,
the code is ready IMO.

To ease merging, though, I'd like you to split this series in multiple series:
  1. Addition of new functions and support for MT8196
  2. Migration of drm-mediatek, mailbox, mdp3 to the new functions
  3. Removal of the temporary functions that were introduced only for migration

This gives everyone the opportunity of getting just the relevant parts for each
merge cycle, avoiding possible confusion on what to pick and what not to.

Keep in mind that soc/mediatek and mailbox are from two different maintainers,
and you may need to split this in more than 3 series.

I believe that we might at least get a mailbox immutable branch if we want to
do this in 3 kernel versions, otherwise it's going to be four, I think.

Cheers,
Angelo


> ---
> Change in v8:
> 1. Use function pointer to select the correct CMDQ APIs when checking
>     subsys is support for the HW component.
> 
> Change in v7:
> 1. Rename cmdq_reg_shift_addr() and cmdq_reg_revert_addr() to
>     cmdq_convert_gce_addr() and cmdq_revert_gce_addr().
> 2. Change cmdq_vm_toggle to cmdq_vm_init().
> 
> Change in v6:
> 1. Move the removal patches to the end of series.
> 2. Fix build error for cmdq_pkt_jump_rel_temp patch.
> 
> Change in RESEND v5:
> 1. Separate the removal of cmdq_get_shift_pa() from [PATCH v5 03/19] to a
>     single patch [PATCH RESEND v5 10/20].
> 
> Change in v5:
> 1. Rebase on tag: next-20250424 + patch [1].
> 2. Split adding driver data for MT8196 patch to 3 independent patch
>     and add more detail commit message to each patch.
> 3. Refine passing shift_pa as the parameter in API to storing it into
>     the cmdq_pkt.
> 4. Refine DMA address potential issue in cmdq mailbox driver.
> 5. Change the mminfra_offset related mbox API to passing it by cmdq_pkt.
> 6. Add new cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() APIs to
>     replace the cmdq_pkt_write().
> 
> [1] mailbox: mtk-cmdq: Refine GCE_GCTL_VALUE setting
> - https://patchwork.kernel.org/project/linux-mediatek/patch/20250421035650.441383-1-jason-jh.lin@mediatek.com/
> 
> Change in v4:
> 1. Remove dt-binding header and add a gce header in dts folder.
> 2. Remove dot in sign-off name.
> 3. Change addr type from u32 to dma_addr_t for cmdq_reg_shift_addr() and
>     cmdq_reg_revert_addr().
> 
> Change in v3:
> 1. Merge 2 dt-bindings pathes together and add more detail commit message.
> 2. Change type u32 to phys_addr_t for pa_base of struct cmdq_client_reg.
> 3. Remove cmdq_subsys_is_valid() and subsys_num in CMDQ driver.
> 4. Add CMDQ_SUBSYS_INVALID to check subsys instead of using
>     cmdq_subsys_is_invalid().
> 5. Make use of CMDQ_THR_SPR0 define to the parameter of CMDQ APIs.
> 6. Rebase on the new MACRO in mtk-mdp3-comp.h.
> 
> Change in v2:
> 1. Remove the constant and fix warning in dt-bindings.
> 2. Remove the pa_base parameter of CMDQ APIs and related modification.
> 3. Move subsys checking to client drivers and use 2 alternative
>     CMDQ APIs to achieve the same functionality.
> 
> ---
> 
> Jason-JH Lin (20):

Series 1 start

>    arm64: dts: mediatek: Add GCE header for MT8196
>    mailbox: mtk-cmdq: Refine DMA address handling for the command buffer
>    mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating
>      instruction
>    soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in cmdq_pkt_create()
>    soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for removing
>      shift_pa
>    mailbox: mtk-cmdq: Add GCE hardware virtualization configuration
>    mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM
>      transaction
>    mailbox: mtk-cmdq: Add driver data to support for MT8196
>    soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without
>      subsys ID support
>    soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without
>      subsys ID
>    soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM
>      addresses
>    soc: mediatek: Use reg_write function pointer for subsys ID
>      compatibility
>    drm/mediatek:Use reg_write function pointer for subsys ID
>      compatibility
>    media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change
>    media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to
>      cmdq_pkt_jump_rel_temp()
>    soc: mediatek: mtk-cmdq: Remove shift_pa parameter from
>      cmdq_pkt_jump()
>    media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa
>    soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and
>      cmdq_pkt_jump_rel_temp()
>    soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and
>      cmdq_pkt_write_mask()
>    mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa()
> 
>   arch/arm64/boot/dts/mediatek/mt8196-gce.h     | 612 ++++++++++++++++++
>   drivers/gpu/drm/mediatek/mtk_ddp_comp.c       |  12 +-
>   drivers/mailbox/mtk-cmdq-mailbox.c            | 113 +++-
>   .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c    |   6 +-
>   .../platform/mediatek/mdp3/mtk-mdp3-comp.h    |   6 +-
>   .../platform/mediatek/mdp3/mtk-mdp3-core.c    |   2 -
>   .../platform/mediatek/mdp3/mtk-mdp3-core.h    |   1 -
>   drivers/soc/mediatek/mtk-cmdq-helper.c        |  82 ++-
>   drivers/soc/mediatek/mtk-mmsys.c              |   8 +-
>   drivers/soc/mediatek/mtk-mutex.c              |   5 +-
>   include/linux/mailbox/mtk-cmdq-mailbox.h      |  19 +-
>   include/linux/soc/mediatek/mtk-cmdq.h         |  87 ++-
>   12 files changed, 879 insertions(+), 74 deletions(-)
>   create mode 100644 arch/arm64/boot/dts/mediatek/mt8196-gce.h
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 00/20] Add GCE support for MT8196
  2025-10-20 10:04 ` [PATCH v8 00/20] Add GCE support for MT8196 AngeloGioacchino Del Regno
@ 2025-10-21 15:32   ` Jason-JH Lin (林睿祥)
  0 siblings, 0 replies; 39+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2025-10-21 15:32 UTC (permalink / raw)
  To: robh, krzk+dt, AngeloGioacchino Del Regno, conor+dt, mchehab,
	chunkuang.hu, jassisinghbrar
  Cc: dri-devel, linux-media, jason-jh.lin,
	Sirius Wang (王皓昱),
	Moudy Ho (何宗原),
	Nancy Lin (林欣螢),
	Xiandong Wang (王先冬),
	linux-kernel, nicolas, Paul-pl Chen (陳柏霖),
	linux-mediatek, Project_Global_Chrome_Upstream_Group, devicetree,
	fshao, Singo Chang (張興國),
	wenst, linux-arm-kernel, matthias.bgg

On Mon, 2025-10-20 at 12:04 +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 17/10/25 08:44, Jason-JH Lin ha scritto:
> > From: Jason-jh Lin <jason-jh.lin@mediatek.corp-partner.google.com>
> > 
> > This patch series adds support for the MediaTek MT8196 SoC in the
> > CMDQ
> > driver and related subsystems. The changes include adding
> > compatible
> > names and iommus property, updating driver data to accommodate
> > hardware
> > changes, and modifying the usage of CMDQ APIs to support non-subsys
> > ID
> > hardware.
> > 
> 
> OK - after applying some last small changes as I pointed out in each
> patch,
> the code is ready IMO.
> 

Thank you very much! I'll fix them in the next version.

> To ease merging, though, I'd like you to split this series in
> multiple series:
>   1. Addition of new functions and support for MT8196
>   2. Migration of drm-mediatek, mailbox, mdp3 to the new functions
>   3. Removal of the temporary functions that were introduced only for
> migration
> 
> This gives everyone the opportunity of getting just the relevant
> parts for each
> merge cycle, avoiding possible confusion on what to pick and what not
> to.
> 

Sure, it make sense.

> Keep in mind that soc/mediatek and mailbox are from two different
> maintainers,
> and you may need to split this in more than 3 series.
> 
> I believe that we might at least get a mailbox immutable branch if we
> want to
> do this in 3 kernel versions, otherwise it's going to be four, I
> think.
> 

I think I will separate them to:
1. A single fixes patch for [PATCH 2/20].
2. Add GCE support for MT8196 (including pkt_write and jump API change)
3. Migration of drm-mediatek, mailbox, mdp3 to the new functions
4. Removal of the temporary functions for migration

I think putting the patches for the same purpose in the same series is
better for maintainers to find the relevant patches. But I'll try to
put the same maintainers' patches together as possible as I can, so
that maintainers can pull them to their tree easier.

Regards
Jason-JH Lin

> Cheers,
> Angelo
> 
> 
> > ---
> > Change in v8:
> > 1. Use function pointer to select the correct CMDQ APIs when
> > checking
> >     subsys is support for the HW component.
> > 
> > Change in v7:
> > 1. Rename cmdq_reg_shift_addr() and cmdq_reg_revert_addr() to
> >     cmdq_convert_gce_addr() and cmdq_revert_gce_addr().
> > 2. Change cmdq_vm_toggle to cmdq_vm_init().
> > 
> > Change in v6:
> > 1. Move the removal patches to the end of series.
> > 2. Fix build error for cmdq_pkt_jump_rel_temp patch.
> > 
> > Change in RESEND v5:
> > 1. Separate the removal of cmdq_get_shift_pa() from [PATCH v5
> > 03/19] to a
> >     single patch [PATCH RESEND v5 10/20].
> > 
> > Change in v5:
> > 1. Rebase on tag: next-20250424 + patch [1].
> > 2. Split adding driver data for MT8196 patch to 3 independent patch
> >     and add more detail commit message to each patch.
> > 3. Refine passing shift_pa as the parameter in API to storing it
> > into
> >     the cmdq_pkt.
> > 4. Refine DMA address potential issue in cmdq mailbox driver.
> > 5. Change the mminfra_offset related mbox API to passing it by
> > cmdq_pkt.
> > 6. Add new cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() APIs to
> >     replace the cmdq_pkt_write().
> > 
> > [1] mailbox: mtk-cmdq: Refine GCE_GCTL_VALUE setting
> > -
> > https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/20250421035650.441383-1-jason-jh.lin@mediatek.com/__;!!CTRNKA9wMg0ARbw!hiTwkE6uvgHt9RF_2sZfL7pAIqMR2_g28hvNkqfCNPCvBhjCXVptG14sT8QST9Zgj3nwopa9ewwUAkbWnlyxUjK01b5TYwDVvQ$
> > 
> > Change in v4:
> > 1. Remove dt-binding header and add a gce header in dts folder.
> > 2. Remove dot in sign-off name.
> > 3. Change addr type from u32 to dma_addr_t for
> > cmdq_reg_shift_addr() and
> >     cmdq_reg_revert_addr().
> > 
> > Change in v3:
> > 1. Merge 2 dt-bindings pathes together and add more detail commit
> > message.
> > 2. Change type u32 to phys_addr_t for pa_base of struct
> > cmdq_client_reg.
> > 3. Remove cmdq_subsys_is_valid() and subsys_num in CMDQ driver.
> > 4. Add CMDQ_SUBSYS_INVALID to check subsys instead of using
> >     cmdq_subsys_is_invalid().
> > 5. Make use of CMDQ_THR_SPR0 define to the parameter of CMDQ APIs.
> > 6. Rebase on the new MACRO in mtk-mdp3-comp.h.
> > 
> > Change in v2:
> > 1. Remove the constant and fix warning in dt-bindings.
> > 2. Remove the pa_base parameter of CMDQ APIs and related
> > modification.
> > 3. Move subsys checking to client drivers and use 2 alternative
> >     CMDQ APIs to achieve the same functionality.
> > 
> > ---
> > 
> > Jason-JH Lin (20):
> 
> Series 1 start
> 
> >    arm64: dts: mediatek: Add GCE header for MT8196
> >    mailbox: mtk-cmdq: Refine DMA address handling for the command
> > buffer
> >    mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for
> > generating
> >      instruction
> >    soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in
> > cmdq_pkt_create()
> >    soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for
> > removing
> >      shift_pa
> >    mailbox: mtk-cmdq: Add GCE hardware virtualization configuration
> >    mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM
> >      transaction
> >    mailbox: mtk-cmdq: Add driver data to support for MT8196
> >    soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware
> > without
> >      subsys ID support
> >    soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs
> > without
> >      subsys ID
> >    soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM
> >      addresses
> >    soc: mediatek: Use reg_write function pointer for subsys ID
> >      compatibility
> >    drm/mediatek:Use reg_write function pointer for subsys ID
> >      compatibility
> >    media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API
> > change
> >    media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to
> >      cmdq_pkt_jump_rel_temp()
> >    soc: mediatek: mtk-cmdq: Remove shift_pa parameter from
> >      cmdq_pkt_jump()
> >    media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without
> > shift_pa
> >    soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and
> >      cmdq_pkt_jump_rel_temp()
> >    soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and
> >      cmdq_pkt_write_mask()
> >    mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa()
> > 
> >   arch/arm64/boot/dts/mediatek/mt8196-gce.h     | 612
> > ++++++++++++++++++
> >   drivers/gpu/drm/mediatek/mtk_ddp_comp.c       |  12 +-
> >   drivers/mailbox/mtk-cmdq-mailbox.c            | 113 +++-
> >   .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c    |   6 +-
> >   .../platform/mediatek/mdp3/mtk-mdp3-comp.h    |   6 +-
> >   .../platform/mediatek/mdp3/mtk-mdp3-core.c    |   2 -
> >   .../platform/mediatek/mdp3/mtk-mdp3-core.h    |   1 -
> >   drivers/soc/mediatek/mtk-cmdq-helper.c        |  82 ++-
> >   drivers/soc/mediatek/mtk-mmsys.c              |   8 +-
> >   drivers/soc/mediatek/mtk-mutex.c              |   5 +-
> >   include/linux/mailbox/mtk-cmdq-mailbox.h      |  19 +-
> >   include/linux/soc/mediatek/mtk-cmdq.h         |  87 ++-
> >   12 files changed, 879 insertions(+), 74 deletions(-)
> >   create mode 100644 arch/arm64/boot/dts/mediatek/mt8196-gce.h
> > 
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
@ 2025-10-23  4:03     ` Jason-JH Lin (林睿祥)
  2025-10-29 11:00       ` AngeloGioacchino Del Regno
  0 siblings, 1 reply; 39+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2025-10-23  4:03 UTC (permalink / raw)
  To: robh, krzk+dt, AngeloGioacchino Del Regno, conor+dt, mchehab,
	chunkuang.hu, jassisinghbrar
  Cc: dri-devel, linux-media, Sirius Wang (王皓昱),
	Moudy Ho (何宗原),
	Nancy Lin (林欣螢),
	Xiandong Wang (王先冬),
	linux-kernel, nicolas, Paul-pl Chen (陳柏霖),
	linux-mediatek, Project_Global_Chrome_Upstream_Group, devicetree,
	fshao, Singo Chang (張興國),
	wenst, linux-arm-kernel, matthias.bgg

On Mon, 2025-10-20 at 12:04 +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 17/10/25 08:44, Jason-JH Lin ha scritto:
> > This patch extends the cmdq_pkt_write API to support SoCs that do
> > not
> > have subsys ID mapping by introducing new register write APIs:
> > - cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() replace
> >    cmdq_pkt_write()
> > - cmdq_pkt_write_mask_pa() and cmdq_pkt_write_mask_subsys() replace
> >    cmdq_pkt_write_mask()
> > 
> > To ensure consistent function pointer interfaces, both
> > cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() provide subsys and
> > pa_base parameters. This unifies how register writes are invoked,
> > regardless of whether subsys ID is supported by the device.
> > 
> > All GCEs support writing registers by PA (with mask) without
> > subsys,
> > but this requires extra GCE instructions to convert the PA into a
> > GCE
> > readable format, reducing performance compared to using subsys
> > directly.
> > Therefore, subsys is preferred for register writes when available.
> > 
> > API documentation and function pointer declarations in
> > cmdq_client_reg
> > have been updated. The original write APIs will be removed after
> > all
> > CMDQ users transition to the new interfaces.
> > 
> > Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> > ---
> >   drivers/soc/mediatek/mtk-cmdq-helper.c | 54 +++++++++++++++++
> >   include/linux/soc/mediatek/mtk-cmdq.h  | 83
> > ++++++++++++++++++++++++++
> >   2 files changed, 137 insertions(+)
> > 
> 
> > diff --git a/include/linux/soc/mediatek/mtk-cmdq.h
> > b/include/linux/soc/mediatek/mtk-cmdq.h
> > index 154d0511a0ad..f6dc43c036bd 100644
> > --- a/include/linux/soc/mediatek/mtk-cmdq.h
> > +++ b/include/linux/soc/mediatek/mtk-cmdq.h
> > @@ -57,6 +57,10 @@ struct cmdq_client_reg {
> >       phys_addr_t pa_base;
> >       u16 offset;
> >       u16 size;
> > +     int (*reg_write)(struct cmdq_pkt *pkt, u8 subsys, u32
> > pa_base,
> > +                      u16 offset, u32 value);
> 
> (*pkt_write)
> 
> > +     int (*reg_write_mask)(struct cmdq_pkt *pkt, u8 subsys, u32
> > pa_base,
> > +                           u16 offset, u32 value, u32 mask);
> 
> (*pkt_write_mask)
> 
> those names make a lot more sense.
> 
Hi Angelo,

The reason why I use reg_write/reg_write_mask is to imply these APIs
only provide writing HW register address function, not writing DRAM
address.
So we don't need to care about mminfra_offset in these APIs.

I can add comment for this.

What do you think?
Or should I change its name to pkt_write/pkt_write_amsk?

Regards,
Jason-JH Lin

> After applying the requested changes,
> 
> Reviewed-by: AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com>
> 
> >   };


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 13/20] drm/mediatek:Use reg_write function pointer for subsys ID compatibility
  2025-10-17  6:44 ` [PATCH v8 13/20] drm/mediatek:Use " Jason-JH Lin
  2025-10-20 10:04   ` AngeloGioacchino Del Regno
@ 2025-10-28  5:47   ` CK Hu (胡俊光)
  1 sibling, 0 replies; 39+ messages in thread
From: CK Hu (胡俊光) @ 2025-10-28  5:47 UTC (permalink / raw)
  To: chunkuang.hu, AngeloGioacchino Del Regno, robh,
	Jason-JH Lin (林睿祥),
	krzk+dt, jassisinghbrar, mchehab, conor+dt
  Cc: dri-devel, linux-media, Sirius Wang (王皓昱),
	Moudy Ho (何宗原),
	Nancy Lin (林欣螢),
	Xiandong Wang (王先冬),
	linux-kernel, nicolas, Paul-pl Chen (陳柏霖),
	linux-mediatek, Project_Global_Chrome_Upstream_Group, devicetree,
	fshao, Singo Chang (張興國),
	wenst, linux-arm-kernel, matthias.bgg

On Fri, 2025-10-17 at 14:44 +0800, Jason-JH Lin wrote:
> Switch to reg_write and reg_write_mask function pointers for register
> access, enabling compatibility with platforms regardless of subsys ID
> support.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_ddp_comp.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
> index ac6620e10262..aa217fb11fd7 100644
> --- a/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_ddp_comp.c
> @@ -72,8 +72,8 @@ void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,
>  {
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>  	if (cmdq_pkt)
> -		cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
> -			       cmdq_reg->offset + offset, value);
> +		cmdq_reg->reg_write(cmdq_pkt, cmdq_reg->subsys, cmdq_reg->pa_base,
> +				    cmdq_reg->offset + offset, value);
>  	else
>  #endif
>  		writel(value, regs + offset);
> @@ -85,8 +85,8 @@ void mtk_ddp_write_relaxed(struct cmdq_pkt *cmdq_pkt, unsigned int value,
>  {
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>  	if (cmdq_pkt)
> -		cmdq_pkt_write(cmdq_pkt, cmdq_reg->subsys,
> -			       cmdq_reg->offset + offset, value);
> +		cmdq_reg->reg_write(cmdq_pkt, cmdq_reg->subsys, cmdq_reg->pa_base,
> +				    cmdq_reg->offset + offset, value);
>  	else
>  #endif
>  		writel_relaxed(value, regs + offset);
> @@ -98,8 +98,8 @@ void mtk_ddp_write_mask(struct cmdq_pkt *cmdq_pkt, unsigned int value,
>  {
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>  	if (cmdq_pkt) {
> -		cmdq_pkt_write_mask(cmdq_pkt, cmdq_reg->subsys,
> -				    cmdq_reg->offset + offset, value, mask);
> +		cmdq_reg->reg_write_mask(cmdq_pkt, cmdq_reg->subsys, cmdq_reg->pa_base,
> +					 cmdq_reg->offset + offset, value, mask);
>  	} else {
>  #endif
>  		u32 tmp = readl(regs + offset);


^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID
  2025-10-23  4:03     ` Jason-JH Lin (林睿祥)
@ 2025-10-29 11:00       ` AngeloGioacchino Del Regno
  0 siblings, 0 replies; 39+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-10-29 11:00 UTC (permalink / raw)
  To: Jason-JH Lin (林睿祥),
	robh, krzk+dt, conor+dt, mchehab, chunkuang.hu, jassisinghbrar
  Cc: dri-devel, linux-media, Sirius Wang (王皓昱),
	Moudy Ho (何宗原),
	Nancy Lin (林欣螢),
	Xiandong Wang (王先冬),
	linux-kernel, nicolas, Paul-pl Chen (陳柏霖),
	linux-mediatek, Project_Global_Chrome_Upstream_Group, devicetree,
	fshao, Singo Chang (張興國),
	wenst, linux-arm-kernel, matthias.bgg

Il 23/10/25 06:03, Jason-JH Lin (林睿祥) ha scritto:
> On Mon, 2025-10-20 at 12:04 +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 17/10/25 08:44, Jason-JH Lin ha scritto:
>>> This patch extends the cmdq_pkt_write API to support SoCs that do
>>> not
>>> have subsys ID mapping by introducing new register write APIs:
>>> - cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() replace
>>>     cmdq_pkt_write()
>>> - cmdq_pkt_write_mask_pa() and cmdq_pkt_write_mask_subsys() replace
>>>     cmdq_pkt_write_mask()
>>>
>>> To ensure consistent function pointer interfaces, both
>>> cmdq_pkt_write_pa() and cmdq_pkt_write_subsys() provide subsys and
>>> pa_base parameters. This unifies how register writes are invoked,
>>> regardless of whether subsys ID is supported by the device.
>>>
>>> All GCEs support writing registers by PA (with mask) without
>>> subsys,
>>> but this requires extra GCE instructions to convert the PA into a
>>> GCE
>>> readable format, reducing performance compared to using subsys
>>> directly.
>>> Therefore, subsys is preferred for register writes when available.
>>>
>>> API documentation and function pointer declarations in
>>> cmdq_client_reg
>>> have been updated. The original write APIs will be removed after
>>> all
>>> CMDQ users transition to the new interfaces.
>>>
>>> Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
>>> ---
>>>    drivers/soc/mediatek/mtk-cmdq-helper.c | 54 +++++++++++++++++
>>>    include/linux/soc/mediatek/mtk-cmdq.h  | 83
>>> ++++++++++++++++++++++++++
>>>    2 files changed, 137 insertions(+)
>>>
>>
>>> diff --git a/include/linux/soc/mediatek/mtk-cmdq.h
>>> b/include/linux/soc/mediatek/mtk-cmdq.h
>>> index 154d0511a0ad..f6dc43c036bd 100644
>>> --- a/include/linux/soc/mediatek/mtk-cmdq.h
>>> +++ b/include/linux/soc/mediatek/mtk-cmdq.h
>>> @@ -57,6 +57,10 @@ struct cmdq_client_reg {
>>>        phys_addr_t pa_base;
>>>        u16 offset;
>>>        u16 size;
>>> +     int (*reg_write)(struct cmdq_pkt *pkt, u8 subsys, u32
>>> pa_base,
>>> +                      u16 offset, u32 value);
>>
>> (*pkt_write)
>>
>>> +     int (*reg_write_mask)(struct cmdq_pkt *pkt, u8 subsys, u32
>>> pa_base,
>>> +                           u16 offset, u32 value, u32 mask);
>>
>> (*pkt_write_mask)
>>
>> those names make a lot more sense.
>>
> Hi Angelo,
> 
> The reason why I use reg_write/reg_write_mask is to imply these APIs
> only provide writing HW register address function, not writing DRAM
> address.
> So we don't need to care about mminfra_offset in these APIs.

Sure I understand that we don't need to care about mminfra_offset - but those
function pointers are effectively replacing the "(xyz)pkt_write" functions.

Changing the name to reg_write will create a lot of confusion.

> 
> I can add comment for this.
> 
> What do you think?
> Or should I change its name to pkt_write/pkt_write_amsk?

Please change the name to pkt_write/pkt_write_mask and if you think it's useful
also add a comment saying that those functions are already accounting for the
mminfra_offset internally.

Cheers,
Angelo

> 
> Regards,
> Jason-JH Lin
> 
>> After applying the requested changes,
>>
>> Reviewed-by: AngeloGioacchino Del Regno
>> <angelogioacchino.delregno@collabora.com>
>>
>>>    };
> 


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2025-10-29 11:00 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-17  6:44 [PATCH v8 00/20] Add GCE support for MT8196 Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 01/20] arm64: dts: mediatek: Add GCE header " Jason-JH Lin
2025-10-20  9:46   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 02/20] mailbox: mtk-cmdq: Refine DMA address handling for the command buffer Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 03/20] mailbox: mtk-cmdq: Add cmdq private data to cmdq_pkt for generating instruction Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 04/20] soc: mediatek: mtk-cmdq: Add cmdq_get_mbox_priv() in cmdq_pkt_create() Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 05/20] soc: mediatek: mtk-cmdq: Add cmdq_pkt_jump_rel_temp() for removing shift_pa Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 06/20] mailbox: mtk-cmdq: Add GCE hardware virtualization configuration Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 07/20] mailbox: mtk-cmdq: Add mminfra_offset configuration for DRAM transaction Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 08/20] mailbox: mtk-cmdq: Add driver data to support for MT8196 Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 09/20] soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without subsys ID support Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 10/20] soc: mediatek: mtk-cmdq: Extend cmdq_pkt_write API for SoCs without subsys ID Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-23  4:03     ` Jason-JH Lin (林睿祥)
2025-10-29 11:00       ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 11/20] soc: mediatek: mtk-cmdq: Add mminfra_offset adjustment for DRAM addresses Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 12/20] soc: mediatek: Use reg_write function pointer for subsys ID compatibility Jason-JH Lin
2025-10-17  6:44 ` [PATCH v8 13/20] drm/mediatek:Use " Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-28  5:47   ` CK Hu (胡俊光)
2025-10-17  6:44 ` [PATCH v8 14/20] media: platform: mtk-mdp3: Refactor CMDQ writes for CMDQ API change Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 15/20] media: platform: mtk-mdp3: Change cmdq_pkt_jump_rel() to cmdq_pkt_jump_rel_temp() Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 16/20] soc: mediatek: mtk-cmdq: Remove shift_pa parameter from cmdq_pkt_jump() Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 17/20] media: platform: mtk-mdp3: Use cmdq_pkt_jump_rel() without shift_pa Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 18/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_jump() and cmdq_pkt_jump_rel_temp() Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 19/20] soc: mediatek: mtk-cmdq: Remove cmdq_pkt_write() and cmdq_pkt_write_mask() Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-17  6:44 ` [PATCH v8 20/20] mailbox: mtk-cmdq: Remove unsued cmdq_get_shift_pa() Jason-JH Lin
2025-10-20 10:04   ` AngeloGioacchino Del Regno
2025-10-20 10:04 ` [PATCH v8 00/20] Add GCE support for MT8196 AngeloGioacchino Del Regno
2025-10-21 15:32   ` Jason-JH Lin (林睿祥)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®