Skip to content

Commit 045e8d1

Browse files
committed
Merge tag 'drm-intel-gt-next-2023-01-18' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
Driver Changes: Fixes/improvements/new stuff: - Fix workarounds on Gen2-3 (Tvrtko Ursulin) - Fix HuC delayed load memory leaks (Daniele Ceraolo Spurio) - Fix a BUG caused by impendance mismatch in dma_fence_wait_timeout and GuC (Janusz Krzysztofik) - Add DG2 workarounds Wa_18018764978 and Wa_18019271663 (Matt Atwood) - Apply recommended L3 hashing mask tuning parameters (Gen12+) (Matt Roper) - Improve suspend / resume times with VT-d scanout workaround active (Andi Shyti, Chris Wilson) - Silence misleading "mailbox access failed" warning in snb_pcode_read (Ashutosh Dixit) - Fix null pointer dereference on HSW perf/OA (Umesh Nerlige Ramappa) - Avoid trampling the ring during buffer migration (and selftests) (Chris Wilson, Matthew Auld) - Fix DG2 visual corruption on small BAR systems by not forgetting to copy CCS aux state (Matthew Auld) - More fixing of DG2 visual corruption by not forgetting to copy CCS aux state of backup objects (Matthew Auld) - Fix TLB invalidation for Gen12.50 video and compute engines (Andrzej Hajda) - Limit Wa_22012654132 to just specific steppings (Matt Roper) - Fix userspace crashes due eviction not working under lock contention after the object locking conversion (Matthew Auld) - Avoid double free is user deploys a corrupt GuC firmware (John Harrison) - Fix 32-bit builds by using "%zu" to format size_t (Nirmoy Das) - Fix a possible BUG in TTM async unbind due not reserving enough fence slots (Nirmoy Das) - Fix potential use after free by not exposing the GEM context id to userspace too early (Rob Clark) - Show clamped PL1 limit to the user (hwmon) (Ashutosh Dixit) - Workaround unreliable reset on Jasperlake (Chris Wilson) - Cover rest of SVG unit MCR registers (Gustavo Sousa) - Avoid PXP log spam on platforms which do not support the feature (Alan Previn) - Re-disable RC6p on Sandy Bridge to avoid GPU hangs and visual glitches (Sasa Dragic) Future platform enablement: - Manage uncore->lock while waiting on MCR register (Matt Roper) - Enable Idle Messaging for GSC CS (Vinay Belgaumkar) - Only initialize GSC in tile 0 (José Roberto de Souza) - Media GT and Render GT share common GGTT (Aravind Iddamsetty) - Add dedicated MCR lock (Matt Roper) - Implement recommended caching policy (PVC) (Wayne Boyer) - Add hardware-level lock for steering (Matt Roper) - Check full IP version when applying hw steering semaphore (Matt Roper) - Enable GuC GGTT invalidation from the start (Daniele Ceraolo Spurio) - MTL GSC firmware support (Daniele Ceraolo Spurio, Jonathan Cavitt) - MTL OA support (Umesh Nerlige Ramappa) - MTL initial gt workarounds (Matt Roper) Driver refactors: - Hold forcewake and MCR lock over PPAT setup (Matt Roper) - Acquire fw before loop in intel_uncore_read64_2x32 (Umesh Nerlige Ramappa) - GuC filename cleanups and use submission API version number (John Harrison) - Promote pxp subsystem to top-level of i915 (Alan Previn) - Finish proofing the code agains object size overflows (Chris Wilson, Gwan-gyeong Mun) - Start adding module oriented dmesg output (John Harrison) Miscellaneous: - Correct kerneldoc for intel_gt_mcr_wait_for_reg() (Matt Roper) - Bump up sample period for busy stats selftest (Umesh Nerlige Ramappa) - Make GuC default_lists const data (Jani Nikula) - Fix table order verification to check all FW types (John Harrison) - Remove some limited use register access wrappers (Jani Nikula) - Remove struct_member macro (Andrzej Hajda) - Remove hardcoded value with a macro (Nirmoy Das) - Use helper func to find out map type (Nirmoy Das) - Fix a static analysis warning (John Harrison) - Consolidate VMA active tracking helpers (Andrzej Hajda) - Do not cover all future platforms in TLB invalidation (Tvrtko Ursulin) - Replace zero-length arrays with flexible-array members (Gustavo A. R. Silva) - Unwind hugepages to drop wakeref on error (Chris Wilson) - Remove a couple of superfluous i915_drm.h includes (Jani Nikula) Merges: - Merge drm/drm-next into drm-intel-gt-next (Rodrigo Vivi) danvet: Fix up merge conflict in intel_uc_fw.c, we ended up with 2 copies of try_firmware_load() somehow. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/Y8fW2Ny1B1hZ5ZmF@tursulin-desk
2 parents 0b45ac1 + 378e04f commit 045e8d1

