All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/mediatek: crtc: Make config-updating atomic
@ 2021-03-13  9:43 ` Chun-Kuang Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Chun-Kuang Hu @ 2021-03-13  9:43 UTC (permalink / raw)
  To: Philipp Zabel, David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, linux-mediatek, Chun-Kuang Hu

While updating config, the irq would occur and get the partial
config, so use variable config_updating to make updating atomic.

Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 8b0de90156c6..870f66210848 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -61,6 +61,7 @@ struct mtk_drm_crtc {
 
 	/* lock for display hardware access */
 	struct mutex			hw_lock;
+	bool				config_updating;
 };
 
 struct mtk_crtc_state {
@@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 {
 	drm_crtc_handle_vblank(&mtk_crtc->base);
-	if (mtk_crtc->pending_needs_vblank) {
+	if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
 		mtk_drm_crtc_finish_page_flip(mtk_crtc);
 		mtk_crtc->pending_needs_vblank = false;
 	}
@@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
 	}
 }
 
-static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
+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;
@@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
 	int i;
 
 	mutex_lock(&mtk_crtc->hw_lock);
+	mtk_crtc->config_updating = true;
+	if (needs_vblank)
+		mtk_crtc->pending_needs_vblank = true;
+
 	for (i = 0; i < mtk_crtc->layer_nr; i++) {
 		struct drm_plane *plane = &mtk_crtc->planes[i];
 		struct mtk_plane_state *plane_state;
@@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
 		cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
 	}
 #endif
+	mtk_crtc->config_updating = false;
 	mutex_unlock(&mtk_crtc->hw_lock);
 }
 
@@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
 		return;
 
 	plane_helper_funcs->atomic_update(plane, new_state);
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, false);
 }
 
 static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
@@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
 	}
 	mtk_crtc->pending_planes = true;
 
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, false);
 	/* Wait for planes to be disabled */
 	drm_crtc_wait_one_vblank(crtc);
 
@@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
 	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
 	int i;
 
-	if (mtk_crtc->event)
-		mtk_crtc->pending_needs_vblank = true;
 	if (crtc->state->color_mgmt_changed)
 		for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
 			mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
 			mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
 		}
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
 }
 
 static const struct drm_crtc_funcs mtk_crtc_funcs = {
-- 
2.17.1


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

* [PATCH] drm/mediatek: crtc: Make config-updating atomic
@ 2021-03-13  9:43 ` Chun-Kuang Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Chun-Kuang Hu @ 2021-03-13  9:43 UTC (permalink / raw)
  To: Philipp Zabel, David Airlie, Daniel Vetter
  Cc: linux-kernel, dri-devel, linux-mediatek, Chun-Kuang Hu

While updating config, the irq would occur and get the partial
config, so use variable config_updating to make updating atomic.

Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 8b0de90156c6..870f66210848 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -61,6 +61,7 @@ struct mtk_drm_crtc {
 
 	/* lock for display hardware access */
 	struct mutex			hw_lock;
+	bool				config_updating;
 };
 
 struct mtk_crtc_state {
@@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 {
 	drm_crtc_handle_vblank(&mtk_crtc->base);
-	if (mtk_crtc->pending_needs_vblank) {
+	if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
 		mtk_drm_crtc_finish_page_flip(mtk_crtc);
 		mtk_crtc->pending_needs_vblank = false;
 	}
@@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
 	}
 }
 
-static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
+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;
@@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
 	int i;
 
 	mutex_lock(&mtk_crtc->hw_lock);
+	mtk_crtc->config_updating = true;
+	if (needs_vblank)
+		mtk_crtc->pending_needs_vblank = true;
+
 	for (i = 0; i < mtk_crtc->layer_nr; i++) {
 		struct drm_plane *plane = &mtk_crtc->planes[i];
 		struct mtk_plane_state *plane_state;
@@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
 		cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
 	}
 #endif
+	mtk_crtc->config_updating = false;
 	mutex_unlock(&mtk_crtc->hw_lock);
 }
 
