lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAAOTY_9UfPVTz2hAdykfKJqKA4GYg2ORnWfg_MJVSnrZ40UDBA@mail.gmail.com>
Date:   Wed, 27 Oct 2021 00:05:16 +0800
From:   Chun-Kuang Hu <chunkuang.hu@...nel.org>
To:     "jason-jh.lin" <jason-jh.lin@...iatek.com>
Cc:     Chun-Kuang Hu <chunkuang.hu@...nel.org>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Jassi Brar <jassisinghbrar@...il.com>,
        Yongqiang Niu <yongqiang.niu@...iatek.com>,
        David Airlie <airlied@...ux.ie>,
        Daniel Vetter <daniel@...ll.ch>,
        DRI Development <dri-devel@...ts.freedesktop.org>,
        "moderated list:ARM/Mediatek SoC support" 
        <linux-mediatek@...ts.infradead.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        linux-kernel <linux-kernel@...r.kernel.org>,
        Hsin-Yi Wang <hsinyi@...omium.org>, fshao@...omium.org,
        Nancy Lin <nancy.lin@...iatek.com>, singo.chang@...iatek.com
Subject: Re: [PATCH v4 4/5] drm/mediatek: Add cmdq_handle in mtk_crtc

Hi, Jason:

jason-jh.lin <jason-jh.lin@...iatek.com> 於 2021年10月26日 週二 下午1:29寫道:
>
> From: Chun-Kuang Hu <chunkuang.hu@...nel.org>
>
> One mtk_crtc need just one cmdq_handle, so add one cmdq_handle
> in mtk_crtc to prevent frequently allocation and free of
> cmdq_handle.
>
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@...nel.org>
> Signed-off-by: jason-jh.lin <jason-jh.lin@...iatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 64 +++++++++++++++++++++++--
>  1 file changed, 60 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index dad1f85ee315..31f05efc1bc0 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -53,6 +53,7 @@ struct mtk_drm_crtc {
>
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>         struct cmdq_client              cmdq_client;
> +       struct cmdq_pkt                 cmdq_handle;
>         u32                             cmdq_event;
>         u32                             cmdq_vblank_cnt;
>  #endif
> @@ -107,12 +108,59 @@ 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) {
> +               kfree(pkt);
> +               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);
> +               kfree(pkt);
> +               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);
> +       kfree(pkt);
> +}
> +#endif
> +
>  static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
>  {
>         struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>
>         mtk_mutex_put(mtk_crtc->mutex);
> +#if IS_REACHABLE(CONFIG_MTK_CMDQ)
> +       mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle);
>
> +       if (mtk_crtc->cmdq_client.chan)

This is not related to this patch, so move to an independent patch.

Regards,
Chun-Kuang.

> +               mbox_free_channel(mtk_crtc->cmdq_client.chan);
> +                                 mtk_crtc->cmdq_client.chan = NULL;
> +#endif
>         drm_crtc_cleanup(crtc);
>  }
>
> @@ -227,12 +275,10 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>  static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
>  {
> -       struct cmdq_cb_data *data = mssg;
>         struct cmdq_client *cmdq_cl = container_of(cl, struct cmdq_client, client);
>         struct mtk_drm_crtc *mtk_crtc = container_of(cmdq_cl, struct mtk_drm_crtc, cmdq_client);
>
>         mtk_crtc->cmdq_vblank_cnt = 0;
> -       cmdq_pkt_destroy(data->pkt);
>  }
>  #endif
>
> @@ -438,7 +484,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
>                                        bool needs_vblank)
>  {
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
> -       struct cmdq_pkt *cmdq_handle;
> +       struct cmdq_pkt *cmdq_handle = &mtk_crtc->cmdq_handle;
>  #endif
>         struct drm_crtc *crtc = &mtk_crtc->base;
>         struct mtk_drm_private *priv = crtc->dev->dev_private;
> @@ -478,7 +524,7 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
>  #if IS_REACHABLE(CONFIG_MTK_CMDQ)
>         if (mtk_crtc->cmdq_client.chan) {
>                 mbox_flush(mtk_crtc->cmdq_client.chan, 2000);
> -               cmdq_handle = cmdq_pkt_create(&mtk_crtc->cmdq_client, PAGE_SIZE);
> +               cmdq_handle->cmd_buf_size = 0;
>                 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);
> @@ -877,6 +923,16 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
>                                 drm_crtc_index(&mtk_crtc->base));
>                         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);
> +                       if (ret) {
> +                               dev_dbg(dev, "mtk_crtc %d failed to create cmdq packet\n",
> +                                       drm_crtc_index(&mtk_crtc->base));
> +                               mbox_free_channel(mtk_crtc->cmdq_client.chan);
> +                               mtk_crtc->cmdq_client.chan = NULL;
> +                       }
>                 }
>         }
>  #endif
> --
> 2.18.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