On 21/04/16 13:04, Tvrtko Ursulin wrote:
From: Tvrtko Ursulin <[email protected]>

Can use the new vma->is_gtt to simplify the check and
get rid of the local variables.

Signed-off-by: Tvrtko Ursulin <[email protected]>
---
  drivers/gpu/drm/i915/i915_gem.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 135e1e9c40c2..c5ca53d2e35d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -5275,12 +5275,10 @@ bool i915_gem_obj_bound(struct drm_i915_gem_object *o,
  bool i915_gem_obj_ggtt_bound_view(struct drm_i915_gem_object *o,
                                  const struct i915_ggtt_view *view)
  {
-       struct drm_i915_private *dev_priv = to_i915(o->base.dev);
-       struct i915_ggtt *ggtt = &dev_priv->ggtt;
        struct i915_vma *vma;

        list_for_each_entry(vma, &o->vma_list, obj_link)
-               if (vma->vm == &ggtt->base &&
+               if (vma->is_ggtt &&
                    i915_ggtt_view_equal(&vma->ggtt_view, view) &&
                    drm_mm_node_allocated(&vma->node))
                        return true;


For patches 2-4,
Reviewed-by: Dave Gordon <[email protected]>

As these three all now contain
        if (vma->is_ggtt &&
            i915_ggtt_view_equal(&vma->ggtt_view, view)
            ...
and these are the ONLY three uses of i915_ggtt_view_equal(), perhaps
the latter could be deleted from the header file and replaced by a local (static) inline that encapsulates the is_ggtt test as well?

The Cocci script below found one more candidate for updating:

--- drivers/gpu/drm/i915/i915_gem_gtt.c
+++ cocci-output-24681-2f2e3b-i915_gem_gtt.c
@@ -3255,7 +3255,7 @@ void i915_gem_restore_gtt_mappings(struc
        list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
                flush = false;
                list_for_each_entry(vma, &obj->vma_list, obj_link) {
-                       if (vma->vm != &ggtt->base)
+                       if (!vma->is_ggtt)
                                continue;

Cocci:
@is_ggtt@
  idexpression struct i915_ggtt *GGTT;
  idexpression struct i915_vma *VMA;
@@
  {
    <...
-     VMA->vm == &GGTT->base
+     VMA->is_ggtt
    ...>
  }

@not_ggtt@
  idexpression struct i915_ggtt *GGTT;
  idexpression struct i915_vma *VMA;
@@
  {
    <...
-     VMA->vm != &GGTT->base
+     !VMA->is_ggtt
    ...>
  }

.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to