public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling
       [not found] ` <20230710093253.32224-3-jason-jh.lin@mediatek.com>
@ 2023-07-10  9:34   ` AngeloGioacchino Del Regno
  2023-07-12 13:03   ` Alexandre Mergnat
  2023-07-14  6:57   ` CK Hu (胡俊光)
  2 siblings, 0 replies; 8+ messages in thread
From: AngeloGioacchino Del Regno @ 2023-07-10  9:34 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu, Alexandre Mergnat
  Cc: Matthias Brugger, Jason-ch Chen, Johnson Wang, Singo Chang,
	Nancy Lin, Shawn Sung, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel,
	Project_Global_Chrome_Upstream_Group

Il 10/07/23 11:32, Jason-JH.Lin ha scritto:
> OVL layer should not be enabled before crtc is enabled.
> The plane_state of drm_atomic_state is not sync to
> the plane_state stored in mtk_crtc during crtc enabling,
> so just set all planes to disabled.
> 
> Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> ---
>   drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index d40142842f85..51d10e65004e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -410,6 +410,9 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc)
>   		unsigned int local_layer;
>   
>   		plane_state = to_mtk_plane_state(plane->state);
> +
> +		/* should not enable layer before crtc enabled */
> +		plane_state->pending.enable = false;
>   		comp = mtk_drm_ddp_comp_for_plane(crtc, plane, &local_layer);
>   		if (comp)
>   			mtk_ddp_comp_layer_config(comp, local_layer,


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] drm/mediatek: Fix iommu fault by swapping FBs after updating plane state
       [not found] ` <20230710093253.32224-2-jason-jh.lin@mediatek.com>
@ 2023-07-12 13:03   ` Alexandre Mergnat
  2023-07-14  6:38   ` CK Hu (胡俊光)
  1 sibling, 0 replies; 8+ messages in thread
From: Alexandre Mergnat @ 2023-07-12 13:03 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu, AngeloGioacchino Del Regno
  Cc: Matthias Brugger, Jason-ch Chen, Johnson Wang, Singo Chang,
	Nancy Lin, Shawn Sung, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel,
	Project_Global_Chrome_Upstream_Group



On 10/07/2023 11:32, Jason-JH.Lin wrote:
> According to the comment in drm_atomic_helper_async_commit(),
> we should make sure FBs have been swapped, so that cleanups in the
> new_state performs a cleanup in the old FB.
> 
> So we should move swapping FBs after calling mtk_plane_update_new_state(),
> to avoid using the old FB which could be freed.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>

-- 
Regards,
Alexandre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling
       [not found] ` <20230710093253.32224-3-jason-jh.lin@mediatek.com>
  2023-07-10  9:34   ` [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling AngeloGioacchino Del Regno
@ 2023-07-12 13:03   ` Alexandre Mergnat
  2023-07-14  6:57   ` CK Hu (胡俊光)
  2 siblings, 0 replies; 8+ messages in thread
From: Alexandre Mergnat @ 2023-07-12 13:03 UTC (permalink / raw)
  To: Jason-JH.Lin, Chun-Kuang Hu, AngeloGioacchino Del Regno
  Cc: Matthias Brugger, Jason-ch Chen, Johnson Wang, Singo Chang,
	Nancy Lin, Shawn Sung, dri-devel, linux-mediatek,
	linux-arm-kernel, linux-kernel,
	Project_Global_Chrome_Upstream_Group



On 10/07/2023 11:32, Jason-JH.Lin wrote:
> OVL layer should not be enabled before crtc is enabled.
> The plane_state of drm_atomic_state is not sync to
> the plane_state stored in mtk_crtc during crtc enabling,
> so just set all planes to disabled.

Reviewed-by: Alexandre Mergnat <amergnat@baylibre.com>

-- 
Regards,
Alexandre

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 1/2] drm/mediatek: Fix iommu fault by swapping FBs after updating plane state
       [not found] ` <20230710093253.32224-2-jason-jh.lin@mediatek.com>
  2023-07-12 13:03   ` [PATCH v3 1/2] drm/mediatek: Fix iommu fault by swapping FBs after updating plane state Alexandre Mergnat
@ 2023-07-14  6:38   ` CK Hu (胡俊光)
  1 sibling, 0 replies; 8+ messages in thread
