Skip to content

Commit b45b6fb

Browse files
committed
Merge tag 'drm-intel-next-fixes-2020-10-22' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
- Tweak initia DPCD backlight.enabled value (Sean) - Initialize reserved MOCS indices (Ayaz) - Mark initial fb obj as WT on eLLC machines to avoid rcu lockup (Ville) - Support parsing of oversize batches (Chris) - Delay execlists processing for TGL (Chris) - Use the active reference on the vma during error capture (Chris) - Widen CSB pointer (Chris) - Wait for CSB entries on TGL (Chris) - Fix unwind for scratch page allocation (Chris) - Exclude low patches of stolen memory (Chris) - Force VT'd workarounds when running as a guest OS (Chris) - Drop runtime-pm assert from vpgu io accessors (Chris) Signed-off-by: Dave Airlie <airlied@redhat.com> From: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20201022205613.GA3469192@intel.com
2 parents 3f31ded + 5c6c13c commit b45b6fb

15 files changed

Lines changed: 334 additions & 53 deletions

drivers/gpu/drm/i915/Kconfig.debug

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ config DRM_I915_SELFTEST
153153
select DRM_EXPORT_FOR_TESTS if m
154154
select FAULT_INJECTION
155155
select PRIME_NUMBERS
156+
select CRC32
156157
help
157158
Choose this option to allow the driver to perform selftests upon
158159
loading; also requires the i915.selftest=1 module parameter. To

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3434,6 +3434,14 @@ initial_plane_vma(struct drm_i915_private *i915,
34343434
if (IS_ERR(obj))
34353435
return NULL;
34363436

3437+
/*
3438+
* Mark it WT ahead of time to avoid changing the
3439+
* cache_level during fbdev initialization. The
3440+
* unbind there would get stuck waiting for rcu.
3441+
*/
3442+
i915_gem_object_set_cache_coherency(obj, HAS_WT(i915) ?
3443+
I915_CACHE_WT : I915_CACHE_NONE);
3444+
34373445
switch (plane_config->tiling) {
34383446
case I915_TILING_NONE:
34393447
break;

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,41 @@ static void set_aux_backlight_enable(struct intel_dp *intel_dp, bool enable)
5252
}
5353
}
5454

