diff mbox series

[v3,2/2] drm/mediatek: Fix iommu fault during crtc enabling

Message ID 20230710093253.32224-3-jason-jh.lin@mediatek.com (mailing list archive)
State New, archived
Headers show
Series Fix OVL iommu fault in cursor plane | expand

Commit Message

Jason-JH Lin (林睿祥) July 10, 2023, 9:32 a.m. UTC
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(+)

Comments

AngeloGioacchino Del Regno July 10, 2023, 9:34 a.m. UTC | #1
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,
Alexandre Mergnat July 12, 2023, 1:03 p.m. UTC | #2
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>
CK Hu (胡俊光) July 14, 2023, 6:57 a.m. UTC | #3
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,
CK Hu (胡俊光) July 26, 2023, 6:56 a.m. UTC | #4
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,
Jason-JH Lin (林睿祥) Aug. 5, 2023, 8:10 a.m. UTC | #5
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,
diff mbox series

Patch

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,