Skip to content

Commit c3b1476

Browse files
committed
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: Ville Syrjälä <[email protected]> Suggested-by: Daniel Vetter <[email protected]> References: ca419f4 ("drm/i915: Fix crash in auto_retire") References: d8e44e4 ("drm/i915/overlay: Fix active retire callback alignment") References: fd5f262 ("drm/i915/selftests: Fix active retire callback alignment") Signed-off-by: Matthew Auld <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Acked-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 0a46be9 commit c3b1476

15 files changed

+28
-41
lines changed

drivers/gpu/drm/i915/display/intel_frontbuffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ static int frontbuffer_active(struct i915_active *ref)
206206
return 0;
207207
}
208208

209-
__i915_active_call
210209
static void frontbuffer_retire(struct i915_active *ref)
211210
{
212211
struct intel_frontbuffer *front =
@@ -261,7 +260,8 @@ intel_frontbuffer_get(struct drm_i915_gem_object *obj)
261260
atomic_set(&front->bits, 0);
262261
i915_active_init(&front->write,
263262
frontbuffer_active,
264-
i915_active_may_sleep(frontbuffer_retire));
263+
frontbuffer_retire,
264+
I915_ACTIVE_RETIRE_SLEEPS);
265265

266266
spin_lock(&i915->fb_tracking.lock);
267267
if (rcu_access_pointer(obj->frontbuffer)) {

drivers/gpu/drm/i915/display/intel_overlay.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ static void intel_overlay_off_tail(struct intel_overlay *overlay)
383383
i830_overlay_clock_gating(dev_priv, true);
384384
}
385385

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

14011400
i915_active_init(&overlay->last_flip,
1402-
NULL, intel_overlay_last_flip_retire);
1401+
NULL, intel_overlay_last_flip_retire, 0);
14031402

14041403
ret = get_registers(overlay, OVERLAY_NEEDS_PHYSICAL(dev_priv));
14051404
if (ret)

drivers/gpu/drm/i915/gem/i915_gem_context.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,6 @@ struct context_barrier_task {
10461046
void *data;
10471047
};
10481048

1049-
__i915_active_call
10501049
static void cb_retire(struct i915_active *base)
10511050
{
10521051
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,
10801079
if (!cb)
10811080
return -ENOMEM;
10821081

1083-
i915_active_init(&cb->base, NULL, cb_retire);
1082+
i915_active_init(&cb->base, NULL, cb_retire, 0);
10841083
err = i915_active_acquire(&cb->base);
10851084
if (err) {
10861085
kfree(cb);

drivers/gpu/drm/i915/gt/gen6_ppgtt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static struct i915_vma *pd_vma_create(struct gen6_ppgtt *ppgtt, int size)
343343
if (!vma)
344344
return ERR_PTR(-ENOMEM);
345345

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

348348
kref_init(&vma->ref);
349349
mutex_init(&vma->pages_mutex);

drivers/gpu/drm/i915/gt/intel_context.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,6 @@ void intel_context_unpin(struct intel_context *ce)
326326
intel_context_put(ce);
327327
}
328328

329-
__i915_active_call
330329
static void __intel_context_retire(struct i915_active *active)
331330
{
332331
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)
385384
mutex_init(&ce->pin_mutex);
386385

387386
i915_active_init(&ce->active,
388-
__intel_context_active, __intel_context_retire);
387+
__intel_context_active, __intel_context_retire, 0);
389388
}
390389

391390
void intel_context_fini(struct intel_context *ce)

drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ void intel_ggtt_init_fences(struct i915_ggtt *ggtt)
867867
for (i = 0; i < num_fences; i++) {
868868
struct i915_fence_reg *fence = &ggtt->fence_regs[i];
869869

870-
i915_active_init(&fence->active, NULL, NULL);
870+
i915_active_init(&fence->active, NULL, NULL, 0);
871871
fence->ggtt = ggtt;
872872
fence->id = i;
873873
list_add_tail(&fence->link, &ggtt->fence_list);

drivers/gpu/drm/i915/gt/intel_gt_buffer_pool.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ static void pool_free_work(struct work_struct *wrk)
9898
round_jiffies_up_relative(HZ));
9999
}
100100

101-
__i915_active_call
102101
static void pool_retire(struct i915_active *ref)
103102
{
104103
struct intel_gt_buffer_pool_node *node =
@@ -154,7 +153,7 @@ node_create(struct intel_gt_buffer_pool *pool, size_t sz,
154153
node->age = 0;
155154
node->pool = pool;
156155
node->pinned = false;
157-
i915_active_init(&node->active, NULL, pool_retire);
156+
i915_active_init(&node->active, NULL, pool_retire, 0);
158157

159158
obj = i915_gem_object_create_internal(gt->i915, sz);
160159
if (IS_ERR(obj)) {

drivers/gpu/drm/i915/gt/intel_timeline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ static struct i915_vma *hwsp_alloc(struct intel_gt *gt)
3232
return vma;
3333
}
3434

35-
__i915_active_call
3635
static void __timeline_retire(struct i915_active *active)
3736
{
3837
struct intel_timeline *tl =
@@ -104,7 +103,8 @@ static int intel_timeline_init(struct intel_timeline *timeline,
104103
INIT_LIST_HEAD(&timeline->requests);
105104

106105
i915_syncmap_init(&timeline->sync);
107-
i915_active_init(&timeline->active, __timeline_active, __timeline_retire);
106+
i915_active_init(&timeline->active, __timeline_active,
107+
__timeline_retire, 0);
108108

109109
return 0;
110110
}

drivers/gpu/drm/i915/gt/mock_engine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static struct intel_ring *mock_ring(struct intel_engine_cs *engine)
5555
kfree(ring);
5656
return NULL;
5757
}
58-
i915_active_init(&ring->vma->active, NULL, NULL);
58+
i915_active_init(&ring->vma->active, NULL, NULL, 0);
5959
__set_bit(I915_VMA_GGTT_BIT, __i915_vma_flags(ring->vma));
6060
__set_bit(DRM_MM_NODE_ALLOCATED_BIT, &ring->vma->node.flags);
6161
ring->vma->node.size = sz;

drivers/gpu/drm/i915/gt/selftest_engine_heartbeat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void pulse_put(struct pulse *p)
6363
kref_put(&p->kref, pulse_free);
6464
}
6565

66-
__i915_active_call static void pulse_retire(struct i915_active *active)
66+
static void pulse_retire(struct i915_active *active)
6767
{
6868
pulse_put(container_of(active, struct pulse, active));
6969
}
@@ -77,7 +77,7 @@ static struct pulse *pulse_create(void)
7777
return p;
7878

7979
kref_init(&p->kref);
80-
i915_active_init(&p->active, pulse_active, pulse_retire);
80+
i915_active_init(&p->active, pulse_active, pulse_retire, 0);
8181

8282
return p;
8383
}

0 commit comments

Comments
 (0)