* Re: [PATCH v4 1/2] drm/mediatek: add wait_for_event for crtc disable by cmdq
[not found] ` <20211202064039.20797-2-jason-jh.lin@mediatek.com>
@ 2021-12-02 23:21 ` Chun-Kuang Hu
2022-02-27 3:36 ` Chun-Kuang Hu
0 siblings, 1 reply; 5+ messages in thread
From: Chun-Kuang Hu @ 2021-12-02 23:21 UTC (permalink / raw)
To: jason-jh.lin
Cc: Chun-Kuang Hu, Philipp Zabel, Matthias Brugger, tzungbi,
David Airlie, Daniel Vetter, DRI Development,
moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
Hsin-Yi Wang, Fei Shao, Nancy Lin, singo.chang
Hi, Jason:
jason-jh.lin <jason-jh.lin@mediatek.com> 於 2021年12月2日 週四 下午2:41寫道:
>
> mtk_drm_crtc_atomic_disable will send an async cmd to cmdq driver,
> so it may not finish when cmdq_suspend is called sometimes.
>
> Add wait_for_event after sending async disable plane cmd to make
> sure the lastest cmd is done before cmdq_suspend.
Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
>
> Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 62529a954b62..0b4012335e7a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -56,6 +56,7 @@ struct mtk_drm_crtc {
> struct cmdq_pkt cmdq_handle;
> u32 cmdq_event;
> u32 cmdq_vblank_cnt;
> + wait_queue_head_t cb_blocking_queue;
> #endif
>
> struct device *mmsys_dev;
> @@ -314,6 +315,7 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
> }
>
> mtk_crtc->cmdq_vblank_cnt = 0;
> + wake_up(&mtk_crtc->cb_blocking_queue);
> }
> #endif
>
> @@ -700,6 +702,13 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
> mtk_crtc->pending_planes = true;
>
> mtk_drm_crtc_update_config(mtk_crtc, false);
> +#if IS_REACHABLE(CONFIG_MTK_CMDQ)
> + /* Wait for planes to be disabled by cmdq */
> + if (mtk_crtc->cmdq_client.chan)
> + wait_event_timeout(mtk_crtc->cb_blocking_queue,
> + mtk_crtc->cmdq_vblank_cnt == 0,
> + msecs_to_jiffies(500));
> +#endif
> /* Wait for planes to be disabled */
> drm_crtc_wait_one_vblank(crtc);
>
> @@ -980,6 +989,9 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> mtk_crtc->cmdq_client.chan = NULL;
> }
> }
> +
> + /* for sending blocking cmd in crtc disable */
> + init_waitqueue_head(&mtk_crtc->cb_blocking_queue);
> }
> #endif
> return 0;
> --
> 2.18.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] drm/mediatek: add devlink to cmdq dev
[not found] ` <20211202064039.20797-3-jason-jh.lin@mediatek.com>
@ 2021-12-02 23:28 ` Chun-Kuang Hu
2022-02-27 3:33 ` Chun-Kuang Hu
1 sibling, 0 replies; 5+ messages in thread
From: Chun-Kuang Hu @ 2021-12-02 23:28 UTC (permalink / raw)
To: jason-jh.lin
Cc: Chun-Kuang Hu, Philipp Zabel, Matthias Brugger, tzungbi,
David Airlie, Daniel Vetter, DRI Development,
moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
Hsin-Yi Wang, Fei Shao, Nancy Lin, singo.chang
Hi, Jason:
jason-jh.lin <jason-jh.lin@mediatek.com> 於 2021年12月2日 週四 下午2:41寫道:
>
> Add devlink to cmdq to make sure the order of suspend and resume
> is correct.
>
Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 43 ++++++++++++++++++-------
> 1 file changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 0b4012335e7a..612d1d69c16c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -60,6 +60,7 @@ struct mtk_drm_crtc {
> #endif
>
> struct device *mmsys_dev;
> + struct device *drm_dev;
> struct mtk_mutex *mutex;
> unsigned int ddp_comp_nr;
> struct mtk_ddp_comp **ddp_comp;
> @@ -159,6 +160,7 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
> mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle);
>
> if (mtk_crtc->cmdq_client.chan) {
> + device_link_remove(mtk_crtc->drm_dev, mtk_crtc->cmdq_client.chan->mbox->dev);
> mbox_free_channel(mtk_crtc->cmdq_client.chan);
> mtk_crtc->cmdq_client.chan = NULL;
> }
> @@ -902,6 +904,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> return -ENOMEM;
>
> mtk_crtc->mmsys_dev = priv->mmsys_dev;
> + mtk_crtc->drm_dev = priv->dev;
> mtk_crtc->ddp_comp_nr = path_len;
> mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
> sizeof(*mtk_crtc->ddp_comp),
> @@ -969,6 +972,18 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> }
>
> if (mtk_crtc->cmdq_client.chan) {
> + struct device_link *link;
> +
> + /* add devlink to cmdq dev to make sure suspend/resume order is correct */
> + link = device_link_add(priv->dev, mtk_crtc->cmdq_client.chan->mbox->dev,
> + DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
> + if (!link) {
> + dev_err(priv->dev, "Unable to link dev=%s\n",
> + dev_name(mtk_crtc->cmdq_client.chan->mbox->dev));
> + ret = -ENODEV;
> + goto cmdq_err;
> + }
> +
> ret = of_property_read_u32_index(priv->mutex_node,
> "mediatek,gce-events",
> i,
> @@ -976,22 +991,26 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> if (ret) {
> dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n",
> 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;
> - }
> + goto cmdq_err;
> + }
> +
> + 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));
> + goto cmdq_err;
> }
>
> /* for sending blocking cmd in crtc disable */
> init_waitqueue_head(&mtk_crtc->cb_blocking_queue);
> +
> +cmdq_err:
> + if (ret) {
> + mbox_free_channel(mtk_crtc->cmdq_client.chan);
> + mtk_crtc->cmdq_client.chan = NULL;
> + }
> }
> #endif
> return 0;
> --
> 2.18.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] drm/mediatek: add devlink to cmdq dev
[not found] ` <20211202064039.20797-3-jason-jh.lin@mediatek.com>
2021-12-02 23:28 ` [PATCH v4 2/2] drm/mediatek: add devlink to cmdq dev Chun-Kuang Hu
@ 2022-02-27 3:33 ` Chun-Kuang Hu
2022-03-01 1:46 ` Jason-JH Lin
1 sibling, 1 reply; 5+ messages in thread
From: Chun-Kuang Hu @ 2022-02-27 3:33 UTC (permalink / raw)
To: jason-jh.lin
Cc: Chun-Kuang Hu, Philipp Zabel, Matthias Brugger, tzungbi,
David Airlie, Daniel Vetter, DRI Development,
moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
Hsin-Yi Wang, Fei Shao, Nancy Lin, singo.chang
Hi, Jason:
Build error:
../drivers/gpu/drm/mediatek/mtk_drm_crtc.c: In function ‘mtk_drm_crtc_create’:
../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:902:26: error: ‘struct
mtk_drm_private’ has no member named ‘dev’
mtk_crtc->drm_dev = priv->dev;
^
../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:974:30: error: ‘struct
mtk_drm_private’ has no member named ‘dev’
link = device_link_add(priv->dev, mtk_crtc->cmdq_client.chan->mbox->dev,
^
In file included from ../include/linux/device.h:15:0,
from ../include/linux/dma-mapping.h:7,
from ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:7:
../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:977:16: error: ‘struct
mtk_drm_private’ has no member named ‘dev’
dev_err(priv->dev, "Unable to link dev=%s\n",
^
Regards,
Chun-Kuang.
jason-jh.lin <jason-jh.lin@mediatek.com> 於 2021年12月2日 週四 下午2:41寫道:
>
> Add devlink to cmdq to make sure the order of suspend and resume
> is correct.
>
> Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 43 ++++++++++++++++++-------
> 1 file changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 0b4012335e7a..612d1d69c16c 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -60,6 +60,7 @@ struct mtk_drm_crtc {
> #endif
>
> struct device *mmsys_dev;
> + struct device *drm_dev;
> struct mtk_mutex *mutex;
> unsigned int ddp_comp_nr;
> struct mtk_ddp_comp **ddp_comp;
> @@ -159,6 +160,7 @@ static void mtk_drm_crtc_destroy(struct drm_crtc *crtc)
> mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle);
>
> if (mtk_crtc->cmdq_client.chan) {
> + device_link_remove(mtk_crtc->drm_dev, mtk_crtc->cmdq_client.chan->mbox->dev);
> mbox_free_channel(mtk_crtc->cmdq_client.chan);
> mtk_crtc->cmdq_client.chan = NULL;
> }
> @@ -902,6 +904,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> return -ENOMEM;
>
> mtk_crtc->mmsys_dev = priv->mmsys_dev;
> + mtk_crtc->drm_dev = priv->dev;
> mtk_crtc->ddp_comp_nr = path_len;
> mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr,
> sizeof(*mtk_crtc->ddp_comp),
> @@ -969,6 +972,18 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> }
>
> if (mtk_crtc->cmdq_client.chan) {
> + struct device_link *link;
> +
> + /* add devlink to cmdq dev to make sure suspend/resume order is correct */
> + link = device_link_add(priv->dev, mtk_crtc->cmdq_client.chan->mbox->dev,
> + DL_FLAG_PM_RUNTIME | DL_FLAG_STATELESS);
> + if (!link) {
> + dev_err(priv->dev, "Unable to link dev=%s\n",
> + dev_name(mtk_crtc->cmdq_client.chan->mbox->dev));
> + ret = -ENODEV;
> + goto cmdq_err;
> + }
> +
> ret = of_property_read_u32_index(priv->mutex_node,
> "mediatek,gce-events",
> i,
> @@ -976,22 +991,26 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> if (ret) {
> dev_dbg(dev, "mtk_crtc %d failed to get mediatek,gce-events property\n",
> 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;
> - }
> + goto cmdq_err;
> + }
> +
> + 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));
> + goto cmdq_err;
> }
>
> /* for sending blocking cmd in crtc disable */
> init_waitqueue_head(&mtk_crtc->cb_blocking_queue);
> +
> +cmdq_err:
> + if (ret) {
> + mbox_free_channel(mtk_crtc->cmdq_client.chan);
> + mtk_crtc->cmdq_client.chan = NULL;
> + }
> }
> #endif
> return 0;
> --
> 2.18.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/2] drm/mediatek: add wait_for_event for crtc disable by cmdq
2021-12-02 23:21 ` [PATCH v4 1/2] drm/mediatek: add wait_for_event for crtc disable by cmdq Chun-Kuang Hu
@ 2022-02-27 3:36 ` Chun-Kuang Hu
0 siblings, 0 replies; 5+ messages in thread
From: Chun-Kuang Hu @ 2022-02-27 3:36 UTC (permalink / raw)
To: Chun-Kuang Hu
Cc: jason-jh.lin, Philipp Zabel, Matthias Brugger, tzungbi,
David Airlie, Daniel Vetter, DRI Development,
moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
Hsin-Yi Wang, Fei Shao, Nancy Lin, singo.chang
Hi, Jason:
Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2021年12月3日 週五 上午7:21寫道:
>
> Hi, Jason:
>
> jason-jh.lin <jason-jh.lin@mediatek.com> 於 2021年12月2日 週四 下午2:41寫道:
> >
> > mtk_drm_crtc_atomic_disable will send an async cmd to cmdq driver,
> > so it may not finish when cmdq_suspend is called sometimes.
> >
> > Add wait_for_event after sending async disable plane cmd to make
> > sure the lastest cmd is done before cmdq_suspend.
>
> Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Applied to mediatek-drm-next[1], thanks.
[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next
Regards,
Chun-Kuang
>
> >
> > Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
> > ---
> > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 12 ++++++++++++
> > 1 file changed, 12 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index 62529a954b62..0b4012335e7a 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -56,6 +56,7 @@ struct mtk_drm_crtc {
> > struct cmdq_pkt cmdq_handle;
> > u32 cmdq_event;
> > u32 cmdq_vblank_cnt;
> > + wait_queue_head_t cb_blocking_queue;
> > #endif
> >
> > struct device *mmsys_dev;
> > @@ -314,6 +315,7 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
> > }
> >
> > mtk_crtc->cmdq_vblank_cnt = 0;
> > + wake_up(&mtk_crtc->cb_blocking_queue);
> > }
> > #endif
> >
> > @@ -700,6 +702,13 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
> > mtk_crtc->pending_planes = true;
> >
> > mtk_drm_crtc_update_config(mtk_crtc, false);
> > +#if IS_REACHABLE(CONFIG_MTK_CMDQ)
> > + /* Wait for planes to be disabled by cmdq */
> > + if (mtk_crtc->cmdq_client.chan)
> > + wait_event_timeout(mtk_crtc->cb_blocking_queue,
> > + mtk_crtc->cmdq_vblank_cnt == 0,
> > + msecs_to_jiffies(500));
> > +#endif
> > /* Wait for planes to be disabled */
> > drm_crtc_wait_one_vblank(crtc);
> >
> > @@ -980,6 +989,9 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
> > mtk_crtc->cmdq_client.chan = NULL;
> > }
> > }
> > +
> > + /* for sending blocking cmd in crtc disable */
> > + init_waitqueue_head(&mtk_crtc->cb_blocking_queue);
> > }
> > #endif
> > return 0;
> > --
> > 2.18.0
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 2/2] drm/mediatek: add devlink to cmdq dev
2022-02-27 3:33 ` Chun-Kuang Hu
@ 2022-03-01 1:46 ` Jason-JH Lin
0 siblings, 0 replies; 5+ messages in thread
From: Jason-JH Lin @ 2022-03-01 1:46 UTC (permalink / raw)
To: Chun-Kuang Hu
Cc: Philipp Zabel, Matthias Brugger, tzungbi, David Airlie,
Daniel Vetter, DRI Development,
moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
Hsin-Yi Wang, Fei Shao, Nancy Lin, singo.chang
Hi Chun-Kuang,
Thanks for the reviews.
I forgot to add the comment that the patch should be based on [1].
We can only apply it after applying [1].
So please apply it after that. Thank you very much!
Regards,
Jason-JH.Lin
---
[1] drm/mediatek: modify mediatek-drm for mt8195 multi mmsys support
https://patchwork.kernel.org/project/linux-mediatek/patch/20220222100741.30138-21-nancy.lin@mediatek.com/
---
On Sun, 2022-02-27 at 11:33 +0800, Chun-Kuang Hu wrote:
> Hi, Jason:
>
> Build error:
>
> ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c: In function
> ‘mtk_drm_crtc_create’:
> ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:902:26: error: ‘struct
> mtk_drm_private’ has no member named ‘dev’
> mtk_crtc->drm_dev = priv->dev;
> ^
> ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:974:30: error: ‘struct
> mtk_drm_private’ has no member named ‘dev’
> link = device_link_add(priv->dev, mtk_crtc->cmdq_client.chan-
> >mbox->dev,
> ^
> In file included from ../include/linux/device.h:15:0,
> from ../include/linux/dma-mapping.h:7,
> from ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:7:
> ../drivers/gpu/drm/mediatek/mtk_drm_crtc.c:977:16: error: ‘struct
> mtk_drm_private’ has no member named ‘dev’
> dev_err(priv->dev, "Unable to link dev=%s\n",
> ^
> Regards,
> Chun-Kuang.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-01 1:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20211202064039.20797-1-jason-jh.lin@mediatek.com>
[not found] ` <20211202064039.20797-2-jason-jh.lin@mediatek.com>
2021-12-02 23:21 ` [PATCH v4 1/2] drm/mediatek: add wait_for_event for crtc disable by cmdq Chun-Kuang Hu
2022-02-27 3:36 ` Chun-Kuang Hu
[not found] ` <20211202064039.20797-3-jason-jh.lin@mediatek.com>
2021-12-02 23:28 ` [PATCH v4 2/2] drm/mediatek: add devlink to cmdq dev Chun-Kuang Hu
2022-02-27 3:33 ` Chun-Kuang Hu
2022-03-01 1:46 ` Jason-JH Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).