Skip to content

Commit d5bcd11

Browse files
committed
Merge tag 'drm-intel-fixes-2017-07-27' of git://anongit.freedesktop.org/git/drm-intel into drm-fixes
i915 fixes for -rc3 Bit more than usual since we missed -rc2. 4x cc: stable, 2 gvt patches, but all fairly minor stuff. Last minute rebase was to add a few missing cc: stable, I did prep the pull this morning already and made sure CI approves. * tag 'drm-intel-fixes-2017-07-27' of git://anongit.freedesktop.org/git/drm-intel: drm/i915: Fix bad comparison in skl_compute_plane_wm. drm/i915: Force CPU synchronisation even if userspace requests ASYNC drm/i915: Only skip updating execobject.offset after error drm/i915: Only mark the execobject as pinned on success drm/i915: Remove assertion from raw __i915_vma_unpin() drm/i915/cnl: Fix loadgen select programming on ddi vswing sequence drm/i915: Fix scaler init during CRTC HW state readout drm/i915/selftests: Fix an error handling path in 'mock_gem_device()' drm/i915: Unbreak gpu reset vs. modeset locking drm/i915: Fix cursor updates on some platforms drm/i915: Fix user ptr check size in eb_relocate_vma() drm/i915/gvt: Extend KBL platform support in GVT-g drm/i915/gvt: Fix the vblank timer close issue after shutdown VMs in reverse
2 parents 2213b66 + 5fe220a commit d5bcd11

File tree

10 files changed

+72
-83
lines changed

10 files changed

+72
-83
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,27 +323,27 @@ void intel_gvt_check_vblank_emulation(struct intel_gvt *gvt)
323323
{
324324
struct intel_gvt_irq *irq = &gvt->irq;
325325
struct intel_vgpu *vgpu;
326-
bool have_enabled_pipe = false;
327326
int pipe, id;
328327

329328
if (WARN_ON(!mutex_is_locked(&gvt->lock)))
330329
return;
331330

332-
hrtimer_cancel(&irq->vblank_timer.timer);
333-
334331
for_each_active_vgpu(gvt, vgpu, id) {
335332
for (pipe = 0; pipe < I915_MAX_PIPES; pipe++) {
336-
have_enabled_pipe =
337-
pipe_is_enabled(vgpu, pipe);
338-
if (have_enabled_pipe)
339-
break;
333+
if (pipe_is_enabled(vgpu, pipe))
334+
goto out;
340335
}
341336
}
342337

343-
if (have_enabled_pipe)
344-
hrtimer_start(&irq->vblank_timer.timer,
345-
ktime_add_ns(ktime_get(), irq->vblank_timer.period),
346-
HRTIMER_MODE_ABS);
338+
/* all the pipes are disabled */
339+
hrtimer_cancel(&irq->vblank_timer.timer);
340+
return;
341+
342+
out:
343+
hrtimer_start(&irq->vblank_timer.timer,
344+
ktime_add_ns(ktime_get(), irq->vblank_timer.period),
345+
HRTIMER_MODE_ABS);
346+
347347
}
348348

349349
static void emulate_vblank_on_pipe(struct intel_vgpu *vgpu, int pipe)

drivers/gpu/drm/i915/i915_gem_clflush.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ i915_clflush_notify(struct i915_sw_fence *fence,
114114
return NOTIFY_DONE;
115115
}
116116

