mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/4] drm/verisilicon: misc fixes
@ 2026-11-02  7:57 Icenowy Zheng
  2026-11-02  7:57 ` [PATCH v2 1/4] drm/verisilicon: disable the output before enabling it Icenowy Zheng
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-02  7:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng, Icenowy Zheng

This patchset fixes several problems. The first one fixes a bug when the
firmware did a modeset with different mode than the one picked by Linux,
and others are fixing problems pointed by Sashiko.

The fixes of atomic_disble NULL dereference is proven to be worse than
the original, and considering Sashiko points out that clearing FB_EN
would prevent showing bound-but-invisible planes, this part of fix is
redone.

Icenowy Zheng (3):
  drm/verisilicon: disable the output before enabling it
  drm/verisilicon: nuke planes' atomic_enable hooks
  drm/verisilicon: check old state CRTC in plane atomic_disable

Joey Lu (1):
  drm/verisilicon: fix DC8200 primary plane disable clearing FB_EN

 drivers/gpu/drm/verisilicon/vs_bridge.c       |  8 ++++
 drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 35 ++++++---------
 .../gpu/drm/verisilicon/vs_primary_plane.c    | 43 ++++++++-----------
 3 files changed, 40 insertions(+), 46 deletions(-)

-- 
2.56.0


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

* [PATCH v2 1/4] drm/verisilicon: disable the output before enabling it
  2026-11-02  7:57 [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
@ 2026-11-02  7:57 ` Icenowy Zheng
  2026-11-02  7:57 ` [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks Icenowy Zheng
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-02  7:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng, Icenowy Zheng

When either of the RUNNING bits are set, change to some timing
parameters won't take effect.

This will lead to failure of the first modeset done by the kernel, if
the bootloader sets a different mode and keeps the display running
before it.

Flip these RUNNING bits off before setting it on to fix this problem.

Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
 drivers/gpu/drm/verisilicon/vs_bridge.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/verisilicon/vs_bridge.c b/drivers/gpu/drm/verisilicon/vs_bridge.c
index dc7c85b07fe32..a095b20e81c00 100644
--- a/drivers/gpu/drm/verisilicon/vs_bridge.c
+++ b/drivers/gpu/drm/verisilicon/vs_bridge.c
@@ -162,6 +162,14 @@ static void vs_bridge_enable_common(struct vs_crtc *crtc,
 			VSDC_DISP_PANEL_CONFIG_DE_EN |
 			VSDC_DISP_PANEL_CONFIG_DAT_EN |
 			VSDC_DISP_PANEL_CONFIG_CLK_EN);
+
+	/* Disable it first to prevent stale hardware state */
+	regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_START,
+			  VSDC_DISP_PANEL_START_MULTI_DISP_SYNC |
+			  VSDC_DISP_PANEL_START_RUNNING(output));
+	regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
+			  VSDC_DISP_PANEL_CONFIG_RUNNING);
+
 	regmap_set_bits(dc->regs, VSDC_DISP_PANEL_CONFIG(output),
 			VSDC_DISP_PANEL_CONFIG_RUNNING);
 	regmap_clear_bits(dc->regs, VSDC_DISP_PANEL_START,
-- 
2.56.0


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

* [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks
  2026-11-02  7:57 [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
  2026-11-02  7:57 ` [PATCH v2 1/4] drm/verisilicon: disable the output before enabling it Icenowy Zheng
