Skip to contentSkip to conversation

drm/ast: Handle framebuffer from dma-buf

PATCH Applied Jocelyn Falempe 2 participants 3 messages Oct 30, 2025 – Nov 10, 2025

Subsystems (3)
lore
Share & tools
lore

Jocelyn Falempe

author reviewer
#0 lore raw

PATCH v2 1/1 drm/ast: Handle framebuffer from dma-buf

In the atomic update callback, ast should call drm_gem_fb_begin_cpu_access() to make sure it can read the framebuffer from the CPU, otherwise the data might not be there due to cache, and synchronization.

Tested on a Lenovo SE100, while rendering on the ArrowLake GPU with i915 driver, and using ast for display.

---

v2:
* If begin_cpu_access() failed, skip the damage copy, but update the pitch register (Thomas Zimmermann)

 drivers/gpu/drm/ast/ast_mode.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +8 -3
index 9ce874dba69c..77d6c2dcfc40 100644
@@ -556,9 +556,14 @@ static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane,
 		ast_set_vbios_color_reg(ast, fb->format, ast_crtc_state->vmode);
 	}
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
-	drm_atomic_for_each_plane_damage(&iter, &damage) {
-		ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+	/* if the buffer comes from another device */
+	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
+		drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+		drm_atomic_for_each_plane_damage(&iter, &damage) {
+			ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+		}
+
+		drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
 	}
 
 	/*

base-commit: 4f9ffd2c80a2fa09dcc8dfa0482cb7e0fb6fcf6c

Signature · 1 line
2.51.0
maintainer Reviewed-by on v2 1/1
#1 lore raw

Am 30.10.25 um 10:14 schrieb Jocelyn Falempe:

Quoted 10 lines

In the atomic update callback, ast should call drm_gem_fb_begin_cpu_access() to make sure it can read the framebuffer from the CPU, otherwise the data might not be there due to cache, and synchronization.

Tested on a Lenovo SE100, while rendering on the ArrowLake GPU with i915 driver, and using ast for display.

Quoted 33 lines

---

v2:
* If begin_cpu_access() failed, skip the damage copy, but update the pitch register (Thomas Zimmermann)

  drivers/gpu/drm/ast/ast_mode.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +8 -3
index 9ce874dba69c..77d6c2dcfc40 100644
@@ -556,9 +556,14 @@ static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane,
  		ast_set_vbios_color_reg(ast, fb->format, ast_crtc_state->vmode);
  	}
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
-	drm_atomic_for_each_plane_damage(&iter, &damage) {
-		ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+	/* if the buffer comes from another device */
+	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
+		drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+		drm_atomic_for_each_plane_damage(&iter, &damage) {
+			ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+		}
+
+		drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
  	}
 
  	/*

base-commit: 4f9ffd2c80a2fa09dcc8dfa0482cb7e0fb6fcf6c

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
author reviewer Applied
#2 lore raw
In reply to Jocelyn Falempe
Quoted 7 lines · Jocelyn Falempe

In the atomic update callback, ast should call drm_gem_fb_begin_cpu_access() to make sure it can read the framebuffer from the CPU, otherwise the data might not be there due to cache, and synchronization.

Tested on a Lenovo SE100, while rendering on the ArrowLake GPU with i915 driver, and using ast for display.

Pushed to drm-misc-next, thanks.

Signature · 1 line
Jocelyn
Quoted 36 lines

---

v2:
* If begin_cpu_access() failed, skip the damage copy, but update the pitch register (Thomas Zimmermann)

  drivers/gpu/drm/ast/ast_mode.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +8 -3
index 9ce874dba69c..77d6c2dcfc40 100644
@@ -556,9 +556,14 @@ static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane,
  		ast_set_vbios_color_reg(ast, fb->format, ast_crtc_state->vmode);
  	}
 
-	drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
-	drm_atomic_for_each_plane_damage(&iter, &damage) {
-		ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+	/* if the buffer comes from another device */
+	if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) == 0) {
+		drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state);
+		drm_atomic_for_each_plane_damage(&iter, &damage) {
+			ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage);
+		}
+
+		drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE);
  	}
 
  	/*

base-commit: 4f9ffd2c80a2fa09dcc8dfa0482cb7e0fb6fcf6c