127 files changed

Lines changed: 2661 additions & 952 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/gpu/drm/i915/Makefile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ i915-y += \
191191
i915_vma_resource.o
192192

193193
# general-purpose microcontroller (GuC) support
194-
i915-y += gt/uc/intel_uc.o \
195-
gt/uc/intel_uc_debugfs.o \
196-
gt/uc/intel_uc_fw.o \
194+
i915-y += \
195+
gt/uc/intel_gsc_fw.o \
196+
gt/uc/intel_gsc_uc.o \
197197
gt/uc/intel_guc.o \
198198
gt/uc/intel_guc_ads.o \
199199
gt/uc/intel_guc_capture.o \
@@ -208,7 +208,10 @@ i915-y += gt/uc/intel_uc.o \
208208
gt/uc/intel_guc_submission.o \
209209
gt/uc/intel_huc.o \
210210
gt/uc/intel_huc_debugfs.o \
211-
gt/uc/intel_huc_fw.o
211+
gt/uc/intel_huc_fw.o \
212+
gt/uc/intel_uc.o \
213+
gt/uc/intel_uc_debugfs.o \
214+
gt/uc/intel_uc_fw.o
212215

213216
# graphics system controller (GSC) support
214217
i915-y += gt/intel_gsc.o

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ intel_pin_fb_obj_dpt(struct drm_framebuffer *fb,
9191
goto err;
9292
}
9393

94-
vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
94+
vma->display_alignment = max(vma->display_alignment, alignment);
9595

9696
i915_gem_object_flush_if_display(obj);
9797

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static int intelfb_create(struct drm_fb_helper *helper,
286286

287287
/* Our framebuffer is the entirety of fbdev's system memory */
288288
info->fix.smem_start =
289-
(unsigned long)(ggtt->gmadr.start + vma->node.start);
289+
(unsigned long)(ggtt->gmadr.start + i915_ggtt_offset(vma));
290290
info->fix.smem_len = vma->size;
291291
}
292292

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1848,7 +1848,7 @@ static bool bo_has_valid_encryption(struct drm_i915_gem_object *obj)
18481848
{
18491849
struct drm_i915_private *i915 = to_i915(obj->base.dev);
18501850

1851-
return intel_pxp_key_check(&to_gt(i915)->pxp, obj, false) == 0;
1851+
return intel_pxp_key_check(i915->pxp, obj, false) == 0;
18521852
}
18531853

