Skip to content

Commit f31d83f

Browse files
committed
Merge tag 'drm-intel-fixes-2020-03-12' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
drm/i915 fixes for v5.6-rc6: - hard lockup fix - GVT fixes - 32-bit alignment issue fix - timeline wait fixes - cacheline_retire and free Signed-off-by: Dave Airlie <[email protected]> From: Jani Nikula <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents d944326 + 14a0d52 commit f31d83f

File tree

9 files changed

+66
-29
lines changed

9 files changed

+66
-29
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ eb_validate_vma(struct i915_execbuffer *eb,
423423
if (unlikely(entry->flags & eb->invalid_flags))
424424
return -EINVAL;
425425

426-
if (unlikely(entry->alignment && !is_power_of_2(entry->alignment)))
426+
if (unlikely(entry->alignment &&
427+
!is_power_of_2_u64(entry->alignment)))
427428
return -EINVAL;
428429

429430
/*

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

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,11 +1679,9 @@ need_timeslice(struct intel_engine_cs *engine, const struct i915_request *rq)
16791679
if (!intel_engine_has_timeslices(engine))
16801680
return false;
16811681

1682-
if (list_is_last(&rq->sched.link, &engine->active.requests))
1683-
return false;
1684-
1685-
hint = max(rq_prio(list_next_entry(rq, sched.link)),
1686-
engine->execlists.queue_priority_hint);
1682+
hint = engine->execlists.queue_priority_hint;
1683+
if (!list_is_last(&rq->sched.link, &engine->active.requests))
1684+
hint = max(hint, rq_prio(list_next_entry(rq, sched.link)));
16871685

16881686
return hint >= effective_prio(rq);
16891687
}
@@ -1725,6 +1723,18 @@ static void set_timeslice(struct intel_engine_cs *engine)
17251723
set_timer_ms(&engine->execlists.timer, active_timeslice(engine));
17261724
}
17271725

1726+
static void start_timeslice(struct intel_engine_cs *engine)
1727+
{
1728+
struct intel_engine_execlists *execlists = &engine->execlists;
1729+
1730+
execlists->switch_priority_hint = execlists->queue_priority_hint;
1731+
1732+
if (timer_pending(&execlists->timer))
1733+
return;
1734+
1735+
set_timer_ms(&execlists->timer, timeslice(engine));
1736+
}
1737+
17281738
static void record_preemption(struct intel_engine_execlists *execlists)
17291739
{
17301740
(void)I915_SELFTEST_ONLY(execlists->preempt_hang.count++);
@@ -1888,11 +1898,7 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
18881898
* Even if ELSP[1] is occupied and not worthy
18891899
* of timeslices, our queue might be.
18901900
*/
1891-
if (!execlists->timer.expires &&
1892-
need_timeslice(engine, last))
1893-
set_timer_ms(&execlists->timer,
1894-
timeslice(engine));
1895-
1901+
start_timeslice(engine);
18961902
return;
18971903
}
18981904
}
@@ -1927,7 +1933,8 @@ static void execlists_dequeue(struct intel_engine_cs *engine)
19271933

19281934
if (last && !can_merge_rq(last, rq)) {
19291935
spin_unlock(&ve->base.active.lock);
1930-
return; /* leave this for another */
1936+
start_timeslice(engine);
1937+
return; /* leave this for another sibling */
19311938
}
19321939

