drm/i915: Remove walk over obj->vma_list for the shrinker
In the next patch, we want to reduce the lock coverage within the shrinker, and one of the dangerous walks we have is over obj->vma_list. We are only walking the obj->vma_list in order to check whether it has been permanently pinned by HW access, typically via use on the scanout. But we have a couple of other long term pins, the context objects for which we currently have to check the individual vma pin_count. If we instead mark these using obj->pin_display, we can forgo the dangerous and sometimes slow list iteration. v2: Rearrange code to try and avoid confusion from false associations due to arrangement of whitespace along with rebasing on obj->pin_global. 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-4-chris@chris-wilson.co.uk
This commit is contained in:
@@ -1244,6 +1244,8 @@ int intel_ring_pin(struct intel_ring *ring,
|
||||
if (IS_ERR(addr))
|
||||
goto err;
|
||||
|
||||
vma->obj->pin_global++;
|
||||
|
||||
ring->vaddr = addr;
|
||||
return 0;
|
||||
|
||||
@@ -1275,6 +1277,7 @@ void intel_ring_unpin(struct intel_ring *ring)
|
||||
i915_gem_object_unpin_map(ring->vma->obj);
|
||||
ring->vaddr = NULL;
|
||||
|
||||
ring->vma->obj->pin_global--;
|
||||
i915_vma_unpin(ring->vma);
|
||||
}
|
||||
|
||||
@@ -1439,6 +1442,7 @@ intel_ring_context_pin(struct intel_engine_cs *engine,
|
||||
goto err;
|
||||
|
||||
ce->state->obj->mm.dirty = true;
|
||||
ce->state->obj->pin_global++;
|
||||
}
|
||||
|
||||
/* The kernel context is only used as a placeholder for flushing the
|
||||
@@ -1473,8 +1477,10 @@ static void intel_ring_context_unpin(struct intel_engine_cs *engine,
|
||||
if (--ce->pin_count)
|
||||
return;
|
||||
|
||||
if (ce->state)
|
||||
if (ce->state) {
|
||||
ce->state->obj->pin_global--;
|
||||
i915_vma_unpin(ce->state);
|
||||
}
|
||||
|
||||
i915_gem_context_put(ctx);
|
||||
}
|
||||
|
Reference in New Issue
Block a user