55-
/*
56-
* Read the current backlight value from DPCD register(s) based
57-
* on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported
58-
*/
59-
static u32 intel_dp_aux_get_backlight(struct intel_connector *connector)
55+
static bool intel_dp_aux_backlight_dpcd_mode(struct intel_connector *connector)
6056
{
6157
struct intel_dp *intel_dp = intel_attached_dp(connector);
6258
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
63-
u8 read_val[2] = { 0x0 };
6459
u8 mode_reg;
65-
u16 level = 0;
6660

6761
if (drm_dp_dpcd_readb(&intel_dp->aux,
6862
DP_EDP_BACKLIGHT_MODE_SET_REGISTER,
6963
&mode_reg) != 1) {
7064
drm_dbg_kms(&i915->drm,
7165
"Failed to read the DPCD register 0x%x\n",
7266
DP_EDP_BACKLIGHT_MODE_SET_REGISTER);
73-
return 0;
67+
return false;
7468
}
7569

70+
return (mode_reg & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) ==
71+
DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD;
72+
}
73+
74+
/*
75+
* Read the current backlight value from DPCD register(s) based
76+
* on if 8-bit(MSB) or 16-bit(MSB and LSB) values are supported
77+
*/
78+
static u32 intel_dp_aux_get_backlight(struct intel_connector *connector)
79+
{
80+
struct intel_dp *intel_dp = intel_attached_dp(connector);
81+
struct drm_i915_private *i915 = dp_to_i915(intel_dp);
82+
u8 read_val[2] = { 0x0 };
83+
u16 level = 0;
84+
7685
/*
7786
* If we're not in DPCD control mode yet, the programmed brightness
7887
* value is meaningless and we should assume max brightness
7988
*/
80-
if ((mode_reg & DP_EDP_BACKLIGHT_CONTROL_MODE_MASK) !=
81-
DP_EDP_BACKLIGHT_CONTROL_MODE_DPCD)
89+
if (!intel_dp_aux_backlight_dpcd_mode(connector))
8290
return connector->panel.backlight.max;
8391

8492
if (drm_dp_dpcd_read(&intel_dp->aux, DP_EDP_BACKLIGHT_BRIGHTNESS_MSB,
@@ -319,7 +327,8 @@ static int intel_dp_aux_setup_backlight(struct intel_connector *connector,
319327

320328
panel->backlight.min = 0;
321329
panel->backlight.level = intel_dp_aux_get_backlight(connector);
322-
panel->backlight.enabled = panel->backlight.level != 0;
330+
panel->backlight.enabled = intel_dp_aux_backlight_dpcd_mode(connector) &&
331+
panel->backlight.level != 0;
323332

324333
return 0;
325334
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ struct i915_execbuffer {
287287
u64 invalid_flags; /** Set of execobj.flags that are invalid */
288288
u32 context_flags; /** Set of execobj.flags to insert from the ctx */
289289

290+
u64 batch_len; /** Length of batch within object */
290291
u32 batch_start_offset; /** Location within object of batch */
291-
u32 batch_len; /** Length of batch within object */
292292
u32 batch_flags; /** Flags composed for emit_bb_start() */
293293
struct intel_gt_buffer_pool_node *batch_pool; /** pool node for batch buffer */
294294

@@ -871,6 +871,10 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
871871

872872
if (eb->batch_len == 0)
873873
eb->batch_len = eb->batch->vma->size - eb->batch_start_offset;
874+
if (unlikely(eb->batch_len == 0)) { /* impossible! */
875+
drm_dbg(&i915->drm, "Invalid batch length\n");
876+
return -EINVAL;
877+
}
874878

875879
return 0;
876880

@@ -2424,7 +2428,7 @@ static int eb_parse(struct i915_execbuffer *eb)
24242428
struct drm_i915_private *i915 = eb->i915;
24252429
struct intel_gt_buffer_pool_node *pool = eb->batch_pool;
24262430
struct i915_vma *shadow, *trampoline, *batch;
2427-
unsigned int len;
2431+
unsigned long len;
24282432
int err;
24292433

24302434
if (!eb_use_cmdparser(eb)) {
@@ -2449,6 +2453,8 @@ static int eb_parse(struct i915_execbuffer *eb)
24492453
} else {
24502454
len += I915_CMD_PARSER_TRAMPOLINE_SIZE;
24512455
}
2456+
if (unlikely(len < eb->batch_len)) /* last paranoid check of overflow */
2457+
return -EINVAL;
24522458

24532459
if (!pool) {
24542460
pool = intel_gt_get_buffer_pool(eb->engine->gt, len);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ int i915_gem_stolen_insert_node(struct drm_i915_private *i915,
5353
struct drm_mm_node *node, u64 size,
5454
unsigned alignment)
5555
{
56-
return i915_gem_stolen_insert_node_in_range(i915, node, size,
57-
alignment, 0, U64_MAX);
56+
return i915_gem_stolen_insert_node_in_range(i915, node,
57+
size, alignment,
58+
I915_GEM_STOLEN_BIAS,
59+
U64_MAX);
5860
}
5961

6062
void i915_gem_stolen_remove_node(struct drm_i915_private *i915,

drivers/gpu/drm/i915/gem/i915_gem_stolen.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_i915_private *dev_priv
3030
resource_size_t stolen_offset,
3131
resource_size_t size);
3232

33+
#define I915_GEM_STOLEN_BIAS SZ_128K
34+
3335
#endif /* __I915_GEM_STOLEN_H__ */

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,18 +239,24 @@ static int gen6_ppgtt_init_scratch(struct gen6_ppgtt *ppgtt)
239239
I915_CACHE_NONE, PTE_READ_ONLY);
240240

241241
vm->scratch[1] = vm->alloc_pt_dma(vm, I915_GTT_PAGE_SIZE_4K);
242-
if (IS_ERR(vm->scratch[1]))
243-
return PTR_ERR(vm->scratch[1]);
242+
if (IS_ERR(vm->scratch[1])) {
243+
ret = PTR_ERR(vm->scratch[1]);
244+
goto err_scratch0;
245+
}
244246

245247
ret = pin_pt_dma(vm, vm->scratch[1]);
246-
if (ret) {
247-
i915_gem_object_put(vm->scratch[1]);
248-
return ret;
249-
}
248+
if (ret)
249+
goto err_scratch1;
250250

251251
fill32_px(vm->scratch[1], vm->scratch[0]->encode);
252252

253253
return 0;
254+
255+
err_scratch1:
256+
i915_gem_object_put(vm->scratch[1]);
257+
err_scratch0:
258+
i915_gem_object_put(vm->scratch[0]);
259+
return ret;
254260
}
255261

256262
static void gen6_ppgtt_free_pd(struct gen6_ppgtt *ppgtt)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,8 @@ static int gen8_init_scratch(struct i915_address_space *vm)
604604
return 0;
605605

606606
free_scratch:
607-
free_scratch(vm);
607+
while (i--)
608+
i915_gem_object_put(vm->scratch[i]);
608609
return -ENOMEM;
609610
}
610611

drivers/gpu/drm/i915/gt/intel_engine_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ struct intel_engine_execlists {
278278
*
279279
* Note these register may be either mmio or HWSP shadow.
280280
*/
281-
u32 *csb_status;
281+
u64 *csb_status;
282282

283283
/**
284284
* @csb_size: context status buffer FIFO size

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

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,9 +1140,8 @@ __unwind_incomplete_requests(struct intel_engine_cs *engine)
11401140

11411141
/* Check in case we rollback so far we wrap [size/2] */
11421142
if (intel_ring_direction(rq->ring,
1143-
intel_ring_wrap(rq->ring,
1144-
rq->tail),
1145-
rq->ring->tail) > 0)
1143+
rq->tail,
1144+
rq->ring->tail + 8) > 0)
11461145
rq->context->lrc.desc |= CTX_DESC_FORCE_RESTORE;
11471146

11481147
active = rq;
@@ -2464,7 +2463,7 @@ cancel_port_requests(struct intel_engine_execlists * const execlists)
24642463
}
24652464

24662465
static inline void
2467-
invalidate_csb_entries(const u32 *first, const u32 *last)
2466+
invalidate_csb_entries(const u64 *first, const u64 *last)
24682467
{
24692468
clflush((void *)first);
24702469
clflush((void *)last);
@@ -2496,14 +2495,25 @@ invalidate_csb_entries(const u32 *first, const u32 *last)
24962495
* bits 47-57: sw context id of the lrc the GT switched away from
24972496
* bits 58-63: sw counter of the lrc the GT switched away from
24982497
*/
2499-
static inline bool
2500-
gen12_csb_parse(const struct intel_engine_execlists *execlists, const u32 *csb)
2501-
{
2502-
u32 lower_dw = csb[0];
2503-
u32 upper_dw = csb[1];
2504-
bool ctx_to_valid = GEN12_CSB_CTX_VALID(lower_dw);
2505-
bool ctx_away_valid = GEN12_CSB_CTX_VALID(upper_dw);
2506-
bool new_queue = lower_dw & GEN12_CTX_STATUS_SWITCHED_TO_NEW_QUEUE;
2498+
static inline bool gen12_csb_parse(const u64 *csb)
2499+
{
2500+
bool ctx_away_valid;
2501+
bool new_queue;
2502+
u64 entry;
2503+
2504+
/* HSD#22011248461 */
2505+
entry = READ_ONCE(*csb);
2506+
if (unlikely(entry == -1)) {
2507+
preempt_disable();
2508+
if (wait_for_atomic_us((entry = READ_ONCE(*csb)) != -1, 50))
2509+
GEM_WARN_ON("50us CSB timeout");
2510+
preempt_enable();
2511+
}
2512+
WRITE_ONCE(*(u64 *)csb, -1);
2513+
2514+
ctx_away_valid = GEN12_CSB_CTX_VALID(upper_32_bits(entry));
2515+
new_queue =
2516+
lower_32_bits(entry) & GEN12_CTX_STATUS_SWITCHED_TO_NEW_QUEUE;
25072517

25082518
/*
25092519
* The context switch detail is not guaranteed to be 5 when a preemption
@@ -2513,7 +2523,7 @@ gen12_csb_parse(const struct intel_engine_execlists *execlists, const u32 *csb)
25132523
* would require some extra handling, but we don't support that.
25142524
*/
25152525
if (!ctx_away_valid || new_queue) {
2516-
GEM_BUG_ON(!ctx_to_valid);
2526+
GEM_BUG_ON(!GEN12_CSB_CTX_VALID(lower_32_bits(entry)));
25172527
return true;
25182528
}
25192529

@@ -2522,20 +2532,19 @@ gen12_csb_parse(const struct intel_engine_execlists *execlists, const u32 *csb)
25222532
* context switch on an unsuccessful wait instruction since we always
25232533
* use polling mode.
25242534
*/
2525-
GEM_BUG_ON(GEN12_CTX_SWITCH_DETAIL(upper_dw));
2535+
GEM_BUG_ON(GEN12_CTX_SWITCH_DETAIL(upper_32_bits(entry)));
25262536
return false;
25272537
}
25282538

2529-
static inline bool
2530-
gen8_csb_parse(const struct intel_engine_execlists *execlists, const u32 *csb)
2539+
static inline bool gen8_csb_parse(const u64 *csb)
25312540
{
25322541
return *csb & (GEN8_CTX_STATUS_IDLE_ACTIVE | GEN8_CTX_STATUS_PREEMPTED);
25332542
}
25342543

25352544
static void process_csb(struct intel_engine_cs *engine)
25362545
{
25372546
struct intel_engine_execlists * const execlists = &engine->execlists;
2538-
const u32 * const buf = execlists->csb_status;
2547+
const u64 * const buf = execlists->csb_status;
25392548
const u8 num_entries = execlists->csb_size;
25402549
u8 head, tail;
25412550

@@ -2616,12 +2625,14 @@ static void process_csb(struct intel_engine_cs *engine)
26162625
*/
26172626

26182627
ENGINE_TRACE(engine, "csb[%d]: status=0x%08x:0x%08x\n",
2619-
head, buf[2 * head + 0], buf[2 * head + 1]);
2628+
head,
2629+
upper_32_bits(buf[head]),
2630+
lower_32_bits(buf[head]));
26202631

26212632
if (INTEL_GEN(engine->i915) >= 12)
2622-
promote = gen12_csb_parse(execlists, buf + 2 * head);
2633+
promote = gen12_csb_parse(buf + head);
26232634
else
2624-
promote = gen8_csb_parse(execlists, buf + 2 * head);
2635+
promote = gen8_csb_parse(buf + head);
26252636
if (promote) {
26262637
struct i915_request * const *old = execlists->active;
26272638

@@ -2649,6 +2660,9 @@ static void process_csb(struct intel_engine_cs *engine)
26492660
smp_wmb(); /* complete the seqlock */
26502661
WRITE_ONCE(execlists->active, execlists->inflight);
26512662

2663+
/* XXX Magic delay for tgl */
2664+
ENGINE_POSTING_READ(engine, RING_CONTEXT_STATUS_PTR);
2665+
26522666
WRITE_ONCE(execlists->pending[0], NULL);
26532667
} else {
26542668
if (GEM_WARN_ON(!*execlists->active)) {
@@ -4005,6 +4019,8 @@ static void reset_csb_pointers(struct intel_engine_cs *engine)
40054019
WRITE_ONCE(*execlists->csb_write, reset_value);
40064020
wmb(); /* Make sure this is visible to HW (paranoia?) */
40074021

4022+
/* Check that the GPU does indeed update the CSB entries! */
4023+
memset(execlists->csb_status, -1, (reset_value + 1) * sizeof(u64));
40084024
invalidate_csb_entries(&execlists->csb_status[0],
40094025
&execlists->csb_status[reset_value]);
40104026

@@ -5157,7 +5173,7 @@ int intel_execlists_submission_setup(struct intel_engine_cs *engine)
51575173
}
51585174

51595175
execlists->csb_status =
5160-
&engine->status_page.addr[I915_HWS_CSB_BUF0_INDEX];
5176+
(u64 *)&engine->status_page.addr[I915_HWS_CSB_BUF0_INDEX];
51615177

51625178
execlists->csb_write =
51635179
&engine->status_page.addr[intel_hws_csb_write_index(i915)];

0 commit comments

Comments
 (0)