19331940
ENGINE_TRACE(engine,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,15 @@ static void cacheline_release(struct intel_timeline_cacheline *cl)
192192

193193
static void cacheline_free(struct intel_timeline_cacheline *cl)
194194
{
195+
if (!i915_active_acquire_if_busy(&cl->active)) {
196+
__idle_cacheline_free(cl);
197+
return;
198+
}
199+
195200
GEM_BUG_ON(ptr_test_bit(cl->vaddr, CACHELINE_FREE));
196201
cl->vaddr = ptr_set_bit(cl->vaddr, CACHELINE_FREE);
197202

198-
if (i915_active_is_idle(&cl->active))
199-
__idle_cacheline_free(cl);
203+
i915_active_release(&cl->active);
200204
}
201205

202206
int intel_timeline_init(struct intel_timeline *timeline,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ void intel_vgpu_emulate_hotplug(struct intel_vgpu *vgpu, bool connected)
457457
struct drm_i915_private *dev_priv = vgpu->gvt->dev_priv;
458458

459459
/* TODO: add more platforms support */
460-
if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv)) {
460+
if (IS_SKYLAKE(dev_priv) || IS_KABYLAKE(dev_priv) ||
461+
IS_COFFEELAKE(dev_priv)) {
461462
if (connected) {
462463
vgpu_vreg_t(vgpu, SFUSE_STRAP) |=
463464
SFUSE_STRAP_DDID_DETECTED;

drivers/gpu/drm/i915/gvt/opregion.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,14 @@ static void virt_vbt_generation(struct vbt *v)
147147
/* there's features depending on version! */
148148
v->header.version = 155;
149149
v->header.header_size = sizeof(v->header);
150-
v->header.vbt_size = sizeof(struct vbt) - sizeof(v->header);
150+
v->header.vbt_size = sizeof(struct vbt);
151151
v->header.bdb_offset = offsetof(struct vbt, bdb_header);
152152

153153
strcpy(&v->bdb_header.signature[0], "BIOS_DATA_BLOCK");
154154
v->bdb_header.version = 186; /* child_dev_size = 33 */
155155
v->bdb_header.header_size = sizeof(v->bdb_header);
156156

157-
v->bdb_header.bdb_size = sizeof(struct vbt) - sizeof(struct vbt_header)
158-
- sizeof(struct bdb_header);
157+
v->bdb_header.bdb_size = sizeof(struct vbt) - sizeof(struct vbt_header);
159158

160159
/* general features */
161160
v->general_features_header.id = BDB_GENERAL_FEATURES;

drivers/gpu/drm/i915/gvt/vgpu.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,17 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)
272272
{
273273
struct intel_gvt *gvt = vgpu->gvt;
274274

275-
mutex_lock(&vgpu->vgpu_lock);
276-
277275
WARN(vgpu->active, "vGPU is still active!\n");
278276

277+
/*
278+
* remove idr first so later clean can judge if need to stop
279+
* service if no active vgpu.
280+
*/
281+
mutex_lock(&gvt->lock);
282+
idr_remove(&gvt->vgpu_idr, vgpu->id);
283+
mutex_unlock(&gvt->lock);
284+
285+
mutex_lock(&vgpu->vgpu_lock);
279286
intel_gvt_debugfs_remove_vgpu(vgpu);
280287
intel_vgpu_clean_sched_policy(vgpu);
281288
intel_vgpu_clean_submission(vgpu);
@@ -290,7 +297,6 @@ void intel_gvt_destroy_vgpu(struct intel_vgpu *vgpu)
290297
mutex_unlock(&vgpu->vgpu_lock);
291298

292299
mutex_lock(&gvt->lock);
293-
idr_remove(&gvt->vgpu_idr, vgpu->id);
294300
if (idr_is_empty(&gvt->vgpu_idr))
295301
intel_gvt_clean_irq(gvt);
296302
intel_gvt_update_vgpu_types(gvt);

drivers/gpu/drm/i915/i915_request.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -527,19 +527,31 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
527527
return NOTIFY_DONE;
528528
}
529529

530+
static void irq_semaphore_cb(struct irq_work *wrk)
531+
{
532+
struct i915_request *rq =
533+
container_of(wrk, typeof(*rq), semaphore_work);
534+
535+
i915_schedule_bump_priority(rq, I915_PRIORITY_NOSEMAPHORE);
536+
i915_request_put(rq);
537+
}
538+
530539
static int __i915_sw_fence_call
531540
semaphore_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
532541
{
533-
struct i915_request *request =
534-
container_of(fence, typeof(*request), semaphore);
542+
struct i915_request *rq = container_of(fence, typeof(*rq), semaphore);
535543

536544
switch (state) {
537545
case FENCE_COMPLETE:
538-
i915_schedule_bump_priority(request, I915_PRIORITY_NOSEMAPHORE);
546+
if (!(READ_ONCE(rq->sched.attr.priority) & I915_PRIORITY_NOSEMAPHORE)) {
547+
i915_request_get(rq);
548+
init_irq_work(&rq->semaphore_work, irq_semaphore_cb);
549+
irq_work_queue(&rq->semaphore_work);
550+
}
539551
break;
540552

541553
case FENCE_FREE:
542-
i915_request_put(request);
554+
i915_request_put(rq);
543555
break;
544556
}
545557

@@ -776,8 +788,8 @@ i915_request_await_start(struct i915_request *rq, struct i915_request *signal)
776788
struct dma_fence *fence;
777789
int err;
778790

779-
GEM_BUG_ON(i915_request_timeline(rq) ==
780-
rcu_access_pointer(signal->timeline));
791+
if (i915_request_timeline(rq) == rcu_access_pointer(signal->timeline))
792+
return 0;
781793

782794
if (i915_request_started(signal))
783795
return 0;
@@ -821,7 +833,7 @@ i915_request_await_start(struct i915_request *rq, struct i915_request *signal)
821833
return 0;
822834

823835
err = 0;
824-
if (intel_timeline_sync_is_later(i915_request_timeline(rq), fence))
836+
if (!intel_timeline_sync_is_later(i915_request_timeline(rq), fence))
825837
err = i915_sw_fence_await_dma_fence(&rq->submit,
826838
fence, 0,
827839
I915_FENCE_GFP);
@@ -1318,9 +1330,9 @@ void __i915_request_queue(struct i915_request *rq,
13181330
* decide whether to preempt the entire chain so that it is ready to
13191331
* run at the earliest possible convenience.
13201332
*/
1321-
i915_sw_fence_commit(&rq->semaphore);
13221333
if (attr && rq->engine->schedule)
13231334
rq->engine->schedule(rq, attr);
1335+
i915_sw_fence_commit(&rq->semaphore);
13241336
i915_sw_fence_commit(&rq->submit);
13251337
}
13261338

drivers/gpu/drm/i915/i915_request.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define I915_REQUEST_H
2727

2828
#include <linux/dma-fence.h>
29+
#include <linux/irq_work.h>
2930
#include <linux/lockdep.h>
3031

3132
#include "gem/i915_gem_context_types.h"
@@ -208,6 +209,7 @@ struct i915_request {
208209
};
209210
struct list_head execute_cb;
210211
struct i915_sw_fence semaphore;
212+
struct irq_work semaphore_work;
211213

212214
/*
213215
* A list of everyone we wait upon, and everyone who waits upon us.

drivers/gpu/drm/i915/i915_utils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ static inline u64 ptr_to_u64(const void *ptr)
234234
__idx; \
235235
})
236236

237+
static inline bool is_power_of_2_u64(u64 n)
238+
{
239+
return (n != 0 && ((n & (n - 1)) == 0));
240+
}
241+
237242
static inline void __list_del_many(struct list_head *head,
238243
struct list_head *first)
239244
{

0 commit comments

Comments
 (0)