@@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
 		return;
 
 	plane_helper_funcs->atomic_update(plane, new_state);
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, false);
 }
 
 static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
@@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
 	}
 	mtk_crtc->pending_planes = true;
 
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, false);
 	/* Wait for planes to be disabled */
 	drm_crtc_wait_one_vblank(crtc);
 
@@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
 	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
 	int i;
 
-	if (mtk_crtc->event)
-		mtk_crtc->pending_needs_vblank = true;
 	if (crtc->state->color_mgmt_changed)
 		for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
 			mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
 			mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
 		}
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
 }
 
 static const struct drm_crtc_funcs mtk_crtc_funcs = {
-- 
2.17.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH] drm/mediatek: crtc: Make config-updating atomic
@ 2021-03-13  9:43 ` Chun-Kuang Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Chun-Kuang Hu @ 2021-03-13  9:43 UTC (permalink / raw)
  To: Philipp Zabel, David Airlie, Daniel Vetter
  Cc: Chun-Kuang Hu, linux-mediatek, linux-kernel, dri-devel

While updating config, the irq would occur and get the partial
config, so use variable config_updating to make updating atomic.

Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 8b0de90156c6..870f66210848 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -61,6 +61,7 @@ struct mtk_drm_crtc {
 
 	/* lock for display hardware access */
 	struct mutex			hw_lock;
+	bool				config_updating;
 };
 
 struct mtk_crtc_state {
@@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
 {
 	drm_crtc_handle_vblank(&mtk_crtc->base);
-	if (mtk_crtc->pending_needs_vblank) {
+	if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
 		mtk_drm_crtc_finish_page_flip(mtk_crtc);
 		mtk_crtc->pending_needs_vblank = false;
 	}
@@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
 	}
 }
 
-static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
+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;
@@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
 	int i;
 
 	mutex_lock(&mtk_crtc->hw_lock);
+	mtk_crtc->config_updating = true;
+	if (needs_vblank)
+		mtk_crtc->pending_needs_vblank = true;
+
 	for (i = 0; i < mtk_crtc->layer_nr; i++) {
 		struct drm_plane *plane = &mtk_crtc->planes[i];
 		struct mtk_plane_state *plane_state;
@@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
 		cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
 	}
 #endif
+	mtk_crtc->config_updating = false;
 	mutex_unlock(&mtk_crtc->hw_lock);
 }
 
@@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
 		return;
 
 	plane_helper_funcs->atomic_update(plane, new_state);
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, false);
 }
 
 static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
@@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
 	}
 	mtk_crtc->pending_planes = true;
 
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, false);
 	/* Wait for planes to be disabled */
 	drm_crtc_wait_one_vblank(crtc);
 
@@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
 	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
 	int i;
 
-	if (mtk_crtc->event)
-		mtk_crtc->pending_needs_vblank = true;
 	if (crtc->state->color_mgmt_changed)
 		for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
 			mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
 			mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
 		}
-	mtk_drm_crtc_hw_config(mtk_crtc);
+	mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
 }
 
 static const struct drm_crtc_funcs mtk_crtc_funcs = {
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/mediatek: crtc: Make config-updating atomic
  2021-03-13  9:43 ` Chun-Kuang Hu
  (?)
