Skip to content

Commit

Permalink
Merge tag 'drm-intel-next-fixes-2017-11-10' of git://anongit.freedesk…
Browse files Browse the repository at this point in the history
…top.org/drm/drm-intel into drm-next

drm/i915 fixes for v4.15

* tag 'drm-intel-next-fixes-2017-11-10' of git://anongit.freedesktop.org/drm/drm-intel:
  drm/i915: Reorder context-close to avoid calling i915_vma_close() under RCU
  drm/i915: Move init_clock_gating() back to where it was
  drm/i915: Prune the reservation shared fence array
  drm/i915: Idle the GPU before shinking everything
  drm/i915: Lock llist_del_first() vs llist_del_all()
  drm/i915: Calculate ironlake intermediate watermarks correctly, v2.
  drm/i915: Disable lazy PPGTT page table optimization for vGPU
  drm/i915/execlists: Remove the priority "optimisation"
  drm/i915: Filter out spurious execlists context-switch interrupts
  • Loading branch information
Dave Airlie committed Nov 13, 2017
2 parents fee25cb + e8c49fa commit 9c11731
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 52 deletions.
8 changes: 7 additions & 1 deletion drivers/gpu/drm/i915/i915_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -4603,11 +4603,17 @@ static void __i915_gem_free_work(struct work_struct *work)
* unbound now.
*/

spin_lock(&i915->mm.free_lock);
while ((freed = llist_del_all(&i915->mm.free_list))) {
spin_unlock(&i915->mm.free_lock);

__i915_gem_free_objects(i915, freed);
if (need_resched())
break;
return;

spin_lock(&i915->mm.free_lock);
}
spin_unlock(&i915->mm.free_lock);
}

static void __i915_gem_free_object_rcu(struct rcu_head *head)
Expand Down
12 changes: 6 additions & 6 deletions drivers/gpu/drm/i915/i915_gem_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,9 @@ static void lut_close(struct i915_gem_context *ctx)

radix_tree_for_each_slot(slot, &ctx->handles_vma, &iter, 0) {
struct i915_vma *vma = rcu_dereference_raw(*slot);
struct drm_i915_gem_object *obj = vma->obj;

radix_tree_iter_delete(&ctx->handles_vma, &iter, slot);

if (!i915_vma_is_ggtt(vma))
i915_vma_close(vma);

__i915_gem_object_release_unless_active(obj);
__i915_gem_object_release_unless_active(vma->obj);
}
}

