Commit 4dfb9706 authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/ast: Wrap cursor framebuffer access in drm_gem_fb_begin/end_cpu_access()



Call drm_gem_fb_begin_cpu_access() and drm_gem_fb_end_cpu_access()
around cursor image updates. Imported buffers might have to be
synchronized for CPU access before they can be used.

Ignore errors from drm_gem_fb_begin_cpu_access(). These errors can
often be transitory. The cursor image will be updated on the next
frame. Meanwhile display a white square where the cursor would be.

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com&gt;>
Link: https://patch.msgid.link/20251126094626.41985-4-tzimmermann@suse.de
parent ef4ed862
Loading
Loading
Loading
Loading
+43 −31
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <drm/drm_damage_helper.h>
#include <drm/drm_format_helper.h>
#include <drm/drm_gem_atomic_helper.h>
#include <drm/drm_gem_framebuffer_helper.h>
#include <drm/drm_print.h>

#include "ast_drv.h"
@@ -189,6 +190,7 @@ static const u8 *ast_cursor_plane_get_argb4444(struct ast_cursor_plane *ast_curs
	struct drm_framebuffer *fb = plane_state->fb;
	u8 *argb4444 = NULL;

	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
		switch (fb->format->format) {
		case DRM_FORMAT_ARGB4444:
			if (shadow_plane_state->data[0].is_iomem) {
@@ -223,6 +225,16 @@ static const u8 *ast_cursor_plane_get_argb4444(struct ast_cursor_plane *ast_curs
			break;
		}

		drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
	} else {
		/*
		 * Fall back to white square if GEM object is not ready. Gives
		 * the user an indication where the cursor is located.
		 */
		memset(ast_cursor_plane->argb4444, 0xff, sizeof(ast_cursor_plane->argb4444));
		argb4444 = ast_cursor_plane->argb4444;
	}

	return argb4444;
}