@ 2021-03-29 16:18   ` Chun-Kuang Hu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chun-Kuang Hu @ 2021-03-29 16:18 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Philipp Zabel, David Airlie, Daniel Vetter, linux-kernel,
	DRI Development, moderated list:ARM/Mediatek SoC support

Applied to mediatek-drm-next [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2021年3月13日 週六 下午5:43寫道:
>
> While updating config, the irq would occur and get the partial
> config, so use variable config_updating to make updating atomic.
>
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 8b0de90156c6..870f66210848 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -61,6 +61,7 @@ struct mtk_drm_crtc {
>
>         /* lock for display hardware access */
>         struct mutex                    hw_lock;
> +       bool                            config_updating;
>  };
>
>  struct mtk_crtc_state {
> @@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
>  static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
>  {
>         drm_crtc_handle_vblank(&mtk_crtc->base);
> -       if (mtk_crtc->pending_needs_vblank) {
> +       if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
>                 mtk_drm_crtc_finish_page_flip(mtk_crtc);
>                 mtk_crtc->pending_needs_vblank = false;
>         }
> @@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
>         }
>  }
>
> -static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
> +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;
> @@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
>         int i;
>
>         mutex_lock(&mtk_crtc->hw_lock);
> +       mtk_crtc->config_updating = true;
> +       if (needs_vblank)
> +               mtk_crtc->pending_needs_vblank = true;
> +
>         for (i = 0; i < mtk_crtc->layer_nr; i++) {
>                 struct drm_plane *plane = &mtk_crtc->planes[i];
>                 struct mtk_plane_state *plane_state;
> @@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
>                 cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
>         }
>  #endif
> +       mtk_crtc->config_updating = false;
>         mutex_unlock(&mtk_crtc->hw_lock);
>  }
>
> @@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
>                 return;
>
>         plane_helper_funcs->atomic_update(plane, new_state);
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, false);
>  }
>
>  static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
> @@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
>         }
>         mtk_crtc->pending_planes = true;
>
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, false);
>         /* Wait for planes to be disabled */
>         drm_crtc_wait_one_vblank(crtc);
>
> @@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
>         struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>         int i;
>
> -       if (mtk_crtc->event)
> -               mtk_crtc->pending_needs_vblank = true;
>         if (crtc->state->color_mgmt_changed)
>                 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
>                         mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
>                         mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
>                 }
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
>  }
>
>  static const struct drm_crtc_funcs mtk_crtc_funcs = {
> --
> 2.17.1
>

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

* Re: [PATCH] drm/mediatek: crtc: Make config-updating atomic
@ 2021-03-29 16:18   ` Chun-Kuang Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Chun-Kuang Hu @ 2021-03-29 16:18 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: Philipp Zabel, David Airlie, Daniel Vetter, linux-kernel,
	DRI Development, moderated list:ARM/Mediatek SoC support