Expand Down Expand Up @@ -198,6 +193,11 @@ static void context_close(struct i915_gem_context *ctx)
{
i915_gem_context_set_closed(ctx);

/*
* The LUT uses the VMA as a backpointer to unref the object,
* so we need to clear the LUT before we close all the VMA (inside
* the ppgtt).
*/
lut_close(ctx);
if (ctx->ppgtt)
i915_ppgtt_close(&ctx->ppgtt->base);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/i915_gem_gtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ static int gen8_ppgtt_alloc_pd(struct i915_address_space *vm,
if (IS_ERR(pt))
goto unwind;

if (count < GEN8_PTES)
if (count < GEN8_PTES || intel_vgpu_active(vm->i915))
gen8_initialize_pt(vm, pt);

gen8_ppgtt_set_pde(vm, pd, pt, pde);
Expand Down
12 changes: 12 additions & 0 deletions drivers/gpu/drm/i915/i915_gem_shrinker.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ i915_gem_shrink(struct drm_i915_private *dev_priv,
if (!shrinker_lock(dev_priv, &unlock))
return 0;

/*
* When shrinking the active list, also consider active contexts.
* Active contexts are pinned until they are retired, and so can
* not be simply unbound to retire and unpin their pages. To shrink
* the contexts, we must wait until the gpu is idle.
*
* We don't care about errors here; if we cannot wait upon the GPU,
* we will free as much as we can and hope to get a second chance.
*/
if (flags & I915_SHRINK_ACTIVE)
i915_gem_wait_for_idle(dev_priv, I915_WAIT_LOCKED);

trace_i915_gem_shrink(dev_priv, target, flags);
i915_gem_retire_requests(dev_priv);

Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/i915/i915_guc_submission.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ static void i915_guc_dequeue(struct intel_engine_cs *engine)
execlists->first = rb;
if (submit) {
port_assign(port, last);
execlists_set_active(execlists, EXECLISTS_ACTIVE_USER);
i915_guc_submit(engine);
}
spin_unlock_irq(&engine->timeline->lock);
Expand All @@ -633,6 +634,8 @@ static void i915_guc_irq_handler(unsigned long data)

rq = port_request(&port[0]);
}
if (!rq)
execlists_clear_active(execlists, EXECLISTS_ACTIVE_USER);

if (!port_isset(last_port))
i915_guc_dequeue(engine);
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpu/drm/i915/i915_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1388,8 +1388,10 @@ gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir, int test_shift)
bool tasklet = false;

if (iir & (GT_CONTEXT_SWITCH_INTERRUPT << test_shift)) {
__set_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
tasklet = true;
if (READ_ONCE(engine->execlists.active)) {
__set_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
tasklet = true;
}
}

if (iir & (GT_RENDER_USER_INTERRUPT << test_shift)) {
Expand Down
7 changes: 7 additions & 0 deletions drivers/gpu/drm/i915/i915_vma.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ i915_vma_retire(struct i915_gem_active *active,
if (--obj->active_count)
return;

/* Prune the shared fence arrays iff completely idle (inc. external) */
if (reservation_object_trylock(obj->resv)) {
if (reservation_object_test_signaled_rcu(obj->resv, true))
reservation_object_add_excl_fence(obj->resv, NULL);
reservation_object_unlock(obj->resv);
}

/* Bump our place on the bound list to keep it roughly in LRU order
* so that we don't steal from recently used but inactive objects
* (unless we are forced to ofc!)
Expand Down
14 changes: 12 additions & 2 deletions drivers/gpu/drm/i915/intel_display.c
Original file line number Diff line number Diff line change
Expand Up @@ -3676,6 +3676,7 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)

intel_pps_unlock_regs_wa(dev_priv);
intel_modeset_init_hw(dev);
intel_init_clock_gating(dev_priv);

spin_lock_irq(&dev_priv->irq_lock);
if (dev_priv->display.hpd_irq_setup)
Expand Down Expand Up @@ -14350,8 +14351,6 @@ void intel_modeset_init_hw(struct drm_device *dev)

intel_update_cdclk(dev_priv);
dev_priv->cdclk.logical = dev_priv->cdclk.actual = dev_priv->cdclk.hw;

intel_init_clock_gating(dev_priv);
}

/*
Expand Down Expand Up @@ -15063,6 +15062,15 @@ intel_modeset_setup_hw_state(struct drm_device *dev,
struct intel_encoder *encoder;
int i;

if (IS_HASWELL(dev_priv)) {
/*
* WaRsPkgCStateDisplayPMReq:hsw
* System hang if this isn't done before disabling all planes!
*/
I915_WRITE(CHICKEN_PAR1_1,
I915_READ(CHICKEN_PAR1_1) | FORCE_ARB_IDLE_PLANES);
}

intel_modeset_readout_hw_state(dev);

/* HW state is read out, now we need to sanitize this mess. */
Expand Down Expand Up @@ -15160,6 +15168,8 @@ void intel_modeset_gem_init(struct drm_device *dev)

intel_init_gt_powersave(dev_priv);

intel_init_clock_gating(dev_priv);

intel_setup_overlay(dev_priv);
}

Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/i915/intel_engine_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1548,8 +1548,8 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
if (test_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted))
return false;

/* Both ports drained, no more ELSP submission? */
if (port_request(&engine->execlists.port[0]))
/* Waiting to drain ELSP? */
if (READ_ONCE(engine->execlists.active))
return false;

