diff mbox series

[4/8] drm/mtk: Use __drm_atomic_helper_crtc_reset

Message ID 20200612160056.2082681-4-daniel.vetter@ffwll.ch (mailing list archive)
State New, archived
Headers show
Series [1/8] drm/atomic-helper: reset vblank on crtc reset | expand

Commit Message

Daniel Vetter June 12, 2020, 4 p.m. UTC
Now also comes with the added benefit of doing a drm_crtc_vblank_off(),
which means vblank state isn't ill-defined and fail-y at driver load
before the first modeset on each crtc.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Comments

Chun-Kuang Hu June 23, 2020, 4:01 p.m. UTC | #1
Hi, Daniel:

Daniel Vetter <daniel.vetter@ffwll.ch> 於 2020年6月13日 週六 上午12:01寫道:
>
> Now also comes with the added benefit of doing a drm_crtc_vblank_off(),
> which means vblank state isn't ill-defined and fail-y at driver load
> before the first modeset on each crtc.
>

Acked-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>

> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index a7dba4ced902..d654c7d514bd 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -112,19 +112,15 @@ static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
>  {
>         struct mtk_crtc_state *state;
>
> -       if (crtc->state) {
> +       if (crtc->state)
>                 __drm_atomic_helper_crtc_destroy_state(crtc->state);
>
> -               state = to_mtk_crtc_state(crtc->state);
> -               memset(state, 0, sizeof(*state));
> -       } else {
> -               state = kzalloc(sizeof(*state), GFP_KERNEL);
> -               if (!state)
> -                       return;
> -               crtc->state = &state->base;
> -       }
> +       kfree(to_mtk_crtc_state(crtc->state));
> +       crtc->state = NULL;
>
> -       state->base.crtc = crtc;
> +       state = kzalloc(sizeof(*state), GFP_KERNEL);
> +       if (state)
> +               __drm_atomic_helper_crtc_reset(crtc, &state->base);
>  }
>
>  static struct drm_crtc_state *mtk_drm_crtc_duplicate_state(struct drm_crtc *crtc)
> --
> 2.26.2
>
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 a7dba4ced902..d654c7d514bd 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -112,19 +112,15 @@  static void mtk_drm_crtc_reset(struct drm_crtc *crtc)
 {
 	struct mtk_crtc_state *state;
 
-	if (crtc->state) {
+	if (crtc->state)
 		__drm_atomic_helper_crtc_destroy_state(crtc->state);
 
-		state = to_mtk_crtc_state(crtc->state);
-		memset(state, 0, sizeof(*state));
-	} else {
-		state = kzalloc(sizeof(*state), GFP_KERNEL);
-		if (!state)
-			return;
-		crtc->state = &state->base;
-	}
+	kfree(to_mtk_crtc_state(crtc->state));
+	crtc->state = NULL;
 
-	state->base.crtc = crtc;
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	if (state)
+		__drm_atomic_helper_crtc_reset(crtc, &state->base);
 }
 
 static struct drm_crtc_state *mtk_drm_crtc_duplicate_state(struct drm_crtc *crtc)