Add CMDQ secure driver for SVP
Subsystems (6)
PATCH v5 2/10 dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler. This property is only required if CMDQ secure driver is supported.
--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +10 -0
@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specific hardware event signal + to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips. + $ref: /schemas/types.yaml#/definitions/uint32-arrayi + + mboxes: + maxItems: 1 + required: - compatible - "#mbox-cells"
Signature · 1 line
2.18.0
PATCH v5 7/10 mailbox: mediatek: Move reuseable definition to header for secure driver
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
To support CMDQ secure driver, move some reuseable definition to header.
- define: e.g. CMDQ_GCE_NUM_MAX, CMDQ_THR_BASE, CMDQ_THR_SIZE.
- struct: e.g. cmdq_thread, cmdq, cmdq_task.
- include: e.g. <linux/clk.h>.
Add "#include <linux/mailbox_controller.h>" for the function that takes "struct mbox_chan * chan" as a parameter. That may occur a build error if secure driver header includes the mtk-cmdq-mailbox.h.
- function: e.g. cmdq_get_shift_pa(struct mbox_chan *chan).
--- drivers/mailbox/mtk-cmdq-mailbox.c | 30 --------------------- include/linux/mailbox/mtk-cmdq-mailbox.h | 34 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 30 deletions(-)
drivers/mailbox/mtk-cmdq-mailbox.c +0 -30
@@ -3,7 +3,6 @@// Copyright (c) 2018 MediaTek Inc. #include <linux/bitops.h> -#include <linux/clk.h> #include <linux/clk-provider.h> #include <linux/dma-mapping.h> #include <linux/errno.h>
@@ -22,13 +21,10 @@#define CMDQ_OP_CODE_MASK (0xff << CMDQ_OP_CODE_SHIFT)#define CMDQ_NUM_CMD (t) (t->cmd_buf_size / CMDQ_INST_SIZE) -#define CMDQ_GCE_NUM_MAX (2)#define CMDQ_CURR_IRQ_STATUS 0x10#define CMDQ_SYNC_TOKEN_UPDATE 0x68#define CMDQ_THR_SLOT_CYCLES 0x30 -#define CMDQ_THR_BASE 0x100 -#define CMDQ_THR_SIZE 0x80#define CMDQ_THR_WARM_RESET 0x00#define CMDQ_THR_ENABLE_TASK 0x04#define CMDQ_THR_SUSPEND_TASK 0x08
@@ -59,32 +55,6 @@#define CMDQ_JUMP_BY_OFFSET 0x10000000#define CMDQ_JUMP_BY_PA 0x10000001 -struct cmdq_thread { -struct mbox_chan *chan; -void __iomem *base; -struct list_head task_busy_list; -u32 priority; -}; - -struct cmdq_task { -struct cmdq *cmdq; -struct list_head list_entry; -dma_addr_t pa_base; -struct cmdq_thread *thread; -struct cmdq_pkt *pkt;/* the packet sent from mailbox client */ -}; - -struct cmdq { -struct mbox_controller mbox; -void __iomem *base; -int irq; -u32 irq_mask; -const struct gce_plat *pdata; -struct cmdq_thread *thread; -struct clk_bulk_data clocks[CMDQ_GCE_NUM_MAX ]; -bool suspended; -}; -struct gce_plat {u32 thread_nr;u8 shift;
include/linux/mailbox/mtk-cmdq-mailbox.h +34 -0
@@ -7,10 +7,17 @@#ifndef __MTK_CMDQ_MAILBOX_H__#define __MTK_CMDQ_MAILBOX_H__ +#include <linux/clk.h> +#include <linux/mailbox_controller.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/types.h> +#define CMDQ_GCE_NUM_MAX 2 + +#define CMDQ_THR_BASE 0x100 +#define CMDQ_THR_SIZE 0x80 +#define CMDQ_INST_SIZE 8/* instruction is 64-bit */ #define CMDQ_SUBSYS_SHIFT 16#define CMDQ_OP_CODE_SHIFT 24
@@ -79,6 +86,33 @@ struct cmdq_pkt { bool loop; }; +struct cmdq_thread { +struct mbox_chan *chan; +void __iomem *base; +struct list_head task_busy_list; +u32 priority; +u32 idx; +}; + +struct cmdq { +struct mbox_controller mbox; +void __iomem *base; +int irq; +u32 irq_mask; +const struct gce_plat *pdata; +struct cmdq_thread *thread; +struct clk_bulk_data clocks[CMDQ_GCE_NUM_MAX ]; +bool suspended; +}; + +struct cmdq_task { +struct cmdq *cmdq; +struct list_head list_entry; +dma_addr_t pa_base; +struct cmdq_thread *thread; +struct cmdq_pkt *pkt;/* the packet sent from mailbox client */ +}; +u8 cmdq_get_shift_pa (struct mbox_chan *chan);#endif /* __MTK_CMDQ_MAILBOX_H__ */
Signature · 1 line
2.18.0
PATCH v5 4/10 soc: mediatek: cmdq: Add cmdq_pkt_write_s_reg_value to support write value to reg
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
Add cmdq_pkt_write_s_reg_value to support write a value to a register.
It appends write_s command to the command buffer in a CMDQ packet, ask GCE to excute a write instruction to write a value to a register with low 16 bits physical address offset.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 13 +++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 11 +++++++++++ 2 files changed, 24 insertions(+)
drivers/soc/mediatek/mtk-cmdq-helper.c +13 -0
@@ -292,6 +292,19 @@ int cmdq_pkt_write_s_value(struct cmdq_pkt *pkt, u8 high_addr_reg_idx, }EXPORT_SYMBOL (cmdq_pkt_write_s_value); +int cmdq_pkt_write_s_reg_value (struct cmdq_pkt *pkt,u8 high_addr_reg_idx,u32 value) +{ +struct cmdq_instruction inst = {}; + + inst.op =CMDQ_CODE_WRITE_S ; + inst.dst_t =CMDQ_REG_TYPE ; + inst.reg_dst = high_addr_reg_idx; + inst.value = value; + +return cmdq_pkt_append_command (pkt, inst); +} +EXPORT_SYMBOL (cmdq_pkt_write_s_reg_value); +int cmdq_pkt_write_s_mask_value (struct cmdq_pkt *pkt,u8 high_addr_reg_idx,u16 addr_low,u32 value,u32 mask) {
include/linux/soc/mediatek/mtk-cmdq.h +11 -0
@@ -207,6 +207,17 @@ int cmdq_pkt_write_s_value(struct cmdq_pkt *pkt, u8 high_addr_reg_idx,int cmdq_pkt_write_s_mask_value (struct cmdq_pkt *pkt,u8 high_addr_reg_idx,u16 addr_low,u32 value,u32 mask); +/** +* cmdq_pkt_write_s_reg_value() - append write_s command to the CMDQ packet which +* write value to a register with low address pa +* @pkt: the CMDQ packet +* @high_addr_reg_idx: internal register ID which contains high address of pa +* @value: the specified target value +* +* Return: 0 for success; else the error code is returned +*/ +int cmdq_pkt_write_s_reg_value (struct cmdq_pkt *pkt,u8 high_addr_reg_idx,u32 value); +/** * cmdq_pkt_mem_move() - append memory move command to the CMDQ packet * @pkt: the CMDQ packet
Signature · 1 line
2.18.0
PATCH v5 10/10 drm/mediatek: Add interface to allocate MediaTek GEM buffer.
In reply to Shawn SungFrom: CK Hu <[email protected]>
Add an interface to allocate MediaTek GEM buffers, allow the IOCTLs to be used by render nodes.
This patch also sets the RENDER driver feature.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 ++++++- drivers/gpu/drm/mediatek/mtk_gem.c | 40 ++++++++++++++++ drivers/gpu/drm/mediatek/mtk_gem.h | 11 +++++ include/uapi/drm/mediatek_drm.h | 64 ++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 include/uapi/drm/mediatek_drm.h
drivers/gpu/drm/mediatek/mtk_drm_drv.c +15 -1
@@ -23,6 +23,7 @@#include <drm/drm_of.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h> +#include <drm/mediatek_drm.h> #include "mtk_crtc.h" #include "mtk_ddp_comp.h"
@@ -570,6 +571,14 @@ static void mtk_drm_kms_deinit(struct drm_device *drm)component_unbind_all (drm->dev, drm); } +static const struct drm_ioctl_desc mtk_ioctls[] = { +DRM_IOCTL_DEF_DRV (MTK_GEM_CREATE , mtk_gem_create_ioctl, +DRM_UNLOCKED |DRM_AUTH |DRM_RENDER_ALLOW ), +DRM_IOCTL_DEF_DRV (MTK_GEM_MAP_OFFSET , + mtk_gem_map_offset_ioctl, +DRM_UNLOCKED |DRM_AUTH |DRM_RENDER_ALLOW ), +}; +DEFINE_DRM_GEM_FOPS (mtk_drm_fops);/*
@@ -585,12 +594,17 @@ static struct drm_gem_object *mtk_gem_prime_import(struct drm_device *dev, }static const struct drm_driver mtk_drm_driver = { - .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC , + .driver_features =DRIVER_MODESET |DRIVER_GEM |DRIVER_ATOMIC | +DRIVER_RENDER , .dumb_create = mtk_gem_dumb_create, .gem_prime_import = mtk_gem_prime_import, .gem_prime_import_sg_table = mtk_gem_prime_import_sg_table, + + .ioctls = mtk_ioctls, + .num_ioctls =ARRAY_SIZE (mtk_ioctls), + .fops = &mtk_drm_fops, .name =DRIVER_NAME ,
drivers/gpu/drm/mediatek/mtk_gem.c +40 -0
@@ -4,9 +4,11 @@*/ #include <linux/dma-buf.h> +#include <drm/mediatek_drm.h> #include <drm/drm.h> #include <drm/drm_device.h> +#include <drm/drm_drv.h> #include <drm/drm_gem.h> #include <drm/drm_gem_dma_helper.h> #include <drm/drm_prime.h>
@@ -285,3 +287,41 @@ void mtk_gem_prime_vunmap(struct drm_gem_object *obj, struct iosys_map *map) mtk_gem->kvaddr =NULL ;kfree (mtk_gem->pages); } + +int mtk_gem_map_offset_ioctl (struct drm_device *drm,void *data, +struct drm_file *file_priv) +{ +struct drm_mtk_gem_map_off *args = data; + +return drm_gem_dumb_map_offset (file_priv, drm, args->handle, + &args->offset); +} + +int mtk_gem_create_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_priv) +{ +struct mtk_gem_obj *mtk_gem; +struct drm_mtk_gem_create *args = data; +int ret; + + mtk_gem =mtk_gem_create (dev, args->size, false); +if (IS_ERR (mtk_gem)) +return PTR_ERR (mtk_gem); + +/* +* allocate a id of idr table where the obj is registered +* and handle has the id what user can see. +*/ + ret =drm_gem_handle_create (file_priv, &mtk_gem->base, &args->handle); +if (ret) + goto err_handle_create; + +/* drop reference from allocate - handle holds it now. */ +drm_gem_object_put (&mtk_gem->base); + +return 0 ; + +err_handle_create: +mtk_gem_free_object (&mtk_gem->base); +return ret; +}
drivers/gpu/drm/mediatek/mtk_gem.h +11 -0
@@ -45,4 +45,15 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev,int mtk_gem_prime_vmap (struct drm_gem_object *obj,struct iosys_map *map);void mtk_gem_prime_vunmap (struct drm_gem_object *obj,struct iosys_map *map); +/* +* request gem object creation and buffer allocation as the size +* that it is calculated with framebuffer information such as width, +* height and bpp. +*/ +int mtk_gem_create_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_priv); + +/* get buffer offset to map to user space. */ +int mtk_gem_map_offset_ioctl (struct drm_device *dev,void *data, +struct drm_file *file_priv);#endif
include/uapi/drm/mediatek_drm.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v5 1/10 dt-bindings: gce: mt8195: Add CMDQ_SYNC_TOKEN_SECURE_THR_EOF event id
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
There are 2 kind of GCE event signal:
- The SW token means: a GCE event signal triggered by SW drivers. e.g. SW driver append a GCE command to set a GCE event after a specific GCE command. Or SW driver use CPU to write a event id to GCE register to trigger the GCE event corresponding to that event id.
- The HW event means: a GCE event signal triggered by HW engines. e.g. When HW OVL fetches all the data in frame buffer, HW OVL will send a frame done irq and also send a frame done GCE event via HW bus directly.
CMDQ_SYNC_TOKEN_SECURE_THR_EOF is a SW token event that is set in the end of each cmdq secure pkt. It is used as a secure irq to notify CMDQ driver in the normal world that GCE secure thread has completed a secure cmd buffer in thee secure world.
--- include/dt-bindings/gce/mt8195-gce.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/dt-bindings/gce/mt8195-gce.h +6 -0
@@ -800,6 +800,12 @@#define CMDQ_EVENT_WPE_VPP1_WPE_GCE_FRAME_DONE 969#define CMDQ_EVENT_WPE_VPP1_WPE_DONE_SYNC_OUT 970 +/* +* Notify normal CMDQ there are some secure task done, +* this token sync with secure world. +*/ +#define CMDQ_SYNC_TOKEN_SECURE_THR_EOF 980 +#define CMDQ_EVENT_DP_TX_VBLANK_FALLING 994#define CMDQ_EVENT_DP_TX_VSC_FINISH 995
Signature · 1 line
2.18.0
PATCH v5 9/10 mailbox: mediatek: Add secure CMDQ driver support for CMDQ driver
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
CMDQ driver will probe a secure CMDQ driver when has_sec flag in platform data is true and its device node in dts has defined a event id of CMDQ_SYNC_TOKEN_SEC_EOF.
Secure CMDQ driver support on mt8188 and mt8195 currently. So add a has_secure flag to their driver data to probe it.
--- drivers/mailbox/mtk-cmdq-mailbox.c | 69 +++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-)
drivers/mailbox/mtk-cmdq-mailbox.c +68 -1
@@ -15,8 +15,8 @@#include <linux/pm_runtime.h> #include <linux/mailbox_controller.h> #include <linux/mailbox/mtk-cmdq-mailbox.h> +#include <linux/mailbox/mtk-cmdq-sec-mailbox.h> #include <linux/of.h> -#define CMDQ_MBOX_AUTOSUSPEND_DELAY_MS 100#define CMDQ_OP_CODE_MASK (0xff << CMDQ_OP_CODE_SHIFT)
@@ -55,11 +55,19 @@#define CMDQ_JUMP_BY_OFFSET 0x10000000#define CMDQ_JUMP_BY_PA 0x10000001 +#define CMDQ_IS_SECURE_THREAD (idx, cmdq) (cmdq->pdata->has_secure && \ + idx >= cmdq->pdata->secure_thread_min && \ + idx < cmdq->pdata->secure_thread_min + \ + cmdq->pdata->secure_thread_nr) +struct gce_plat {u32 thread_nr;u8 shift;bool control_by_sw;bool sw_ddr_en; +bool has_secure; +u32 secure_thread_nr; +u32 secure_thread_min;u32 gce_num; };
@@ -377,6 +385,13 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)if (ret <0 )return ret; +if (CMDQ_IS_SECURE_THREAD (thread->idx, cmdq)) { + ret = cmdq_sec_mbox.ops->send_data (chan, data); +pm_runtime_mark_last_busy (cmdq->mbox.dev); +pm_runtime_put_autosuspend (cmdq->mbox.dev); +return ret; + } + task =kzalloc (sizeof (*task),GFP_ATOMIC );if (!task) {pm_runtime_put_autosuspend (cmdq->mbox.dev);
@@ -436,6 +451,12 @@ static int cmdq_mbox_send_data(struct mbox_chan *chan, void *data)static int cmdq_mbox_startup (struct mbox_chan *chan) { +struct cmdq *cmdq =dev_get_drvdata (chan->mbox->dev); +struct cmdq_thread *thread = (struct cmdq_thread *)chan->con_priv; + +if (CMDQ_IS_SECURE_THREAD (thread->idx, cmdq)) + cmdq_sec_mbox.ops->startup (chan); +return 0 ; }
@@ -448,6 +469,13 @@ static void cmdq_mbox_shutdown(struct mbox_chan *chan)WARN_ON (pm_runtime_get_sync (cmdq->mbox.dev)); +if (CMDQ_IS_SECURE_THREAD (thread->idx, cmdq)) { + cmdq_sec_mbox.ops->shutdown (chan); +pm_runtime_mark_last_busy (cmdq->mbox.dev); +pm_runtime_put_autosuspend (cmdq->mbox.dev); +return ; + } +spin_lock_irqsave (&thread->chan->lock, flags);if (list_empty (&thread->task_busy_list)) goto done;
@@ -494,6 +522,13 @@ static int cmdq_mbox_flush(struct mbox_chan *chan, unsigned long timeout)if (ret <0 )return ret; +if (CMDQ_IS_SECURE_THREAD (thread->idx, cmdq)) { + cmdq_sec_mbox.ops->flush (chan, timeout); +pm_runtime_mark_last_busy (cmdq->mbox.dev); +pm_runtime_put_autosuspend (cmdq->mbox.dev); +return 0 ; + } +spin_lock_irqsave (&thread->chan->lock, flags);if (list_empty (&thread->task_busy_list)) goto out;
@@ -569,6 +604,7 @@ static int cmdq_probe(struct platform_device *pdev)int alias_id =0 ;static const char *const clk_name ="gce" ;static const char *const clk_names[] = {"gce0" ,"gce1" }; +u32 hwid =0 ; cmdq =devm_kzalloc (dev,sizeof (*cmdq),GFP_KERNEL );if (!cmdq)
@@ -594,6 +630,8 @@ static int cmdq_probe(struct platform_device *pdev) dev, cmdq->base, cmdq->irq);if (cmdq->pdata->gce_num >1 ) { + hwid =of_alias_get_id (dev->of_node, clk_name); +for_each_child_of_node (phandle->parent, node) { alias_id =of_alias_get_id (node, clk_name);if (alias_id >=0 && alias_id < cmdq->pdata->gce_num) {
@@ -643,6 +681,29 @@ static int cmdq_probe(struct platform_device *pdev) cmdq->mbox.chans[i].con_priv = (void *)&cmdq->thread[i]; } +if (cmdq->pdata->has_secure) { +struct platform_device *cmdq_sec; +static struct gce_sec_plat sec_plat = {0 }; + +if (of_property_read_u32_index (dev->of_node,"mediatek,gce-events" ,0 , + &sec_plat.cmdq_event) ==0 ) { + sec_plat.mbox = &cmdq->mbox; + sec_plat.base = cmdq->base; + sec_plat.hwid = hwid; + sec_plat.secure_thread_nr = cmdq->pdata->secure_thread_nr; + sec_plat.secure_thread_min = cmdq->pdata->secure_thread_min; + + cmdq_sec =platform_device_register_data (dev,"mtk-cmdq-sec" , +PLATFORM_DEVID_AUTO , + &sec_plat, +sizeof (sec_plat)); +if (IS_ERR (cmdq_sec)) { +dev_err (dev,"failed to register platform_device mtk-cmdq-sec\n" ); +return PTR_ERR (cmdq_sec); + } + } + } + err =devm_mbox_controller_register (dev, &cmdq->mbox);if (err <0 ) {dev_err (dev,"failed to register mailbox: %d\n" , err);
@@ -719,6 +780,9 @@ static const struct gce_plat gce_plat_mt8188 = { .thread_nr = 32, .shift = 3, .control_by_sw = true, + .has_secure = true, + .secure_thread_nr = 2, + .secure_thread_min = 8, .gce_num = 2 };
@@ -733,6 +797,9 @@ static const struct gce_plat gce_plat_mt8195 = { .thread_nr = 24, .shift = 3, .control_by_sw = true, + .has_secure = true, + .secure_thread_nr = 2, + .secure_thread_min = 8, .gce_num = 2 };
Signature · 1 line
2.18.0
PATCH v5 3/10 soc: mediatek: cmdq: Add cmdq_pkt_logic_command to support math operation
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
Add cmdq_pkt_logic_command to support math operation.
cmdq_pkt_logic_command can append logic command to the CMDQ packet, ask GCE to execute a arithmetic calculate instruction, such as add, subtract, multiply, AND, OR and NOT, etc.
Note that all arithmetic instructions are unsigned calculations. If there are any overflows, GCE will sent the invalid IRQ to notify CMDQ driver.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 39 ++++++++++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 42 ++++++++++++++++++++++++++ 2 files changed, 81 insertions(+)
drivers/soc/mediatek/mtk-cmdq-helper.c +39 -0
@@ -15,9 +15,21 @@/* dedicate the last GPR_R15 to assign the register address to be poll */ #define CMDQ_POLL_ADDR_GPR (15)#define CMDQ_EOC_IRQ_EN BIT(0) +#define CMDQ_IMMEDIATE_VALUE 0#define CMDQ_REG_TYPE 1#define CMDQ_JUMP_RELATIVE 1 +#define CMDQ_GET_ARG_B (arg) (((arg) & GENMASK(31, 16)) >> 16) +#define CMDQ_GET_ARG_C (arg) ((arg) & GENMASK(15, 0)) + +#define CMDQ_OPERAND_GET_IDX_VALUE (operand) \ + ({ \ + struct cmdq_operand *op = operand; \ + op->reg ? op->idx : op->value; \ + }) +#define CMDQ_OPERAND_TYPE (operand) \ + ((operand)->reg ? CMDQ_REG_TYPE : CMDQ_IMMEDIATE_VALUE) + struct cmdq_instruction { union { u32 value;
@@ -470,6 +482,33 @@ int cmdq_pkt_poll_addr(struct cmdq_pkt *pkt, dma_addr_t addr, u32 value, u32 mas }EXPORT_SYMBOL (cmdq_pkt_poll_addr); +int cmdq_pkt_logic_command (struct cmdq_pkt *pkt,u16 result_reg_idx, +struct cmdq_operand *left_operand, +enum cmdq_logic_op s_op, +struct cmdq_operand *right_operand) +{ +struct cmdq_instruction inst = { {0 } }; +u32 left_idx_value; +u32 right_idx_value; + +if (!left_operand || !right_operand || s_op >=CMDQ_LOGIC_MAX ) +return -EINVAL ; + + left_idx_value =CMDQ_OPERAND_GET_IDX_VALUE (left_operand); + right_idx_value =CMDQ_OPERAND_GET_IDX_VALUE (right_operand); + inst.op =CMDQ_CODE_LOGIC ; + inst.dst_t =CMDQ_REG_TYPE ; + inst.src_t =CMDQ_OPERAND_TYPE (left_operand); + inst.arg_c_t =CMDQ_OPERAND_TYPE (right_operand); + inst.sop = s_op; + inst.reg_dst = right_idx_value; + inst.src_reg = left_idx_value; + inst.arg_c = result_reg_idx; + +return cmdq_pkt_append_command (pkt, inst); +} +EXPORT_SYMBOL (cmdq_pkt_logic_command); +int cmdq_pkt_assign (struct cmdq_pkt *pkt,u16 reg_idx,u32 value) {struct cmdq_instruction inst = {};
include/linux/soc/mediatek/mtk-cmdq.h +42 -0
54 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v5 5/10 mailbox: mtk-cmdq: Support GCE loop packets in interrupt handler
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
1. Add a loop flag for CMDQ packet struct.
CMDQ helper will use a loop flag to mark CMDQ packet as lopping command and make current command buffer jumps to the beginning when GCE executes to the end of command buffer.
2. Add a looping task handle flow in irq handler.
GCE irq occurs when GCE executes to the end of command(EOC) instruction. If the CMDQ packet is a loopping command, GCE irq handler can not delete the CMDQ task and disable the GCE thread.
--- drivers/mailbox/mtk-cmdq-mailbox.c | 11 +++++++++++ include/linux/mailbox/mtk-cmdq-mailbox.h | 1 + 2 files changed, 12 insertions(+)
drivers/mailbox/mtk-cmdq-mailbox.c +11 -0
@@ -267,6 +267,17 @@ static void cmdq_thread_irq_handler(struct cmdq *cmdq, curr_pa =readl (thread->base +CMDQ_THR_CURR_ADDR ) << cmdq->pdata->shift; + task =list_first_entry_or_null (&thread->task_busy_list, + struct cmdq_task, list_entry); +if (task && task->pkt->loop) { +struct cmdq_cb_data data; + + data.sta = err; + data.pkt = task->pkt; +mbox_chan_received_data (task->thread->chan, &data); +return ; + } +list_for_each_entry_safe (task, tmp, &thread->task_busy_list, list_entry) { task_end_pa = task->pa_base + task->pkt->cmd_buf_size;
include/linux/mailbox/mtk-cmdq-mailbox.h +1 -0
@@ -76,6 +76,7 @@ struct cmdq_pkt {size_t cmd_buf_size;/* command occupied size */ size_t buf_size;/* real buffer size */ void *cl; +bool loop; };u8 cmdq_get_shift_pa (struct mbox_chan *chan);
Signature · 1 line
2.18.0
v5 cover Add CMDQ secure driver for SVP
From: Hsiao Chien Sung <[email protected]>
For the Secure Video Path (SVP) feature, inculding the memory stored secure video content, the registers of display HW pipeline and the HW configure operations are required to execute in the secure world.
So using a CMDQ secure driver to make all display HW registers configuration secure DRAM access permision settings execute by GCE secure thread in the secure world.
We are landing this feature on mt8188 and mt8195 currently.
---
Based on 2 series and 1 patch:
[1] Add CMDQ driver support for mt8188
- https://patchwork.kernel.org/project/linux-mediatek/list/?series=810382
[2] Add mediatek,gce-events definition to mediatek,gce-mailbox bindings
- https://patchwork.kernel.org/project/linux-mediatek/list/?series=810938
[3] soc: mediatek: Add register definitions for GCE
- https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
---
Changes in v5:
1. Sync the local changes
Changes in v4:
1. Rebase on mediatek-drm-next(278640d4d74cd) and fix the conflicts
2. This series is based on [email protected]
Changes in v3:
1. separate mt8188 driver porting patches to another series
2. separate adding 'mediatek,gce-events' event prop to another series
3. sepatate mailbox helper and controller driver modification to a single patch for adding looping thread
4. add kerneldoc for secure mailbox related definition
5. add moving reuseable definition patch before adding secure mailbox driver patch
6. adjust redundant logic in mtk-cmdq-sec-mailbox
Changes in v2:
1. adjust dt-binding SW event define patch before the dt-binding patch using it
2. adjust dt-binding patch for secure cmdq driver
3. remove the redundant patches or merge the patches of modification for the same API
CK Hu (1):
drm/mediatek: Add interface to allocate MediaTek GEM buffer.
Jason-JH.Lin (9):
dt-bindings: gce: mt8195: Add CMDQ_SYNC_TOKEN_SECURE_THR_EOF event id
dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
soc: mediatek: cmdq: Add cmdq_pkt_logic_command to support math
operation
soc: mediatek: cmdq: Add cmdq_pkt_write_s_reg_value to support write
value to reg
mailbox: mtk-cmdq: Support GCE loop packets in interrupt handler
soc: mediatek: cmdq: Add cmdq_pkt_finalize_loop for looping cmd with
irq
mailbox: mediatek: Move reuseable definition to header for secure
driver
mailbox: mediatek: Add CMDQ secure mailbox driver
mailbox: mediatek: Add secure CMDQ driver support for CMDQ driver
.../mailbox/mediatek,gce-mailbox.yaml | 10 + drivers/gpu/drm/mediatek/mtk_drm_drv.c | 16 +- drivers/gpu/drm/mediatek/mtk_gem.c | 40 + drivers/gpu/drm/mediatek/mtk_gem.h | 11 + drivers/mailbox/Makefile | 2 +- drivers/mailbox/mtk-cmdq-mailbox.c | 108 +- drivers/mailbox/mtk-cmdq-sec-mailbox.c | 1045 +++++++++++++++++ drivers/mailbox/mtk-cmdq-sec-tee.c | 165 +++ drivers/soc/mediatek/mtk-cmdq-helper.c | 75 ++ include/dt-bindings/gce/mt8195-gce.h | 6 + include/linux/mailbox/mtk-cmdq-mailbox.h | 37 + .../linux/mailbox/mtk-cmdq-sec-iwc-common.h | 385 ++++++ include/linux/mailbox/mtk-cmdq-sec-mailbox.h | 159 +++ include/linux/mailbox/mtk-cmdq-sec-tee.h | 105 ++ include/linux/soc/mediatek/mtk-cmdq.h | 61 + include/uapi/drm/mediatek_drm.h | 64 + 16 files changed, 2257 insertions(+), 32 deletions(-) create mode 100644 drivers/mailbox/mtk-cmdq-sec-mailbox.c create mode 100644 drivers/mailbox/mtk-cmdq-sec-tee.c create mode 100644 include/linux/mailbox/mtk-cmdq-sec-iwc-common.h create mode 100644 include/linux/mailbox/mtk-cmdq-sec-mailbox.h create mode 100644 include/linux/mailbox/mtk-cmdq-sec-tee.h create mode 100644 include/uapi/drm/mediatek_drm.h
--
2.18.0
PATCH v5 6/10 soc: mediatek: cmdq: Add cmdq_pkt_finalize_loop for looping cmd with irq
From: "Jason-JH.Lin" <[email protected]>
Add cmdq_pkt_finalize_loop to CMDQ driver.
cmdq_pkt_finalize_loop appends end of command(EOC) instruction and jump to start of command buffer instruction to make the command buffer loopable.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 23 +++++++++++++++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 8 ++++++++ 2 files changed, 31 insertions(+)
drivers/soc/mediatek/mtk-cmdq-helper.c +23 -0
@@ -568,6 +568,29 @@ int cmdq_pkt_finalize(struct cmdq_pkt *pkt) }EXPORT_SYMBOL (cmdq_pkt_finalize); +int cmdq_pkt_finalize_loop (struct cmdq_pkt *pkt) +{ +struct cmdq_instruction inst = { {0 } }; +int err; + +/* insert EOC and generate IRQ for each command iteration */ + inst.op =CMDQ_CODE_EOC ; + inst.value =CMDQ_EOC_IRQ_EN ; + err =cmdq_pkt_append_command (pkt, inst); +if (err <0 ) +return err; + +/* JUMP to start of pkt */ + err =cmdq_pkt_jump (pkt, pkt->pa_base); +if (err <0 ) +return err; + + pkt->loop = true; + +return err; +} +EXPORT_SYMBOL (cmdq_pkt_finalize_loop); +int cmdq_pkt_flush_async (struct cmdq_pkt *pkt) {int err;
include/linux/soc/mediatek/mtk-cmdq.h +8 -0
@@ -371,6 +371,14 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr);*/ int cmdq_pkt_finalize (struct cmdq_pkt *pkt); +/** +* cmdq_pkt_finalize_loop() - Append EOC and jump to start command. +* @pkt: the CMDQ packet +* +* Return: 0 for success; else the error code is returned +*/ +int cmdq_pkt_finalize_loop (struct cmdq_pkt *pkt); +/** * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ * packet and call back at the end of done packet
Signature · 1 line
2.18.0
PATCH v5 8/10 mailbox: mediatek: Add CMDQ secure mailbox driver
In reply to Shawn SungFrom: "Jason-JH.Lin" <[email protected]>
To support secure video path feature, GCE have to read/write registgers in the secure world. GCE will enable the secure access permission to the HW who wants to access the secure content buffer.
Add CMDQ secure mailbox driver to make CMDQ client user is able to sending their HW settings to the secure world. So that GCE can execute all instructions to configure HW in the secure world.
--- drivers/mailbox/Makefile | 2 +- drivers/mailbox/mtk-cmdq-sec-mailbox.c | 1045 +++++++++++++++++ drivers/mailbox/mtk-cmdq-sec-tee.c | 165 +++ include/linux/mailbox/mtk-cmdq-mailbox.h | 2 + .../linux/mailbox/mtk-cmdq-sec-iwc-common.h | 385 ++++++ include/linux/mailbox/mtk-cmdq-sec-mailbox.h | 159 +++ include/linux/mailbox/mtk-cmdq-sec-tee.h | 105 ++ 7 files changed, 1862 insertions(+), 1 deletion(-) create mode 100644 drivers/mailbox/mtk-cmdq-sec-mailbox.c create mode 100644 drivers/mailbox/mtk-cmdq-sec-tee.c create mode 100644 include/linux/mailbox/mtk-cmdq-sec-iwc-common.h create mode 100644 include/linux/mailbox/mtk-cmdq-sec-mailbox.h create mode 100644 include/linux/mailbox/mtk-cmdq-sec-tee.h
drivers/mailbox/Makefile +1 -1
@@ -51,7 +51,7 @@ obj-$(CONFIG_STM32_IPCC) += stm32-ipcc.o obj-$(CONFIG_MTK_ADSP_MBOX) += mtk-adsp-mailbox.o -obj-$(CONFIG_MTK_CMDQ_MBOX) += mtk-cmdq-mailbox.o +obj-$(CONFIG_MTK_CMDQ_MBOX) += mtk-cmdq-mailbox.o mtk-cmdq-sec-mailbox.o mtk-cmdq-sec-tee.o obj-$(CONFIG_ZYNQMP_IPI_MBOX) += zynqmp-ipi-mailbox.o
drivers/mailbox/mtk-cmdq-sec-mailbox.c new file +1045 -0
1,045 lines not on this page · raw message
drivers/mailbox/mtk-cmdq-sec-tee.c new file +165 -0
165 lines not on this page · raw message
include/linux/mailbox/mtk-cmdq-mailbox.h +2 -0
@@ -22,6 +22,7 @@#define CMDQ_SUBSYS_SHIFT 16#define CMDQ_OP_CODE_SHIFT 24#define CMDQ_JUMP_PASS CMDQ_INST_SIZE +#define CMDQ_EOC_CMD 0x4000000000000001ULL#define CMDQ_WFE_UPDATE BIT(31)#define CMDQ_WFE_UPDATE_VALUE BIT(16)
@@ -84,6 +85,7 @@ struct cmdq_pkt {size_t buf_size;/* real buffer size */ void *cl;bool loop; +void *sec_data; };struct cmdq_thread {
include/linux/mailbox/mtk-cmdq-sec-iwc-common.h new file +385 -0
385 lines not on this page · raw message
include/linux/mailbox/mtk-cmdq-sec-mailbox.h new file +159 -0
159 lines not on this page · raw message
include/linux/mailbox/mtk-cmdq-sec-tee.h new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.18.0
Rob Herring
maintainerRe: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
In reply to Shawn SungQuoted 11 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler. This property is only required if CMDQ secure driver is supported.
Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml:
Unresolvable JSON pointer: 'definitions/uint32-arrayi'
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/project/devicetree-bindings/patch/[email protected]
The base for the series is generally the latest rc1. A different dependency should be noted in *this* patch.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit after running the above command yourself. Note that DT_SCHEMA_FILES can be set to your schema file to speed up checking your schema. However, it must be unset to test all examples with your schema.
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
In reply to Shawn SungQuoted 16 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler. This property is only required if CMDQ secure driver is supported.
Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +0
-0
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 56
Quoted 8 lines
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +5
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specific hardware event signal + to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.
Missing any info here about when this should be used, hint - you have it in the commit message.
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 57
Quoted 1 line
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +1
-0+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Why is the ID used by the CMDQ service not fixed for each SoC?
Cheers,
Conor
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Hi Conor,
Thanks for the reviews.
Quoted 38 lines · Conor Dooley
Quoted 30 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler. This property is only required if CMDQ secure driver is supported.
Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
--- a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
+++ b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yamlDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specific hardware eventsignal
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 56
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +2
-0+ to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.Missing any info here about when this should be used, hint - you have it
in the commit message.
Quoted 4 lines
Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Why is the ID used by the CMDQ service not fixed for each SoC?
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]
I'll fix it at the next version.
Regards,
Jason-JH.Lin
Quoted 2 lines
Cheers,
Conor
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 45 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 40 lines · Conor Dooley
Quoted 30 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler. This property is only required if CMDQ secure driver is supported.
Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
--- a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
+++ b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yamlDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specific hardware eventsignal
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 56
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +2
-0+ to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.Missing any info here about when this should be used, hint - you have it
in the commit message.Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Quoted 7 lines
Quoted 2 lines
Why is the ID used by the CMDQ service not fixed for each SoC?
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]I'll fix it at the next version.
When I say "fixed" I don't mean "this is wrong, please fix it", I mean "why is the value not static for a particular SoC". This needs to be explained in the patch (and the description for the event here needs to explain what the gce-mailbox is reserving an event for).
Thanks,
Conor.
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 57 lines · Conor Dooley
Quoted 56 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 42 lines · Conor Dooley
Quoted 33 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler.
This property is only required if CMDQ secure driver is supported.Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
--- a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
+++ b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yamlDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specific hardwareevent
signalDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 56
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +2
-0+ to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.Missing any info here about when this should be used, hint - you have
it
in the commit message.Quoted 4 lines
Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Why is the ID used by the CMDQ service not fixed for each SoC?
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]
Quoted 9 lines
Quoted 1 line
I'll fix it at the next version.
When I say "fixed" I don't mean "this is wrong, please fix it", I mean
"why is the value not static for a particular SoC". This needs to be explained in the patch (and the description for the event here needs to
explain what the gce-mailbox is reserving an event for).
Oh, I see. Thanks for noticing me.
We do want to reserve a static event ID for gce-mailbox to different SoCs. There are 2 mainly reasons to why we set it in DTS:
1. There are 1024 events IDs for GCE to use to execute instructions in the specific event happened. These events could be signaled by HW or SW and their value would be different in different SoC because of HW event IDs distribution range from 0 to 1023.
If we set a static event ID: 855 for mt8188, it might be conflict the event ID original set in mt8195.
2. If we defined the event ID in DTS, we might know how many SW or HW event IDs are used.
If someone wants to use a new event ID for a new feature, they could find out the used event IDs in DTS easily and avoid the event ID conflicting.
The reason why we define a event ID is we want to get a SW signal from secure world. We design a GCE looping thread in gce-mailbox driver to wait for the GCE execute done event for each cmdq secure packets from secure world.
Regards,
Jason-JH.Lin
Quoted 2 lines
Thanks,
Conor.
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 69 lines · Jason-JH Lin (林睿祥)
Quoted 57 lines · Conor Dooley
Quoted 56 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 42 lines · Conor Dooley
Quoted 33 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler.
This property is only required if CMDQ secure driver is supported.Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>--- .../bindings/mailbox/mediatek,gce-mailbox.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
--- a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
+++ b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yamlDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specific hardwareevent
signalDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 56
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +2
-0+ to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.Missing any info here about when this should be used, hint - you have
it
in the commit message.Quoted 4 lines
Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Why is the ID used by the CMDQ service not fixed for each SoC?
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]Quoted 9 lines
Quoted 1 line
I'll fix it at the next version.
When I say "fixed" I don't mean "this is wrong, please fix it", I mean
"why is the value not static for a particular SoC". This needs to be explained in the patch (and the description for the event here needs to
explain what the gce-mailbox is reserving an event for).Oh, I see. Thanks for noticing me.
Quoted 8 lines
We do want to reserve a static event ID for gce-mailbox to different SoCs. There are 2 mainly reasons to why we set it in DTS:
1. There are 1024 events IDs for GCE to use to execute instructions in the specific event happened. These events could be signaled by HW or SW and their value would be different in different SoC because of HW event IDs distribution range from 0 to 1023.
If we set a static event ID: 855 for mt8188, it might be conflict the event ID original set in mt8195.
That's not a problem, we have compatibles for this purpose.
Quoted 5 lines
2. If we defined the event ID in DTS, we might know how many SW or HW event IDs are used.
If someone wants to use a new event ID for a new feature, they could find out the used event IDs in DTS easily and avoid the event ID conflicting.
Are the event IDs not documented in the reference manual for the SoC in question? Or in documentation for the secure world for these devices? A DTS should not be the authoritive source for this information for developers.
Additionally, the driver could very easily detect if someone does happen to put in the reserved ID. That could be generically useful (IOW, check all of them for re-use) if the ID are to not allowed to be shared.
Quoted 4 lines
The reason why we define a event ID is we want to get a SW signal from secure world. We design a GCE looping thread in gce-mailbox driver to wait for the GCE execute done event for each cmdq secure packets from secure world.
This sort of information needs to be in the commit message, but I don't think this property is needed at all since it seems to be something detectable from the compatible.
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 94 lines · Conor Dooley
Quoted 79 lines · Jason-JH Lin (林睿祥)
Quoted 66 lines · Conor Dooley
Quoted 58 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 47 lines · Conor Dooley
Quoted 37 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler.
This property is only required if CMDQ secure driver is supported.Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>---
.../bindings/mailbox/mediatek,gce-mailbox.yaml|
10
++++++++++1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
---
a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
+++
b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yamlDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specifichardware
event
signalDocumentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml properties: · line 56
Quoted 2 lines
Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml +2
-0+ to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.Missing any info here about when this should be used, hint - you
have
it
in the commit message.Quoted 5 lines
Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Why is the ID used by the CMDQ service not fixed for each SoC?
Quoted 5 lines
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]I'll fix it at the next version.
Quoted 9 lines
When I say "fixed" I don't mean "this is wrong, please fix it", I mean
"why is the value not static for a particular SoC". This needs to be
explained in the patch (and the description for the event here needs
to
explain what the gce-mailbox is reserving an event for).Oh, I see. Thanks for noticing me.
Quoted 13 lines
We do want to reserve a static event ID for gce-mailbox to different
SoCs. There are 2 mainly reasons to why we set it in DTS:
1. There are 1024 events IDs for GCE to use to execute instructions in
the specific event happened. These events could be signaled by HW or SW
and their value would be different in different SoC because of HW event
IDs distribution range from 0 to 1023.
If we set a static event ID: 855 for mt8188, it might be conflict the
event ID original set in mt8195.
Quoted 1 line
That's not a problem, we have compatibles for this purpose.
I agree that compatibles can do the same things.
Quoted 9 lines
Quoted 8 lines
2. If we defined the event ID in DTS, we might know how many SW or HW
event IDs are used.
If someone wants to use a new event ID for a new feature, they could
find out the used event IDs in DTS easily and avoid the event ID conflicting.
Quoted 7 lines
Are the event IDs not documented in the reference manual for the SoC in
question? Or in documentation for the secure world for these devices? A
DTS should not be the authoritive source for this information for developers.
The event IDs were defined in:inculde/dt-bindings/mailbox/mediatek,mt8188-gce.h.
Quoted 14 lines
Additionally, the driver could very easily detect if someone does happen
to put in the reserved ID. That could be generically useful (IOW, check
all of them for re-use) if the ID are to not allowed to be shared.Quoted 7 lines
The reason why we define a event ID is we want to get a SW signal from
secure world. We design a GCE looping thread in gce-mailbox driver to
wait for the GCE execute done event for each cmdq secure packets from
secure world.
Quoted 4 lines
This sort of information needs to be in the commit message, but I don't
think this property is needed at all since it seems to be something detectable from the compatible.
I think put this event ID in driver data and distinguish them by different compatibles can achieve the same thing.
However, I originally thought that align to the existing way like MUTEX, CCORR, WDMA in
https://lore.kernel.org/all/[email protected]
would be better choice.
I think their usage of gce-events are the same.
What do you think?
Regards,
Jason-JH.Lin
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 140 lines · Jason-JH Lin (林睿祥)
Quoted 94 lines · Conor Dooley
Quoted 79 lines · Jason-JH Lin (林睿祥)
Quoted 66 lines · Conor Dooley
Quoted 58 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 47 lines · Conor Dooley
Quoted 37 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq handler.
This property is only required if CMDQ secure driver is supported.Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>---
.../bindings/mailbox/mediatek,gce-mailbox.yaml|
10
++++++++++1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gce-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
---
a/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml
+++
b/Documentation/devicetree/bindings/mailbox/mediatek,gce-mailbox.yaml(quoted diff) +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specifichardware
event
signalReview
Quoted 2 lines
(quoted diff) +2
-0+ to gce. The event id is defined in the gce header + include/dt-bindings/gce/<chip>-gce.h of each chips.Missing any info here about when this should be used, hint - you
have
it
in the commit message.Quoted 5 lines
Quoted 1 line
+ $ref: /schemas/types.yaml#/definitions/uint32-arrayi
Why is the ID used by the CMDQ service not fixed for each SoC?
Quoted 5 lines
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]I'll fix it at the next version.
Quoted 9 lines
When I say "fixed" I don't mean "this is wrong, please fix it", I mean
"why is the value not static for a particular SoC". This needs to be
explained in the patch (and the description for the event here needs
to
explain what the gce-mailbox is reserving an event for).Oh, I see. Thanks for noticing me.
Quoted 13 lines
We do want to reserve a static event ID for gce-mailbox to different
SoCs. There are 2 mainly reasons to why we set it in DTS:
1. There are 1024 events IDs for GCE to use to execute instructions in
the specific event happened. These events could be signaled by HW or SW
and their value would be different in different SoC because of HW event
IDs distribution range from 0 to 1023.
If we set a static event ID: 855 for mt8188, it might be conflict the
event ID original set in mt8195.Quoted 1 line
That's not a problem, we have compatibles for this purpose.
I agree that compatibles can do the same things.
Quoted 9 lines
Quoted 8 lines
2. If we defined the event ID in DTS, we might know how many SW or HW
event IDs are used.
If someone wants to use a new event ID for a new feature, they could
find out the used event IDs in DTS easily and avoid the event ID conflicting.Quoted 7 lines
Are the event IDs not documented in the reference manual for the SoC in
question? Or in documentation for the secure world for these devices? A
DTS should not be the authoritive source for this information for developers.The event IDs were defined in:
inculde/dt-bindings/mailbox/mediatek,mt8188-gce.h.Quoted 14 lines
Additionally, the driver could very easily detect if someone does happen
to put in the reserved ID. That could be generically useful (IOW, check
all of them for re-use) if the ID are to not allowed to be shared.Quoted 7 lines
The reason why we define a event ID is we want to get a SW signal from
secure world. We design a GCE looping thread in gce-mailbox driver to
wait for the GCE execute done event for each cmdq secure packets from
secure world.Quoted 4 lines
This sort of information needs to be in the commit message, but I don't
think this property is needed at all since it seems to be something detectable from the compatible.I think put this event ID in driver data and distinguish them by different compatibles can achieve the same thing.
Quoted 7 lines
However, I originally thought that align to the existing way like MUTEX, CCORR, WDMA in
https://lore.kernel.org/all/[email protected]
would be better choice.
I think their usage of gce-events are the same.What do you think?
To me it comes down to whether the IDs are fixed on a particular SoC (in which case they can be deduced by the compatible) or not. I don't really see how this is actually a fixed property of the SoC though, if you came along tomorrow with a "gce-2.0" you could totally end up with different numbering because (as far as I can tell) this numbering is actually a property of the os-firmware interface, not actually a property of the SoC itself. I was expecting you to say "no" when I asked if the IDs were fixed for a given SoC because changing the firmware /could/ change the IDs. Although, I think you'd likely not ever want to change them, because that'd just be an annoying ABI break to deal with.
What I think is that you need to write a property description that explains what the mailbox is using the gce channel for so that someone can populate the property correctly. The commit message also needs to explain why this is not a fixed value for a given SoC.
And yes, as you pointed out earlier in this thread, Shawn needs to update this to have a reference to the gce-events binding which has a great description in it of what a gce event is.
Quoted 1 line
I think their usage of gce-events are the same.
Also, just because a property got introduced doesn't mean that it is correct and adding new instances can definitely by required to provide justification, not just saying "it's used by xyz too".
Cheers,
Conor.
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 70 lines · Conor Dooley
Quoted 69 lines · Jason-JH Lin (林睿祥)
Quoted 68 lines · Conor Dooley
Quoted 66 lines · Jason-JH Lin (林睿祥)
Quoted 65 lines · Conor Dooley
Quoted 63 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 58 lines · Conor Dooley
Quoted 41 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
Add mboxes to define a GCE loopping thread as a secure irq
handler.
This property is only required if CMDQ secure driver is supported.Signed-off-by Jason-JH.Lin <[email protected]>Signed-off-by Hsiao Chien Sung <[email protected]>
---
.../bindings/mailbox/mediatek,gce-mailbox.yaml|
10
++++++++++1 file changed, 10 insertions(+)diff --git a/Documentation/devicetree/bindings/mailbox/mediatek,gc e-
mailbox.yamlb/Documentation/devicetree/bindings/mailbox/mediatek,gc e-mailbox.yaml
indexcef9d76013985..c0d80cc770899100644
---
a/Documentation/devicetree/bindings/mailbox/mediatek,gc e-mailbox.yaml
+++
b/Documentation/devicetree/bindings/mailbox/mediatek,gc e-mailbox.yaml(quoted diff) +3
-0@@ -49,6 +49,16 @@ properties: items: - const: gce + mediatek,gce-events: + description: + The event id which is mapping to the specificQuoted 7 lines
hardware
event
signal
+ to gce. The event id is defined in the gce
header
+ include/dt-bindings/gce/<chip>-gce.h of each
chips.Missing any info here about when this should be used, hint -
you
have
it
in the commit message.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
+ $ref: /schemas/types.yaml#/definitions/uint32-
arrayiWhy is the ID used by the CMDQ service not fixed for each SoC?
Did I misunderstand the ID here?
I thought we were talking about event IDs, but it looks like we are talking about mbox IDs.
Quoted 93 lines
Quoted 93 lines
Quoted 41 lines
Quoted 32 lines
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
I forgot to sync with Shawn about this:
https://lore.kernel.org/all/20240124011459.12204-1-jason-
[email protected]I'll fix it at the next version.
Quoted 12 lines
When I say "fixed" I don't mean "this is wrong, please fix it", I
mean
"why is the value not static for a particular SoC". This needs to
be
explained in the patch (and the description for the event here
needs
to
explain what the gce-mailbox is reserving an event for).Oh, I see. Thanks for noticing me.
We do want to reserve a static event ID for gce-mailbox to different
SoCs. There are 2 mainly reasons to why we set it in DTS:
1. There are 1024 events IDs for GCE to use to execute instructions
in
the specific event happened. These events could be signaled by HW
or SWQuoted 8 lines
and their value would be different in different SoC because of HW
event
IDs distribution range from 0 to 1023.
If we set a static event ID: 855 for mt8188, it might be conflict
the
event ID original set in mt8195.Quoted 1 line
That's not a problem, we have compatibles for this purpose.
I agree that compatibles can do the same things.
Quoted 11 lines
Quoted 10 lines
2. If we defined the event ID in DTS, we might know how many SW or
HW
event IDs are used.
If someone wants to use a new event ID for a new feature, they could
find out the used event IDs in DTS easily and avoid the event ID
conflicting.Quoted 9 lines
Are the event IDs not documented in the reference manual for the SoC
in
question? Or in documentation for the secure world for these devices?
A
DTS should not be the authoritive source for this information for developers.The event IDs were defined in:
inculde/dt-bindings/mailbox/mediatek,mt8188-gce.h.Quoted 23 lines
Additionally, the driver could very easily detect if someone does happen
to put in the reserved ID. That could be generically useful (IOW, check
all of them for re-use) if the ID are to not allowed to be shared.Quoted 10 lines
The reason why we define a event ID is we want to get a SW signal
from
secure world. We design a GCE looping thread in gce-mailbox driver
to
wait for the GCE execute done event for each cmdq secure packets
from
secure world.This sort of information needs to be in the commit message, but I don't
think this property is needed at all since it seems to be something
detectable from the compatible.
Quoted 6 lines
Quoted 6 lines
I think put this event ID in driver data and distinguish them by different compatibles can achieve the same thing.
However, I originally thought that align to the existing way like MUTEX, CCORR, WDMA in
https://lore.kernel.org/all/[email protected]
Quoted 5 lines
Quoted 4 lines
would be better choice.
I think their usage of gce-events are the same.What do you think?
Quoted 17 lines
To me it comes down to whether the IDs are fixed on a particular SoC (in
which case they can be deduced by the compatible) or not. I don't really
see how this is actually a fixed property of the SoC though, if you came
along tomorrow with a "gce-2.0" you could totally end up with different
numbering because (as far as I can tell) this numbering is actually a property of the os-firmware interface, not actually a property of the SoC itself. I was expecting you to say "no" when I asked if the IDs were
fixed for a given SoC because changing the firmware /could/ change the IDs.
Although, I think you'd likely not ever want to change them, because that'd just be an annoying ABI break to deal with.
mbox IDs are "not" fixed property of the SoC.
Some of the event IDs(HW event) are fixed of the SoC and some of the event IDs are not fixed of the SoC.
So we need to change the non-fixed event IDs to make sure they won't conflict to the fixed event IDs of another SoC.
Quoted 6 lines
What I think is that you need to write a property description that explains what the mailbox is using the gce channel for so that someone
can populate the property correctly. The commit message also needs to explain why this is not a fixed value for a given SoC.
Totally agree!
Quoted 11 lines
And yes, as you pointed out earlier in this thread, Shawn needs to update this to have a reference to the gce-events binding which has a great description in it of what a gce event is.
Quoted 1 line
I think their usage of gce-events are the same.
Also, just because a property got introduced doesn't mean that it is correct and adding new instances can definitely by required to provide
justification, not just saying "it's used by xyz too".
Sure, I think we need to add more explanation for what we use a mbox channel for.
I think the main reason is we want to request a mbox channel for sending a looping command to GCE thread. The looping command will get secure task done event signal every time from secure world and notify CMDQ driver to do the same operation as the IRQ handler.
This can reduce the latency of software communication between secure world and we can also remove the complex logic after every secure task done in the secure world.
Regards,
Jason-JH.Lin
Quoted 2 lines
Cheers,
Conor.
Re: [PATCH v5 02/10] dt-bindings: mailbox: Add mboxes property for CMDQ secure driver
Quoted 38 lines · Jason-JH Lin (林睿祥)
Quoted 37 lines · Conor Dooley
Quoted 36 lines · Jason-JH Lin (林睿祥)
Quoted 35 lines · Conor Dooley
Quoted 33 lines · Jason-JH Lin (林睿祥)
Quoted 32 lines · Conor Dooley
Quoted 30 lines · Jason-JH Lin (林睿祥)
Hi Conor,
Thanks for the reviews.
Quoted 25 lines · Conor Dooley
Quoted 5 lines · Shawn Sung
From: "Jason-JH.Lin" <[email protected]>
(quoted diff) +3
-0+ mediatek,gce-events: + description: + The event id which is mapping to the specificQuoted 7 lines
hardware
event
signal
+ to gce. The event id is defined in the gce
header
+ include/dt-bindings/gce/<chip>-gce.h of each
chips.Missing any info here about when this should be used, hint -
you
have
it
in the commit message.Quoted 2 lines
+ $ref: /schemas/types.yaml#/definitions/uint32-
arrayi
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Why is the ID used by the CMDQ service not fixed for each SoC?
Did I misunderstand the ID here?
I thought we were talking about event IDs, but it looks like we are talking about mbox IDs.
We were talking about the event IDs FWIW.
Just send a new version with some actual explanations added (as we discussed earlier on this thread) and we should be good here I think.
Cheers,
Conor.