drm/i915: Add function to clear scanout flag for vmas
authorJouni Högander <jouni.hogander@intel.com>
Thu, 27 Jul 2023 06:41:42 +0000 (09:41 +0300)
committerJouni Högander <jouni.hogander@intel.com>
Tue, 1 Aug 2023 05:47:10 +0000 (08:47 +0300)
Currently frontbuffer tracking code is directly iterating over object vmas
and clearing scanout flags for them. Add function to clear scanout flag for
vmas and use it from frontbuffer tracking code.

v2: describe function parameter.

Signed-off-by: Jouni Högander <jouni.hogander@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Nirmoy Das <nirmoy.das@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230727064142.751976-5-jouni.hogander@intel.com
drivers/gpu/drm/i915/display/intel_frontbuffer.c
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/i915_vma.h

index 56f45370fee0d6e06c047f8b72ed9dd0b0237773..22392f94b62677d45f1466a75a2f87f8df8a1fa0 100644 (file)
@@ -226,16 +226,10 @@ static void frontbuffer_release(struct kref *ref)
        struct intel_frontbuffer *front =
                container_of(ref, typeof(*front), ref);
        struct drm_i915_gem_object *obj = front->obj;
-       struct i915_vma *vma;
 
        drm_WARN_ON(&intel_bo_to_i915(obj)->drm, atomic_read(&front->bits));
 
-       spin_lock(&obj->vma.lock);
-       for_each_ggtt_vma(vma, obj) {
-               i915_vma_clear_scanout(vma);
-               vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
-       }
-       spin_unlock(&obj->vma.lock);
+       i915_ggtt_clear_scanout(obj);
 
        i915_gem_object_set_frontbuffer(obj, NULL);
        spin_unlock(&intel_bo_to_i915(obj)->display.fb_tracking.lock);
index e90b9c812180f81a522e8f1f3f2c7c64b186b43e..63e111266de1640e18f83bff54cdcec25da18717 100644 (file)
@@ -1629,6 +1629,26 @@ int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
        return err;
 }
 
+/**
+ * i915_ggtt_clear_scanout - Clear scanout flag for all objects ggtt vmas
+ * @obj: i915 GEM object
+ * This function clears scanout flags for objects ggtt vmas. These flags are set
+ * when object is pinned for display use and this function to clear them all is
+ * targeted to be called by frontbuffer tracking code when the frontbuffer is
+ * about to be released.
+ */
+void i915_ggtt_clear_scanout(struct drm_i915_gem_object *obj)
+{
+       struct i915_vma *vma;
+
+       spin_lock(&obj->vma.lock);
+       for_each_ggtt_vma(vma, obj) {
+               i915_vma_clear_scanout(vma);
+               vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
+       }
+       spin_unlock(&obj->vma.lock);
+}
+
 static void __vma_close(struct i915_vma *vma, struct intel_gt *gt)
 {
        /*
index 9a9729205d5be6c8eeaf4a73a33c1cf1b3fffdab..eaa31086437001664b057fdf68cf2b8ed55293f9 100644 (file)
@@ -435,6 +435,8 @@ static inline void i915_vma_clear_scanout(struct i915_vma *vma)
        clear_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
 }
 
+void i915_ggtt_clear_scanout(struct drm_i915_gem_object *obj);
+
 #define for_each_until(cond) if (cond) break; else
 
 /**