The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 2/2] drm/sun4i: layer: stop frontend programming after resume failure
       [not found] <fe6c5928c90337afceaa.1.20261129142251759663@1298662399.qq.com>
@ 2026-11-29 13:05 ` Jiawen Liu
  2026-11-30 18:26   ` Jernej Škrabec
  0 siblings, 1 reply; 3+ messages in thread
From: Jiawen Liu @ 2026-11-29 13:05 UTC (permalink / raw)
  To: Chen-Yu Tsai, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Jernej Skrabec, Samuel Holland
  Cc: dri-devel, linux-arm-kernel, linux-sunxi, linux-kernel

sun4i_backend_layer_atomic_update() ignores a failed
sun4i_frontend_init() and still programs the frontend through MMIO. Now
that the runtime resume callback can report clock and reset failures,
stop the update before touching the frontend.

pm_runtime_get_sync() returns 1 when the device is already active, so
only a negative result is an error. On failure it retains the usage
reference, which the existing deferred-vblank path releases when the
plane is disabled.

Fixes: dd0421f47505 ("drm/sun4i: Add a driver for the display frontend")
Signed-off-by: Jiawen Liu <1298662399@qq.com>
---
 drivers/gpu/drm/sun4i/sun4i_layer.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
index cdfefbeee7b88..384e210d78503 100644
--- a/drivers/gpu/drm/sun4i/sun4i_layer.c
+++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
@@ -84,11 +84,17 @@ static void sun4i_backend_layer_atomic_update(struct drm_plane *plane,
 	struct sun4i_layer *layer = plane_to_sun4i_layer(plane);
 	struct sun4i_backend *backend = layer->backend;
 	struct sun4i_frontend *frontend = backend->frontend;
+	int ret;
 
 	sun4i_backend_cleanup_layer(backend, layer->id);
 
 	if (layer_state->uses_frontend) {
-		sun4i_frontend_init(frontend);
+		ret = sun4i_frontend_init(frontend);
+		if (ret < 0) {
+			dev_err(frontend->dev, "failed to resume frontend: %d\n",
+				ret);
+			return;
+		}
 		sun4i_frontend_update_coord(frontend, plane);
 		sun4i_frontend_update_buffer(frontend, plane);
 		sun4i_frontend_update_formats(frontend, plane,
-- 
2.34.1


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

* Re: [PATCH 2/2] drm/sun4i: layer: stop frontend programming after resume failure
  2026-11-29 13:05 ` [PATCH 2/2] drm/sun4i: layer: stop frontend programming after resume failure Jiawen Liu
@ 2026-11-30 18:26   ` Jernej Škrabec
  2026-11-30 19:54     ` Jiawen Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Jernej Škrabec @ 2026-11-30 18:26 UTC (permalink / raw)
  To: Chen-Yu Tsai, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Samuel Holland, Jiawen Liu
  Cc: dri-devel, linux-arm-kernel, linux-sunxi, linux-kernel

Dne nedelja, 29. november 2026 ob 14:05:07 Srednjeevropski standardni čas je Jiawen Liu napisal(a):
> sun4i_backend_layer_atomic_update() ignores a failed
> sun4i_frontend_init() and still programs the frontend through MMIO. Now
> that the runtime resume callback can report clock and reset failures,
> stop the update before touching the frontend.
> 
> pm_runtime_get_sync() returns 1 when the device is already active, so
> only a negative result is an error. On failure it retains the usage
> reference, which the existing deferred-vblank path releases when the
> plane is disabled.
> 
> Fixes: dd0421f47505 ("drm/sun4i: Add a driver for the display frontend")
> Signed-off-by: Jiawen Liu <1298662399@qq.com>
> ---
>  drivers/gpu/drm/sun4i/sun4i_layer.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_layer.c b/drivers/gpu/drm/sun4i/sun4i_layer.c
> index cdfefbeee7b88..384e210d78503 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_layer.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_layer.c
> @@ -84,11 +84,17 @@ static void sun4i_backend_layer_atomic_update(struct drm_plane *plane,
>  	struct sun4i_layer *layer = plane_to_sun4i_layer(plane);
>  	struct sun4i_backend *backend = layer->backend;
>  	struct sun4i_frontend *frontend = backend->frontend;
> +	int ret;
>  
>  	sun4i_backend_cleanup_layer(backend, layer->id);
>  
>  	if (layer_state->uses_frontend) {
> -		sun4i_frontend_init(frontend);
> +		ret = sun4i_frontend_init(frontend);
> +		if (ret < 0) {
> +			dev_err(frontend->dev, "failed to resume frontend: %d\n",
> +				ret);
> +			return;
> +		}

sun4i_backend_cleanup_layer() above has already cleared LAY_VDOEN, but
returning here skips sun4i_backend_layer_enable(), so if the layer was
enabled in the previous state it stays enabled and the backend starts
fetching directly from whatever the layer framebuffer address registers
still point at, which may be a buffer that's already been released.
Please disable the layer explicitly on this path:

	sun4i_backend_layer_enable(backend, layer->id, false);

Also, atomic_update runs on every commit, and once runtime resume has
failed, subsequent pm_runtime_get_sync() calls keep failing, so this
will print on every frame. Please use dev_err_ratelimited() or
dev_err_once().

Side note, not for this patch: frontend runtime PM refcounting is
unbalanced already (get on every update, put only once on disable), so
the frontend never suspends once used. That deserves a separate fix.

Best regards,
Jernej

>  		sun4i_frontend_update_coord(frontend, plane);
>  		sun4i_frontend_update_buffer(frontend, plane);
>  		sun4i_frontend_update_formats(frontend, plane,
> 





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

* Re: [PATCH 2/2] drm/sun4i: layer: stop frontend programming after resume failure
  2026-11-30 18:26   ` Jernej Škrabec
@ 2026-11-30 19:54     ` Jiawen Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Jiawen Liu @ 2026-11-30 19:54 UTC (permalink / raw)
  To: Jernej Škrabec
  Cc: Chen-Yu Tsai, Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Samuel Holland, dri-devel,
	linux-arm-kernel, linux-sunxi, linux-kernel

Hi Jernej,

Thanks for catching the stale framebuffer case. I'll disable the layer
before returning from the failed frontend init and use
dev_err_ratelimited() so repeated atomic updates don't flood the log.

I'll also correct the commit message. The put on disable doesn't balance
a get on every update. The existing PM refcount issue deserves a
separate fix.

Thanks for the Reviewed-by on 1/2. I'll keep that patch unchanged and
carry your tag. I'll send v2 as one thread with a cover letter.

Thanks,
Jiawen


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

end of thread, other threads:[~2026-11-30 19:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <fe6c5928c90337afceaa.1.20261129142251759663@1298662399.qq.com>
2026-11-29 13:05 ` [PATCH 2/2] drm/sun4i: layer: stop frontend programming after resume failure Jiawen Liu
2026-11-30 18:26   ` Jernej Škrabec
2026-11-30 19:54     ` Jiawen Liu

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