Commit 71e51ca8 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915: Lift i915_vma_parked() onto the gt



Currently even though i915_vma_parked() operates on a per-gt struct, it
is called from a global pm notify. This oddity was only because the long
term plan is to decouple the vma cache from the pm notification, but
right now the oddity stands out like a sore thumb!

Suggested-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191021183236.21790-1-chris@chris-wilson.co.uk
parent b5e8e954
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ static int pm_notifier(struct notifier_block *nb,
		break;

	case INTEL_GT_PARK:
		i915_vma_parked(i915);
		break;
	}

+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ static int __gt_park(struct intel_wakeref *wf)
	pm_notify(gt, INTEL_GT_PARK);
	intel_gt_park_requests(gt);

	i915_vma_parked(gt);
	i915_pmu_gt_parked(i915);
	if (INTEL_GEN(i915) >= 6)
		gen6_rps_idle(i915);
+16 −16
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ vma_create(struct drm_i915_gem_object *obj,
	struct rb_node *rb, **p;

	/* The aliasing_ppgtt should never be used directly! */
	GEM_BUG_ON(vm == &vm->i915->ggtt.alias->vm);
	GEM_BUG_ON(vm == &vm->gt->ggtt->alias->vm);

	vma = i915_vma_alloc();
	if (vma == NULL)
@@ -412,7 +412,7 @@ void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
	int err;

	/* Access through the GTT requires the device to be awake. */
	assert_rpm_wakelock_held(&vma->vm->i915->runtime_pm);
	assert_rpm_wakelock_held(vma->vm->gt->uncore->rpm);
	if (GEM_WARN_ON(!i915_vma_is_map_and_fenceable(vma))) {
		err = -ENODEV;
		goto err;
@@ -945,7 +945,7 @@ err_pages:

void i915_vma_close(struct i915_vma *vma)
{
	struct drm_i915_private *i915 = vma->vm->i915;
	struct intel_gt *gt = vma->vm->gt;
	unsigned long flags;

	GEM_BUG_ON(i915_vma_is_closed(vma));
@@ -962,18 +962,18 @@ void i915_vma_close(struct i915_vma *vma)
	 * causing us to rebind the VMA once more. This ends up being a lot
	 * of wasted work for the steady state.
	 */
	spin_lock_irqsave(&i915->gt.closed_lock, flags);
	list_add(&vma->closed_link, &i915->gt.closed_vma);
	spin_unlock_irqrestore(&i915->gt.closed_lock, flags);
	spin_lock_irqsave(&gt->closed_lock, flags);
	list_add(&vma->closed_link, &gt->closed_vma);
	spin_unlock_irqrestore(&gt->closed_lock, flags);
}

static void __i915_vma_remove_closed(struct i915_vma *vma)
{
	struct drm_i915_private *i915 = vma->vm->i915;
	struct intel_gt *gt = vma->vm->gt;

	spin_lock_irq(&i915->gt.closed_lock);
	spin_lock_irq(&gt->closed_lock);
	list_del_init(&vma->closed_link);
	spin_unlock_irq(&i915->gt.closed_lock);
	spin_unlock_irq(&gt->closed_lock);
}

void i915_vma_reopen(struct i915_vma *vma)
@@ -1009,12 +1009,12 @@ void i915_vma_destroy(struct i915_vma *vma)
	i915_vma_free(vma);
}

void i915_vma_parked(struct drm_i915_private *i915)
void i915_vma_parked(struct intel_gt *gt)
{
	struct i915_vma *vma, *next;

	spin_lock_irq(&i915->gt.closed_lock);
	list_for_each_entry_safe(vma, next, &i915->gt.closed_vma, closed_link) {
	spin_lock_irq(&gt->closed_lock);
	list_for_each_entry_safe(vma, next, &gt->closed_vma, closed_link) {
		struct drm_i915_gem_object *obj = vma->obj;
		struct i915_address_space *vm = vma->vm;

@@ -1028,7 +1028,7 @@ void i915_vma_parked(struct drm_i915_private *i915)
			obj = NULL;
		}

		spin_unlock_irq(&i915->gt.closed_lock);
		spin_unlock_irq(&gt->closed_lock);

		if (obj) {
			i915_vma_destroy(vma);
@@ -1038,11 +1038,11 @@ void i915_vma_parked(struct drm_i915_private *i915)
		i915_vm_close(vm);

		/* Restart after dropping lock */
		spin_lock_irq(&i915->gt.closed_lock);
		next = list_first_entry(&i915->gt.closed_vma,
		spin_lock_irq(&gt->closed_lock);
		next = list_first_entry(&gt->closed_vma,
					typeof(*next), closed_link);
	}
	spin_unlock_irq(&i915->gt.closed_lock);
	spin_unlock_irq(&gt->closed_lock);
}

static void __i915_vma_iounmap(struct i915_vma *vma)
+1 −1
Original line number Diff line number Diff line
@@ -462,7 +462,7 @@ i915_vma_unpin_fence(struct i915_vma *vma)
		__i915_vma_unpin_fence(vma);
}

void i915_vma_parked(struct drm_i915_private *i915);
void i915_vma_parked(struct intel_gt *gt);

#define for_each_until(cond) if (cond) break; else