/* ELSP is empty, but there are ready requests? */
Expand Down Expand Up @@ -1749,6 +1749,7 @@ void intel_engine_dump(struct intel_engine_cs *engine, struct drm_printer *m)
idx);
}
}
drm_printf(m, "\t\tHW active? 0x%x\n", execlists->active);
rcu_read_unlock();
} else if (INTEL_GEN(dev_priv) > 6) {
drm_printf(m, "\tPP_DIR_BASE: 0x%08x\n",
Expand Down
29 changes: 20 additions & 9 deletions drivers/gpu/drm/i915/intel_lrc.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
* the state of the GPU is known (idle).
*/
inject_preempt_context(engine);
execlists->preempt = true;
execlists_set_active(execlists,
EXECLISTS_ACTIVE_PREEMPT);
goto unlock;
} else {
/*
Expand Down Expand Up @@ -683,8 +684,10 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
unlock:
spin_unlock_irq(&engine->timeline->lock);

if (submit)
if (submit) {
execlists_set_active(execlists, EXECLISTS_ACTIVE_USER);
execlists_submit_ports(engine);
}
}

static void
Expand All @@ -696,6 +699,7 @@ execlist_cancel_port_requests(struct intel_engine_execlists *execlists)
while (num_ports-- && port_isset(port)) {
struct drm_i915_gem_request *rq = port_request(port);

GEM_BUG_ON(!execlists->active);
execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_PREEMPTED);
i915_gem_request_put(rq);

Expand Down Expand Up @@ -730,7 +734,6 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine)

list_for_each_entry_safe(rq, rn, &p->requests, priotree.link) {
INIT_LIST_HEAD(&rq->priotree.link);
rq->priotree.priority = INT_MAX;

dma_fence_set_error(&rq->fence, -EIO);
__i915_gem_request_submit(rq);
Expand Down Expand Up @@ -861,15 +864,21 @@ static void intel_lrc_irq_handler(unsigned long data)
unwind_incomplete_requests(engine);
spin_unlock_irq(&engine->timeline->lock);

GEM_BUG_ON(!execlists->preempt);
execlists->preempt = false;
GEM_BUG_ON(!execlists_is_active(execlists,
EXECLISTS_ACTIVE_PREEMPT));
execlists_clear_active(execlists,
EXECLISTS_ACTIVE_PREEMPT);
continue;
}

if (status & GEN8_CTX_STATUS_PREEMPTED &&
execlists->preempt)
execlists_is_active(execlists,
EXECLISTS_ACTIVE_PREEMPT))
continue;

GEM_BUG_ON(!execlists_is_active(execlists,
EXECLISTS_ACTIVE_USER));

/* Check the context/desc id for this event matches */
GEM_DEBUG_BUG_ON(buf[2 * head + 1] != port->context_id);

Expand All @@ -881,7 +890,6 @@ static void intel_lrc_irq_handler(unsigned long data)
execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);

trace_i915_gem_request_out(rq);
rq->priotree.priority = INT_MAX;
i915_gem_request_put(rq);

execlists_port_complete(execlists, port);
Expand All @@ -892,6 +900,9 @@ static void intel_lrc_irq_handler(unsigned long data)
/* After the final element, the hw should be idle */
GEM_BUG_ON(port_count(port) == 0 &&
!(status & GEN8_CTX_STATUS_ACTIVE_IDLE));
if (port_count(port) == 0)
execlists_clear_active(execlists,
EXECLISTS_ACTIVE_USER);
}

if (head != execlists->csb_head) {
Expand All @@ -901,7 +912,7 @@ static void intel_lrc_irq_handler(unsigned long data)
}
}

if (!execlists->preempt)
if (!execlists_is_active(execlists, EXECLISTS_ACTIVE_PREEMPT))
execlists_dequeue(engine);

intel_uncore_forcewake_put(dev_priv, execlists->fw_domains);
Expand Down Expand Up @@ -1460,7 +1471,7 @@ static int gen8_init_common_ring(struct intel_engine_cs *engine)
GT_CONTEXT_SWITCH_INTERRUPT << engine->irq_shift);
clear_bit(ENGINE_IRQ_EXECLIST, &engine->irq_posted);
execlists->csb_head = -1;
execlists->preempt = false;
execlists->active = 0;

/* After a GPU reset, we may have requests to replay */
if (!i915_modparams.enable_guc_submission && execlists->first)
Expand Down
Loading

0 comments on commit 9c11731

Please sign in to comment.