Skip to contentSkip to conversation

Frontbuffer tracking and dirtyfb

PATCH Superseded Jouni Högander 2 participants 6 messages Oct 2, 2023

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Frontbuffer tracking and dirtyfb

Generic dirtyfb implementation which Xe is currently using is doing atomic commit which is inefficient. We have now dma fence handling in our dirtyfb implementation. This works with Xe and CPU/GPU frontbuffer rendering as long as sync objects are imported by userspace (dma_buf_import_sync_file).

v2: rebased

Cc Maarten Lankhorst <[email protected]>
Cc Jani Nikula <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Uma Shankar <[email protected]>

Jouni Högander (4):
fixup! drm/xe: Add empty def for i915_gem_object_flush_if_display Revert "FIXME: drm/i915: More display ugly wa needed after rebase" drm/i915/display: Use intel_bo_to_drm_bo instead of obj->base fixup! FIXME: drm/i915/display: Remaining changes to make xe compile

 drivers/gpu/drm/i915/display/intel_fb.c                | 10 ++--------
 drivers/gpu/drm/i915/display/intel_frontbuffer.c       |  2 --
 .../gem/i915_gem_object_frontbuffer.h                  |  1 -
 drivers/gpu/drm/xe/xe_bo.h                             |  2 ++
 4 files changed, 4 insertions(+), 11 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/4 fixup! drm/xe: Add empty def for i915_gem_object_flush_if_display

---
 .../xe/compat-i915-headers/gem/i915_gem_object_frontbuffer.h    | 1 -
 drivers/gpu/drm/xe/xe_bo.h                                      | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object_frontbuffer.h +0 -1
index 2361a6313308..227965e5f784 100644
@@ -8,6 +8,5 @@
 
 #define i915_gem_object_get_frontbuffer(obj)		NULL
 #define i915_gem_object_set_frontbuffer(obj, front)	(front)
-#define i915_gem_object_flush_if_display(obj)		((void)(obj))
 
 #endif
drivers/gpu/drm/xe/xe_bo.h +2 -0
index 5090bdd1e462..e5e8173433c3 100644
@@ -316,6 +316,8 @@ static inline unsigned int xe_sg_segment_size(struct device *dev)
 	return round_down(max / 2, PAGE_SIZE);
 }
 
+#define i915_gem_object_flush_if_display(obj)		((void)(obj))
+
 #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
 /**
  * xe_bo_is_mem_type - Whether the bo currently resides in the given
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/4 Revert "FIXME: drm/i915: More display ugly wa needed after rebase"

In reply to Jouni Högander

This reverts commit 4bf10efdff69a34bfa55813593bfecbf6f5d6db9.

We have now emtpy define for i915_gem_object_flush_if_display about to enable custom dirtyfb for Xe as well.

---
 drivers/gpu/drm/i915/display/intel_fb.c          | 2 +-
 drivers/gpu/drm/i915/display/intel_frontbuffer.c | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_fb.c +1 -1
index 961fa778ba88..abca5a3652d4 100644
@@ -1939,7 +1939,6 @@ struct frontbuffer_fence_cb {
 	struct intel_frontbuffer *front;
 };
 
-#ifdef I915
 static void intel_user_framebuffer_fence_wake(struct dma_fence *dma,
 					      struct dma_fence_cb *data)
 {
@@ -1950,6 +1949,7 @@ static void intel_user_framebuffer_fence_wake(struct dma_fence *dma,
 	dma_fence_put(dma);
 }
 
+#ifdef I915
 static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
 					struct drm_file *file,
 					unsigned int flags, unsigned int color,
drivers/gpu/drm/i915/display/intel_frontbuffer.c +0 -2
index b80cf8fb1c97..d64ce5bfeca8 100644
@@ -209,9 +209,7 @@ static void intel_frontbuffer_flush_work(struct work_struct *work)
 	struct intel_frontbuffer *front =
 		container_of(work, struct intel_frontbuffer, flush_work);
 
-#ifdef I915
 	i915_gem_object_flush_if_display(front->obj);
-#endif
 	intel_frontbuffer_flush(front, ORIGIN_DIRTYFB);
 	intel_frontbuffer_put(front);
 }
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/4 drm/i915/display: Use intel_bo_to_drm_bo instead of obj->base

In reply to Jouni Högander

Xe and i915 objects have differing implementation. Use intel_bo_to_drm_bo instead of obj->base as xe_bo doesn't have base pointer.

---
 drivers/gpu/drm/i915/display/intel_fb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_fb.c +2 -2
index abca5a3652d4..6aa1a6ac0728 100644
@@ -1965,10 +1965,10 @@ static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
 	if (!atomic_read(&front->bits))
 		return 0;
 
-	if (dma_resv_test_signaled(obj->base.resv, dma_resv_usage_rw(false)))
+	if (dma_resv_test_signaled(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false)))
 		goto flush;
 
-	ret = dma_resv_get_singleton(obj->base.resv, dma_resv_usage_rw(false),
+	ret = dma_resv_get_singleton(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false),
 				     &fence);
 	if (ret || !fence)
 		goto flush;
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 4/4 fixup! FIXME: drm/i915/display: Remaining changes to make xe compile

In reply to Jouni Högander

Generic dirtyfb implementation which Xe is currently using is doing atomic commit which is inefficient. We have now dma fence handling in our dirtyfb implementation. This works with Xe and CPU/GPU frontbuffer rendering as long as sync objects are imported by userspace (dma_buf_import_sync_file). Switch to our custom dirtyfb implementation.

---
 drivers/gpu/drm/i915/display/intel_fb.c | 6 ------
 1 file changed, 6 deletions(-)
drivers/gpu/drm/i915/display/intel_fb.c +0 -6
index 6aa1a6ac0728..fd0b978dbef9 100644
@@ -1949,7 +1949,6 @@ static void intel_user_framebuffer_fence_wake(struct dma_fence *dma,
 	dma_fence_put(dma);
 }
 
-#ifdef I915
 static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
 					struct drm_file *file,
 					unsigned int flags, unsigned int color,
@@ -1999,16 +1998,11 @@ static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
 	intel_frontbuffer_flush(front, ORIGIN_DIRTYFB);
 	return ret;
 }
-#endif
 
 static const struct drm_framebuffer_funcs intel_fb_funcs = {
 	.destroy = intel_user_framebuffer_destroy,
 	.create_handle = intel_user_framebuffer_create_handle,
-#ifdef I915
 	.dirty = intel_user_framebuffer_dirty,
-#else
-	.dirty = drm_atomic_helper_dirtyfb,
-#endif
 };
 
 int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
Signature · 1 line
2.34.1
#5 lore raw

[Intel-xe] ✗ CI.Patch_applied: failure for Frontbuffer tracking and dirtyfb (rev2)

In reply to Jouni Högander
== Series Details ==

== Series Details ==

Series: Frontbuffer tracking and dirtyfb (rev2)
URL : https://patchwork.freedesktop.org/series/123751/
State : failure

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: ===
Base commit: 22fcf2404 drm/xe: timeout needs to be a signed value
=== git am output follows ===
error: patch failed: drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object_frontbuffer.h:8
error: drivers/gpu/drm/xe/compat-i915-headers/gem/i915_gem_object_frontbuffer.h: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch
Applying: fixup! drm/xe: Add empty def for i915_gem_object_flush_if_display
Patch failed at 0001 fixup! drm/xe: Add empty def for i915_gem_object_flush_if_display When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".