* [PATCH v2 0/1] Fix cursor plane didn't update
@ 2021-07-19 8:22 jason-jh.lin
2021-07-19 8:22 ` [PATCH v2 1/1] " jason-jh.lin
0 siblings, 1 reply; 3+ messages in thread
From: jason-jh.lin @ 2021-07-19 8:22 UTC (permalink / raw)
To: Chun-Kuang Hu, Matthias Brugger, Maxime Ripard
Cc: Philipp Zabel, David Airlie, Daniel Vetter,
Ville Syrjälä,
Thomas Zimmermann, dri-devel, linux-mediatek, linux-arm-kernel,
linux-kernel, fshao, hsinyi, jason-jh.lin, nancy.lin,
singo.chang, David-YH.Chiu
Change in v2:
Fix typo in patch message.
jason-jh.lin (1):
Fix cursor plane didn't update
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 1 -
drivers/gpu/drm/mediatek/mtk_drm_plane.c | 60 ++++++++++++++----------
2 files changed, 34 insertions(+), 27 deletions(-)
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] Fix cursor plane didn't update
2021-07-19 8:22 [PATCH v2 0/1] Fix cursor plane didn't update jason-jh.lin
@ 2021-07-19 8:22 ` jason-jh.lin
2021-07-19 10:27 ` Enric Balletbo Serra
0 siblings, 1 reply; 3+ messages in thread
From: jason-jh.lin @ 2021-07-19 8:22 UTC (permalink / raw)
To: Chun-Kuang Hu, Matthias Brugger, Maxime Ripard
Cc: Philipp Zabel, David Airlie, Daniel Vetter,
Ville Syrjälä,
Thomas Zimmermann, dri-devel, linux-mediatek, linux-arm-kernel,
linux-kernel, fshao, hsinyi, jason-jh.lin, nancy.lin,
singo.chang, David-YH.Chiu
The cursor plane should use the current plane state in atomic_async_update
because it would not be the new plane state in the global atomic state
since _swap_state happened when those hook are run.
Fix cursor plane issue by below modification:
1. Remove plane_helper_funcs->atomic_update(plane, state) in
mtk_drm_crtc_async_update.
2. Add mtk_drm_update_new_state in to mtk_plane_atomic_async_update to
update the cursor plane by current plan hook and update the normal
plane by the new_state.
Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state pointer")
Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
---
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 1 -
drivers/gpu/drm/mediatek/mtk_drm_plane.c | 60 ++++++++++++++----------
2 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 474efb844249..063c75bab3a8 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -538,7 +538,6 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
if (!mtk_crtc->enabled)
return;
- plane_helper_funcs->atomic_update(plane, state);
mtk_drm_crtc_update_config(mtk_crtc, false);
}
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index b5582dcf564c..e6dcb34d3052 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -110,6 +110,35 @@ static int mtk_plane_atomic_async_check(struct drm_plane *plane,
true, true);
}
+static void mtk_plane_update_new_state(struct drm_plane_state *new_state,
+ struct mtk_plane_state *mtk_plane_state)
+{
+ struct drm_framebuffer *fb = new_state->fb;
+ struct drm_gem_object *gem;
+ struct mtk_drm_gem_obj *mtk_gem;
+ unsigned int pitch, format;
+ dma_addr_t addr;
+
+ gem = fb->obj[0];
+ mtk_gem = to_mtk_gem_obj(gem);
+ addr = mtk_gem->dma_addr;
+ pitch = fb->pitches[0];
+ format = fb->format->format;
+
+ addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
+ addr += (new_state->src.y1 >> 16) * pitch;
+
+ mtk_plane_state->pending.enable = true;
+ mtk_plane_state->pending.pitch = pitch;
+ mtk_plane_state->pending.format = format;
+ mtk_plane_state->pending.addr = addr;
+ mtk_plane_state->pending.x = new_state->dst.x1;
+ mtk_plane_state->pending.y = new_state->dst.y1;
+ mtk_plane_state->pending.width = drm_rect_width(&new_state->dst);
+ mtk_plane_state->pending.height = drm_rect_height(&new_state->dst);
+ mtk_plane_state->pending.rotation = new_state->rotation;
+}
+
static void mtk_plane_atomic_async_update(struct drm_plane *plane,
struct drm_atomic_state *state)
{
@@ -126,8 +155,10 @@ static void mtk_plane_atomic_async_update(struct drm_plane *plane,
plane->state->src_h = new_state->src_h;
plane->state->src_w = new_state->src_w;
swap(plane->state->fb, new_state->fb);
- new_plane_state->pending.async_dirty = true;
+ mtk_plane_update_new_state(new_state, new_plane_state);
+ 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);
}
@@ -189,14 +220,8 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
plane);
struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
- struct drm_crtc *crtc = new_state->crtc;
- struct drm_framebuffer *fb = new_state->fb;
- struct drm_gem_object *gem;
- struct mtk_drm_gem_obj *mtk_gem;
- unsigned int pitch, format;
- dma_addr_t addr;
- if (!crtc || WARN_ON(!fb))
+ if (!new_state->crtc || WARN_ON(!new_state->fb))
return;
if (!new_state->visible) {
@@ -204,24 +229,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
return;
}
- gem = fb->obj[0];
- mtk_gem = to_mtk_gem_obj(gem);
- addr = mtk_gem->dma_addr;
- pitch = fb->pitches[0];
- format = fb->format->format;
-
- addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
- addr += (new_state->src.y1 >> 16) * pitch;
-
- mtk_plane_state->pending.enable = true;
- mtk_plane_state->pending.pitch = pitch;
- mtk_plane_state->pending.format = format;
- mtk_plane_state->pending.addr = addr;
- mtk_plane_state->pending.x = new_state->dst.x1;
- mtk_plane_state->pending.y = new_state->dst.y1;
- mtk_plane_state->pending.width = drm_rect_width(&new_state->dst);
- mtk_plane_state->pending.height = drm_rect_height(&new_state->dst);
- mtk_plane_state->pending.rotation = new_state->rotation;
+ mtk_plane_update_new_state(new_state, mtk_plane_state);
wmb(); /* Make sure the above parameters are set before update */
mtk_plane_state->pending.dirty = true;
}
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] Fix cursor plane didn't update
2021-07-19 8:22 ` [PATCH v2 1/1] " jason-jh.lin
@ 2021-07-19 10:27 ` Enric Balletbo Serra
0 siblings, 0 replies; 3+ messages in thread
From: Enric Balletbo Serra @ 2021-07-19 10:27 UTC (permalink / raw)
To: jason-jh.lin
Cc: Chun-Kuang Hu, Matthias Brugger, Maxime Ripard, Philipp Zabel,
David Airlie, Daniel Vetter, Ville Syrjälä,
Thomas Zimmermann, dri-devel,
moderated list:ARM/Mediatek SoC support, Linux ARM, linux-kernel,
fshao, hsinyi, nancy.lin, singo.chang, David-YH.Chiu
Hi Jason-jh,
Thank you for your patch. Please prefix this patch with 'drm/mediatek'
so it is clear what the changes are.
Missatge de jason-jh.lin <jason-jh.lin@mediatek.com> del dia dl., 19
de jul. 2021 a les 10:24:
>
> The cursor plane should use the current plane state in atomic_async_update
> because it would not be the new plane state in the global atomic state
> since _swap_state happened when those hook are run.
>
> Fix cursor plane issue by below modification:
> 1. Remove plane_helper_funcs->atomic_update(plane, state) in
> mtk_drm_crtc_async_update.
> 2. Add mtk_drm_update_new_state in to mtk_plane_atomic_async_update to
> update the cursor plane by current plan hook and update the normal
> plane by the new_state.
>
> Fixes: 37418bf14c13 ("drm: Use state helper instead of the plane state pointer")
>
Drop this new line
> Signed-off-by: jason-jh.lin <jason-jh.lin@mediatek.com>
The patch below fixes the cursor issue on my two boards, one based on
mt8173 and the other on mt8183, so
Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 1 -
> drivers/gpu/drm/mediatek/mtk_drm_plane.c | 60 ++++++++++++++----------
> 2 files changed, 34 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 474efb844249..063c75bab3a8 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -538,7 +538,6 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
> if (!mtk_crtc->enabled)
> return;
>
> - plane_helper_funcs->atomic_update(plane, state);
> mtk_drm_crtc_update_config(mtk_crtc, false);
> }
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index b5582dcf564c..e6dcb34d3052 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -110,6 +110,35 @@ static int mtk_plane_atomic_async_check(struct drm_plane *plane,
> true, true);
> }
>
> +static void mtk_plane_update_new_state(struct drm_plane_state *new_state,
> + struct mtk_plane_state *mtk_plane_state)
> +{
> + struct drm_framebuffer *fb = new_state->fb;
> + struct drm_gem_object *gem;
> + struct mtk_drm_gem_obj *mtk_gem;
> + unsigned int pitch, format;
> + dma_addr_t addr;
> +
> + gem = fb->obj[0];
> + mtk_gem = to_mtk_gem_obj(gem);
> + addr = mtk_gem->dma_addr;
> + pitch = fb->pitches[0];
> + format = fb->format->format;
> +
> + addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
> + addr += (new_state->src.y1 >> 16) * pitch;
> +
> + mtk_plane_state->pending.enable = true;
> + mtk_plane_state->pending.pitch = pitch;
> + mtk_plane_state->pending.format = format;
> + mtk_plane_state->pending.addr = addr;
> + mtk_plane_state->pending.x = new_state->dst.x1;
> + mtk_plane_state->pending.y = new_state->dst.y1;
> + mtk_plane_state->pending.width = drm_rect_width(&new_state->dst);
> + mtk_plane_state->pending.height = drm_rect_height(&new_state->dst);
> + mtk_plane_state->pending.rotation = new_state->rotation;
> +}
> +
> static void mtk_plane_atomic_async_update(struct drm_plane *plane,
> struct drm_atomic_state *state)
> {
> @@ -126,8 +155,10 @@ static void mtk_plane_atomic_async_update(struct drm_plane *plane,
> plane->state->src_h = new_state->src_h;
> plane->state->src_w = new_state->src_w;
> swap(plane->state->fb, new_state->fb);
> - new_plane_state->pending.async_dirty = true;
>
> + mtk_plane_update_new_state(new_state, new_plane_state);
> + 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);
> }
>
> @@ -189,14 +220,8 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
> struct drm_plane_state *new_state = drm_atomic_get_new_plane_state(state,
> plane);
> struct mtk_plane_state *mtk_plane_state = to_mtk_plane_state(new_state);
> - struct drm_crtc *crtc = new_state->crtc;
> - struct drm_framebuffer *fb = new_state->fb;
> - struct drm_gem_object *gem;
> - struct mtk_drm_gem_obj *mtk_gem;
> - unsigned int pitch, format;
> - dma_addr_t addr;
>
> - if (!crtc || WARN_ON(!fb))
> + if (!new_state->crtc || WARN_ON(!new_state->fb))
> return;
>
> if (!new_state->visible) {
> @@ -204,24 +229,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
> return;
> }
>
> - gem = fb->obj[0];
> - mtk_gem = to_mtk_gem_obj(gem);
> - addr = mtk_gem->dma_addr;
> - pitch = fb->pitches[0];
> - format = fb->format->format;
> -
> - addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
> - addr += (new_state->src.y1 >> 16) * pitch;
> -
> - mtk_plane_state->pending.enable = true;
> - mtk_plane_state->pending.pitch = pitch;
> - mtk_plane_state->pending.format = format;
> - mtk_plane_state->pending.addr = addr;
> - mtk_plane_state->pending.x = new_state->dst.x1;
> - mtk_plane_state->pending.y = new_state->dst.y1;
> - mtk_plane_state->pending.width = drm_rect_width(&new_state->dst);
> - mtk_plane_state->pending.height = drm_rect_height(&new_state->dst);
> - mtk_plane_state->pending.rotation = new_state->rotation;
> + mtk_plane_update_new_state(new_state, mtk_plane_state);
> wmb(); /* Make sure the above parameters are set before update */
> mtk_plane_state->pending.dirty = true;
> }
> --
> 2.18.0
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-19 10:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-19 8:22 [PATCH v2 0/1] Fix cursor plane didn't update jason-jh.lin
2021-07-19 8:22 ` [PATCH v2 1/1] " jason-jh.lin
2021-07-19 10:27 ` Enric Balletbo Serra
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).