Commit c3b14760 authored by Matthew Auld's avatar Matthew Auld
Browse files

drm/i915: drop the __i915_active_call pointer packing



We use some of the lower bits of the retire function pointer for
potential flags, which is quite thorny, since the caller needs to
remember to give the function the correct alignment with
__i915_active_call, otherwise we might incorrectly unpack the pointer
and jump to some garbage address later. Instead of all this let's just
pass the flags along as a separate parameter.

Suggested-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Suggested-by: default avatarDaniel Vetter <daniel@ffwll.ch>
References: ca419f40 ("drm/i915: Fix crash in auto_retire")
References: d8e44e4d ("drm/i915/overlay: Fix active retire callback alignment")
References: fd5f262d ("drm/i915/selftests: Fix active retire callback alignment")
Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20210504164136.96456-1-matthew.auld@intel.com
parent 0a46be95
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -206,7 +206,6 @@ static int frontbuffer_active(struct i915_active *ref)
	return 0;
}

__i915_active_call
static void frontbuffer_retire(struct i915_active *ref)
{
	struct intel_frontbuffer *front =
@@ -261,7 +260,8 @@ intel_frontbuffer_get(struct drm_i915_gem_object *obj)
	atomic_set(&front->bits, 0);
	i915_active_init(&front->write,
			 frontbuffer_active,
			 i915_active_may_sleep(frontbuffer_retire));
			 frontbuffer_retire,
			 I915_ACTIVE_RETIRE_SLEEPS);

	spin_lock(&i915->fb_tracking.lock);
	if (rcu_access_pointer(obj->frontbuffer)) {
+2 −3
Original line number Diff line number Diff line
@@ -383,8 +383,7 @@ static void intel_overlay_off_tail(struct intel_overlay *overlay)
		i830_overlay_clock_gating(dev_priv, true);
}

__i915_active_call static void
intel_overlay_last_flip_retire(struct i915_active *active)
static void intel_overlay_last_flip_retire(struct i915_active *active)
{
	struct intel_overlay *overlay =
		container_of(active, typeof(*overlay), last_flip);
@@ -1399,7 +1398,7 @@ void intel_overlay_setup(struct drm_i915_private *dev_priv)
	overlay->saturation = 146;

	i915_active_init(&overlay->last_flip,
			 NULL, intel_overlay_last_flip_retire);
			 NULL, intel_overlay_last_flip_retire, 0);

	ret = get_registers(overlay, OVERLAY_NEEDS_PHYSICAL(dev_priv));
	if (ret)
+1 −2
Original line number Diff line number Diff line
@@ -1046,7 +1046,6 @@ struct context_barrier_task {
	void *data;
};

__i915_active_call
static void cb_retire(struct i915_active *base)
{
	struct context_barrier_task *cb = container_of(base, typeof(*cb), base);
@@ -1080,7 +1079,7 @@ static int context_barrier_task(struct i915_gem_context *ctx,
	if (!cb)
		return -ENOMEM;

	i915_active_init(&cb->base, NULL, cb_retire);
	i915_active_init(&cb->base, NULL, cb_retire, 0);
	err = i915_active_acquire(&cb->base);
	if (err) {
		kfree(cb);
+1 −1
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ static struct i915_vma *pd_vma_create(struct gen6_ppgtt *ppgtt, int size)
	if (!vma)
		return ERR_PTR(-ENOMEM);

	i915_active_init(&vma->active, NULL, NULL);
	i915_active_init(&vma->active, NULL, NULL, 0);

	kref_init(&vma->ref);
	mutex_init(&vma->pages_mutex);
+1 −2
Original line number Diff line number Diff line
@@ -326,7 +326,6 @@ void intel_context_unpin(struct intel_context *ce)
	intel_context_put(ce);
}

__i915_active_call
static void __intel_context_retire(struct i915_active *active)
{
	struct intel_context *ce = container_of(active, typeof(*ce), active);
@@ -385,7 +384,7 @@ intel_context_init(struct intel_context *ce, struct intel_engine_cs *engine)
	mutex_init(&ce->pin_mutex);

	i915_active_init(&ce->active,
			 __intel_context_active, __intel_context_retire);
			 __intel_context_active, __intel_context_retire, 0);
}

void intel_context_fini(struct intel_context *ce)
Loading