From: CK Hu (胡俊光) @ 2023-07-14  6:38 UTC (permalink / raw)
  To: amergnat@baylibre.com, Jason-JH Lin (林睿祥),
	chunkuang.hu@kernel.org, angelogioacchino.delregno@collabora.com
  Cc: linux-kernel@vger.kernel.org,
	Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	linux-mediatek@lists.infradead.org,
	Nancy Lin (林欣螢),
	dri-devel@lists.freedesktop.org,
	Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com

Hi, Jason:

On Mon, 2023-07-10 at 17:32 +0800, Jason-JH.Lin wrote:
> According to the comment in drm_atomic_helper_async_commit(),
> we should make sure FBs have been swapped, so that cleanups in the
> new_state performs a cleanup in the old FB.
> 
> So we should move swapping FBs after calling
> mtk_plane_update_new_state(),
> to avoid using the old FB which could be freed.

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Fixes: 1a64a7aff8da ("drm/mediatek: Fix cursor plane no update")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> Reviewed-by: AngeloGioacchino Del Regno <
> angelogioacchino.delregno@collabora.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 31f9420aff6f..b1a918ffe457 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -210,9 +210,9 @@ static void mtk_plane_atomic_async_update(struct
> drm_plane *plane,
>  	plane->state->src_y = new_state->src_y;
>  	plane->state->src_h = new_state->src_h;
>  	plane->state->src_w = new_state->src_w;
> -	swap(plane->state->fb, new_state->fb);
>  
>  	mtk_plane_update_new_state(new_state, new_plane_state);
> +	swap(plane->state->fb, new_state->fb);
>  	wmb(); /* Make sure the above parameters are set before update
> */
>  	new_plane_state->pending.async_dirty = true;
>  	mtk_drm_crtc_async_update(new_state->crtc, plane, state);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling
       [not found] ` <20230710093253.32224-3-jason-jh.lin@mediatek.com>
  2023-07-10  9:34   ` [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling AngeloGioacchino Del Regno
  2023-07-12 13:03   ` Alexandre Mergnat
@ 2023-07-14  6:57   ` CK Hu (胡俊光)
  2023-07-18 15:48     ` Jason-JH Lin (林睿祥)
  2 siblings, 1 reply; 8+ messages in thread
From: CK Hu (胡俊光) @ 2023-07-14  6:57 UTC (permalink / raw)
  To: amergnat@baylibre.com, Jason-JH Lin (林睿祥),
	chunkuang.hu@kernel.org, angelogioacchino.delregno@collabora.com
  Cc: linux-mediatek@lists.infradead.org,
	Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	linux-kernel@vger.kernel.org,
	Nancy Lin (林欣螢),
	dri-devel@lists.freedesktop.org,
	Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com

Hi, Jason:

On Mon, 2023-07-10 at 17:32 +0800, Jason-JH.Lin wrote:
> OVL layer should not be enabled before crtc is enabled.
> The plane_state of drm_atomic_state is not sync to
> the plane_state stored in mtk_crtc during crtc enabling,
> so just set all planes to disabled.
> 
> Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC
> MT8173.")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index d40142842f85..51d10e65004e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -410,6 +410,9 @@ static int mtk_crtc_ddp_hw_init(struct
> mtk_drm_crtc *mtk_crtc)
>  		unsigned int local_layer;
>  
>  		plane_state = to_mtk_plane_state(plane->state);
> +
> +		/* should not enable layer before crtc enabled */
> +		plane_state->pending.enable = false;

All plane has been disable in mtk_drm_crtc_atomic_disable(), doesn't
it?

Regards,
CK

>  		comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
> &local_layer);
>  		if (comp)
>  			mtk_ddp_comp_layer_config(comp, local_layer,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling
  2023-07-14  6:57   ` CK Hu (胡俊光)
@ 2023-07-18 15:48     ` Jason-JH Lin (林睿祥)
  2023-07-26  6:56       ` CK Hu (胡俊光)
  0 siblings, 1 reply; 8+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2023-07-18 15:48 UTC (permalink / raw)
  To: CK Hu (胡俊光), amergnat@baylibre.com,
	chunkuang.hu@kernel.org, angelogioacchino.delregno@collabora.com
  Cc: linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	Nancy Lin (林欣螢),
	dri-devel@lists.freedesktop.org,
	Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com

Hi CK,

Thanks for the reviews.

On Fri, 2023-07-14 at 06:57 +0000, CK Hu (胡俊光) wrote:
> Hi, Jason:
> 
> On Mon, 2023-07-10 at 17:32 +0800, Jason-JH.Lin wrote:
> > OVL layer should not be enabled before crtc is enabled.
> > The plane_state of drm_atomic_state is not sync to
> > the plane_state stored in mtk_crtc during crtc enabling,
> > so just set all planes to disabled.
> > 
> > Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC
> > MT8173.")
> > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index d40142842f85..51d10e65004e 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -410,6 +410,9 @@ static int mtk_crtc_ddp_hw_init(struct
> > mtk_drm_crtc *mtk_crtc)
> >  		unsigned int local_layer;
> >  
> >  		plane_state = to_mtk_plane_state(plane->state);
> > +
> > +		/* should not enable layer before crtc enabled */
> > +		plane_state->pending.enable = false;
> 
> All plane has been disable in mtk_drm_crtc_atomic_disable(), doesn't
> it?
> 
Yes, it does.

But somehow the plane_state get from to_mtk_plane_state(mtk_crtc-
>planes[i]) is not synced to the plane_state in atomic_state.

So I think we should disable ovl layer to avoid incorrect plane_state
applying to OVL HW at the HW init stage.

Regards,
Jason-JH.Lin


> Regards,
> CK
> 
> >  		comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
> > &local_layer);
> >  		if (comp)
> >  			mtk_ddp_comp_layer_config(comp, local_layer,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling
  2023-07-18 15:48     ` Jason-JH Lin (林睿祥)
@ 2023-07-26  6:56       ` CK Hu (胡俊光)
  2023-08-05  8:10         ` Jason-JH Lin (林睿祥)
  0 siblings, 1 reply; 8+ messages in thread
From: CK Hu (胡俊光) @ 2023-07-26  6:56 UTC (permalink / raw)
  To: amergnat@baylibre.com, Jason-JH Lin (林睿祥),
	chunkuang.hu@kernel.org, angelogioacchino.delregno@collabora.com
  Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	Nancy Lin (林欣螢),
	dri-devel@lists.freedesktop.org,
	Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com

Hi, Jason:

On Tue, 2023-07-18 at 15:48 +0000, Jason-JH Lin (林睿祥) wrote:
> Hi CK,
> 
> Thanks for the reviews.
> 
> On Fri, 2023-07-14 at 06:57 +0000, CK Hu (胡俊光) wrote:
> > Hi, Jason:
> > 
> > On Mon, 2023-07-10 at 17:32 +0800, Jason-JH.Lin wrote:
> > > OVL layer should not be enabled before crtc is enabled.
> > > The plane_state of drm_atomic_state is not sync to
> > > the plane_state stored in mtk_crtc during crtc enabling,
> > > so just set all planes to disabled.
> > > 
> > > Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek
> > > SoC
> > > MT8173.")
> > > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > index d40142842f85..51d10e65004e 100644
> > > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > @@ -410,6 +410,9 @@ static int mtk_crtc_ddp_hw_init(struct
> > > mtk_drm_crtc *mtk_crtc)
> > >  		unsigned int local_layer;
> > >  
> > >  		plane_state = to_mtk_plane_state(plane->state);
> > > +
> > > +		/* should not enable layer before crtc enabled */
> > > +		plane_state->pending.enable = false;
> > 
> > All plane has been disable in mtk_drm_crtc_atomic_disable(),
> > doesn't
> > it?
> > 
> 
> Yes, it does.
> 
> But somehow the plane_state get from to_mtk_plane_state(mtk_crtc-
> > planes[i]) is not synced to the plane_state in atomic_state.
> 
> So I think we should disable ovl layer to avoid incorrect plane_state
> applying to OVL HW at the HW init stage.

Do you mean plane_state in atomic_state is correct but it's not synced
to mtk_crtc->planes? If so, the atomic_state is bypassed into
mtk_drm_crtc_atomic_eanble() and you could sync it here.

Regards,
CK 

> 
> Regards,
> Jason-JH.Lin
> 
> 
> > Regards,
> > CK
> > 
> > >  		comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
> > > &local_layer);
> > >  		if (comp)
> > >  			mtk_ddp_comp_layer_config(comp, local_layer,

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling
  2023-07-26  6:56       ` CK Hu (胡俊光)
@ 2023-08-05  8:10         ` Jason-JH Lin (林睿祥)
  0 siblings, 0 replies; 8+ messages in thread
From: Jason-JH Lin (林睿祥) @ 2023-08-05  8:10 UTC (permalink / raw)
  To: CK Hu (胡俊光), amergnat@baylibre.com,
	chunkuang.hu@kernel.org, angelogioacchino.delregno@collabora.com
  Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
	Singo Chang (張興國),
	Johnson Wang (王聖鑫),
	Jason-ch Chen (陳建豪),
	Shawn Sung (宋孝謙),
	Nancy Lin (林欣螢),
	dri-devel@lists.freedesktop.org,
	Project_Global_Chrome_Upstream_Group,
	linux-arm-kernel@lists.infradead.org, matthias.bgg@gmail.com

Hi CK,

On Wed, 2023-07-26 at 06:56 +0000, CK Hu (胡俊光) wrote:
> Hi, Jason:
> 
> On Tue, 2023-07-18 at 15:48 +0000, Jason-JH Lin (林睿祥) wrote:
> > Hi CK,
> > 
> > Thanks for the reviews.
> > 
> > On Fri, 2023-07-14 at 06:57 +0000, CK Hu (胡俊光) wrote:
> > > Hi, Jason:
> > > 
> > > On Mon, 2023-07-10 at 17:32 +0800, Jason-JH.Lin wrote:
> > > > OVL layer should not be enabled before crtc is enabled.
> > > > The plane_state of drm_atomic_state is not sync to
> > > > the plane_state stored in mtk_crtc during crtc enabling,
> > > > so just set all planes to disabled.
> > > > 
> > > > Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek
> > > > SoC
> > > > MT8173.")
> > > > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > > > ---
> > > >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> > > > 
> > > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > index d40142842f85..51d10e65004e 100644
> > > > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > > > @@ -410,6 +410,9 @@ static int mtk_crtc_ddp_hw_init(struct
> > > > mtk_drm_crtc *mtk_crtc)
> > > >  		unsigned int local_layer;
> > > >  
> > > >  		plane_state = to_mtk_plane_state(plane->state);
> > > > +
> > > > +		/* should not enable layer before crtc enabled
> > > > */
> > > > +		plane_state->pending.enable = false;
> > > 
> > > All plane has been disable in mtk_drm_crtc_atomic_disable(),
> > > doesn't
> > > it?
> > > 
> > 
> > Yes, it does.
> > 
> > But somehow the plane_state get from to_mtk_plane_state(mtk_crtc-
> > > planes[i]) is not synced to the plane_state in atomic_state.
> > 
> > So I think we should disable ovl layer to avoid incorrect
> > plane_state
> > applying to OVL HW at the HW init stage.
> 
> Do you mean plane_state in atomic_state is correct but it's not
> synced
> to mtk_crtc->planes? 
Yes.

> If so, the atomic_state is bypassed into
> mtk_drm_crtc_atomic_eanble() and you could sync it here.
> 
I'vd tried this method. It can also fix this problem.
So I'll use atomic_state to update mtk_plane_state here.
Thanks~

Regards,
Jason-JH.Lin

> Regards,
> CK 
> 
> > 
> > Regards,
> > Jason-JH.Lin
> > 
> > 
> > > Regards,
> > > CK
> > > 
> > > >  		comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
> > > > &local_layer);
> > > >  		if (comp)
> > > >  			mtk_ddp_comp_layer_config(comp,
> > > > local_layer,

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-05  8:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230710093253.32224-1-jason-jh.lin@mediatek.com>
     [not found] ` <20230710093253.32224-3-jason-jh.lin@mediatek.com>
2023-07-10  9:34   ` [PATCH v3 2/2] drm/mediatek: Fix iommu fault during crtc enabling AngeloGioacchino Del Regno
2023-07-12 13:03   ` Alexandre Mergnat
2023-07-14  6:57   ` CK Hu (胡俊光)
2023-07-18 15:48     ` Jason-JH Lin (林睿祥)
2023-07-26  6:56       ` CK Hu (胡俊光)
2023-08-05  8:10         ` Jason-JH Lin (林睿祥)
     [not found] ` <20230710093253.32224-2-jason-jh.lin@mediatek.com>
2023-07-12 13:03   ` [PATCH v3 1/2] drm/mediatek: Fix iommu fault by swapping FBs after updating plane state Alexandre Mergnat
2023-07-14  6:38   ` CK Hu (胡俊光)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox