Skip to content

Commit 614351f

Browse files
committed
Merge tag 'drm-intel-gt-next-2023-10-12' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
Driver Changes: Fixes/improvements/new stuff: - Register engines early to avoid type confusion (Mathias Krause) - Suppress 'ignoring reset notification' message [guc] (John Harrison) - Update 'recommended' version to 70.12.1 for DG2/ADL-S/ADL-P/MTL [guc] (John Harrison) - Enable WA 14018913170 [guc, dg2] (Daniele Ceraolo Spurio) Future platform enablement: - Clean steer semaphore on resume (Nirmoy Das) - Skip MCR ops for ring fault register [mtl] (Nirmoy Das) - Make i915_gem_shrinker multi-gt aware [gem] (Jonathan Cavitt) - Enable GGTT updates with binder in MTL (Nirmoy Das, Chris Wilson) - Invalidate the TLBs on each GT (Chris Wilson) Miscellaneous: - Clarify type evolution of uabi_node/uabi_engines (Mathias Krause) - Annotate struct ct_incoming_msg with __counted_by [guc] (Kees Cook) - More use of GT specific print helpers [gt] (John Harrison) Signed-off-by: Dave Airlie <[email protected]> From: Tvrtko Ursulin <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/ZSfKotZVdypU6NaX@tursulin-desk
2 parents 7971deb + 039adf3 commit 614351f

34 files changed

+577
-130
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static void flush_tlb_invalidate(struct drm_i915_gem_object *obj)
198198

199199
for_each_gt(gt, i915, id) {
200200
if (!obj->mm.tlb[id])
201-
return;
201+
continue;
202202

203203
intel_gt_invalidate_tlb_full(gt, obj->mm.tlb[id]);
204204
obj->mm.tlb[id] = 0;

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

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/vmalloc.h>
1515

1616
#include "gt/intel_gt_requests.h"
17+
#include "gt/intel_gt.h"
1718

1819
#include "i915_trace.h"
1920

@@ -119,7 +120,8 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
119120
intel_wakeref_t wakeref = 0;
120121
unsigned long count = 0;
121122
unsigned long scanned = 0;
122-
int err = 0;
123+
int err = 0, i = 0;
124+
struct intel_gt *gt;
123125

124126
/* CHV + VTD workaround use stop_machine(); need to trylock vm->mutex */
125127
bool trylock_vm = !ww && intel_vm_no_concurrent_access_wa(i915);
@@ -147,9 +149,11 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
147149
* what we can do is give them a kick so that we do not keep idle
148150
* contexts around longer than is necessary.
149151
*/
150-
if (shrink & I915_SHRINK_ACTIVE)
151-
/* Retire requests to unpin all idle contexts */
152-
intel_gt_retire_requests(to_gt(i915));
152+
if (shrink & I915_SHRINK_ACTIVE) {
153+
for_each_gt(gt, i915, i)
154+
/* Retire requests to unpin all idle contexts */
155+
intel_gt_retire_requests(gt);
156+
}
153157

154158
/*
155159
* As we may completely rewrite the (un)bound list whilst unbinding
@@ -389,6 +393,8 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
389393
struct i915_vma *vma, *next;
390394
unsigned long freed_pages = 0;
391395
intel_wakeref_t wakeref;
396+
struct intel_gt *gt;
397+
int i;
392398

393399
with_intel_runtime_pm(&i915->runtime_pm, wakeref)
394400
freed_pages += i915_gem_shrink(NULL, i915, -1UL, NULL,
@@ -397,24 +403,26 @@ i915_gem_shrinker_vmap(struct notifier_block *nb, unsigned long event, void *ptr
397403
I915_SHRINK_VMAPS);
398404

399405
/* We also want to clear any cached iomaps as they wrap vmap */
400-
mutex_lock(&to_gt(i915)->ggtt->vm.mutex);
401-
list_for_each_entry_safe(vma, next,
402-
&to_gt(i915)->ggtt->vm.bound_list, vm_link) {
403-
unsigned long count = i915_vma_size(vma) >> PAGE_SHIFT;
404-
struct drm_i915_gem_object *obj = vma->obj;
405-
406-
if (!vma->iomap || i915_vma_is_active(vma))
407-
continue;
406+
for_each_gt(gt, i915, i) {
407+
mutex_lock(&gt->ggtt->vm.mutex);
408+
list_for_each_entry_safe(vma, next,
409+
&gt->ggtt->vm.bound_list, vm_link) {
410+
unsigned long count = i915_vma_size(vma) >> PAGE_SHIFT;
411+
struct drm_i915_gem_object *obj = vma->obj;
412+
413+
if (!vma->iomap || i915_vma_is_active(vma))
414+
continue;
408415

409-
if (!i915_gem_object_trylock(obj, NULL))
410-
continue;
416+
if (!i915_gem_object_trylock(obj, NULL))
417+
continue;
411418

412-
if (__i915_vma_unbind(vma) == 0)
413-
freed_pages += count;
419+
if (__i915_vma_unbind(vma) == 0)
420+
freed_pages += count;
414421

415-
i915_gem_object_unlock(obj);
422+
i915_gem_object_unlock(obj);
423+
}
424+
mutex_unlock(&gt->ggtt->vm.mutex);
416425
}
417-
mutex_unlock(&to_gt(i915)->ggtt->vm.mutex);
418426

419427
*(unsigned long *)ptr += freed_pages;
420428
return NOTIFY_DONE;

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)
170170
#define I915_GEM_HWS_SEQNO 0x40
171171
#define I915_GEM_HWS_SEQNO_ADDR (I915_GEM_HWS_SEQNO * sizeof(u32))
172172
#define I915_GEM_HWS_MIGRATE (0x42 * sizeof(u32))
173+
#define I915_GEM_HWS_GGTT_BIND 0x46
174+
#define I915_GEM_HWS_GGTT_BIND_ADDR (I915_GEM_HWS_GGTT_BIND * sizeof(u32))
173175
#define I915_GEM_HWS_PXP 0x60
174176
#define I915_GEM_HWS_PXP_ADDR (I915_GEM_HWS_PXP * sizeof(u32))
175177
#define I915_GEM_HWS_GSC 0x62

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

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,9 @@ u32 intel_engine_context_size(struct intel_gt *gt, u8 class)
316316
* out in the wash.
317317
*/
318318
cxt_size = intel_uncore_read(uncore, CXT_SIZE) + 1;
319-
drm_dbg(&gt->i915->drm,
320-
"graphics_ver = %d CXT_SIZE = %d bytes [0x%08x]\n",
321-
GRAPHICS_VER(gt->i915), cxt_size * 64,
322-
cxt_size - 1);
319+
gt_dbg(gt, "graphics_ver = %d CXT_SIZE = %d bytes [0x%08x]\n",
320+
GRAPHICS_VER(gt->i915), cxt_size * 64,
321+
cxt_size - 1);
323322
return round_up(cxt_size * 64, PAGE_SIZE);
324323
case 3:
325324
case 2:
@@ -788,16 +787,15 @@ static void engine_mask_apply_media_fuses(struct intel_gt *gt)
788787

789788
if (!(BIT(i) & vdbox_mask)) {
790789
gt->info.engine_mask &= ~BIT(_VCS(i));
791-
drm_dbg(&i915->drm, "vcs%u fused off\n", i);
790+
gt_dbg(gt, "vcs%u fused off\n", i);
792791
continue;
793792
}
794793

795794
if (gen11_vdbox_has_sfc(gt, i, logical_vdbox, vdbox_mask))
796795
gt->info.vdbox_sfc_access |= BIT(i);
797796
logical_vdbox++;
798797
}
799-
drm_dbg(&i915->drm, "vdbox enable: %04x, instances: %04lx\n",
800-
vdbox_mask, VDBOX_MASK(gt));
798+
gt_dbg(gt, "vdbox enable: %04x, instances: %04lx\n", vdbox_mask, VDBOX_MASK(gt));
801799
GEM_BUG_ON(vdbox_mask != VDBOX_MASK(gt));
802800

803801
for (i = 0; i < I915_MAX_VECS; i++) {
@@ -808,11 +806,10 @@ static void engine_mask_apply_media_fuses(struct intel_gt *gt)
808806

809807
if (!(BIT(i) & vebox_mask)) {
810808
gt->info.engine_mask &= ~BIT(_VECS(i));
811-
drm_dbg(&i915->drm, "vecs%u fused off\n", i);
809+
gt_dbg(gt, "vecs%u fused off\n", i);
812810
}
813811
}
814-
drm_dbg(&i915->drm, "vebox enable: %04x, instances: %04lx\n",
815-
vebox_mask, VEBOX_MASK(gt));
812+
gt_dbg(gt, "vebox enable: %04x, instances: %04lx\n", vebox_mask, VEBOX_MASK(gt));
816813
GEM_BUG_ON(vebox_mask != VEBOX_MASK(gt));
817814
}
818815

@@ -838,7 +835,7 @@ static void engine_mask_apply_compute_fuses(struct intel_gt *gt)
838835
*/
839836
for_each_clear_bit(i, &ccs_mask, I915_MAX_CCS) {
840837
info->engine_mask &= ~BIT(_CCS(i));
841-
drm_dbg(&i915->drm, "ccs%u fused off\n", i);
838+
gt_dbg(gt, "ccs%u fused off\n", i);
842839
}
843840
}
844841

@@ -866,8 +863,8 @@ static void engine_mask_apply_copy_fuses(struct intel_gt *gt)
866863
_BCS(instance));
867864

868865
if (mask & info->engine_mask) {
869-
drm_dbg(&i915->drm, "bcs%u fused off\n", instance);
870-
drm_dbg(&i915->drm, "bcs%u fused off\n", instance + 1);
866+
gt_dbg(gt, "bcs%u fused off\n", instance);
867+
gt_dbg(gt, "bcs%u fused off\n", instance + 1);
871868

872869
info->engine_mask &= ~mask;
873870
}
@@ -907,8 +904,7 @@ static intel_engine_mask_t init_engine_mask(struct intel_gt *gt)
907904
* submission, which will wake up the GSC power well.
908905
*/
909906
if (__HAS_ENGINE(info->engine_mask, GSC0) && !intel_uc_wants_gsc_uc(&gt->uc)) {
910-
drm_notice(&gt->i915->drm,
911-
"No GSC FW selected, disabling GSC CS and media C6\n");
907+
gt_notice(gt, "No GSC FW selected, disabling GSC CS and media C6\n");
912908
info->engine_mask &= ~BIT(GSC0);
913909
}
914910

@@ -1097,8 +1093,7 @@ static int init_status_page(struct intel_engine_cs *engine)
10971093
*/
10981094
obj = i915_gem_object_create_internal(engine->i915, PAGE_SIZE);
10991095
if (IS_ERR(obj)) {
1100-
drm_err(&engine->i915->drm,
1101-
"Failed to allocate status page\n");
1096+
gt_err(engine->gt, "Failed to allocate status page\n");
11021097
return PTR_ERR(obj);
11031098
}
11041099

@@ -1418,6 +1413,20 @@ void intel_engine_destroy_pinned_context(struct intel_context *ce)
14181413
intel_context_put(ce);
14191414
}
14201415

1416+
static struct intel_context *
1417+
create_ggtt_bind_context(struct intel_engine_cs *engine)
1418+
{
1419+
static struct lock_class_key kernel;
1420+
1421+
/*
1422+
* MI_UPDATE_GTT can insert up to 511 PTE entries and there could be multiple
1423+
* bind requets at a time so get a bigger ring.
1424+
*/
1425+
return intel_engine_create_pinned_context(engine, engine->gt->vm, SZ_512K,
1426+
I915_GEM_HWS_GGTT_BIND_ADDR,
1427+
&kernel, "ggtt_bind_context");
1428+
}
1429+
14211430
static struct intel_context *
14221431
create_kernel_context(struct intel_engine_cs *engine)
14231432
{
@@ -1441,7 +1450,7 @@ create_kernel_context(struct intel_engine_cs *engine)
14411450
*/
14421451
static int engine_init_common(struct intel_engine_cs *engine)
14431452
{
1444-
struct intel_context *ce;
1453+
struct intel_context *ce, *bce = NULL;
14451454
int ret;
14461455

14471456
engine->set_default_submission(engine);
@@ -1457,17 +1466,33 @@ static int engine_init_common(struct intel_engine_cs *engine)
14571466
ce = create_kernel_context(engine);
14581467
if (IS_ERR(ce))
14591468
return PTR_ERR(ce);
1469+
/*
1470+
* Create a separate pinned context for GGTT update with blitter engine
1471+
* if a platform require such service. MI_UPDATE_GTT works on other
1472+
* engines as well but BCS should be less busy engine so pick that for
1473+
* GGTT updates.
1474+
*/
1475+
if (i915_ggtt_require_binder(engine->i915) && engine->id == BCS0) {
1476+
bce = create_ggtt_bind_context(engine);
1477+
if (IS_ERR(bce)) {
1478+
ret = PTR_ERR(bce);
1479+
goto err_ce_context;
1480+
}
1481+
}
14601482

14611483
ret = measure_breadcrumb_dw(ce);
14621484
if (ret < 0)
1463-
goto err_context;
1485+
goto err_bce_context;
14641486

14651487
engine->emit_fini_breadcrumb_dw = ret;
14661488
engine->kernel_context = ce;
1489+
engine->bind_context = bce;
14671490

14681491
return 0;
14691492

1470-
err_context:
1493+
err_bce_context:
1494+
intel_engine_destroy_pinned_context(bce);
1495+
err_ce_context:
14711496
intel_engine_destroy_pinned_context(ce);
14721497
return ret;
14731498
}
@@ -1537,6 +1562,10 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine)
15371562
if (engine->kernel_context)
15381563
intel_engine_destroy_pinned_context(engine->kernel_context);
15391564

1565+
if (engine->bind_context)
1566+
intel_engine_destroy_pinned_context(engine->bind_context);
1567+
1568+
15401569
GEM_BUG_ON(!llist_empty(&engine->barrier_tasks));
15411570
cleanup_status_page(engine);
15421571

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,15 @@ struct intel_engine_cs {
402402

403403
unsigned long context_tag;
404404

405-
struct rb_node uabi_node;
405+
/*
406+
* The type evolves during initialization, see related comment for
407+
* struct drm_i915_private's uabi_engines member.
408+
*/
409+
union {
410+
struct llist_node uabi_llist;
411+
struct list_head uabi_list;
412+
struct rb_node uabi_node;
413+
};
406414

407415
struct intel_sseu sseu;
408416

@@ -416,6 +424,9 @@ struct intel_engine_cs {
416424
struct llist_head barrier_tasks;
417425

418426
struct intel_context *kernel_context; /* pinned */
427+
struct intel_context *bind_context; /* pinned, only for BCS0 */
428+
/* mark the bind context's availability status */
429+
bool bind_context_ready;
419430

420431
/**
421432
* pinned_contexts_list: List of pinned contexts. This list is only

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance)
3838

3939
void intel_engine_add_user(struct intel_engine_cs *engine)
4040
{
41-
llist_add((struct llist_node *)&engine->uabi_node,
42-
(struct llist_head *)&engine->i915->uabi_engines);
41+
llist_add(&engine->uabi_llist, &engine->i915->uabi_engines_llist);
4342
}
4443

4544
static const u8 uabi_classes[] = {
@@ -54,9 +53,9 @@ static int engine_cmp(void *priv, const struct list_head *A,
5453
const struct list_head *B)
5554
{
5655
const struct intel_engine_cs *a =
57-
container_of((struct rb_node *)A, typeof(*a), uabi_node);
56+
container_of(A, typeof(*a), uabi_list);
5857
const struct intel_engine_cs *b =
59-
container_of((struct rb_node *)B, typeof(*b), uabi_node);
58+
container_of(B, typeof(*b), uabi_list);
6059

6160
if (uabi_classes[a->class] < uabi_classes[b->class])
6261
return -1;
@@ -73,7 +72,7 @@ static int engine_cmp(void *priv, const struct list_head *A,
7372

7473
static struct llist_node *get_engines(struct drm_i915_private *i915)
7574
{
76-
return llist_del_all((struct llist_head *)&i915->uabi_engines);
75+
return llist_del_all(&i915->uabi_engines_llist);
7776
}
7877

7978
static void sort_engines(struct drm_i915_private *i915,
@@ -83,9 +82,8 @@ static void sort_engines(struct drm_i915_private *i915,
8382

8483
llist_for_each_safe(pos, next, get_engines(i915)) {
8584
struct intel_engine_cs *engine =
86-
container_of((struct rb_node *)pos, typeof(*engine),
87-
uabi_node);
88-
list_add((struct list_head *)&engine->uabi_node, engines);
85+
container_of(pos, typeof(*engine), uabi_llist);
86+
list_add(&engine->uabi_list, engines);
8987
}
9088
list_sort(NULL, engines, engine_cmp);
9189
}
@@ -213,8 +211,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
213211
p = &i915->uabi_engines.rb_node;
214212
list_for_each_safe(it, next, &engines) {
215213
struct intel_engine_cs *engine =
216-
container_of((struct rb_node *)it, typeof(*engine),
217-
uabi_node);
214+
container_of(it, typeof(*engine), uabi_list);
218215

219216
if (intel_gt_has_unrecoverable_error(engine->gt))
220217
continue; /* ignore incomplete engines */

0 commit comments

Comments
 (0)