Remove cl in struct cmdq_pkt
Subsystems (4)
Chun-Kuang Hu
maintainerv2 cover Remove cl in struct cmdq_pkt
cl in struct cmdq_pkt is used to store struct cmdq_client, but every client driver has the struct cmdq_client information, so it's not necessary to store struct cmdq_client in struct cmdq_pkt. Because mailbox maintainer do not like to mix mailbox patch with other patches in a series, so mailbox patch [1] would be sent independently.
Changes in v2:
1. Fix typo of CMDQ_JUMP_RELATIVE
2. Refine cmdq_pkt_create() and cmdq_pkt_destroy()
3. Rename cmdq_pkt_jump() to cmdq_pkt_jump_abs()
4. Add cmdq_pkt_jump_rel() helper function
5. drm/mediatek: Use cmdq_pkt_create() and cmdq_pkt_destroy()
6. mtk-mdp3: Get fine-grain control of cmdq_pkt_finalize()
7. mtk-mdp3: Use cmdq_pkt_create() and cmdq_pkt_destroy()
Chun-Kuang Hu (12):
soc: mediatek: cmdq: Fix typo of CMDQ_JUMP_RELATIVE
soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()
soc: mediatek: cmdq: Rename cmdq_pkt_jump() to cmdq_pkt_jump_abs()
soc: mediatek: cmdq: Add cmdq_pkt_jump_rel() helper function
soc: mediatek: cmdq: Add cmdq_pkt_eoc() helper function
soc: mediatek: cmdq: Remove cmdq_pkt_flush_async() helper function
soc: mediatek: cmdq: Refine cmdq_pkt_create() and cmdq_pkt_destroy() drm/mediatek: Use cmdq_pkt_eoc() instead of cmdq_pkt_finalize() drm/mediatek: Use cmdq_pkt_create() and cmdq_pkt_destroy()
media: platform: mtk-mdp3: Get fine-grain control of
cmdq_pkt_finalize()
media: platform: mtk-mdp3: Use cmdq_pkt_create() and
cmdq_pkt_destroy()
soc: mediatek: cmdq: Remove cmdq_pkt_finalize() helper function
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 48 ++---------- .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 48 ++---------- .../platform/mediatek/mdp3/mtk-mdp3-core.c | 2 + .../platform/mediatek/mdp3/mtk-mdp3-core.h | 1 + drivers/soc/mediatek/mtk-cmdq-helper.c | 73 ++++++------------- include/linux/soc/mediatek/mtk-cmdq.h | 60 +++++++++------ 6 files changed, 73 insertions(+), 159 deletions(-)
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 1/12 soc: mediatek: cmdq: Fix typo of CMDQ_JUMP_RELATIVE
For cmdq jump command, offset 0 means relative jump and offset 1 means absolute jump. cmdq_pkt_jump() is absolute jump, so fix the typo of CMDQ_JUMP_RELATIVE in cmdq_pkt_jump().
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +3 -2
@@ -14,7 +14,8 @@#define CMDQ_POLL_ENABLE_MASK BIT(0)#define CMDQ_EOC_IRQ_EN BIT(0)#define CMDQ_REG_TYPE 1 -#define CMDQ_JUMP_RELATIVE 1 +#define CMDQ_JUMP_RELATIVE 0 +#define CMDQ_JUMP_ABSOLUTE 1 struct cmdq_instruction { union {
@@ -397,7 +398,7 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr)struct cmdq_instruction inst = {}; inst.op =CMDQ_CODE_JUMP ; - inst.offset =CMDQ_JUMP_RELATIVE ; + inst.offset =CMDQ_JUMP_ABSOLUTE ; inst.value = addr >>cmdq_get_shift_pa (((struct cmdq_client *)pkt->cl)->chan);return cmdq_pkt_append_command (pkt, inst);
Signature · 1 line
2.34.1
Re: [PATCH v2 01/12] soc: mediatek: cmdq: Fix typo of CMDQ_JUMP_RELATIVE
Il 22/02/24 16:41, Chun-Kuang Hu ha scritto:
Quoted 6 lines
For cmdq jump command, offset 0 means relative jump and offset 1 means absolute jump.
cmdq_pkt_jump()is absolute jump, so fix the typo ofCMDQ_JUMP_RELATIVEincmdq_pkt_jump().Fixes 946f1792d3d7 ("soc: mediatek: cmdq: add jump function")Signed-off-by Chun-Kuang Hu <[email protected]>
Chun-Kuang Hu
maintainerPATCH v2 2/12 soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()
In reply to Chun-Kuang HuIn original design, cmdq_pkt_jump() call cmdq_get_shift_pa() every time to get shift_pa. But the shift_pa is constant value for each SoC, so client driver just need to call cmdq_get_shift_pa() once and pass shift_pa to cmdq_pkt_jump() to prevent frequent function call.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 5 ++--- include/linux/soc/mediatek/mtk-cmdq.h | 6 ++++-- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +2 -3
@@ -393,14 +393,13 @@ int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value) }EXPORT_SYMBOL (cmdq_pkt_assign); -int cmdq_pkt_jump (struct cmdq_pkt *pkt,dma_addr_t addr) +int cmdq_pkt_jump (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa) {struct cmdq_instruction inst = {}; inst.op =CMDQ_CODE_JUMP ; inst.offset =CMDQ_JUMP_ABSOLUTE ; - inst.value = addr >> -cmdq_get_shift_pa (((struct cmdq_client *)pkt->cl)->chan); + inst.value = addr >> shift_pa;return cmdq_pkt_append_command (pkt, inst); }EXPORT_SYMBOL (cmdq_pkt_jump);
include/linux/soc/mediatek/mtk-cmdq.h +4 -2
@@ -253,10 +253,12 @@ int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value);* a physical address which should contains more instruction. * @pkt: the CMDQ packet * @addr: 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 (struct cmdq_pkt *pkt,dma_addr_t addr); +int cmdq_pkt_jump (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa);/** * cmdq_pkt_finalize() - Append EOC and jump command to pkt.
@@ -374,7 +376,7 @@ static inline int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value)return -EINVAL ; } -static inline int cmdq_pkt_jump (struct cmdq_pkt *pkt,dma_addr_t addr) +static inline int cmdq_pkt_jump (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa) {return -EINVAL ; }
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 3/12 soc: mediatek: cmdq: Rename cmdq_pkt_jump() to cmdq_pkt_jump_abs()
In reply to Chun-Kuang HuIn order to distinguish absolute jump and relative jump, cmdq_pkt_jump() append absolute jump command, so rename it to cmdq_pkt_jump_abs().
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 4 ++-- include/linux/soc/mediatek/mtk-cmdq.h | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +2 -2
@@ -393,7 +393,7 @@ int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value) }EXPORT_SYMBOL (cmdq_pkt_assign); -int cmdq_pkt_jump (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa) +int cmdq_pkt_jump_abs (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa) {struct cmdq_instruction inst = {};
@@ -402,7 +402,7 @@ int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa) inst.value = addr >> shift_pa;return cmdq_pkt_append_command (pkt, inst); } -EXPORT_SYMBOL (cmdq_pkt_jump); +EXPORT_SYMBOL (cmdq_pkt_jump_abs);int cmdq_pkt_finalize (struct cmdq_pkt *pkt) {
include/linux/soc/mediatek/mtk-cmdq.h +7 -6
@@ -248,17 +248,18 @@ int cmdq_pkt_poll_mask(struct cmdq_pkt *pkt, u8 subsys,int cmdq_pkt_assign (struct cmdq_pkt *pkt,u16 reg_idx,u32 value);/** -* cmdq_pkt_jump() - Append jump command to the CMDQ packet, ask GCE -* to execute an instruction that change current thread PC to -* a physical address which should contains more instruction. +* cmdq_pkt_jump_abs() - Append jump command to the CMDQ packet, ask GCE +* to execute an instruction that change current thread +* PC to a absolute physical address which should +* contains more instruction. * @pkt: the CMDQ packet -* @addr: physical address of target instruction buffer +* @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 (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa); +int cmdq_pkt_jump_abs (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa);/** * cmdq_pkt_finalize() - Append EOC and jump command to pkt.
@@ -376,7 +377,7 @@ static inline int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value)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_abs (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa) {return -EINVAL ; }
Signature · 1 line
2.34.1
Re: [PATCH v2 03/12] soc: mediatek: cmdq: Rename cmdq_pkt_jump() to cmdq_pkt_jump_abs()
Il 22/02/24 16:41, Chun-Kuang Hu ha scritto:
Quoted 5 lines
In order to distinguish absolute jump and relative jump,
cmdq_pkt_jump()append absolute jump command, so rename it tocmdq_pkt_jump_abs().Signed-off-by Chun-Kuang Hu <[email protected]>
Chun-Kuang Hu
maintainerPATCH v2 4/12 soc: mediatek: cmdq: Add cmdq_pkt_jump_rel() helper function
In reply to Chun-Kuang Hucmdq_pkt_jump_rel() append relative jump command to the packet. Relative jump change PC to the target address with offset from current PC.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 10 ++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+)
drivers/soc/mediatek/mtk-cmdq-helper.c +10 -0
@@ -404,6 +404,16 @@ 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) +{ +struct cmdq_instruction inst = { {0 } }; + + inst.op =CMDQ_CODE_JUMP ; + inst.value = (u32 )offset >> shift_pa; +return cmdq_pkt_append_command (pkt, inst); +} +EXPORT_SYMBOL (cmdq_pkt_jump_rel); +int cmdq_pkt_finalize (struct cmdq_pkt *pkt) {struct cmdq_instruction inst = { {0 } };
include/linux/soc/mediatek/mtk-cmdq.h +19 -0
@@ -261,6 +261,20 @@ int cmdq_pkt_assign(struct cmdq_pkt *pkt, u16 reg_idx, u32 value);*/ int cmdq_pkt_jump_abs (struct cmdq_pkt *pkt,dma_addr_t addr,u8 shift_pa); +/** +* cmdq_pkt_jump_rel() - Append jump command to the CMDQ packet, ask GCE +* to execute an instruction that change current thread +* PC to a physical address with relative offset. The +* 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); +/** * cmdq_pkt_finalize() - Append EOC and jump command to pkt. * @pkt: the CMDQ packet
@@ -382,6 +396,11 @@ static inline int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shreturn -EINVAL ; } +static inline int cmdq_pkt_jump_rel (struct cmdq_pkt *pkt,s32 offset,u8 shift_pa) +{ +return -EINVAL ; +} +static inline int cmdq_pkt_finalize (struct cmdq_pkt *pkt) {return -EINVAL ;
Signature · 1 line
2.34.1
Re: [PATCH v2 04/12] soc: mediatek: cmdq: Add cmdq_pkt_jump_rel() helper function
Il 22/02/24 16:41, Chun-Kuang Hu ha scritto:
Quoted 5 lines
cmdq_pkt_jump_rel()append relative jump command to the packet. Relative jump change PC to the target address with offset from current PC.Signed-off-by Chun-Kuang Hu <[email protected]>
Chun-Kuang Hu
maintainerPATCH v2 5/12 soc: mediatek: cmdq: Add cmdq_pkt_eoc() helper function
In reply to Chun-Kuang Hucmdq_pkt_eoc() append eoc command to CMDQ packet. eoc command would ask GCE to generate IRQ. It's usually appended to the end of packet to notify all command in the packet is done.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 10 ++++++++++ include/linux/soc/mediatek/mtk-cmdq.h | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+)
drivers/soc/mediatek/mtk-cmdq-helper.c +10 -0
@@ -414,6 +414,16 @@ int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa) }EXPORT_SYMBOL (cmdq_pkt_jump_rel); +int cmdq_pkt_eoc (struct cmdq_pkt *pkt) +{ +struct cmdq_instruction inst = { {0 } }; + + inst.op =CMDQ_CODE_EOC ; + inst.value =CMDQ_EOC_IRQ_EN ; +return cmdq_pkt_append_command (pkt, inst); +} +EXPORT_SYMBOL (cmdq_pkt_eoc); +int cmdq_pkt_finalize (struct cmdq_pkt *pkt) {struct cmdq_instruction inst = { {0 } };
include/linux/soc/mediatek/mtk-cmdq.h +19 -0
@@ -275,6 +275,20 @@ int cmdq_pkt_jump_abs(struct cmdq_pkt *pkt, dma_addr_t addr, u8 shift_pa);*/ int cmdq_pkt_jump_rel (struct cmdq_pkt *pkt,s32 offset,u8 shift_pa); +/** +* cmdq_pkt_eoc() - Append EOC and ask GCE to generate an IRQ at end of execution +* @pkt: The CMDQ packet +* +* Appends an End Of Code (EOC) command to the CMDQ packet and asks the GCE +* to generate an interrupt at the end of the execution of all commands in +* the pipeline. +* The EOC command is usually appended to the end of the pipeline to notify +* that all commands are done. +* +* Return: 0 for success or negative error number +*/ +int cmdq_pkt_eoc (struct cmdq_pkt *pkt); +/** * cmdq_pkt_finalize() - Append EOC and jump command to pkt. * @pkt: the CMDQ packet
@@ -401,6 +415,11 @@ static inline int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_preturn -EINVAL ; } +static inline int cmdq_pkt_eoc (struct cmdq_pkt *pkt) +{ +return -EINVAL ; +} +static inline int cmdq_pkt_finalize (struct cmdq_pkt *pkt) {return -EINVAL ;
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 6/12 soc: mediatek: cmdq: Remove cmdq_pkt_flush_async() helper function
In reply to Chun-Kuang Hucmdq_pkt_flush_async() is not used by all client drivers (MediaTek drm driver and MediaTek mdp3 driver), so remove it.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 15 --------------- include/linux/soc/mediatek/mtk-cmdq.h | 18 ------------------ 2 files changed, 33 deletions(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +0 -15
@@ -446,19 +446,4 @@ int cmdq_pkt_finalize(struct cmdq_pkt *pkt) }EXPORT_SYMBOL (cmdq_pkt_finalize); -int cmdq_pkt_flush_async (struct cmdq_pkt *pkt) -{ -int err; -struct cmdq_client *client = (struct cmdq_client *)pkt->cl; - - err =mbox_send_message (client->chan, pkt); -if (err <0 ) -return err; -/* We can send next packet immediately, so just call txdone. */ -mbox_client_txdone (client->chan,0 ); - -return 0 ; -} -EXPORT_SYMBOL (cmdq_pkt_flush_async); -MODULE_LICENSE ("GPL v2" );
include/linux/soc/mediatek/mtk-cmdq.h +0 -18
@@ -297,19 +297,6 @@ int cmdq_pkt_eoc(struct cmdq_pkt *pkt);*/ int cmdq_pkt_finalize (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 -* @pkt: the CMDQ packet -* -* Return: 0 for success; else the error code is returned -* -* Trigger CMDQ to asynchronously execute the CMDQ packet and call back -* at the end of done packet. Note that this is an ASYNC function. When the -* function returned, it may or may not be finished. -*/ -int cmdq_pkt_flush_async (struct cmdq_pkt *pkt); -#else /* IS_ENABLED(CONFIG_MTK_CMDQ) */ static inline int cmdq_dev_get_client_reg(struct device *dev,
@@ -425,11 +412,6 @@ static inline int cmdq_pkt_finalize(struct cmdq_pkt *pkt)return -EINVAL ; } -static inline int cmdq_pkt_flush_async (struct cmdq_pkt *pkt) -{ -return -EINVAL ; -} -#endif /* IS_ENABLED(CONFIG_MTK_CMDQ) */ #endif /* __MTK_CMDQ_H__ */
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 7/12 soc: mediatek: cmdq: Refine cmdq_pkt_create() and cmdq_pkt_destroy()
In reply to Chun-Kuang Hucmdq_pkt_create() and cmdq_pkt_destroy() is not suitable for client drivers so each client driver has implement its own function. This refinement would pass struct cmdq_pkt pointer into cmdq_pkt_create(). In addition, client driver has the struct cmdq_client information, so it's not necessary to store this information in struct cmdq_pkt. After this refinement, client drivers could use these helper funciton instead of implementing its own version.
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 24 +++++++----------------- include/linux/soc/mediatek/mtk-cmdq.h | 14 ++++++++------ 2 files changed, 15 insertions(+), 23 deletions(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +7 -17
@@ -106,22 +106,16 @@ void cmdq_mbox_destroy(struct cmdq_client *client) }EXPORT_SYMBOL (cmdq_mbox_destroy); -struct cmdq_pkt *cmdq_pkt_create (struct cmdq_client *client,size_t size) +int cmdq_pkt_create (struct cmdq_client *client,struct cmdq_pkt *pkt,size_t size) { -struct cmdq_pkt *pkt;struct device *dev;dma_addr_t dma_addr; - pkt =kzalloc (sizeof (*pkt),GFP_KERNEL ); -if (!pkt) -return ERR_PTR (-ENOMEM ); pkt->va_base =kzalloc (size,GFP_KERNEL ); -if (!pkt->va_base) { -kfree (pkt); -return ERR_PTR (-ENOMEM ); - } +if (!pkt->va_base) +return -ENOMEM ; + pkt->buf_size = size; - pkt->cl = (void *)client; dev = client->chan->mbox->dev; dma_addr = dma_map_single(dev, pkt->va_base, pkt->buf_size,
@@ -129,24 +123,20 @@ struct cmdq_pkt *cmdq_pkt_create(struct cmdq_client *client, size_t size)if (dma_mapping_error (dev, dma_addr)) {dev_err (dev,"dma map failed, size=%u\n" , (u32 )(u64 )size);kfree (pkt->va_base); -kfree (pkt); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; } pkt->pa_base = dma_addr; -return pkt; +return 0 ; }EXPORT_SYMBOL (cmdq_pkt_create); -void cmdq_pkt_destroy (struct cmdq_pkt *pkt) +void cmdq_pkt_destroy (struct cmdq_client *client,struct cmdq_pkt *pkt) { -struct cmdq_client *client = (struct cmdq_client *)pkt->cl; -dma_unmap_single (client->chan->mbox->dev, pkt->pa_base, pkt->buf_size,DMA_TO_DEVICE );kfree (pkt->va_base); -kfree (pkt); }EXPORT_SYMBOL (cmdq_pkt_destroy);
include/linux/soc/mediatek/mtk-cmdq.h +8 -6
@@ -62,17 +62,19 @@ void cmdq_mbox_destroy(struct cmdq_client *client);/** * cmdq_pkt_create() - create a CMDQ packet * @client: the CMDQ mailbox client +* @pkt: the CMDQ packet * @size: required CMDQ buffer size * -* Return: CMDQ packet pointer +* Return: 0 for success; else the error code is returned */ -struct cmdq_pkt *cmdq_pkt_create (struct cmdq_client *client,size_t size); +int cmdq_pkt_create (struct cmdq_client *client,struct cmdq_pkt *pkt,size_t size);/** * cmdq_pkt_destroy() - destroy the CMDQ packet +* @client: the CMDQ mailbox client * @pkt: the CMDQ packet */ -void cmdq_pkt_destroy (struct cmdq_pkt *pkt); +void cmdq_pkt_destroy (struct cmdq_client *client,struct cmdq_pkt *pkt);/** * cmdq_pkt_write() - append write command to the CMDQ packet
@@ -312,12 +314,12 @@ static inline struct cmdq_client *cmdq_mbox_create(struct device *dev, int indexstatic inline void cmdq_mbox_destroy (struct cmdq_client *client) { } -static inline struct cmdq_pkt *cmdq_pkt_create (struct cmdq_client *client,size_t size) +static inline int cmdq_pkt_create (struct cmdq_client *client,struct cmdq_pkt *pkt,size_t size) { -return ERR_PTR (-EINVAL ); +return -EINVAL ; } -static inline void cmdq_pkt_destroy (struct cmdq_pkt *pkt) { } +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) {
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 8/12 drm/mediatek: Use cmdq_pkt_eoc() instead of cmdq_pkt_finalize()
In reply to Chun-Kuang HuFor some client driver, it want to reduce latency between excuting previous packet command and next packet command, so append jump command to the end of previous packet and the jump destination address is the start address of next packet command buffer. Before next packet exist, the previous packet has no information of where to jump to, so append nop command first. When next packet exist, change nop command to jump command. For mediatek drm driver, it never has next packet, so appending nop command is redundant. Because cmdq_pkt_finalize() would append nop command, so change calling cmdq_pkt_finalize() to cmdq_pkt_eoc() to prevent append redundant nop command.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +1 -1
@@ -593,7 +593,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,cmdq_pkt_clear_event (cmdq_handle, mtk_crtc->cmdq_event);cmdq_pkt_wfe (cmdq_handle, mtk_crtc->cmdq_event, false);mtk_crtc_ddp_config (crtc, cmdq_handle); -cmdq_pkt_finalize (cmdq_handle); +cmdq_pkt_eoc (cmdq_handle); dma_sync_single_for_device(mtk_crtc->cmdq_client.chan->mbox->dev, cmdq_handle->pa_base, cmdq_handle->cmd_buf_size,
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 9/12 drm/mediatek: Use cmdq_pkt_create() and cmdq_pkt_destroy()
In reply to Chun-Kuang HuUse cmdq_pkt_create() and cmdq_pkt_destroy() common function instead of implementing drm version.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 46 +++---------------------- 1 file changed, 4 insertions(+), 42 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +4 -42
@@ -111,44 +111,6 @@ static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) } } -#if IS_REACHABLE (CONFIG_MTK_CMDQ ) -static int mtk_drm_cmdq_pkt_create (struct cmdq_client *client,struct cmdq_pkt *pkt, -size_t size) -{ -struct device *dev; -dma_addr_t dma_addr; - - pkt->va_base =kzalloc (size,GFP_KERNEL ); -if (!pkt->va_base) -return -ENOMEM ; - - pkt->buf_size = size; - pkt->cl = (void *)client; - - dev = client->chan->mbox->dev; - dma_addr =dma_map_single (dev, pkt->va_base, pkt->buf_size, -DMA_TO_DEVICE ); -if (dma_mapping_error (dev, dma_addr)) { -dev_err (dev,"dma map failed, size=%u\n" , (u32 )(u64 )size); -kfree (pkt->va_base); -return -ENOMEM ; - } - - pkt->pa_base = dma_addr; - -return 0 ; -} - -static void mtk_drm_cmdq_pkt_destroy (struct cmdq_pkt *pkt) -{ -struct cmdq_client *client = (struct cmdq_client *)pkt->cl; - -dma_unmap_single (client->chan->mbox->dev, pkt->pa_base, pkt->buf_size, -DMA_TO_DEVICE ); -kfree (pkt->va_base); -} -#endif -static void mtk_drm_crtc_destroy (struct drm_crtc *crtc) {struct mtk_drm_crtc *mtk_crtc =to_mtk_crtc (crtc);
@@ -156,7 +118,7 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)mtk_mutex_put (mtk_crtc->mutex);#if IS_REACHABLE (CONFIG_MTK_CMDQ ) -mtk_drm_cmdq_pkt_destroy (&mtk_crtc->cmdq_handle); +cmdq_pkt_destroy (&mtk_crtc->cmdq_client, &mtk_crtc->cmdq_handle);if (mtk_crtc->cmdq_client.chan) {mbox_free_channel (mtk_crtc->cmdq_client.chan);
@@ -1083,9 +1045,9 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,mbox_free_channel (mtk_crtc->cmdq_client.chan); mtk_crtc->cmdq_client.chan =NULL ; }else { - ret =mtk_drm_cmdq_pkt_create (&mtk_crtc->cmdq_client, - &mtk_crtc->cmdq_handle, -PAGE_SIZE ); + ret =cmdq_pkt_create (&mtk_crtc->cmdq_client, + &mtk_crtc->cmdq_handle, +PAGE_SIZE );if (ret) {dev_dbg (dev,"mtk_crtc %d failed to create cmdq packet\n" ,drm_crtc_index (&mtk_crtc->base));
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 10/12 media: platform: mtk-mdp3: Get fine-grain control of cmdq_pkt_finalize()
In reply to Chun-Kuang HuIn order to have fine-grained control, use cmdq_pkt_eoc() and cmdq_pkt_jump_rel() to replace cmdq_pkt_finalize().
--- drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 3 ++- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 2 ++ drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +2 -1
@@ -471,7 +471,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)dev_err (dev,"mdp_path_config error\n" ); goto err_free_path; } -cmdq_pkt_finalize (&cmd->pkt); +cmdq_pkt_eoc (&cmd->pkt); +cmdq_pkt_jump_rel (&cmd->pkt,CMDQ_INST_SIZE , mdp->cmdq_shift_pa);for (i =0 ; i < num_comp; i++) memcpy(&comps[i], path->comps[i].comp,
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +2 -0
@@ -231,6 +231,8 @@ static int mdp_probe(struct platform_device *pdev) goto err_put_scp; } + mdp->cmdq_shift_pa =cmdq_get_shift_pa (mdp->cmdq_clt->chan); +init_waitqueue_head (&mdp->callback_wq);ida_init (&mdp->mdp_ida);platform_set_drvdata (pdev, mdp);
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +1 -0
@@ -83,6 +83,7 @@ struct mdp_dev {u32 id_count;struct ida mdp_ida;struct cmdq_client *cmdq_clt; +u8 cmdq_shift_pa;wait_queue_head_t callback_wq;struct v4l2_device v4l2_dev;
Signature · 1 line
2.34.1
Re: [PATCH v2 10/12] media: platform: mtk-mdp3: Get fine-grain control of cmdq_pkt_finalize()
Le 22/02/2024 à 16:41, Chun-Kuang Hu a écrit :
Quoted 42 lines
In order to have fine-grained control, use
cmdq_pkt_eoc()andcmdq_pkt_jump_rel()to replacecmdq_pkt_finalize().Signed-off-by Chun-Kuang Hu <[email protected]>--- drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 3 ++- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 2 ++ drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +2
-1@@ -471,7 +471,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)dev_err (dev,"mdp_path_config error\n" ); goto err_free_path; } -cmdq_pkt_finalize (&cmd->pkt); +cmdq_pkt_eoc (&cmd->pkt); +cmdq_pkt_jump_rel (&cmd->pkt,CMDQ_INST_SIZE , mdp->cmdq_shift_pa);for (i =0 ; i < num_comp; i++) memcpy(&comps[i], path->comps[i].comp,drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +2
-0@@ -231,6 +231,8 @@ static int mdp_probe(struct platform_device *pdev) goto err_put_scp; } + mdp->cmdq_shift_pa =cmdq_get_shift_pa (mdp->cmdq_clt->chan); +init_waitqueue_head (&mdp->callback_wq);ida_init (&mdp->mdp_ida);platform_set_drvdata (pdev, mdp);drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +0
-0
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h struct mdp_dev { · line 86
Quoted 4 lines
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +1
-0@@ -83,6 +83,7 @@ struct mdp_dev {u32 id_count;struct ida mdp_ida;struct cmdq_client *cmdq_clt; +u8 cmdq_shift_pa;
Can send a new version of this series because this patch can't be applied on media_tree/master branch.
The code look correct for me but we need to be able to applied it to perform more checks.
Regards,
Benjamin
Quoted 3 lines
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +0
-0wait_queue_head_t callback_wq;struct v4l2_device v4l2_dev;
Re: [PATCH v2 10/12] media: platform: mtk-mdp3: Get fine-grain control of cmdq_pkt_finalize()
Hi, Benjamin:
Quoted 44 lines · Benjamin Gaignard
Quoted 43 lines · Chun-Kuang Hu
In order to have fine-grained control, use
cmdq_pkt_eoc()andcmdq_pkt_jump_rel()to replacecmdq_pkt_finalize().Signed-off-by Chun-Kuang Hu <[email protected]>--- drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 3 ++- drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c | 2 ++ drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h | 1 + 3 files changed, 5 insertions(+), 1 deletion(-)drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +2
-1@@ -471,7 +471,8 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param)dev_err (dev,"mdp_path_config error\n" ); goto err_free_path; } -cmdq_pkt_finalize (&cmd->pkt); +cmdq_pkt_eoc (&cmd->pkt); +cmdq_pkt_jump_rel (&cmd->pkt,CMDQ_INST_SIZE , mdp->cmdq_shift_pa);for (i =0 ; i < num_comp; i++) memcpy(&comps[i], path->comps[i].comp,drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.c +2
-0@@ -231,6 +231,8 @@ static int mdp_probe(struct platform_device *pdev) goto err_put_scp; } + mdp->cmdq_shift_pa =cmdq_get_shift_pa (mdp->cmdq_clt->chan); +init_waitqueue_head (&mdp->callback_wq);ida_init (&mdp->mdp_ida);platform_set_drvdata (pdev, mdp);drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +0
-0@@ -83,6 +83,7 @@ struct mdp_dev {u32 id_count;
Quoted 8 lines
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h struct mdp_dev { · line 86
Quoted 3 lines
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +1
-0struct ida mdp_ida;struct cmdq_client *cmdq_clt; +u8 cmdq_shift_pa;Can send a new version of this series because this patch can't be applied on media_tree/master branch.
The code look correct for me but we need to be able to applied it to perform more checks.
New version has been sent.
[1] https://patchwork.kernel.org/project/linux-media/patch/[email protected]/
Regards,
CK
Quoted 9 lines
Regards,
BenjaminQuoted 3 lines
drivers/media/platform/mediatek/mdp3/mtk-mdp3-core.h +0
-0wait_queue_head_t callback_wq;struct v4l2_device v4l2_dev;
Chun-Kuang Hu
maintainerPATCH v2 11/12 media: platform: mtk-mdp3: Use cmdq_pkt_create() and cmdq_pkt_destroy()
In reply to Chun-Kuang HuUse cmdq_pkt_create() and cmdq_pkt_destroy() common function instead of implementing mdp3 version.
--- .../platform/mediatek/mdp3/mtk-mdp3-cmdq.c | 45 ++----------------- 1 file changed, 4 insertions(+), 41 deletions(-)
drivers/media/platform/mediatek/mdp3/mtk-mdp3-cmdq.c +4 -41
@@ -287,43 +287,6 @@ static int mdp_path_config(struct mdp_dev *mdp, struct mdp_cmdq_cmd *cmd,return 0 ; } -static int mdp_cmdq_pkt_create (struct cmdq_client *client,struct cmdq_pkt *pkt, -size_t size) -{ -struct device *dev; -dma_addr_t dma_addr; - - pkt->va_base =kzalloc (size,GFP_KERNEL ); -if (!pkt->va_base) -return -ENOMEM ; - - pkt->buf_size = size; - pkt->cl = (void *)client; - - dev = client->chan->mbox->dev; - dma_addr =dma_map_single (dev, pkt->va_base, pkt->buf_size, -DMA_TO_DEVICE ); -if (dma_mapping_error (dev, dma_addr)) { -dev_err (dev,"dma map failed, size=%u\n" , (u32 )(u64 )size); -kfree (pkt->va_base); -return -ENOMEM ; - } - - pkt->pa_base = dma_addr; - -return 0 ; -} - -static void mdp_cmdq_pkt_destroy (struct cmdq_pkt *pkt) -{ -struct cmdq_client *client = (struct cmdq_client *)pkt->cl; - -dma_unmap_single (client->chan->mbox->dev, pkt->pa_base, pkt->buf_size, -DMA_TO_DEVICE ); -kfree (pkt->va_base); - pkt->va_base =NULL ; -} -static void mdp_auto_release_work (struct work_struct *work) {struct mdp_cmdq_cmd *cmd;
@@ -341,7 +304,7 @@ static void mdp_auto_release_work(struct work_struct *work)atomic_dec (&mdp->job_count);wake_up (&mdp->callback_wq); -mdp_cmdq_pkt_destroy (&cmd->pkt); +cmdq_pkt_destroy (mdp->cmdq_clt, &cmd->pkt);kfree (cmd->comps); cmd->comps =NULL ;kfree (cmd);
@@ -388,7 +351,7 @@ static void mdp_handle_cmdq_callback(struct mbox_client *cl, void *mssg)atomic_dec (&mdp->job_count);wake_up (&mdp->callback_wq); -mdp_cmdq_pkt_destroy (&cmd->pkt); +cmdq_pkt_destroy (mdp->cmdq_clt, &cmd->pkt);kfree (cmd->comps); cmd->comps =NULL ;kfree (cmd);
@@ -418,7 +381,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) goto err_cancel_job; } - ret =mdp_cmdq_pkt_create (mdp->cmdq_clt, &cmd->pkt,SZ_16K ); + ret =cmdq_pkt_create (mdp->cmdq_clt, &cmd->pkt,SZ_16K );if (ret) goto err_free_cmd;
@@ -513,7 +476,7 @@ int mdp_cmdq_send(struct mdp_dev *mdp, struct mdp_cmdq_param *param) err_free_comps:kfree (comps); err_destroy_pkt: -mdp_cmdq_pkt_destroy (&cmd->pkt); +cmdq_pkt_destroy (mdp->cmdq_clt, &cmd->pkt); err_free_cmd:kfree (cmd); err_cancel_job:
Signature · 1 line
2.34.1
Chun-Kuang Hu
maintainerPATCH v2 12/12 soc: mediatek: cmdq: Remove cmdq_pkt_finalize() helper function
In reply to Chun-Kuang HuIn order to have fine-grained control, use cmdq_pkt_eoc() and cmdq_pkt_jump_rel() to replace cmdq_pkt_finalize().
--- drivers/soc/mediatek/mtk-cmdq-helper.c | 22 ---------------------- include/linux/soc/mediatek/mtk-cmdq.h | 13 ------------- 2 files changed, 35 deletions(-)
drivers/soc/mediatek/mtk-cmdq-helper.c +0 -22
@@ -414,26 +414,4 @@ int cmdq_pkt_eoc(struct cmdq_pkt *pkt) }EXPORT_SYMBOL (cmdq_pkt_eoc); -int cmdq_pkt_finalize (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 end */ - inst.op =CMDQ_CODE_JUMP ; - inst.value =CMDQ_JUMP_PASS >> -cmdq_get_shift_pa (((struct cmdq_client *)pkt->cl)->chan); - err =cmdq_pkt_append_command (pkt, inst); - -return err; -} -EXPORT_SYMBOL (cmdq_pkt_finalize); -MODULE_LICENSE ("GPL v2" );
include/linux/soc/mediatek/mtk-cmdq.h +0 -13
@@ -291,14 +291,6 @@ int cmdq_pkt_jump_rel(struct cmdq_pkt *pkt, s32 offset, u8 shift_pa);*/ int cmdq_pkt_eoc (struct cmdq_pkt *pkt); -/** -* cmdq_pkt_finalize() - Append EOC and jump command to pkt. -* @pkt: the CMDQ packet -* -* Return: 0 for success; else the error code is returned -*/ -int cmdq_pkt_finalize (struct cmdq_pkt *pkt); -#else /* IS_ENABLED(CONFIG_MTK_CMDQ) */ static inline int cmdq_dev_get_client_reg(struct device *dev,
@@ -409,11 +401,6 @@ static inline int cmdq_pkt_eoc(struct cmdq_pkt *pkt)return -EINVAL ; } -static inline int cmdq_pkt_finalize (struct cmdq_pkt *pkt) -{ -return -EINVAL ; -} -#endif /* IS_ENABLED(CONFIG_MTK_CMDQ) */ #endif /* __MTK_CMDQ_H__ */
Signature · 1 line
2.34.1
Re: (subset) [PATCH v2 00/12] Remove cl in struct cmdq_pkt
In reply to Chun-Kuang HuQuoted 15 lines · Chun-Kuang Hu
cl in struct
cmdq_pktis used to store structcmdq_client, but every client driver has the structcmdq_clientinformation, so it's not necessary to store structcmdq_clientin structcmdq_pkt. Because mailbox maintainer do not like to mix mailbox patch with other patches in a series, so mailbox patch [1] would be sent independently.Changes in v2:
1. Fix typo ofCMDQ_JUMP_RELATIVE
2. Refinecmdq_pkt_create()andcmdq_pkt_destroy()
3. Renamecmdq_pkt_jump()tocmdq_pkt_jump_abs()
4. Addcmdq_pkt_jump_rel()helper function
5. drm/mediatek: Usecmdq_pkt_create()andcmdq_pkt_destroy()
6. mtk-mdp3: Get fine-grain control ofcmdq_pkt_finalize()
7. mtk-mdp3: Usecmdq_pkt_create()andcmdq_pkt_destroy()
Quoted 1 line
[...]
Applied to v6.9-next/soc, thanks!
[01/12] soc: mediatek: cmdq: Fix typo of CMDQ_JUMP_RELATIVE
commit: 7349d4bdee457715308e6229a674f4cebf42be92
[02/12] soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump()
commit: e24e0ff0871b8e3287f258b76b82238b64714628
[03/12] soc: mediatek: cmdq: Rename cmdq_pkt_jump() to cmdq_pkt_jump_abs()
commit: 8a8bcf23b3e0ab333bfc827ea7ed2f9bece9bea8
[04/12] soc: mediatek: cmdq: Add cmdq_pkt_jump_rel() helper function
commit: 78462e312e63c5bc0859934d9457155fb50da2e1
[05/12] soc: mediatek: cmdq: Add cmdq_pkt_eoc() helper function
commit: cad76fa0221c3f8e656b56b7673ae752a65108d8
[06/12] soc: mediatek: cmdq: Remove cmdq_pkt_flush_async() helper function
commit: 3e2b3be190ace43841011ec0bec950a28a012601
[07/12] soc: mediatek: cmdq: Refine cmdq_pkt_create() and cmdq_pkt_destroy()
commit: 62d2fb402b132e52899f52b4d5f150fd1dfd1895Cheers,
Angelo