Applied to mediatek-drm-next [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2021年3月13日 週六 下午5:43寫道:
>
> While updating config, the irq would occur and get the partial
> config, so use variable config_updating to make updating atomic.
>
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 8b0de90156c6..870f66210848 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -61,6 +61,7 @@ struct mtk_drm_crtc {
>
>         /* lock for display hardware access */
>         struct mutex                    hw_lock;
> +       bool                            config_updating;
>  };
>
>  struct mtk_crtc_state {
> @@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
>  static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
>  {
>         drm_crtc_handle_vblank(&mtk_crtc->base);
> -       if (mtk_crtc->pending_needs_vblank) {
> +       if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
>                 mtk_drm_crtc_finish_page_flip(mtk_crtc);
>                 mtk_crtc->pending_needs_vblank = false;
>         }
> @@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
>         }
>  }
>
> -static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
> +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;
> @@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
>         int i;
>
>         mutex_lock(&mtk_crtc->hw_lock);
> +       mtk_crtc->config_updating = true;
> +       if (needs_vblank)
> +               mtk_crtc->pending_needs_vblank = true;
> +
>         for (i = 0; i < mtk_crtc->layer_nr; i++) {
>                 struct drm_plane *plane = &mtk_crtc->planes[i];
>                 struct mtk_plane_state *plane_state;
> @@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
>                 cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
>         }
>  #endif
> +       mtk_crtc->config_updating = false;
>         mutex_unlock(&mtk_crtc->hw_lock);
>  }
>
> @@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
>                 return;
>
>         plane_helper_funcs->atomic_update(plane, new_state);
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, false);
>  }
>
>  static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
> @@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
>         }
>         mtk_crtc->pending_planes = true;
>
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, false);
>         /* Wait for planes to be disabled */
>         drm_crtc_wait_one_vblank(crtc);
>
> @@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
>         struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>         int i;
>
> -       if (mtk_crtc->event)
> -               mtk_crtc->pending_needs_vblank = true;
>         if (crtc->state->color_mgmt_changed)
>                 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
>                         mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
>                         mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
>                 }
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
>  }
>
>  static const struct drm_crtc_funcs mtk_crtc_funcs = {
> --
> 2.17.1
>

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH] drm/mediatek: crtc: Make config-updating atomic
@ 2021-03-29 16:18   ` Chun-Kuang Hu
  0 siblings, 0 replies; 6+ messages in thread
From: Chun-Kuang Hu @ 2021-03-29 16:18 UTC (permalink / raw)
  To: Chun-Kuang Hu
  Cc: David Airlie, linux-kernel, DRI Development,
	moderated list:ARM/Mediatek SoC support

Applied to mediatek-drm-next [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

Chun-Kuang Hu <chunkuang.hu@kernel.org> 於 2021年3月13日 週六 下午5:43寫道:
>
> While updating config, the irq would occur and get the partial
> config, so use variable config_updating to make updating atomic.
>
> Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 8b0de90156c6..870f66210848 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -61,6 +61,7 @@ struct mtk_drm_crtc {
>
>         /* lock for display hardware access */
>         struct mutex                    hw_lock;
> +       bool                            config_updating;
>  };
>
>  struct mtk_crtc_state {
> @@ -97,7 +98,7 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
>  static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)
>  {
>         drm_crtc_handle_vblank(&mtk_crtc->base);
> -       if (mtk_crtc->pending_needs_vblank) {
> +       if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
>                 mtk_drm_crtc_finish_page_flip(mtk_crtc);
>                 mtk_crtc->pending_needs_vblank = false;
>         }
> @@ -425,7 +426,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc,
>         }
>  }
>
> -static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
> +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;
> @@ -436,6 +438,10 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
>         int i;
>
>         mutex_lock(&mtk_crtc->hw_lock);
> +       mtk_crtc->config_updating = true;
> +       if (needs_vblank)
> +               mtk_crtc->pending_needs_vblank = true;
> +
>         for (i = 0; i < mtk_crtc->layer_nr; i++) {
>                 struct drm_plane *plane = &mtk_crtc->planes[i];
>                 struct mtk_plane_state *plane_state;
> @@ -472,6 +478,7 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc)
>                 cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handle);
>         }
>  #endif
> +       mtk_crtc->config_updating = false;
>         mutex_unlock(&mtk_crtc->hw_lock);
>  }
>
> @@ -532,7 +539,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
>                 return;
>
>         plane_helper_funcs->atomic_update(plane, new_state);
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, false);
>  }
>
>  static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
> @@ -582,7 +589,7 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
>         }
>         mtk_crtc->pending_planes = true;
>
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, false);
>         /* Wait for planes to be disabled */
>         drm_crtc_wait_one_vblank(crtc);
>
> @@ -618,14 +625,12 @@ static void mtk_drm_crtc_atomic_flush(struct drm_crtc *crtc,
>         struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
>         int i;
>
> -       if (mtk_crtc->event)
> -               mtk_crtc->pending_needs_vblank = true;
>         if (crtc->state->color_mgmt_changed)
>                 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
>                         mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state);
>                         mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state);
>                 }
> -       mtk_drm_crtc_hw_config(mtk_crtc);
> +       mtk_drm_crtc_update_config(mtk_crtc, !!mtk_crtc->event);
>  }
>
>  static const struct drm_crtc_funcs mtk_crtc_funcs = {
> --
> 2.17.1
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2021-03-29 23:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13  9:43 [PATCH] drm/mediatek: crtc: Make config-updating atomic Chun-Kuang Hu
2021-03-13  9:43 ` Chun-Kuang Hu
2021-03-13  9:43 ` Chun-Kuang Hu
2021-03-29 16:18 ` Chun-Kuang Hu
2021-03-29 16:18   ` Chun-Kuang Hu
2021-03-29 16:18   ` Chun-Kuang Hu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.