@ 2026-11-02  7:57 ` Icenowy Zheng
  2026-11-16 13:37   ` Thomas Zimmermann
  2026-11-02  7:57 ` [PATCH v2 3/4] drm/verisilicon: fix DC8200 primary plane disable clearing FB_EN Icenowy Zheng
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-02  7:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng, Icenowy Zheng

The atomic_update hooks of both planes are just bailing out early when
the planes are invisible, so it's reasonable to just remove these hooks
and update the enabled state in atomic_update.

This fixes the problem that invisible but enabled planes won't be
shown when made visible, as pointed by Sashiko.

Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor planes")
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
 drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 22 +++-------------
 .../gpu/drm/verisilicon/vs_primary_plane.c    | 26 +++++--------------
 2 files changed, 10 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
index da456dced88aa..5295dc2f9ee2e 100644
--- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
@@ -98,23 +98,6 @@ static void vs_cursor_plane_commit(struct vs_dc *dc, unsigned int output)
 			VSDC_CURSOR_CONFIG_IMG_UPDATE);
 }
 
-static void vs_cursor_plane_atomic_enable(struct drm_plane *plane,
-					   struct drm_atomic_commit *atomic_state)
-{
-	struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
-								       plane);
-	struct drm_crtc *crtc = state->crtc;
-	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
-	unsigned int output = vcrtc->id;
-	struct vs_dc *dc = vcrtc->dc;
-
-	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
-			   VSDC_CURSOR_CONFIG_FMT_MASK,
-			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
-
-	vs_cursor_plane_commit(dc, output);
-}
-
 static void vs_cursor_plane_atomic_disable(struct drm_plane *plane,
 					    struct drm_atomic_commit *atomic_state)
 {
@@ -153,6 +136,10 @@ static void vs_cursor_plane_atomic_update(struct drm_plane *plane,
 	output = vcrtc->id;
 	dc = vcrtc->dc;
 
+	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
+			   VSDC_CURSOR_CONFIG_FMT_MASK,
+			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
+
 	/* Other sizes should be rejected by atomic_check */
 	switch (state->crtc_w) {
 	case 32:
@@ -225,7 +212,6 @@ static void vs_cursor_plane_atomic_update(struct drm_plane *plane,
 static const struct drm_plane_helper_funcs vs_cursor_plane_helper_funcs = {
 	.atomic_check	= vs_cursor_plane_atomic_check,
 	.atomic_update	= vs_cursor_plane_atomic_update,
-	.atomic_enable	= vs_cursor_plane_atomic_enable,
 	.atomic_disable	= vs_cursor_plane_atomic_disable,
 };
 
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
index 8e94491693019..fca692f4f7d5c 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -59,25 +59,6 @@ static void vs_primary_plane_commit(struct vs_dc *dc, unsigned int output)
 			VSDC_FB_CONFIG_EX_COMMIT);
 }
 
-static void vs_primary_plane_atomic_enable(struct drm_plane *plane,
-					   struct drm_atomic_commit *atomic_state)
-{
-	struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
-								       plane);
-	struct drm_crtc *crtc = state->crtc;
-	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
-	unsigned int output = vcrtc->id;
-	struct vs_dc *dc = vcrtc->dc;
-
-	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
-			VSDC_FB_CONFIG_EX_FB_EN);
-	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
-			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
-			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
-
-	vs_primary_plane_commit(dc, output);
-}
-
 static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
 					    struct drm_atomic_commit *atomic_state)
 {
@@ -144,13 +125,18 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,
 	regmap_write(dc->regs, VSDC_FB_BLEND_CONFIG(output),
 		     VSDC_FB_BLEND_CONFIG_BLEND_DISABLE);
 
+	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+			VSDC_FB_CONFIG_EX_FB_EN);
+	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
+			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
+
 	vs_primary_plane_commit(dc, output);
 }
 
 static const struct drm_plane_helper_funcs vs_primary_plane_helper_funcs = {
 	.atomic_check	= vs_primary_plane_atomic_check,
 	.atomic_update	= vs_primary_plane_atomic_update,
-	.atomic_enable	= vs_primary_plane_atomic_enable,
 	.atomic_disable	= vs_primary_plane_atomic_disable,
 };
 
-- 
2.56.0


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

* [PATCH v2 3/4] drm/verisilicon: fix DC8200 primary plane disable clearing FB_EN
  2026-11-02  7:57 [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
  2026-11-02  7:57 ` [PATCH v2 1/4] drm/verisilicon: disable the output before enabling it Icenowy Zheng
  2026-11-02  7:57 ` [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks Icenowy Zheng
@ 2026-11-02  7:57 ` Icenowy Zheng
  2026-11-02  7:57 ` [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable Icenowy Zheng
  2026-11-12  7:46 ` [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
  4 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-02  7:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng, Icenowy Zheng

From: Joey Lu <a0987203069@gmail.com>

vs_primary_plane_atomic_disable() calls regmap_set_bits() on
VSDC_FB_CONFIG_EX_FB_EN instead of regmap_clear_bits(), so disabling
the primary plane on DC8200-family hardware actually leaves the
framebuffer enable bit instead of clearing it.

Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
Signed-off-by: Joey Lu <a0987203069@gmail.com>
[Icenowy: rebased and reworked the commit message]
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
 drivers/gpu/drm/verisilicon/vs_primary_plane.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
index fca692f4f7d5c..e687313d6f057 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -69,8 +69,8 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
 	unsigned int output = vcrtc->id;
 	struct vs_dc *dc = vcrtc->dc;
 
-	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
-			VSDC_FB_CONFIG_EX_FB_EN);
+	regmap_clear_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
+			  VSDC_FB_CONFIG_EX_FB_EN);
 
 	vs_primary_plane_commit(dc, output);
 }
-- 
2.56.0


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