18541854
static bool pxp_is_borked(struct drm_i915_gem_object *obj)

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ static int proto_context_set_protected(struct drm_i915_private *i915,
257257

258258
if (!protected) {
259259
pc->uses_protected_content = false;
260-
} else if (!intel_pxp_is_enabled(&to_gt(i915)->pxp)) {
260+
} else if (!intel_pxp_is_enabled(i915->pxp)) {
261261
ret = -ENODEV;
262262
} else if ((pc->user_flags & BIT(UCONTEXT_RECOVERABLE)) ||
263263
!(pc->user_flags & BIT(UCONTEXT_BANNABLE))) {
@@ -271,8 +271,8 @@ static int proto_context_set_protected(struct drm_i915_private *i915,
271271
*/
272272
pc->pxp_wakeref = intel_runtime_pm_get(&i915->runtime_pm);
273273

274-
if (!intel_pxp_is_active(&to_gt(i915)->pxp))
275-
ret = intel_pxp_start(&to_gt(i915)->pxp);
274+
if (!intel_pxp_is_active(i915->pxp))
275+
ret = intel_pxp_start(i915->pxp);
276276
}
277277

278278
return ret;
@@ -1688,6 +1688,10 @@ void i915_gem_init__contexts(struct drm_i915_private *i915)
16881688
init_contexts(&i915->gem.contexts);
16891689
}
16901690

1691+
/*
1692+
* Note that this implicitly consumes the ctx reference, by placing
1693+
* the ctx in the context_xa.
1694+
*/
16911695
static void gem_context_register(struct i915_gem_context *ctx,
16921696
struct drm_i915_file_private *fpriv,
16931697
u32 id)
@@ -1703,17 +1707,17 @@ static void gem_context_register(struct i915_gem_context *ctx,
17031707
snprintf(ctx->name, sizeof(ctx->name), "%s[%d]",
17041708
current->comm, pid_nr(ctx->pid));
17051709

1706-
/* And finally expose ourselves to userspace via the idr */
1707-
old = xa_store(&fpriv->context_xa, id, ctx, GFP_KERNEL);
1708-
WARN_ON(old);
1709-
17101710
spin_lock(&ctx->client->ctx_lock);
17111711
list_add_tail_rcu(&ctx->client_link, &ctx->client->ctx_list);
17121712
spin_unlock(&ctx->client->ctx_lock);
17131713

17141714
spin_lock(&i915->gem.contexts.lock);
17151715
list_add_tail(&ctx->link, &i915->gem.contexts.list);
17161716
spin_unlock(&i915->gem.contexts.lock);
1717+
1718+
/* And finally expose ourselves to userspace via the idr */
1719+
old = xa_store(&fpriv->context_xa, id, ctx, GFP_KERNEL);
1720+
WARN_ON(old);
17171721
}
17181722

17191723
int i915_gem_context_open(struct drm_i915_private *i915,
@@ -2199,14 +2203,22 @@ finalize_create_context_locked(struct drm_i915_file_private *file_priv,
21992203
if (IS_ERR(ctx))
22002204
return ctx;
22012205

2206+
/*
2207+
* One for the xarray and one for the caller. We need to grab
2208+
* the reference *prior* to making the ctx visble to userspace
2209+
* in gem_context_register(), as at any point after that
2210+
* userspace can try to race us with another thread destroying
2211+
* the context under our feet.
2212+
*/
2213+
i915_gem_context_get(ctx);
2214+
22022215
gem_context_register(ctx, file_priv, id);
22032216

22042217
old = xa_erase(&file_priv->proto_context_xa, id);
22052218
GEM_BUG_ON(old != pc);
22062219
proto_context_close(file_priv->dev_priv, pc);
22072220

2208-
/* One for the xarray and one for the caller */
2209-
return i915_gem_context_get(ctx);
2221+
return ctx;
22102222
}
22112223

22122224
struct i915_gem_context *

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ static int ext_set_protected(struct i915_user_extension __user *base, void *data
384384
if (ext.flags)
385385
return -EINVAL;
386386

387-
if (!intel_pxp_is_enabled(&to_gt(ext_data->i915)->pxp))
387+
if (!intel_pxp_is_enabled(ext_data->i915->pxp))
388388
return -ENODEV;
389389

390390
ext_data->flags |= I915_BO_PROTECTED;

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "i915_gem_object.h"
1818
#include "i915_vma.h"
1919

20+
#define VTD_GUARD (168u * I915_GTT_PAGE_SIZE) /* 168 or tile-row PTE padding */
21+
2022
static bool gpu_write_needs_clflush(struct drm_i915_gem_object *obj)
2123
{
2224
struct drm_i915_private *i915 = to_i915(obj->base.dev);
@@ -424,6 +426,17 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
424426
if (ret)
425427
return ERR_PTR(ret);
426428

429+
/* VT-d may overfetch before/after the vma, so pad with scratch */
430+
if (intel_scanout_needs_vtd_wa(i915)) {
431+
unsigned int guard = VTD_GUARD;
432+
433+
if (i915_gem_object_is_tiled(obj))
434+
guard = max(guard,
435+
i915_gem_object_get_tile_row_size(obj));
436+
437+
flags |= PIN_OFFSET_GUARD | guard;
438+
}
439+
427440
/*
428441
* As the user may map the buffer once pinned in the display plane
429442
* (e.g. libkms for the bootup splash), we have to ensure that we
@@ -444,7 +457,7 @@ i915_gem_object_pin_to_display_plane(struct drm_i915_gem_object *obj,
444457
if (IS_ERR(vma))
445458
return vma;
446459

447-
vma->display_alignment = max_t(u64, vma->display_alignment, alignment);
460+
vma->display_alignment = max(vma->display_alignment, alignment);
448461
i915_vma_mark_scanout(vma);
449462

450463
i915_gem_object_flush_if_display_locked(obj);

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -379,22 +379,25 @@ eb_vma_misplaced(const struct drm_i915_gem_exec_object2 *entry,
379379
const struct i915_vma *vma,
380380
unsigned int flags)
381381
{
382-
if (vma->node.size < entry->pad_to_size)
382+
const u64 start = i915_vma_offset(vma);
383+
const u64 size = i915_vma_size(vma);
384+
385+
if (size < entry->pad_to_size)
383386
return true;
384387

385-
if (entry->alignment && !IS_ALIGNED(vma->node.start, entry->alignment))
388+
if (entry->alignment && !IS_ALIGNED(start, entry->alignment))
386389
return true;
387390

388391
if (flags & EXEC_OBJECT_PINNED &&
389-
vma->node.start != entry->offset)
392+
start != entry->offset)
390393
return true;
391394

392395
if (flags & __EXEC_OBJECT_NEEDS_BIAS &&
393-
vma->node.start < BATCH_OFFSET_BIAS)
396+
start < BATCH_OFFSET_BIAS)
394397
return true;
395398

396399
if (!(flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS) &&
397-
(vma->node.start + vma->node.size + 4095) >> 32)
400+
(start + size + 4095) >> 32)
398401
return true;
399402

400403
if (flags & __EXEC_OBJECT_NEEDS_MAP &&
@@ -440,7 +443,7 @@ eb_pin_vma(struct i915_execbuffer *eb,
440443
int err;
441444

442445
if (vma->node.size)
443-
pin_flags = vma->node.start;
446+
pin_flags = __i915_vma_offset(vma);
444447
else
445448
pin_flags = entry->offset & PIN_OFFSET_MASK;
446449

@@ -663,8 +666,8 @@ static int eb_reserve_vma(struct i915_execbuffer *eb,
663666
if (err)
664667
return err;
665668

666-
if (entry->offset != vma->node.start) {
667-
entry->offset = vma->node.start | UPDATE;
669+
if (entry->offset != i915_vma_offset(vma)) {
670+
entry->offset = i915_vma_offset(vma) | UPDATE;
668671
eb->args->flags |= __EXEC_HAS_RELOC;
669672
}
670673

@@ -906,7 +909,7 @@ static struct i915_vma *eb_lookup_vma(struct i915_execbuffer *eb, u32 handle)
906909
*/
907910
if (i915_gem_context_uses_protected_content(eb->gem_context) &&
908911
i915_gem_object_is_protected(obj)) {
909-
err = intel_pxp_key_check(&vm->gt->pxp, obj, true);
912+
err = intel_pxp_key_check(eb->i915->pxp, obj, true);
910913
if (err) {
911914
i915_gem_object_put(obj);
912915
return ERR_PTR(err);
@@ -1021,8 +1024,8 @@ static int eb_validate_vmas(struct i915_execbuffer *eb)
10211024
return err;
10221025

10231026
if (!err) {
1024-
if (entry->offset != vma->node.start) {
1025-
entry->offset = vma->node.start | UPDATE;
1027+
if (entry->offset != i915_vma_offset(vma)) {
1028+
entry->offset = i915_vma_offset(vma) | UPDATE;
10261029
eb->args->flags |= __EXEC_HAS_RELOC;
10271030
}
10281031
} else {
@@ -1103,7 +1106,7 @@ static inline u64
11031106
relocation_target(const struct drm_i915_gem_relocation_entry *reloc,
11041107
const struct i915_vma *target)
11051108
{
1106-
return gen8_canonical_addr((int)reloc->delta + target->node.start);
1109+
return gen8_canonical_addr((int)reloc->delta + i915_vma_offset(target));
11071110
}
11081111

11091112
static void reloc_cache_init(struct reloc_cache *cache,
@@ -1312,7 +1315,7 @@ static void *reloc_iomap(struct i915_vma *batch,
13121315
if (err) /* no inactive aperture space, use cpu reloc */
13131316
return NULL;
13141317
} else {
1315-
cache->node.start = vma->node.start;
1318+
cache->node.start = i915_ggtt_offset(vma);
13161319
cache->node.mm = (void *)vma;
13171320
}
13181321
}
@@ -1475,7 +1478,7 @@ eb_relocate_entry(struct i915_execbuffer *eb,
14751478
* more work needs to be done.
14761479
*/
14771480
if (!DBG_FORCE_RELOC &&
1478-
gen8_canonical_addr(target->vma->node.start) == reloc->presumed_offset)
1481+
gen8_canonical_addr(i915_vma_offset(target->vma)) == reloc->presumed_offset)
14791482
return 0;
14801483

14811484
/* Check that the relocation address is valid... */
@@ -2405,7 +2408,7 @@ static int eb_request_submit(struct i915_execbuffer *eb,
24052408
}
24062409

24072410
err = rq->context->engine->emit_bb_start(rq,
2408-
batch->node.start +
2411+
i915_vma_offset(batch) +
24092412
eb->batch_start_offset,
24102413
batch_len,
24112414
eb->batch_flags);
@@ -2416,7 +2419,7 @@ static int eb_request_submit(struct i915_execbuffer *eb,
24162419
GEM_BUG_ON(intel_context_is_parallel(rq->context));
24172420
GEM_BUG_ON(eb->batch_start_offset);
24182421
err = rq->context->engine->emit_bb_start(rq,
2419-
eb->trampoline->node.start +
2422+
i915_vma_offset(eb->trampoline) +
24202423
batch_len, 0, 0);
24212424
if (err)
24222425
return err;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,15 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)
3535
struct drm_i915_private *i915 = to_i915(obj->base.dev);
3636
struct sg_table *st;
3737
struct scatterlist *sg;
38-
unsigned int npages;
38+
unsigned int npages; /* restricted by sg_alloc_table */
3939
int max_order = MAX_ORDER;
4040
unsigned int max_segment;
4141
gfp_t gfp;
4242

43+
if (overflows_type(obj->base.size >> PAGE_SHIFT, npages))
44+
return -E2BIG;
45+
46+
npages = obj->base.size >> PAGE_SHIFT;
4347
max_segment = i915_sg_segment_size(i915->drm.dev) >> PAGE_SHIFT;
4448
max_order = min(max_order, get_order(max_segment));
4549

@@ -55,7 +59,6 @@ static int i915_gem_object_get_pages_internal(struct drm_i915_gem_object *obj)
5559
if (!st)
5660
return -ENOMEM;
5761

58-
npages = obj->base.size / PAGE_SIZE;
5962
if (sg_alloc_table(st, npages, GFP_KERNEL)) {
6063
kfree(st);
6164
return -ENOMEM;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf)
395395
/* Finally, remap it using the new GTT offset */
396396
ret = remap_io_mapping(area,
397397
area->vm_start + (vma->gtt_view.partial.offset << PAGE_SHIFT),
398-
(ggtt->gmadr.start + vma->node.start) >> PAGE_SHIFT,
398+
(ggtt->gmadr.start + i915_ggtt_offset(vma)) >> PAGE_SHIFT,
399399
min_t(u64, vma->size, area->vm_end - area->vm_start),
400400
&ggtt->iomap);
401401
if (ret)

0 commit comments

Comments
 (0)