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 <[email protected]>
---
 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

Reply via email to