diff mbox series

soc: mediatek: cmdq: Remove unused helper funciton

Message ID 20230219233439.3157-1-chunkuang.hu@kernel.org (mailing list archive)
State New, archived
Headers show
Series soc: mediatek: cmdq: Remove unused helper funciton | expand

Commit Message

Chun-Kuang Hu Feb. 19, 2023, 11:34 p.m. UTC
cmdq_pkt_create(), cmdq_pkt_destroy(), and cmdq_pkt_flush_async()
are not used by all client drivers (MediaTek drm driver and
MediaTek mdp3 driver), so remove them.

Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
---
 drivers/soc/mediatek/mtk-cmdq-helper.c | 59 --------------------------
 include/linux/soc/mediatek/mtk-cmdq.h  | 28 ------------
 2 files changed, 87 deletions(-)

Comments

AngeloGioacchino Del Regno Feb. 20, 2023, 11:31 a.m. UTC | #1
Il 20/02/23 00:34, Chun-Kuang Hu ha scritto:
> cmdq_pkt_create(), cmdq_pkt_destroy(), and cmdq_pkt_flush_async()
> are not used by all client drivers (MediaTek drm driver and
> MediaTek mdp3 driver), so remove them.
> 
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>

My next cleanup step would be to migrate both the MediaTek DRM driver
and MDP3 to use the common functions present in mtk-cmdq-helper.
Function mtk_drm_cmdq_pkt_create() is (almost) a clone of cmdq_pkt_create().

NACK.

Regards,
Angelo
Chun-Kuang Hu Feb. 20, 2023, 4:39 p.m. UTC | #2
Hi, Angelo:

AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> 於
2023年2月20日 週一 下午7:31寫道:
>
> Il 20/02/23 00:34, Chun-Kuang Hu ha scritto:
> > cmdq_pkt_create(), cmdq_pkt_destroy(), and cmdq_pkt_flush_async()
> > are not used by all client drivers (MediaTek drm driver and
> > MediaTek mdp3 driver), so remove them.
> >
> > Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
>
> My next cleanup step would be to migrate both the MediaTek DRM driver
> and MDP3 to use the common functions present in mtk-cmdq-helper.
> Function mtk_drm_cmdq_pkt_create() is (almost) a clone of cmdq_pkt_create().

It's good to hear that you have plan to refine cmdq_pkt_create(). I
have one plan and wish you may consider in your patch. The plan is to
remove cl in struct cmdq_pkt because cl is used for channel
information and the client would have the channel information, so it's
not necessary to store the channel information in every packet. In
cmdq_pkt_jump() and cmdq_pkt_finalize() use cl to get
cmdq_get_shift_pa(), I think it's not necessary to get shift pa every
cmdq_pkt_jump() and every cmdq_pkt_finalize(), so client could
cmdq_get_shift_pa() once and pass this information to cmdq_pkt_jump()
and cmdq_pkt_finalize().

Regards,
Chun-Kuang.

>
> NACK.
>
> Regards,
> Angelo
diff mbox series

Patch

diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
index c1837a468267..d4ab39236c79 100644
--- a/drivers/soc/mediatek/mtk-cmdq-helper.c
+++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
@@ -104,50 +104,6 @@  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)
-{
-	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);
-	}
-	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);
-		kfree(pkt);
-		return ERR_PTR(-ENOMEM);
-	}
-
-	pkt->pa_base = dma_addr;
-
-	return pkt;
-}
-EXPORT_SYMBOL(cmdq_pkt_create);
-
-void 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);
-	kfree(pkt);
-}
-EXPORT_SYMBOL(cmdq_pkt_destroy);
-
 static int cmdq_pkt_append_command(struct cmdq_pkt *pkt,
 				   struct cmdq_instruction inst)
 {
@@ -425,19 +381,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");
diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h
index 2b498f4f3946..60e4c0ca52a1 100644
--- a/include/linux/soc/mediatek/mtk-cmdq.h
+++ b/include/linux/soc/mediatek/mtk-cmdq.h
@@ -57,21 +57,6 @@  struct cmdq_client *cmdq_mbox_create(struct device *dev, int index);
  */
 void cmdq_mbox_destroy(struct cmdq_client *client);
 
-/**
- * cmdq_pkt_create() - create a CMDQ packet
- * @client:	the CMDQ mailbox client
- * @size:	required CMDQ buffer size
- *
- * Return: CMDQ packet pointer
- */
-struct cmdq_pkt *cmdq_pkt_create(struct cmdq_client *client, size_t size);
-
-/**
- * cmdq_pkt_destroy() - destroy the CMDQ packet
- * @pkt:	the CMDQ packet
- */
-void cmdq_pkt_destroy(struct cmdq_pkt *pkt);
-
 /**
  * cmdq_pkt_write() - append write command to the CMDQ packet
  * @pkt:	the CMDQ packet
@@ -264,17 +249,4 @@  int cmdq_pkt_jump(struct cmdq_pkt *pkt, dma_addr_t addr);
  */
 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);
-
 #endif	/* __MTK_CMDQ_H__ */