drm/i915: Rename obj->pin_display to obj->pin_global
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 13 Oct 2017 20:26:14 +0000 (21:26 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Mon, 16 Oct 2017 19:44:19 +0000 (20:44 +0100)
In the next patch, we want to extend use of the global pin counter for
semi-permanent pinning of context/ring objects. Given that we plan to
extend the usage to encompass a disparate set of objects, we want a name
that reflects both and should entail less confusion.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171013202621.7276-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/i915_debugfs.c
drivers/gpu/drm/i915/i915_gem.c
drivers/gpu/drm/i915/i915_gem_object.h
drivers/gpu/drm/i915/i915_gem_userptr.c

index 0bb6e01121fcf9a8156314149e93a1ecdc6183c1..fb9b343028118297c1b1a7ac35f66fe1d1bccc55 100644 (file)
@@ -83,7 +83,7 @@ static char get_active_flag(struct drm_i915_gem_object *obj)
 
 static char get_pin_flag(struct drm_i915_gem_object *obj)
 {
-       return obj->pin_display ? 'p' : ' ';
+       return obj->pin_global ? 'p' : ' ';
 }
 
 static char get_tiling_flag(struct drm_i915_gem_object *obj)
@@ -180,8 +180,8 @@ describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
                        pin_count++;
        }
        seq_printf(m, " (pinned x %d)", pin_count);
-       if (obj->pin_display)
-               seq_printf(m, " (display)");
+       if (obj->pin_global)
+               seq_printf(m, " (global)");
        list_for_each_entry(vma, &obj->vma_list, obj_link) {
                if (!drm_mm_node_allocated(&vma->node))
                        continue;
@@ -481,7 +481,7 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
                size += obj->base.size;
                ++count;
 
-               if (obj->pin_display) {
+               if (obj->pin_global) {
                        dpy_size += obj->base.size;
                        ++dpy_count;
                }
@@ -512,7 +512,7 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
                   huge_count,
                   stringify_page_sizes(page_sizes, buf, sizeof(buf)),
                   huge_size);
-       seq_printf(m, "%u display objects (pinned), %llu bytes\n",
+       seq_printf(m, "%u display objects (globally pinned), %llu bytes\n",
                   dpy_count, dpy_size);
 
        seq_printf(m, "%llu [%llu] gtt total\n",
@@ -579,7 +579,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
 
        total_obj_size = total_gtt_size = count = 0;
        list_for_each_entry(obj, &dev_priv->mm.bound_list, global_link) {
-               if (show_pin_display_only && !obj->pin_display)
+               if (show_pin_display_only && !obj->pin_global)
                        continue;
 
                seq_puts(m, "   ");
index 05907171505337f6bb662155bf588592c32da5da..1f66a6168444e3d1f5cbdfbcdc8910f731f58caa 100644 (file)
@@ -56,7 +56,7 @@ static bool cpu_write_needs_clflush(struct drm_i915_gem_object *obj)
        if (!(obj->cache_coherent & I915_BO_CACHE_COHERENT_FOR_WRITE))
                return true;
 
-       return obj->pin_display;
+       return obj->pin_global; /* currently in use by HW, keep flushed */
 }
 
 static int
@@ -3493,7 +3493,7 @@ static void __i915_gem_object_flush_for_display(struct drm_i915_gem_object *obj)
 
 void i915_gem_object_flush_if_display(struct drm_i915_gem_object *obj)
 {
-       if (!READ_ONCE(obj->pin_display))
+       if (!READ_ONCE(obj->pin_global))
                return;
 
        mutex_lock(&obj->base.dev->struct_mutex);
@@ -3860,10 +3860,10 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 
        lockdep_assert_held(&obj->base.dev->struct_mutex);
 
-       /* Mark the pin_display early so that we account for the
+       /* Mark the global pin early so that we account for the
         * display coherency whilst setting up the cache domains.
         */
-       obj->pin_display++;
+       obj->pin_global++;
 
        /* The display engine is not coherent with the LLC cache on gen6.  As
         * a result, we make sure that the pinning that is about to occur is
@@ -3879,7 +3879,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
                                              I915_CACHE_WT : I915_CACHE_NONE);
        if (ret) {
                vma = ERR_PTR(ret);
-               goto err_unpin_display;
+               goto err_unpin_global;
        }
 
        /* As the user may map the buffer once pinned in the display plane
@@ -3910,7 +3910,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
                vma = i915_gem_object_ggtt_pin(obj, view, 0, alignment, flags);
        }
        if (IS_ERR(vma))
-               goto err_unpin_display;
+               goto err_unpin_global;
 
        vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
 
@@ -3925,8 +3925,8 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
 
        return vma;
 
-err_unpin_display:
-       obj->pin_display--;
+err_unpin_global:
+       obj->pin_global--;
        return vma;
 }
 
@@ -3935,10 +3935,10 @@ i915_gem_object_unpin_from_display_plane(struct i915_vma *vma)
 {
        lockdep_assert_held(&vma->vm->i915->drm.struct_mutex);
 
-       if (WARN_ON(vma->obj->pin_display == 0))
+       if (WARN_ON(vma->obj->pin_global == 0))
                return;
 
-       if (--vma->obj->pin_display == 0)
+       if (--vma->obj->pin_global == 0)
                vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
 
        /* Bump the LRU to try and avoid premature eviction whilst flipping  */
index d67f1cbe842d23aa3c6d318aef60b5a0467d6151..72aa02f3a0f8a03281619f200295335848179999 100644 (file)
@@ -161,7 +161,8 @@ struct drm_i915_gem_object {
        /** Count of VMA actually bound by this object */
        unsigned int bind_count;
        unsigned int active_count;
-       unsigned int pin_display;
+       /** Count of how many global VMA are currently pinned for use by HW */
+       unsigned int pin_global;
 
        struct {
                struct mutex lock; /* protects the pages and their use */
index 9afeb68e2d448edfbf5e2d7610309380163f8546..cdc9be799eeefcdb5f7b09f7dc44b7b84dbffad2 100644 (file)
@@ -83,10 +83,10 @@ static void cancel_userptr(struct work_struct *work)
        if (i915_gem_object_unbind(obj) == 0)
                __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
        WARN_ONCE(i915_gem_object_has_pages(obj),
-                 "Failed to release pages: bind_count=%d, pages_pin_count=%d, pin_display=%d\n",
+                 "Failed to release pages: bind_count=%d, pages_pin_count=%d, pin_global=%d\n",
                  obj->bind_count,
                  atomic_read(&obj->mm.pages_pin_count),
-                 obj->pin_display);
+                 obj->pin_global);
 
        mutex_unlock(&obj->base.dev->struct_mutex);