Call drm_gem_fb_begin_cpu_access() and drm_gem_fb_end_cpu_access() in the simple pipe's {begin,end}_fb_access helpers. This allows to abort commits correctly after observing an error. Remove the corresponding CPU-access calls from the driver's damage handler. It runs during the atomic-apply phase when it's already too late to handle errors. Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> --- drivers/gpu/drm/tiny/repaper.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c index e62f4d16b2c6b..e0f1ac8ab2186 100644 --- a/drivers/gpu/drm/tiny/repaper.c +++ b/drivers/gpu/drm/tiny/repaper.c @@ -539,10 +539,6 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb) goto out_exit; } - ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); - if (ret) - goto out_free; - iosys_map_set_vaddr(&dst, buf); iosys_map_set_vaddr(&vmap, dma_obj->vaddr); drm_fb_xrgb8888_to_mono(&dst, &dst_pitch, &vmap, fb, &clip); @@ -596,8 +592,6 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb) } } -out_free: - kfree(buf); out_exit: drm_dev_exit(idx); @@ -839,11 +833,35 @@ static void repaper_pipe_update(struct drm_simple_display_pipe *pipe, repaper_fb_dirty(state->fb); } +static int repaper_pipe_begin_fb_access(struct drm_simple_display_pipe *pipe, + struct drm_plane_state *plane_state) +{ + struct drm_framebuffer *fb = plane_state->fb; + + if (!fb) + return 0; + + return drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); +} + +static void repaper_pipe_end_fb_access(struct drm_simple_display_pipe *pipe, + struct drm_plane_state *plane_state) +{ + struct drm_framebuffer *fb = plane_state->fb; + + if (!fb) + return; + + drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); +} + static const struct drm_simple_display_pipe_funcs repaper_pipe_funcs = { .mode_valid = repaper_pipe_mode_valid, .enable = repaper_pipe_enable, .disable = repaper_pipe_disable, .update = repaper_pipe_update, + .begin_fb_access = repaper_pipe_begin_fb_access, + .end_fb_access = repaper_pipe_end_fb_access, }; static int repaper_connector_get_modes(struct drm_connector *connector) -- 2.38.0