From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Chun-Kuang Hu <chunkuang.hu@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH 1/9] soc: mediatek: cmdq: Remove unused helper funciton
Date: Thu, 15 Feb 2024 11:40:35 +0100 [thread overview]
Message-ID: <c87af05e-9017-4806-88b1-7aa65f2b7070@collabora.com> (raw)
In-Reply-To: <20240215004931.3808-2-chunkuang.hu@kernel.org>
Il 15/02/24 01:49, 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),
>
Hello CK,
We can technically force the hand to say that this is true - but only because
these two functions are copy-pasted in both mediatek-drm and MDP3 drivers with
no meaningful changes, as in, the only change is that `pkt` is supposed to be
preallocated in both of the variants, while the one in mtk-cmdq-helper allocates
it on its own.
Code duplication is something that we want to avoid, not something that we want
to embrace: removing those functions from cmdq-helper with the plan to keep
duplicating them in each MediaTek driver that uses CMDQ packets is plain wrong.
This - especially because I'm sure that we will see yet another copy-paste of
those two functions in a future ISP driver, bringing the duplication count to
3 (or actually, 3 by 2 functions = 6 times).
On the other hand, removing the cmdq_pkt_flush_async() function is something
that I *do* support, as it's only doing two simple calls that are not even
specific to cmdq, but more like "generic stuff".
In short, as it is right now, this is a NACK - but if you change this commit to
remove only cmdq_pkt_flush_async() I would agree.
The right thing to do is to remove the duplicated functions:
- mtk_drm_cmdq_pkt_create()
- mtk_drm_cmdq_pkt_destroy()
- mdp_cmdq_pkt_create()
- mdp_cmdq_pkt_destroy()
...and migrate both drivers to use the common cmdq helper code instea, but that's
something that can come later.
For now, you can simply perform the ->cl removal on all duplicated functions, then
we can migrate them all to the common helper, removing duplication all along.
Regards,
Angelo
> 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 | 40 -----------------
> 2 files changed, 99 deletions(-)
>
> diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c
> index b0cd071c4719..67e17974d1e6 100644
> --- a/drivers/soc/mediatek/mtk-cmdq-helper.c
> +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c
> @@ -105,50 +105,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)
> {
> @@ -426,19 +382,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 649955d2cf5c..6c42d817d368 100644
> --- a/include/linux/soc/mediatek/mtk-cmdq.h
> +++ b/include/linux/soc/mediatek/mtk-cmdq.h
> @@ -59,21 +59,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
> @@ -266,19 +251,6 @@ 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);
> -
> #else /* IS_ENABLED(CONFIG_MTK_CMDQ) */
>
> static inline int cmdq_dev_get_client_reg(struct device *dev,
> @@ -294,13 +266,6 @@ static inline struct cmdq_client *cmdq_mbox_create(struct device *dev, int index
>
> static inline void cmdq_mbox_destroy(struct cmdq_client *client) { }
>
> -static inline struct cmdq_pkt *cmdq_pkt_create(struct cmdq_client *client, size_t size)
> -{
> - return ERR_PTR(-EINVAL);
> -}
> -
> -static inline void cmdq_pkt_destroy(struct cmdq_pkt *pkt) { }
> -
> static inline int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value)
> {
> return -ENOENT;
> @@ -384,11 +349,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__ */
next prev parent reply other threads:[~2024-02-15 10:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-15 0:49 [PATCH 0/9] Remove cl in struct cmdq_pkt Chun-Kuang Hu
2024-02-15 0:49 ` [PATCH 1/9] soc: mediatek: cmdq: Remove unused helper funciton Chun-Kuang Hu
2024-02-15 10:40 ` AngeloGioacchino Del Regno [this message]
2024-02-16 2:11 ` CK Hu (胡俊光)
2024-02-15 0:49 ` [PATCH 2/9] soc: mediatek: cmdq: Add parameter shift_pa to cmdq_pkt_jump() Chun-Kuang Hu
2024-02-15 10:40 ` AngeloGioacchino Del Regno
2024-02-16 1:36 ` CK Hu (胡俊光)
2024-02-15 0:49 ` [PATCH 3/9] soc: mediatek: cmdq: Add cmdq_pkt_eoc() helper function Chun-Kuang Hu
2024-02-15 10:40 ` AngeloGioacchino Del Regno
2024-02-15 0:49 ` [PATCH 4/9] soc: mediatek: cmdq: Add cmdq_pkt_nop() " Chun-Kuang Hu
2024-02-15 10:40 ` AngeloGioacchino Del Regno
2024-02-16 1:39 ` CK Hu (胡俊光)
2024-02-15 0:49 ` [PATCH 5/9] drm/mediatek: Drop calling cmdq_pkt_finalize() Chun-Kuang Hu
2024-02-15 10:40 ` AngeloGioacchino Del Regno
2024-02-15 0:49 ` [PATCH 6/9] media: platform: mtk-mdp3: drop " Chun-Kuang Hu
2024-02-15 10:29 ` AngeloGioacchino Del Regno
2024-02-16 6:20 ` Moudy Ho (何宗原)
2024-02-16 7:56 ` AngeloGioacchino Del Regno
2024-02-22 3:11 ` CK Hu (胡俊光)
2024-02-15 0:49 ` [PATCH 7/9] soc: mediatek: cmdq: Remove cmdq_pkt_finalize() helper function Chun-Kuang Hu
2024-02-15 0:49 ` [PATCH 8/9] drm/mediatek: Do not store struct cmdq_client in struct cmdq_pkt Chun-Kuang Hu
2024-02-15 10:40 ` AngeloGioacchino Del Regno
2024-02-15 0:49 ` [PATCH 9/9] media: platform: mtk-mdp3: do " Chun-Kuang Hu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c87af05e-9017-4806-88b1-7aa65f2b7070@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=chunkuang.hu@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mchehab@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®