Skip to content

Commit f6d790e

Browse files
committed
Merge tag 'drm-intel-next-fixes-2022-03-10' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
- Reduce overzealous alignment constraints for GGTT - Add missing mdev attribute "name" for GVT - Async flip fixes (Ville) - Static checker fix (Ville) Signed-off-by: Dave Airlie <[email protected]> From: Joonas Lahtinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 955ad0c + 5e7f44b commit f6d790e

File tree

8 files changed

+136
-52
lines changed

8 files changed

+136
-52
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
262262
crtc_state->preload_luts = false;
263263
crtc_state->inherited = false;
264264
crtc_state->wm.need_postvbl_update = false;
265+
crtc_state->do_async_flip = false;
265266
crtc_state->fb_bits = 0;
266267
crtc_state->update_planes = 0;
267268
crtc_state->dsb = NULL;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ intel_plane_duplicate_state(struct drm_plane *plane)
110110
intel_state->ggtt_vma = NULL;
111111
intel_state->dpt_vma = NULL;
112112
intel_state->flags = 0;
113-
intel_state->do_async_flip = false;
114113

115114
/* add reference to fb */
116115
if (intel_state->hw.fb)
@@ -506,7 +505,7 @@ static int intel_plane_atomic_calc_changes(const struct intel_crtc_state *old_cr
506505
new_crtc_state->disable_lp_wm = true;
507506

508507
if (intel_plane_do_async_flip(plane, old_crtc_state, new_crtc_state))
509-
new_plane_state->do_async_flip = true;
508+
new_crtc_state->do_async_flip = true;
510509

511510
return 0;
512511
}
@@ -678,7 +677,7 @@ void intel_plane_update_arm(struct intel_plane *plane,
678677

679678
trace_intel_plane_update_arm(&plane->base, crtc);
680679

681-
if (plane_state->do_async_flip)
680+
if (crtc_state->do_async_flip && plane->async_flip)
682681
plane->async_flip(plane, crtc_state, plane_state, true);
683682
else
684683
plane->update_arm(plane, crtc_state, plane_state);
@@ -703,7 +702,7 @@ void intel_crtc_planes_update_noarm(struct intel_atomic_state *state,
703702
struct intel_plane *plane;
704703
int i;
705704

706-
if (new_crtc_state->uapi.async_flip)
705+
if (new_crtc_state->do_async_flip)
707706
return;
708707

709708
/*

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ void intel_pipe_update_start(struct intel_crtc_state *new_crtc_state)
485485
intel_crtc_has_type(new_crtc_state, INTEL_OUTPUT_DSI);
486486
DEFINE_WAIT(wait);
487487

488-
if (new_crtc_state->uapi.async_flip)
488+
if (new_crtc_state->do_async_flip)
489489
return;
490490

491491
if (intel_crtc_needs_vblank_work(new_crtc_state))
@@ -630,7 +630,7 @@ void intel_pipe_update_end(struct intel_crtc_state *new_crtc_state)
630630
ktime_t end_vbl_time = ktime_get();
631631
struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
632632

633-
if (new_crtc_state->uapi.async_flip)
633+
if (new_crtc_state->do_async_flip)
634634
return;
635635

636636
trace_intel_pipe_update_end(crtc, end_vbl_count, scanline_end);

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

Lines changed: 98 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,10 @@ static enum pipe bigjoiner_master_pipe(const struct intel_crtc_state *crtc_state
346346

347347
u8 intel_crtc_bigjoiner_slave_pipes(const struct intel_crtc_state *crtc_state)
348348
{
349-
return crtc_state->bigjoiner_pipes & ~BIT(bigjoiner_master_pipe(crtc_state));
349+
if (crtc_state->bigjoiner_pipes)
350+
return crtc_state->bigjoiner_pipes & ~BIT(bigjoiner_master_pipe(crtc_state));
351+
else
352+
return 0;
350353
}
351354

352355
bool intel_crtc_is_bigjoiner_slave(const struct intel_crtc_state *crtc_state)
@@ -1260,10 +1263,8 @@ static void intel_crtc_enable_flip_done(struct intel_atomic_state *state,
12601263
int i;
12611264

12621265
for_each_new_intel_plane_in_state(state, plane, plane_state, i) {
1263-
if (plane->enable_flip_done &&
1264-
plane->pipe == crtc->pipe &&
1265-
update_planes & BIT(plane->id) &&
1266-
plane_state->do_async_flip)
1266+
if (plane->pipe == crtc->pipe &&
1267+
update_planes & BIT(plane->id))
12671268
plane->enable_flip_done(plane);
12681269
}
12691270
}
@@ -1279,10 +1280,8 @@ static void intel_crtc_disable_flip_done(struct intel_atomic_state *state,
12791280
int i;
12801281

12811282
for_each_new_intel_plane_in_state(state, plane, plane_state, i) {
1282-
if (plane->disable_flip_done &&
1283-
plane->pipe == crtc->pipe &&
1284-
update_planes & BIT(plane->id) &&
1285-
plane_state->do_async_flip)
1283+
if (plane->pipe == crtc->pipe &&
1284+
update_planes & BIT(plane->id))
12861285
plane->disable_flip_done(plane);
12871286
}
12881287
}
@@ -7398,7 +7397,7 @@ static void kill_bigjoiner_slave(struct intel_atomic_state *state,
73987397
* Correspondingly, support is currently added for primary plane only.
73997398
*
74007399
* Async flip can only change the plane surface address, so anything else
7401-
* changing is rejected from the intel_atomic_check_async() function.
7400+
* changing is rejected from the intel_async_flip_check_hw() function.
74027401
* Once this check is cleared, flip done interrupt is enabled using
74037402
* the intel_crtc_enable_flip_done() function.
74047403
*
@@ -7408,7 +7407,65 @@ static void kill_bigjoiner_slave(struct intel_atomic_state *state,
74087407
* correspond to the last vblank and have no relation to the actual time when
74097408
* the flip done event was sent.
74107409
*/
7411-
static int intel_atomic_check_async(struct intel_atomic_state *state, struct intel_crtc *crtc)
7410+
static int intel_async_flip_check_uapi(struct intel_atomic_state *state,
7411+
struct intel_crtc *crtc)
7412+
{
7413+
struct drm_i915_private *i915 = to_i915(state->base.dev);
7414+
const struct intel_crtc_state *new_crtc_state =
7415+
intel_atomic_get_new_crtc_state(state, crtc);
7416+
const struct intel_plane_state *old_plane_state;
7417+
struct intel_plane_state *new_plane_state;
7418+
struct intel_plane *plane;
7419+
int i;
7420+
7421+
if (!new_crtc_state->uapi.async_flip)
7422+
return 0;
7423+
7424+
if (!new_crtc_state->uapi.active) {
7425+
drm_dbg_kms(&i915->drm,
7426+
"[CRTC:%d:%s] not active\n",
7427+
crtc->base.base.id, crtc->base.name);
7428+
return -EINVAL;
7429+
}
7430+
7431+
if (intel_crtc_needs_modeset(new_crtc_state)) {
7432+
drm_dbg_kms(&i915->drm,
7433+
"[CRTC:%d:%s] modeset required\n",
7434+
crtc->base.base.id, crtc->base.name);
7435+
return -EINVAL;
7436+
}
7437+
7438+
for_each_oldnew_intel_plane_in_state(state, plane, old_plane_state,
7439+
new_plane_state, i) {
7440+
if (plane->pipe != crtc->pipe)
7441+
continue;
7442+
7443+
/*
7444+
* TODO: Async flip is only supported through the page flip IOCTL
7445+
* as of now. So support currently added for primary plane only.
7446+
* Support for other planes on platforms on which supports
7447+
* this(vlv/chv and icl+) should be added when async flip is
7448+
* enabled in the atomic IOCTL path.
7449+
*/
7450+
if (!plane->async_flip) {
7451+
drm_dbg_kms(&i915->drm,
7452+
"[PLANE:%d:%s] async flip not supported\n",
7453+
plane->base.base.id, plane->base.name);
7454+
return -EINVAL;
7455+
}
7456+
7457+
if (!old_plane_state->uapi.fb || !new_plane_state->uapi.fb) {
7458+
drm_dbg_kms(&i915->drm,
7459+
"[PLANE:%d:%s] no old or new framebuffer\n",
7460+
plane->base.base.id, plane->base.name);
7461+
return -EINVAL;
7462+
}
7463+
}
7464+
7465+
return 0;
7466+
}
7467+
7468+
static int intel_async_flip_check_hw(struct intel_atomic_state *state, struct intel_crtc *crtc)
74127469
{
74137470
struct drm_i915_private *i915 = to_i915(state->base.dev);
74147471
const struct intel_crtc_state *old_crtc_state, *new_crtc_state;
@@ -7419,6 +7476,9 @@ static int intel_atomic_check_async(struct intel_atomic_state *state, struct int
74197476
old_crtc_state = intel_atomic_get_old_crtc_state(state, crtc);
74207477
new_crtc_state = intel_atomic_get_new_crtc_state(state, crtc);
74217478

7479+
if (!new_crtc_state->uapi.async_flip)
7480+
return 0;
7481+
74227482
if (intel_crtc_needs_modeset(new_crtc_state)) {
74237483
drm_dbg_kms(&i915->drm, "Modeset Required. Async flip not supported\n");
74247484
return -EINVAL;
@@ -7440,15 +7500,25 @@ static int intel_atomic_check_async(struct intel_atomic_state *state, struct int
74407500
continue;
74417501

74427502
/*
7443-
* TODO: Async flip is only supported through the page flip IOCTL
7444-
* as of now. So support currently added for primary plane only.
7445-
* Support for other planes on platforms on which supports
7446-
* this(vlv/chv and icl+) should be added when async flip is
7447-
* enabled in the atomic IOCTL path.
7503+
* Only async flip capable planes should be in the state
7504+
* if we're really about to ask the hardware to perform
7505+
* an async flip. We should never get this far otherwise.
74487506
*/
7449-
if (!plane->async_flip)
7507+
if (drm_WARN_ON(&i915->drm,
7508+
new_crtc_state->do_async_flip && !plane->async_flip))
74507509
return -EINVAL;
74517510

7511+
/*
7512+
* Only check async flip capable planes other planes
7513+
* may be involved in the initial commit due to
7514+
* the wm0/ddb optimization.
7515+
*
7516+
* TODO maybe should track which planes actually
7517+
* were requested to do the async flip...
7518+
*/
7519+
if (!plane->async_flip)
7520+
continue;
7521+
74527522
/*
74537523
* FIXME: This check is kept generic for all platforms.
74547524
* Need to verify this for all gen9 platforms to enable
@@ -7613,6 +7683,12 @@ static int intel_atomic_check(struct drm_device *dev,
76137683
if (ret)
76147684
goto fail;
76157685

7686+
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
7687+
ret = intel_async_flip_check_uapi(state, crtc);
7688+
if (ret)
7689+
return ret;
7690+
}
7691+
76167692
ret = intel_bigjoiner_add_affected_crtcs(state);
76177693
if (ret)
76187694
goto fail;
@@ -7769,11 +7845,9 @@ static int intel_atomic_check(struct drm_device *dev,
77697845

77707846
for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state,
77717847
new_crtc_state, i) {
7772-
if (new_crtc_state->uapi.async_flip) {
7773-
ret = intel_atomic_check_async(state, crtc);
7774-
if (ret)
7775-
goto fail;
7776-
}
7848+
ret = intel_async_flip_check_hw(state, crtc);
7849+
if (ret)
7850+
goto fail;
77777851

77787852
if (!intel_crtc_needs_modeset(new_crtc_state) &&
77797853
!new_crtc_state->update_pipe)
@@ -8395,7 +8469,7 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
83958469
intel_dbuf_pre_plane_update(state);
83968470

83978471
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
8398-
if (new_crtc_state->uapi.async_flip)
8472+
if (new_crtc_state->do_async_flip)
83998473
intel_crtc_enable_flip_done(state, crtc);
84008474
}
84018475

@@ -8421,7 +8495,7 @@ static void intel_atomic_commit_tail(struct intel_atomic_state *state)
84218495
drm_atomic_helper_wait_for_flip_done(dev, &state->base);
84228496

84238497
for_each_new_intel_crtc_in_state(state, crtc, new_crtc_state, i) {
8424-
if (new_crtc_state->uapi.async_flip)
8498+
if (new_crtc_state->do_async_flip)
84258499
intel_crtc_disable_flip_done(state, crtc);
84268500
}
84278501

drivers/gpu/drm/i915/display/intel_display_types.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,6 @@ struct intel_plane_state {
613613

614614
struct intel_fb_view view;
615615

616-
/* Indicates if async flip is required */
617-
bool do_async_flip;
618-
619616
/* Plane pxp decryption state */
620617
bool decrypt;
621618

@@ -951,6 +948,9 @@ struct intel_crtc_state {
951948
bool preload_luts;
952949
bool inherited; /* state inherited from BIOS? */
953950

951+
/* Ask the hardware to actually async flip? */
952+
bool do_async_flip;
953+
954954
/* Pipe source size (ie. panel fitter input size)
955955
* All planes will be positioned inside this space,
956956
* and get clipped at the edges. */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,8 @@ void i915_address_space_init(struct i915_address_space *vm, int subclass)
234234
memset64(vm->min_alignment, I915_GTT_MIN_ALIGNMENT,
235235
ARRAY_SIZE(vm->min_alignment));
236236

237-
if (HAS_64K_PAGES(vm->i915) && NEEDS_COMPACT_PT(vm->i915)) {
237+
if (HAS_64K_PAGES(vm->i915) && NEEDS_COMPACT_PT(vm->i915) &&
238+
subclass == VM_CLASS_PPGTT) {
238239
vm->min_alignment[INTEL_MEMORY_LOCAL] = I915_GTT_PAGE_SIZE_2M;
239240
vm->min_alignment[INTEL_MEMORY_STOLEN_LOCAL] = I915_GTT_PAGE_SIZE_2M;
240241
} else if (HAS_64K_PAGES(vm->i915)) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,29 @@ static ssize_t description_show(struct mdev_type *mtype,
188188
type->weight);
189189
}
190190

191+
static ssize_t name_show(struct mdev_type *mtype,
192+
struct mdev_type_attribute *attr, char *buf)
193+
{
194+
struct intel_vgpu_type *type;
195+
struct intel_gvt *gvt = kdev_to_i915(mtype_get_parent_dev(mtype))->gvt;
196+
197+
type = &gvt->types[mtype_get_type_group_id(mtype)];
198+
if (!type)
199+
return 0;
200+
201+
return sprintf(buf, "%s\n", type->name);
202+
}
203+
191204
static MDEV_TYPE_ATTR_RO(available_instances);
192205
static MDEV_TYPE_ATTR_RO(device_api);
193206
static MDEV_TYPE_ATTR_RO(description);
207+
static MDEV_TYPE_ATTR_RO(name);
194208

195209
static struct attribute *gvt_type_attrs[] = {
196210
&mdev_type_attr_available_instances.attr,
197211
&mdev_type_attr_device_api.attr,
198212
&mdev_type_attr_description.attr,
213+
&mdev_type_attr_name.attr,
199214
NULL,
200215
};
201216

drivers/gpu/drm/i915/intel_pm.c

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5145,12 +5145,15 @@ skl_allocate_plane_ddb(struct skl_plane_ddb_iter *iter,
51455145
const struct skl_wm_level *wm,
51465146
u64 data_rate)
51475147
{
5148-
u16 extra;
5148+
u16 extra = 0;
51495149

5150-
extra = min_t(u16, iter->size,
5151-
DIV64_U64_ROUND_UP(iter->size * data_rate, iter->data_rate));
5152-
iter->size -= extra;
5153-
iter->data_rate -= data_rate;
5150+
if (data_rate) {
5151+
extra = min_t(u16, iter->size,
5152+
DIV64_U64_ROUND_UP(iter->size * data_rate,
5153+
iter->data_rate));
5154+
iter->size -= extra;
5155+
iter->data_rate -= data_rate;
5156+
}
51545157

51555158
return wm->min_ddb_alloc + extra;
51565159
}
@@ -5193,9 +5196,6 @@ skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state,
51935196
skl_ddb_entry_init(&crtc_state->wm.skl.plane_ddb_y[PLANE_CURSOR],
51945197
alloc->end - iter.total[PLANE_CURSOR], alloc->end);
51955198

5196-
if (iter.data_rate == 0)
5197-
return 0;
5198-
51995199
/*
52005200
* Find the highest watermark level for which we can satisfy the block
52015201
* requirement of active planes.
@@ -5234,6 +5234,10 @@ skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state,
52345234
return -EINVAL;
52355235
}
52365236

5237+
/* avoid the WARN later when we don't allocate any extra DDB */
5238+
if (iter.data_rate == 0)
5239+
iter.size = 0;
5240+
52375241
/*
52385242
* Grant each plane the blocks it requires at the highest achievable
52395243
* watermark level, plus an extra share of the leftover blocks
@@ -5246,20 +5250,10 @@ skl_crtc_allocate_plane_ddb(struct intel_atomic_state *state,
52465250
if (plane_id == PLANE_CURSOR)
52475251
continue;
52485252

5249-
/*
5250-
* We've accounted for all active planes; remaining planes are
5251-
* all disabled.
5252-
*/
5253-
if (iter.data_rate == 0)
5254-
break;
5255-
52565253
iter.total[plane_id] =
52575254
skl_allocate_plane_ddb(&iter, &wm->wm[level],
52585255
crtc_state->plane_data_rate[plane_id]);
52595256

5260-
if (iter.data_rate == 0)
5261-
break;
5262-
52635257
iter.uv_total[plane_id] =
52645258
skl_allocate_plane_ddb(&iter, &wm->uv_wm[level],
52655259
crtc_state->uv_plane_data_rate[plane_id]);

0 commit comments

Comments
 (0)