* [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable
  2026-11-02  7:57 [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
                   ` (2 preceding siblings ...)
  2026-11-02  7:57 ` [PATCH v2 3/4] drm/verisilicon: fix DC8200 primary plane disable clearing FB_EN Icenowy Zheng
@ 2026-11-02  7:57 ` Icenowy Zheng
  2026-11-16 13:42   ` Thomas Zimmermann
  2026-11-12  7:46 ` [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
  4 siblings, 1 reply; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-02  7:57 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng, Icenowy Zheng

As atomic_update hooks of both planes would utilize atomic_disable
functions to disable the plane when it's set to invisible (even when
technically enabled), the atomic_disable functions need to check whether
the plane is really enabled before.

Add such a check to prevent NULL dereference.

Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor planes")
Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
---
 drivers/gpu/drm/verisilicon/vs_cursor_plane.c  | 13 ++++++++++---
 drivers/gpu/drm/verisilicon/vs_primary_plane.c | 13 ++++++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
index 5295dc2f9ee2e..bee19b65b9a4e 100644
--- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
@@ -104,9 +104,16 @@ static void vs_cursor_plane_atomic_disable(struct drm_plane *plane,
 	struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
 								       plane);
 	struct drm_crtc *crtc = state->crtc;
-	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
-	unsigned int output = vcrtc->id;
-	struct vs_dc *dc = vcrtc->dc;
+	struct vs_crtc *vcrtc;
+	unsigned int output;
+	struct vs_dc *dc;
+
+	if (!crtc)
+		return;
+
+	vcrtc = drm_crtc_to_vs_crtc(crtc);
+	output = vcrtc->id;
+	dc = vcrtc->dc;
 
 	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
 			   VSDC_CURSOR_CONFIG_FMT_MASK,
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
index e687313d6f057..01725e60e5fbd 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -65,9 +65,16 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
 	struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
 								       plane);
 	struct drm_crtc *crtc = state->crtc;
-	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
-	unsigned int output = vcrtc->id;
-	struct vs_dc *dc = vcrtc->dc;
+	struct vs_crtc *vcrtc;
+	unsigned int output;
+	struct vs_dc *dc;
+
+	if (!crtc)
+		return;
+
+	vcrtc = drm_crtc_to_vs_crtc(crtc);
+	output = vcrtc->id;
+	dc = vcrtc->dc;
 
 	regmap_clear_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
 			  VSDC_FB_CONFIG_EX_FB_EN);
-- 
2.56.0


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

* Re: [PATCH v2 0/4] drm/verisilicon: misc fixes
  2026-11-02  7:57 [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
                   ` (3 preceding siblings ...)
  2026-11-02  7:57 ` [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable Icenowy Zheng
@ 2026-11-12  7:46 ` Icenowy Zheng
  4 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-12  7:46 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel

在 2026-11-02一的 15:57 +0800,Icenowy Zheng写道:
> This patchset fixes several problems. The first one fixes a bug when
> the
> firmware did a modeset with different mode than the one picked by
> Linux,
> and others are fixing problems pointed by Sashiko.
> 
> The fixes of atomic_disble NULL dereference is proven to be worse
> than
> the original, and considering Sashiko points out that clearing FB_EN
> would prevent showing bound-but-invisible planes, this part of fix is
> redone.

Ping.

Could anyone try to do some review on this patchset?

Thanks,
Icenowy

> 
> Icenowy Zheng (3):
>   drm/verisilicon: disable the output before enabling it
>   drm/verisilicon: nuke planes' atomic_enable hooks
>   drm/verisilicon: check old state CRTC in plane atomic_disable
> 
> Joey Lu (1):
>   drm/verisilicon: fix DC8200 primary plane disable clearing FB_EN
> 
>  drivers/gpu/drm/verisilicon/vs_bridge.c       |  8 ++++
>  drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 35 ++++++---------
>  .../gpu/drm/verisilicon/vs_primary_plane.c    | 43 ++++++++---------
> --
>  3 files changed, 40 insertions(+), 46 deletions(-)


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

* Re: [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks
  2026-11-02  7:57 ` [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks Icenowy Zheng
@ 2026-11-16 13:37   ` Thomas Zimmermann
  2026-11-16 15:11     ` Icenowy Zheng
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Zimmermann @ 2026-11-16 13:37 UTC (permalink / raw)
  To: Icenowy Zheng, Maarten Lankhorst, Maxime Ripard
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng

Hi

Am 02.11.26 um 08:57 schrieb Icenowy Zheng:
> The atomic_update hooks of both planes are just bailing out early when
> the planes are invisible, so it's reasonable to just remove these hooks
> and update the enabled state in atomic_update.
>
> This fixes the problem that invisible but enabled planes won't be
> shown when made visible, as pointed by Sashiko.
>
> Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
> Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor planes")
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> ---
>   drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 22 +++-------------
>   .../gpu/drm/verisilicon/vs_primary_plane.c    | 26 +++++--------------
>   2 files changed, 10 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> index da456dced88aa..5295dc2f9ee2e 100644
> --- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> +++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> @@ -98,23 +98,6 @@ static void vs_cursor_plane_commit(struct vs_dc *dc, unsigned int output)
>   			VSDC_CURSOR_CONFIG_IMG_UPDATE);
>   }
>   
> -static void vs_cursor_plane_atomic_enable(struct drm_plane *plane,
> -					   struct drm_atomic_commit *atomic_state)
> -{
> -	struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
> -								       plane);
> -	struct drm_crtc *crtc = state->crtc;
> -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> -	unsigned int output = vcrtc->id;
> -	struct vs_dc *dc = vcrtc->dc;
> -
> -	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
> -			   VSDC_CURSOR_CONFIG_FMT_MASK,
> -			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
> -
> -	vs_cursor_plane_commit(dc, output);
> -}
> -
>   static void vs_cursor_plane_atomic_disable(struct drm_plane *plane,
>   					    struct drm_atomic_commit *atomic_state)
>   {
> @@ -153,6 +136,10 @@ static void vs_cursor_plane_atomic_update(struct drm_plane *plane,
>   	output = vcrtc->id;
>   	dc = vcrtc->dc;
>   
> +	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
> +			   VSDC_CURSOR_CONFIG_FMT_MASK,
> +			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
> +
>   	/* Other sizes should be rejected by atomic_check */
>   	switch (state->crtc_w) {
>   	case 32:
> @@ -225,7 +212,6 @@ static void vs_cursor_plane_atomic_update(struct drm_plane *plane,
>   static const struct drm_plane_helper_funcs vs_cursor_plane_helper_funcs = {
>   	.atomic_check	= vs_cursor_plane_atomic_check,
>   	.atomic_update	= vs_cursor_plane_atomic_update,
> -	.atomic_enable	= vs_cursor_plane_atomic_enable,
>   	.atomic_disable	= vs_cursor_plane_atomic_disable,

But now you have the worst of both worlds: atomic_disable is still 
around but also done by atomic_update. And atomic_update always sets 
these registers even if the plane is already visible.

I'd instead remove the disable calls from atomic_update [1] . I think 
you should never reach this is you have an atomic_disable installed. See 
[1] for the logic.

[1] 
https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/drm_atomic_helper.c#L3030

Best regards
Thomas

>   };
>   
> diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> index 8e94491693019..fca692f4f7d5c 100644
> --- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> +++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> @@ -59,25 +59,6 @@ static void vs_primary_plane_commit(struct vs_dc *dc, unsigned int output)
>   			VSDC_FB_CONFIG_EX_COMMIT);
>   }
>   
> -static void vs_primary_plane_atomic_enable(struct drm_plane *plane,
> -					   struct drm_atomic_commit *atomic_state)
> -{
> -	struct drm_plane_state *state = drm_atomic_get_new_plane_state(atomic_state,
> -								       plane);
> -	struct drm_crtc *crtc = state->crtc;
> -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> -	unsigned int output = vcrtc->id;
> -	struct vs_dc *dc = vcrtc->dc;
> -
> -	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> -			VSDC_FB_CONFIG_EX_FB_EN);
> -	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> -			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
> -			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
> -
> -	vs_primary_plane_commit(dc, output);
> -}
> -
>   static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
>   					    struct drm_atomic_commit *atomic_state)
>   {
> @@ -144,13 +125,18 @@ static void vs_primary_plane_atomic_update(struct drm_plane *plane,
>   	regmap_write(dc->regs, VSDC_FB_BLEND_CONFIG(output),
>   		     VSDC_FB_BLEND_CONFIG_BLEND_DISABLE);
>   
> +	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> +			VSDC_FB_CONFIG_EX_FB_EN);
> +	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> +			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
> +			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
> +
>   	vs_primary_plane_commit(dc, output);
>   }
>   
>   static const struct drm_plane_helper_funcs vs_primary_plane_helper_funcs = {
>   	.atomic_check	= vs_primary_plane_atomic_check,
>   	.atomic_update	= vs_primary_plane_atomic_update,
> -	.atomic_enable	= vs_primary_plane_atomic_enable,
>   	.atomic_disable	= vs_primary_plane_atomic_disable,
>   };
>   

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



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

* Re: [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable
  2026-11-02  7:57 ` [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable Icenowy Zheng
@ 2026-11-16 13:42   ` Thomas Zimmermann
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Zimmermann @ 2026-11-16 13:42 UTC (permalink / raw)
  To: Icenowy Zheng, Maarten Lankhorst, Maxime Ripard
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel, Icenowy Zheng

Hi

Am 02.11.26 um 08:57 schrieb Icenowy Zheng:
> As atomic_update hooks of both planes would utilize atomic_disable
> functions to disable the plane when it's set to invisible (even when
> technically enabled), the atomic_disable functions need to check whether
> the plane is really enabled before.

Why? Why not just disable the plane?

Also see my review of the other patch. Why not remove that disable call 
from atomic_update?

Best regards
Thomas

>
> Add such a check to prevent NULL dereference.
>
> Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
> Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor planes")
> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> ---
>   drivers/gpu/drm/verisilicon/vs_cursor_plane.c  | 13 ++++++++++---
>   drivers/gpu/drm/verisilicon/vs_primary_plane.c | 13 ++++++++++---
>   2 files changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> index 5295dc2f9ee2e..bee19b65b9a4e 100644
> --- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> +++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> @@ -104,9 +104,16 @@ static void vs_cursor_plane_atomic_disable(struct drm_plane *plane,
>   	struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
>   								       plane);
>   	struct drm_crtc *crtc = state->crtc;
> -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> -	unsigned int output = vcrtc->id;
> -	struct vs_dc *dc = vcrtc->dc;
> +	struct vs_crtc *vcrtc;
> +	unsigned int output;
> +	struct vs_dc *dc;
> +
> +	if (!crtc)
> +		return;
> +
> +	vcrtc = drm_crtc_to_vs_crtc(crtc);
> +	output = vcrtc->id;
> +	dc = vcrtc->dc;
>   
>   	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
>   			   VSDC_CURSOR_CONFIG_FMT_MASK,
> diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> index e687313d6f057..01725e60e5fbd 100644
> --- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> +++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> @@ -65,9 +65,16 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
>   	struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
>   								       plane);
>   	struct drm_crtc *crtc = state->crtc;
> -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> -	unsigned int output = vcrtc->id;
> -	struct vs_dc *dc = vcrtc->dc;
> +	struct vs_crtc *vcrtc;
> +	unsigned int output;
> +	struct vs_dc *dc;
> +
> +	if (!crtc)
> +		return;
> +
> +	vcrtc = drm_crtc_to_vs_crtc(crtc);
> +	output = vcrtc->id;
> +	dc = vcrtc->dc;
>   
>   	regmap_clear_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
>   			  VSDC_FB_CONFIG_EX_FB_EN);

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



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

* Re: [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks
  2026-11-16 13:37   ` Thomas Zimmermann
@ 2026-11-16 15:11     ` Icenowy Zheng
  2026-11-16 15:20       ` Thomas Zimmermann
  0 siblings, 1 reply; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-16 15:11 UTC (permalink / raw)
  To: Thomas Zimmermann, Maarten Lankhorst, Maxime Ripard
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel

在 2026-11-16一的 14:37 +0100,Thomas Zimmermann写道:
> Hi
> 
> Am 02.11.26 um 08:57 schrieb Icenowy Zheng:
> > The atomic_update hooks of both planes are just bailing out early
> > when
> > the planes are invisible, so it's reasonable to just remove these
> > hooks
> > and update the enabled state in atomic_update.
> > 
> > This fixes the problem that invisible but enabled planes won't be
> > shown when made visible, as pointed by Sashiko.
> > 
> > Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for
> > Verisilicon display controllers")
> > Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor
> > planes")
> > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > ---
> >   drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 22 +++-----------
> > --
> >   .../gpu/drm/verisilicon/vs_primary_plane.c    | 26 +++++---------
> > -----
> >   2 files changed, 10 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > index da456dced88aa..5295dc2f9ee2e 100644
> > --- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > +++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > @@ -98,23 +98,6 @@ static void vs_cursor_plane_commit(struct vs_dc
> > *dc, unsigned int output)
> >   			VSDC_CURSOR_CONFIG_IMG_UPDATE);
> >   }
> >   
> > -static void vs_cursor_plane_atomic_enable(struct drm_plane *plane,
> > -					   struct
> > drm_atomic_commit *atomic_state)
> > -{
> > -	struct drm_plane_state *state =
> > drm_atomic_get_new_plane_state(atomic_state,
> > -
> > 								       plane);
> > -	struct drm_crtc *crtc = state->crtc;
> > -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> > -	unsigned int output = vcrtc->id;
> > -	struct vs_dc *dc = vcrtc->dc;
> > -
> > -	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
> > -			   VSDC_CURSOR_CONFIG_FMT_MASK,
> > -			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
> > -
> > -	vs_cursor_plane_commit(dc, output);
> > -}
> > -
> >   static void vs_cursor_plane_atomic_disable(struct drm_plane
> > *plane,
> >   					    struct
> > drm_atomic_commit *atomic_state)
> >   {
> > @@ -153,6 +136,10 @@ static void
> > vs_cursor_plane_atomic_update(struct drm_plane *plane,
> >   	output = vcrtc->id;
> >   	dc = vcrtc->dc;
> >   
> > +	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
> > +			   VSDC_CURSOR_CONFIG_FMT_MASK,
> > +			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
> > +
> >   	/* Other sizes should be rejected by atomic_check */
> >   	switch (state->crtc_w) {
> >   	case 32:
> > @@ -225,7 +212,6 @@ static void
> > vs_cursor_plane_atomic_update(struct drm_plane *plane,
> >   static const struct drm_plane_helper_funcs
> > vs_cursor_plane_helper_funcs = {
> >   	.atomic_check	= vs_cursor_plane_atomic_check,
> >   	.atomic_update	= vs_cursor_plane_atomic_update,
> > -	.atomic_enable	= vs_cursor_plane_atomic_enable,
> >   	.atomic_disable	= vs_cursor_plane_atomic_disable,
> 
> But now you have the worst of both worlds: atomic_disable is still 
> around but also done by atomic_update. And atomic_update always sets 
> these registers even if the plane is already visible.
> 
> I'd instead remove the disable calls from atomic_update [1] . I think
> you should never reach this is you have an atomic_disable installed.
> See 
> [1] for the logic.

The drm_atomic_plane_disabling() function only checks whether a CRTC is
bound -- I think it could be possible that a plane is bound to a CRTC
but with an invisible coordinate (especially for the cursor plane).

The end of drm_atomic_helper_check_plane_state() says:

```
	if (!plane_state->visible)
		/*
		 * Plane isn't visible; some drivers can handle this
		 * so we just return success here.  Drivers that can't
		 * (including those that use the primary plane
helper's
		 * update function) will return an error from their
		 * update_plane handler.
		 */
		return 0;
```

Thanks,
Icenowy

> 
> [1] 
> https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/drm_atomic_helper.c#L3030
> 
> Best regards
> Thomas
> 
> >   };
> >   
> > diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > index 8e94491693019..fca692f4f7d5c 100644
> > --- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > +++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > @@ -59,25 +59,6 @@ static void vs_primary_plane_commit(struct vs_dc
> > *dc, unsigned int output)
> >   			VSDC_FB_CONFIG_EX_COMMIT);
> >   }
> >   
> > -static void vs_primary_plane_atomic_enable(struct drm_plane
> > *plane,
> > -					   struct
> > drm_atomic_commit *atomic_state)
> > -{
> > -	struct drm_plane_state *state =
> > drm_atomic_get_new_plane_state(atomic_state,
> > -
> > 								       plane);
> > -	struct drm_crtc *crtc = state->crtc;
> > -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> > -	unsigned int output = vcrtc->id;
> > -	struct vs_dc *dc = vcrtc->dc;
> > -
> > -	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> > -			VSDC_FB_CONFIG_EX_FB_EN);
> > -	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> > -			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
> > -			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
> > -
> > -	vs_primary_plane_commit(dc, output);
> > -}
> > -
> >   static void vs_primary_plane_atomic_disable(struct drm_plane
> > *plane,
> >   					    struct
> > drm_atomic_commit *atomic_state)
> >   {
> > @@ -144,13 +125,18 @@ static void
> > vs_primary_plane_atomic_update(struct drm_plane *plane,
> >   	regmap_write(dc->regs, VSDC_FB_BLEND_CONFIG(output),
> >   		     VSDC_FB_BLEND_CONFIG_BLEND_DISABLE);
> >   
> > +	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> > +			VSDC_FB_CONFIG_EX_FB_EN);
> > +	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> > +			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
> > +			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
> > +
> >   	vs_primary_plane_commit(dc, output);
> >   }
> >   
> >   static const struct drm_plane_helper_funcs
> > vs_primary_plane_helper_funcs = {
> >   	.atomic_check	= vs_primary_plane_atomic_check,
> >   	.atomic_update	= vs_primary_plane_atomic_update,
> > -	.atomic_enable	= vs_primary_plane_atomic_enable,
> >   	.atomic_disable	= vs_primary_plane_atomic_disable,
> >   };
> >   


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

* Re: [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks
  2026-11-16 15:11     ` Icenowy Zheng
@ 2026-11-16 15:20       ` Thomas Zimmermann
  2026-11-16 15:25         ` Icenowy Zheng
  0 siblings, 1 reply; 11+ messages in thread
From: Thomas Zimmermann @ 2026-11-16 15:20 UTC (permalink / raw)
  To: Icenowy Zheng, Maarten Lankhorst, Maxime Ripard
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel

Hi

Am 16.11.26 um 16:11 schrieb Icenowy Zheng:
> 在 2026-11-16一的 14:37 +0100,Thomas Zimmermann写道:
>> Hi
>>
>> Am 02.11.26 um 08:57 schrieb Icenowy Zheng:
>>> The atomic_update hooks of both planes are just bailing out early
>>> when
>>> the planes are invisible, so it's reasonable to just remove these
>>> hooks
>>> and update the enabled state in atomic_update.
>>>
>>> This fixes the problem that invisible but enabled planes won't be
>>> shown when made visible, as pointed by Sashiko.
>>>
>>> Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for
>>> Verisilicon display controllers")
>>> Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor
>>> planes")
>>> Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
>>> ---
>>>    drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 22 +++-----------
>>> --
>>>    .../gpu/drm/verisilicon/vs_primary_plane.c    | 26 +++++---------
>>> -----
>>>    2 files changed, 10 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
>>> b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
>>> index da456dced88aa..5295dc2f9ee2e 100644
>>> --- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
>>> +++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
>>> @@ -98,23 +98,6 @@ static void vs_cursor_plane_commit(struct vs_dc
>>> *dc, unsigned int output)
>>>    			VSDC_CURSOR_CONFIG_IMG_UPDATE);
>>>    }
>>>    
>>> -static void vs_cursor_plane_atomic_enable(struct drm_plane *plane,
>>> -					   struct
>>> drm_atomic_commit *atomic_state)
>>> -{
>>> -	struct drm_plane_state *state =
>>> drm_atomic_get_new_plane_state(atomic_state,
>>> -
>>> 								       plane);
>>> -	struct drm_crtc *crtc = state->crtc;
>>> -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
>>> -	unsigned int output = vcrtc->id;
>>> -	struct vs_dc *dc = vcrtc->dc;
>>> -
>>> -	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
>>> -			   VSDC_CURSOR_CONFIG_FMT_MASK,
>>> -			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
>>> -
>>> -	vs_cursor_plane_commit(dc, output);
>>> -}
>>> -
>>>    static void vs_cursor_plane_atomic_disable(struct drm_plane
>>> *plane,
>>>    					    struct
>>> drm_atomic_commit *atomic_state)
>>>    {
>>> @@ -153,6 +136,10 @@ static void
>>> vs_cursor_plane_atomic_update(struct drm_plane *plane,
>>>    	output = vcrtc->id;
>>>    	dc = vcrtc->dc;
>>>    
>>> +	regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
>>> +			   VSDC_CURSOR_CONFIG_FMT_MASK,
>>> +			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
>>> +
>>>    	/* Other sizes should be rejected by atomic_check */
>>>    	switch (state->crtc_w) {
>>>    	case 32:
>>> @@ -225,7 +212,6 @@ static void
>>> vs_cursor_plane_atomic_update(struct drm_plane *plane,
>>>    static const struct drm_plane_helper_funcs
>>> vs_cursor_plane_helper_funcs = {
>>>    	.atomic_check	= vs_cursor_plane_atomic_check,
>>>    	.atomic_update	= vs_cursor_plane_atomic_update,
>>> -	.atomic_enable	= vs_cursor_plane_atomic_enable,
>>>    	.atomic_disable	= vs_cursor_plane_atomic_disable,
>> But now you have the worst of both worlds: atomic_disable is still
>> around but also done by atomic_update. And atomic_update always sets
>> these registers even if the plane is already visible.
>>
>> I'd instead remove the disable calls from atomic_update [1] . I think
>> you should never reach this is you have an atomic_disable installed.
>> See
>> [1] for the logic.
> The drm_atomic_plane_disabling() function only checks whether a CRTC is
> bound -- I think it could be possible that a plane is bound to a CRTC
> but with an invisible coordinate (especially for the cursor plane).

Sure, but is that a problem for this hardware?

Best regards
Thomas

>
> The end of drm_atomic_helper_check_plane_state() says:
>
> ```
> 	if (!plane_state->visible)
> 		/*
> 		 * Plane isn't visible; some drivers can handle this
> 		 * so we just return success here.  Drivers that can't
> 		 * (including those that use the primary plane
> helper's
> 		 * update function) will return an error from their
> 		 * update_plane handler.
> 		 */
> 		return 0;
> ```
>
> Thanks,
> Icenowy
>
>> [1]
>> https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/drm_atomic_helper.c#L3030
>>
>> Best regards
>> Thomas
>>
>>>    };
>>>    
>>> diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
>>> b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
>>> index 8e94491693019..fca692f4f7d5c 100644
>>> --- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
>>> +++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
>>> @@ -59,25 +59,6 @@ static void vs_primary_plane_commit(struct vs_dc
>>> *dc, unsigned int output)
>>>    			VSDC_FB_CONFIG_EX_COMMIT);
>>>    }
>>>    
>>> -static void vs_primary_plane_atomic_enable(struct drm_plane
>>> *plane,
>>> -					   struct
>>> drm_atomic_commit *atomic_state)
>>> -{
>>> -	struct drm_plane_state *state =
>>> drm_atomic_get_new_plane_state(atomic_state,
>>> -
>>> 								       plane);
>>> -	struct drm_crtc *crtc = state->crtc;
>>> -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
>>> -	unsigned int output = vcrtc->id;
>>> -	struct vs_dc *dc = vcrtc->dc;
>>> -
>>> -	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
>>> -			VSDC_FB_CONFIG_EX_FB_EN);
>>> -	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
>>> -			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
>>> -			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
>>> -
>>> -	vs_primary_plane_commit(dc, output);
>>> -}
>>> -
>>>    static void vs_primary_plane_atomic_disable(struct drm_plane
>>> *plane,
>>>    					    struct
>>> drm_atomic_commit *atomic_state)
>>>    {
>>> @@ -144,13 +125,18 @@ static void
>>> vs_primary_plane_atomic_update(struct drm_plane *plane,
>>>    	regmap_write(dc->regs, VSDC_FB_BLEND_CONFIG(output),
>>>    		     VSDC_FB_BLEND_CONFIG_BLEND_DISABLE);
>>>    
>>> +	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
>>> +			VSDC_FB_CONFIG_EX_FB_EN);
>>> +	regmap_update_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
>>> +			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
>>> +			   VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
>>> +
>>>    	vs_primary_plane_commit(dc, output);
>>>    }
>>>    
>>>    static const struct drm_plane_helper_funcs
>>> vs_primary_plane_helper_funcs = {
>>>    	.atomic_check	= vs_primary_plane_atomic_check,
>>>    	.atomic_update	= vs_primary_plane_atomic_update,
>>> -	.atomic_enable	= vs_primary_plane_atomic_enable,
>>>    	.atomic_disable	= vs_primary_plane_atomic_disable,
>>>    };
>>>    

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)



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

* Re: [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks
  2026-11-16 15:20       ` Thomas Zimmermann
@ 2026-11-16 15:25         ` Icenowy Zheng
  0 siblings, 0 replies; 11+ messages in thread
From: Icenowy Zheng @ 2026-11-16 15:25 UTC (permalink / raw)
  To: Thomas Zimmermann, Maarten Lankhorst, Maxime Ripard
  Cc: David Airlie, Simona Vetter, Dmitry Baryshkov, Joey Lu, Han Gao,
	dri-devel, linux-kernel

在 2026-11-16一的 16:20 +0100,Thomas Zimmermann写道:
> Hi
> 
> Am 16.11.26 um 16:11 schrieb Icenowy Zheng:
> > 在 2026-11-16一的 14:37 +0100,Thomas Zimmermann写道:
> > > Hi
> > > 
> > > Am 02.11.26 um 08:57 schrieb Icenowy Zheng:
> > > > The atomic_update hooks of both planes are just bailing out
> > > > early
> > > > when
> > > > the planes are invisible, so it's reasonable to just remove
> > > > these
> > > > hooks
> > > > and update the enabled state in atomic_update.
> > > > 
> > > > This fixes the problem that invisible but enabled planes won't
> > > > be
> > > > shown when made visible, as pointed by Sashiko.
> > > > 
> > > > Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for
> > > > Verisilicon display controllers")
> > > > Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor
> > > > planes")
> > > > Signed-off-by: Icenowy Zheng <zhengxingda@iscas.ac.cn>
> > > > ---
> > > >    drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 22 +++------
> > > > -----
> > > > --
> > > >    .../gpu/drm/verisilicon/vs_primary_plane.c    | 26 +++++----
> > > > -----
> > > > -----
> > > >    2 files changed, 10 insertions(+), 38 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > > > b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > > > index da456dced88aa..5295dc2f9ee2e 100644
> > > > --- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > > > +++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
> > > > @@ -98,23 +98,6 @@ static void vs_cursor_plane_commit(struct
> > > > vs_dc
> > > > *dc, unsigned int output)
> > > >    			VSDC_CURSOR_CONFIG_IMG_UPDATE);
> > > >    }
> > > >    
> > > > -static void vs_cursor_plane_atomic_enable(struct drm_plane
> > > > *plane,
> > > > -					   struct
> > > > drm_atomic_commit *atomic_state)
> > > > -{
> > > > -	struct drm_plane_state *state =
> > > > drm_atomic_get_new_plane_state(atomic_state,
> > > > -
> > > > 							
> > > > 	       plane);
> > > > -	struct drm_crtc *crtc = state->crtc;
> > > > -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> > > > -	unsigned int output = vcrtc->id;
> > > > -	struct vs_dc *dc = vcrtc->dc;
> > > > -
> > > > -	regmap_update_bits(dc->regs,
> > > > VSDC_CURSOR_CONFIG(output),
> > > > -			   VSDC_CURSOR_CONFIG_FMT_MASK,
> > > > -			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
> > > > -
> > > > -	vs_cursor_plane_commit(dc, output);
> > > > -}
> > > > -
> > > >    static void vs_cursor_plane_atomic_disable(struct drm_plane
> > > > *plane,
> > > >    					    struct
> > > > drm_atomic_commit *atomic_state)
> > > >    {
> > > > @@ -153,6 +136,10 @@ static void
> > > > vs_cursor_plane_atomic_update(struct drm_plane *plane,
> > > >    	output = vcrtc->id;
> > > >    	dc = vcrtc->dc;
> > > >    
> > > > +	regmap_update_bits(dc->regs,
> > > > VSDC_CURSOR_CONFIG(output),
> > > > +			   VSDC_CURSOR_CONFIG_FMT_MASK,
> > > > +			   VSDC_CURSOR_CONFIG_FMT_ARGB8888);
> > > > +
> > > >    	/* Other sizes should be rejected by atomic_check */
> > > >    	switch (state->crtc_w) {
> > > >    	case 32:
> > > > @@ -225,7 +212,6 @@ static void
> > > > vs_cursor_plane_atomic_update(struct drm_plane *plane,
> > > >    static const struct drm_plane_helper_funcs
> > > > vs_cursor_plane_helper_funcs = {
> > > >    	.atomic_check	= vs_cursor_plane_atomic_check,
> > > >    	.atomic_update	= vs_cursor_plane_atomic_update,
> > > > -	.atomic_enable	= vs_cursor_plane_atomic_enable,
> > > >    	.atomic_disable	=
> > > > vs_cursor_plane_atomic_disable,
> > > But now you have the worst of both worlds: atomic_disable is
> > > still
> > > around but also done by atomic_update. And atomic_update always
> > > sets
> > > these registers even if the plane is already visible.
> > > 
> > > I'd instead remove the disable calls from atomic_update [1] . I
> > > think
> > > you should never reach this is you have an atomic_disable
> > > installed.
> > > See
> > > [1] for the logic.
> > The drm_atomic_plane_disabling() function only checks whether a
> > CRTC is
> > bound -- I think it could be possible that a plane is bound to a
> > CRTC
> > but with an invisible coordinate (especially for the cursor plane).
> 
> Sure, but is that a problem for this hardware?

For the cursor plane, the unchecked coordinate might be improper for
the registers.

For the primary plane, if the plane is found to be totally off by
drm_atomic_helper_check_plane_state(), the check for can_position,
which is below the code snippet I referenced, would be bypassed, and
such plane would be programmed to be visible by the atomic_update hook
even if it shouldn't be visible.

Thanks,
Icenowy

> 
> Best regards
> Thomas
> 
> > 
> > The end of drm_atomic_helper_check_plane_state() says:
> > 
> > ```
> > 	if (!plane_state->visible)
> > 		/*
> > 		 * Plane isn't visible; some drivers can handle
> > this
> > 		 * so we just return success here.  Drivers that
> > can't
> > 		 * (including those that use the primary plane
> > helper's
> > 		 * update function) will return an error from
> > their
> > 		 * update_plane handler.
> > 		 */
> > 		return 0;
> > ```
> > 
> > Thanks,
> > Icenowy
> > 
> > > [1]
> > > https://elixir.bootlin.com/linux/v7.3.1/source/drivers/gpu/drm/drm_atomic_helper.c#L3030
> > > 
> > > Best regards
> > > Thomas
> > > 
> > > >    };
> > > >    
> > > > diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > > > b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > > > index 8e94491693019..fca692f4f7d5c 100644
> > > > --- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > > > +++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
> > > > @@ -59,25 +59,6 @@ static void vs_primary_plane_commit(struct
> > > > vs_dc
> > > > *dc, unsigned int output)
> > > >    			VSDC_FB_CONFIG_EX_COMMIT);
> > > >    }
> > > >    
> > > > -static void vs_primary_plane_atomic_enable(struct drm_plane
> > > > *plane,
> > > > -					   struct
> > > > drm_atomic_commit *atomic_state)
> > > > -{
> > > > -	struct drm_plane_state *state =
> > > > drm_atomic_get_new_plane_state(atomic_state,
> > > > -
> > > > 							
> > > > 	       plane);
> > > > -	struct drm_crtc *crtc = state->crtc;
> > > > -	struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
> > > > -	unsigned int output = vcrtc->id;
> > > > -	struct vs_dc *dc = vcrtc->dc;
> > > > -
> > > > -	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> > > > -			VSDC_FB_CONFIG_EX_FB_EN);
> > > > -	regmap_update_bits(dc->regs,
> > > > VSDC_FB_CONFIG_EX(output),
> > > > -			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
> > > > -			  
> > > > VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
> > > > -
> > > > -	vs_primary_plane_commit(dc, output);
> > > > -}
> > > > -
> > > >    static void vs_primary_plane_atomic_disable(struct drm_plane
> > > > *plane,
> > > >    					    struct
> > > > drm_atomic_commit *atomic_state)
> > > >    {
> > > > @@ -144,13 +125,18 @@ static void
> > > > vs_primary_plane_atomic_update(struct drm_plane *plane,
> > > >    	regmap_write(dc->regs, VSDC_FB_BLEND_CONFIG(output),
> > > >    		     VSDC_FB_BLEND_CONFIG_BLEND_DISABLE);
> > > >    
> > > > +	regmap_set_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
> > > > +			VSDC_FB_CONFIG_EX_FB_EN);
> > > > +	regmap_update_bits(dc->regs,
> > > > VSDC_FB_CONFIG_EX(output),
> > > > +			   VSDC_FB_CONFIG_EX_DISPLAY_ID_MASK,
> > > > +			  
> > > > VSDC_FB_CONFIG_EX_DISPLAY_ID(output));
> > > > +
> > > >    	vs_primary_plane_commit(dc, output);
> > > >    }
> > > >    
> > > >    static const struct drm_plane_helper_funcs
> > > > vs_primary_plane_helper_funcs = {
> > > >    	.atomic_check	= vs_primary_plane_atomic_check,
> > > >    	.atomic_update	= vs_primary_plane_atomic_update,
> > > > -	.atomic_enable	= vs_primary_plane_atomic_enable,
> > > >    	.atomic_disable	=
> > > > vs_primary_plane_atomic_disable,
> > > >    };
> > > >    


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

end of thread, other threads:[~2026-11-16 15:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02  7:57 [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng
2026-11-02  7:57 ` [PATCH v2 1/4] drm/verisilicon: disable the output before enabling it Icenowy Zheng
2026-11-02  7:57 ` [PATCH v2 2/4] drm/verisilicon: nuke planes' atomic_enable hooks Icenowy Zheng
2026-11-16 13:37   ` Thomas Zimmermann
2026-11-16 15:11     ` Icenowy Zheng
2026-11-16 15:20       ` Thomas Zimmermann
2026-11-16 15:25         ` Icenowy Zheng
2026-11-02  7:57 ` [PATCH v2 3/4] drm/verisilicon: fix DC8200 primary plane disable clearing FB_EN Icenowy Zheng
2026-11-02  7:57 ` [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable Icenowy Zheng
2026-11-16 13:42   ` Thomas Zimmermann
2026-11-12  7:46 ` [PATCH v2 0/4] drm/verisilicon: misc fixes Icenowy Zheng

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

all inboxes | Powered by JetHome®