117-
void i915_gem_clflush_object(struct drm_i915_gem_object *obj,
117+
bool i915_gem_clflush_object(struct drm_i915_gem_object *obj,
118118
unsigned int flags)
119119
{
120120
struct clflush *clflush;
@@ -128,7 +128,7 @@ void i915_gem_clflush_object(struct drm_i915_gem_object *obj,
128128
*/
129129
if (!i915_gem_object_has_struct_page(obj)) {
130130
obj->cache_dirty = false;
131-
return;
131+
return false;
132132
}
133133

134134
/* If the GPU is snooping the contents of the CPU cache,
@@ -140,7 +140,7 @@ void i915_gem_clflush_object(struct drm_i915_gem_object *obj,
140140
* tracking.
141141
*/
142142
if (!(flags & I915_CLFLUSH_FORCE) && obj->cache_coherent)
143-
return;
143+
return false;
144144

145145
trace_i915_gem_object_clflush(obj);
146146

@@ -179,4 +179,5 @@ void i915_gem_clflush_object(struct drm_i915_gem_object *obj,
179179
}
180180

181181
obj->cache_dirty = false;
182+
return true;
182183
}

drivers/gpu/drm/i915/i915_gem_clflush.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
struct drm_i915_private;
2929
struct drm_i915_gem_object;
3030

31-
void i915_gem_clflush_object(struct drm_i915_gem_object *obj,
31+
bool i915_gem_clflush_object(struct drm_i915_gem_object *obj,
3232
unsigned int flags);
3333
#define I915_CLFLUSH_FORCE BIT(0)
3434
#define I915_CLFLUSH_SYNC BIT(1)

drivers/gpu/drm/i915/i915_gem_execbuffer.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,6 @@ static int eb_reserve_vma(const struct i915_execbuffer *eb,
560560
eb->args->flags |= __EXEC_HAS_RELOC;
561561
}
562562

563-
entry->flags |= __EXEC_OBJECT_HAS_PIN;
564-
GEM_BUG_ON(eb_vma_misplaced(entry, vma));
565-
566563
if (unlikely(entry->flags & EXEC_OBJECT_NEEDS_FENCE)) {
567564
err = i915_vma_get_fence(vma);
568565
if (unlikely(err)) {
@@ -574,6 +571,9 @@ static int eb_reserve_vma(const struct i915_execbuffer *eb,
574571
entry->flags |= __EXEC_OBJECT_HAS_FENCE;
575572
}
576573

574+
entry->flags |= __EXEC_OBJECT_HAS_PIN;
575+
GEM_BUG_ON(eb_vma_misplaced(entry, vma));
576+
577577
return 0;
578578
}
579579

@@ -1458,7 +1458,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
14581458
* to read. However, if the array is not writable the user loses
14591459
* the updated relocation values.
14601460
*/
1461-
if (unlikely(!access_ok(VERIFY_READ, urelocs, remain*sizeof(urelocs))))
1461+
if (unlikely(!access_ok(VERIFY_READ, urelocs, remain*sizeof(*urelocs))))
14621462
return -EFAULT;
14631463

14641464
do {
@@ -1775,7 +1775,7 @@ static noinline int eb_relocate_slow(struct i915_execbuffer *eb)
17751775
}
17761776
}
17771777

1778-
return err ?: have_copy;
1778+
return err;
17791779
}
17801780

17811781
static int eb_relocate(struct i915_execbuffer *eb)
@@ -1825,7 +1825,7 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
18251825
int err;
18261826

18271827
for (i = 0; i < count; i++) {
1828-
const struct drm_i915_gem_exec_object2 *entry = &eb->exec[i];
1828+
struct drm_i915_gem_exec_object2 *entry = &eb->exec[i];
18291829
struct i915_vma *vma = exec_to_vma(entry);
18301830
struct drm_i915_gem_object *obj = vma->obj;
18311831

@@ -1841,12 +1841,14 @@ static int eb_move_to_gpu(struct i915_execbuffer *eb)
18411841
eb->request->capture_list = capture;
18421842
}
18431843

1844+
if (unlikely(obj->cache_dirty && !obj->cache_coherent)) {
1845+
if (i915_gem_clflush_object(obj, 0))
1846+
entry->flags &= ~EXEC_OBJECT_ASYNC;
1847+
}
1848+
18441849
if (entry->flags & EXEC_OBJECT_ASYNC)
18451850
goto skip_flushes;
18461851

1847-
if (unlikely(obj->cache_dirty && !obj->cache_coherent))
1848-
i915_gem_clflush_object(obj, 0);
1849-
18501852
err = i915_gem_request_await_object
18511853
(eb->request, obj, entry->flags & EXEC_OBJECT_WRITE);
18521854
if (err)
@@ -2209,7 +2211,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
22092211
goto err_unlock;
22102212

22112213
err = eb_relocate(&eb);
2212-
if (err)
2214+
if (err) {
22132215
/*
22142216
* If the user expects the execobject.offset and
22152217
* reloc.presumed_offset to be an exact match,
@@ -2218,8 +2220,8 @@ i915_gem_do_execbuffer(struct drm_device *dev,
22182220
* relocation.
22192221
*/
22202222
args->flags &= ~__EXEC_HAS_RELOC;
2221-
if (err < 0)
22222223
goto err_vma;
2224+
}
22232225

22242226
if (unlikely(eb.batch->exec_entry->flags & EXEC_OBJECT_WRITE)) {
22252227
DRM_DEBUG("Attempting to use self-modifying batch buffer\n");

drivers/gpu/drm/i915/i915_vma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,12 @@ static inline void __i915_vma_pin(struct i915_vma *vma)
284284

285285
static inline void __i915_vma_unpin(struct i915_vma *vma)
286286
{
287-
GEM_BUG_ON(!i915_vma_is_pinned(vma));
288287
vma->flags--;
289288
}
290289

291290
static inline void i915_vma_unpin(struct i915_vma *vma)
292291
{
292+
GEM_BUG_ON(!i915_vma_is_pinned(vma));
293293
GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
294294
__i915_vma_unpin(vma);
295295
}

drivers/gpu/drm/i915/intel_ddi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,8 +1896,8 @@ static void cnl_ddi_vswing_sequence(struct intel_encoder *encoder, u32 level)
18961896
val = I915_READ(CNL_PORT_TX_DW4_LN(port, ln));
18971897
val &= ~LOADGEN_SELECT;
18981898

1899-
if (((rate < 600000) && (width == 4) && (ln >= 1)) ||
1900-
((rate < 600000) && (width < 4) && ((ln == 1) || (ln == 2)))) {
1899+
if ((rate <= 600000 && width == 4 && ln >= 1) ||
1900+
(rate <= 600000 && width < 4 && (ln == 1 || ln == 2))) {
19011901
val |= LOADGEN_SELECT;
19021902
}
19031903
I915_WRITE(CNL_PORT_TX_DW4_LN(port, ln), val);

drivers/gpu/drm/i915/intel_display.c

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,26 +3427,6 @@ static void intel_complete_page_flips(struct drm_i915_private *dev_priv)
34273427
intel_finish_page_flip_cs(dev_priv, crtc->pipe);
34283428
}
34293429

3430-
static void intel_update_primary_planes(struct drm_device *dev)
3431-
{
3432-
struct drm_crtc *crtc;
3433-
3434-
for_each_crtc(dev, crtc) {
3435-
struct intel_plane *plane = to_intel_plane(crtc->primary);
3436-
struct intel_plane_state *plane_state =
3437-
to_intel_plane_state(plane->base.state);
3438-
3439-
if (plane_state->base.visible) {
3440-
trace_intel_update_plane(&plane->base,
3441-
to_intel_crtc(crtc));
3442-
3443-
plane->update_plane(plane,
3444-
to_intel_crtc_state(crtc->state),
3445-
plane_state);
3446-
}
3447-
}
3448-
}
3449-
34503430
static int
34513431
__intel_display_resume(struct drm_device *dev,
34523432
struct drm_atomic_state *state,
@@ -3499,6 +3479,12 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)
34993479
struct drm_atomic_state *state;
35003480
int ret;
35013481

3482+
3483+
/* reset doesn't touch the display */
3484+
if (!i915.force_reset_modeset_test &&
3485+
!gpu_reset_clobbers_display(dev_priv))
3486+
return;
3487+
35023488
/*
35033489
* Need mode_config.mutex so that we don't
35043490
* trample ongoing ->detect() and whatnot.
@@ -3512,12 +3498,6 @@ void intel_prepare_reset(struct drm_i915_private *dev_priv)
35123498

35133499
drm_modeset_backoff(ctx);
35143500
}
3515-
3516-
/* reset doesn't touch the display, but flips might get nuked anyway, */
3517-
if (!i915.force_reset_modeset_test &&
3518-
!gpu_reset_clobbers_display(dev_priv))
3519-
return;
3520-
35213501
/*
35223502
* Disabling the crtcs gracefully seems nicer. Also the
35233503
* g33 docs say we should at least disable all the planes.
@@ -3547,6 +3527,14 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
35473527
struct drm_atomic_state *state = dev_priv->modeset_restore_state;
35483528
int ret;
35493529

3530+
/* reset doesn't touch the display */
3531+
if (!i915.force_reset_modeset_test &&
3532+
!gpu_reset_clobbers_display(dev_priv))
3533+
return;
3534+
3535+
if (!state)
3536+
goto unlock;
3537+
35503538
/*
35513539
* Flips in the rings will be nuked by the reset,
35523540
* so complete all pending flips so that user space
@@ -3558,22 +3546,10 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
35583546

35593547
/* reset doesn't touch the display */
35603548
if (!gpu_reset_clobbers_display(dev_priv)) {
3561-
if (!state) {
3562-
/*
3563-
* Flips in the rings have been nuked by the reset,
3564-
* so update the base address of all primary
3565-
* planes to the the last fb to make sure we're
3566-
* showing the correct fb after a reset.
3567-
*
3568-
* FIXME: Atomic will make this obsolete since we won't schedule
3569-
* CS-based flips (which might get lost in gpu resets) any more.
3570-
*/
3571-
intel_update_primary_planes(dev);
3572-
} else {
3573-
ret = __intel_display_resume(dev, state, ctx);
3549+
/* for testing only restore the display */
3550+
ret = __intel_display_resume(dev, state, ctx);
35743551
if (ret)
35753552
DRM_ERROR("Restoring old state failed with %i\n", ret);
3576-
}
35773553
} else {
35783554
/*
35793555
* The display has been reset as well,
@@ -3597,8 +3573,8 @@ void intel_finish_reset(struct drm_i915_private *dev_priv)
35973573
intel_hpd_init(dev_priv);
35983574
}
35993575

3600-
if (state)
3601-
drm_atomic_state_put(state);
3576+
drm_atomic_state_put(state);
3577+
unlock:
36023578
drm_modeset_drop_locks(ctx);
36033579
drm_modeset_acquire_fini(ctx);
36043580
mutex_unlock(&dev->mode_config.mutex);
@@ -9117,6 +9093,13 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
91179093
u64 power_domain_mask;
91189094
bool active;
91199095

9096+
if (INTEL_GEN(dev_priv) >= 9) {
9097+
intel_crtc_init_scalers(crtc, pipe_config);
9098+
9099+
pipe_config->scaler_state.scaler_id = -1;
9100+
pipe_config->scaler_state.scaler_users &= ~(1 << SKL_CRTC_INDEX);
9101+
}
9102+
91209103
power_domain = POWER_DOMAIN_PIPE(crtc->pipe);
91219104
if (!intel_display_power_get_if_enabled(dev_priv, power_domain))
91229105
return false;
@@ -9145,13 +9128,6 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
91459128
pipe_config->gamma_mode =
91469129
I915_READ(GAMMA_MODE(crtc->pipe)) & GAMMA_MODE_MODE_MASK;
91479130

9148-
if (INTEL_GEN(dev_priv) >= 9) {
9149-
intel_crtc_init_scalers(crtc, pipe_config);
9150-
9151-
pipe_config->scaler_state.scaler_id = -1;
9152-
pipe_config->scaler_state.scaler_users &= ~(1 << SKL_CRTC_INDEX);
9153-
}
9154-
91559131
power_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
91569132
if (intel_display_power_get_if_enabled(dev_priv, power_domain)) {
91579133
power_domain_mask |= BIT_ULL(power_domain);
@@ -9540,7 +9516,16 @@ static void i9xx_update_cursor(struct intel_plane *plane,
95409516
* On some platforms writing CURCNTR first will also
95419517
* cause CURPOS to be armed by the CURBASE write.
95429518
* Without the CURCNTR write the CURPOS write would
9543-
* arm itself.
9519+
* arm itself. Thus we always start the full update
9520+
* with a CURCNTR write.
9521+
*
9522+
* On other platforms CURPOS always requires the
9523+
* CURBASE write to arm the update. Additonally
9524+
* a write to any of the cursor register will cancel
9525+
* an already armed cursor update. Thus leaving out
9526+
* the CURBASE write after CURPOS could lead to a
9527+
* cursor that doesn't appear to move, or even change
9528+
* shape. Thus we always write CURBASE.
95449529
*
95459530
* CURCNTR and CUR_FBC_CTL are always
95469531
* armed by the CURBASE write only.
@@ -9559,6 +9544,7 @@ static void i9xx_update_cursor(struct intel_plane *plane,
95599544
plane->cursor.cntl = cntl;
95609545
} else {
95619546
I915_WRITE_FW(CURPOS(pipe), pos);
9547+
I915_WRITE_FW(CURBASE(pipe), base);
95629548
}
95639549

95649550
POSTING_READ_FW(CURBASE(pipe));

drivers/gpu/drm/i915/intel_gvt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static bool is_supported_device(struct drm_i915_private *dev_priv)
4545
return true;
4646
if (IS_SKYLAKE(dev_priv))
4747
return true;
48-
if (IS_KABYLAKE(dev_priv) && INTEL_DEVID(dev_priv) == 0x591D)
48+
if (IS_KABYLAKE(dev_priv))
4949
return true;
5050
return false;
5151
}

drivers/gpu/drm/i915/intel_pm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,8 +4463,8 @@ static int skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
44634463
if ((cpp * cstate->base.adjusted_mode.crtc_htotal / 512 < 1) &&
44644464
(plane_bytes_per_line / 512 < 1))
44654465
selected_result = method2;
4466-
else if ((ddb_allocation && ddb_allocation /
4467-
fixed_16_16_to_u32_round_up(plane_blocks_per_line)) >= 1)
4466+
else if (ddb_allocation >=
4467+
fixed_16_16_to_u32_round_up(plane_blocks_per_line))
44684468
selected_result = min_fixed_16_16(method1, method2);
44694469
else if (latency >= linetime_us)
44704470
selected_result = min_fixed_16_16(method1, method2);

drivers/gpu/drm/i915/selftests/mock_gem_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct drm_i915_private *mock_gem_device(void)
206206
mkwrite_device_info(i915)->ring_mask = BIT(0);
207207
i915->engine[RCS] = mock_engine(i915, "mock");
208208
if (!i915->engine[RCS])
209-
goto err_dependencies;
209+
goto err_priorities;
210210

211211
i915->kernel_context = mock_context(i915, NULL);
212212
if (!i915->kernel_context)

0 commit comments

Comments
 (0)