Skip to content

Commit 4bf83dd

Browse files
committed
Merge tag 'drm-intel-gt-next-2025-09-01' of https://gitlab.freedesktop.org/drm/i915/kernel into drm-next
Driver Changes: - Apply multiple JSL/EHL/Gen7/Gen6 workaround properly at context level (Sebastian) - Protect against overflow in active_engine() (Krzysztof) - Use try_cmpxchg64() in __active_lookup() (Uros) - Enable GuC CT_DEAD output in regular debug builds (John) - Static checker and style fixes (Sebastian) - Selftest improvements (Krzysztof) Signed-off-by: Dave Airlie <[email protected]> From: Joonas Lahtinen <[email protected]> Link: https://lore.kernel.org/r/aLWZoEZVlBj2d8J9@jlahtine-mobl
2 parents 83631c7 + b7a855f commit 4bf83dd

File tree

7 files changed

+98
-98
lines changed

7 files changed

+98
-98
lines changed

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

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,8 +1382,9 @@ static void clflush_write32(u32 *addr, u32 value, unsigned int flushes)
13821382
*/
13831383
if (flushes & CLFLUSH_AFTER)
13841384
drm_clflush_virt_range(addr, sizeof(*addr));
1385-
} else
1385+
} else {
13861386
*addr = value;
1387+
}
13871388
}
13881389

13891390
static u64
@@ -1567,36 +1568,36 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)
15671568
do {
15681569
u64 offset = eb_relocate_entry(eb, ev, r);
15691570

1570-
if (likely(offset == 0)) {
1571-
} else if ((s64)offset < 0) {
1571+
if (likely(offset == 0))
1572+
continue;
1573+
1574+
if ((s64)offset < 0) {
15721575
remain = (int)offset;
15731576
goto out;
1574-
} else {
1575-
/*
1576-
* Note that reporting an error now
1577-
* leaves everything in an inconsistent
1578-
* state as we have *already* changed
1579-
* the relocation value inside the
1580-
* object. As we have not changed the
1581-
* reloc.presumed_offset or will not
1582-
* change the execobject.offset, on the
1583-
* call we may not rewrite the value
1584-
* inside the object, leaving it
1585-
* dangling and causing a GPU hang. Unless
1586-
* userspace dynamically rebuilds the
1587-
* relocations on each execbuf rather than
1588-
* presume a static tree.
1589-
*
1590-
* We did previously check if the relocations
1591-
* were writable (access_ok), an error now
1592-
* would be a strange race with mprotect,
1593-
* having already demonstrated that we
1594-
* can read from this userspace address.
1595-
*/
1596-
offset = gen8_canonical_addr(offset & ~UPDATE);
1597-
__put_user(offset,
1598-
&urelocs[r - stack].presumed_offset);
15991577
}
1578+
/*
1579+
* Note that reporting an error now
1580+
* leaves everything in an inconsistent
1581+
* state as we have *already* changed
1582+
* the relocation value inside the
1583+
* object. As we have not changed the
1584+
* reloc.presumed_offset or will not
1585+
* change the execobject.offset, on the
1586+
* call we may not rewrite the value
1587+
* inside the object, leaving it
1588+
* dangling and causing a GPU hang. Unless
1589+
* userspace dynamically rebuilds the
1590+
* relocations on each execbuf rather than
1591+
* presume a static tree.
1592+
*
1593+
* We did previously check if the relocations
1594+
* were writable (access_ok), an error now
1595+
* would be a strange race with mprotect,
1596+
* having already demonstrated that we
1597+
* can read from this userspace address.
1598+
*/
1599+
offset = gen8_canonical_addr(offset & ~UPDATE);
1600+
__put_user(offset, &urelocs[r - stack].presumed_offset);
16001601
} while (r++, --count);
16011602
urelocs += ARRAY_SIZE(stack);
16021603
} while (remain);

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

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,32 +1096,20 @@ static int ___igt_mmap_migrate(struct drm_i915_private *i915,
10961096
unsigned long addr,
10971097
bool unfaultable)
10981098
{
1099-
struct vm_area_struct *area;
1100-
int err = 0, i;
1099+
int i;
11011100

11021101
pr_info("igt_mmap(%s, %d) @ %lx\n",
11031102
obj->mm.region->name, I915_MMAP_TYPE_FIXED, addr);
11041103

1105-
mmap_read_lock(current->mm);
1106-
area = vma_lookup(current->mm, addr);
1107-
mmap_read_unlock(current->mm);
1108-
if (!area) {
1109-
pr_err("%s: Did not create a vm_area_struct for the mmap\n",
1110-
obj->mm.region->name);
1111-
err = -EINVAL;
1112-
goto out_unmap;
1113-
}
1114-
11151104
for (i = 0; i < obj->base.size / sizeof(u32); i++) {
11161105
u32 __user *ux = u64_to_user_ptr((u64)(addr + i * sizeof(*ux)));
11171106
u32 x;
11181107

11191108
if (get_user(x, ux)) {
1120-
err = -EFAULT;
11211109
if (!unfaultable) {
11221110
pr_err("%s: Unable to read from mmap, offset:%zd\n",
11231111
obj->mm.region->name, i * sizeof(x));
1124-
goto out_unmap;
1112+
return -EFAULT;
11251113
}
11261114

11271115
continue;
@@ -1130,37 +1118,29 @@ static int ___igt_mmap_migrate(struct drm_i915_private *i915,
11301118
if (unfaultable) {
11311119
pr_err("%s: Faulted unmappable memory\n",
11321120
obj->mm.region->name);
1133-
err = -EINVAL;
1134-
goto out_unmap;
1121+
return -EINVAL;
11351122
}
11361123

11371124
if (x != expand32(POISON_INUSE)) {
11381125
pr_err("%s: Read incorrect value from mmap, offset:%zd, found:%x, expected:%x\n",
11391126
obj->mm.region->name,
11401127
i * sizeof(x), x, expand32(POISON_INUSE));
1141-
err = -EINVAL;
1142-
goto out_unmap;
1128+
return -EINVAL;
11431129
}
11441130

11451131
x = expand32(POISON_FREE);
11461132
if (put_user(x, ux)) {
11471133
pr_err("%s: Unable to write to mmap, offset:%zd\n",
11481134
obj->mm.region->name, i * sizeof(x));
1149-
err = -EFAULT;
1150-
goto out_unmap;
1135+
return -EFAULT;
11511136
}
11521137
}
11531138

1154-
if (unfaultable) {
1155-
if (err == -EFAULT)
1156-
err = 0;
1157-
} else {
1158-
obj->flags &= ~I915_BO_ALLOC_GPU_ONLY;
1159-
err = wc_check(obj);
1160-
}
1161-
out_unmap:
1162-
vm_munmap(addr, obj->base.size);
1163-
return err;
1139+
if (unfaultable)
1140+
return 0;
1141+
1142+
obj->flags &= ~I915_BO_ALLOC_GPU_ONLY;
1143+
return wc_check(obj);
11641144
}
11651145

11661146
#define IGT_MMAP_MIGRATE_TOPDOWN (1 << 0)
@@ -1176,6 +1156,7 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements,
11761156
struct drm_i915_private *i915 = placements[0]->i915;
11771157
struct drm_i915_gem_object *obj;
11781158
struct i915_request *rq = NULL;
1159+
struct vm_area_struct *area;
11791160
unsigned long addr;
11801161
LIST_HEAD(objects);
11811162
u64 offset;
@@ -1207,28 +1188,38 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements,
12071188
goto out_put;
12081189
}
12091190

1191+
mmap_read_lock(current->mm);
1192+
area = vma_lookup(current->mm, addr);
1193+
mmap_read_unlock(current->mm);
1194+
if (!area) {
1195+
pr_err("%s: Did not create a vm_area_struct for the mmap\n",
1196+
obj->mm.region->name);
1197+
err = -EINVAL;
1198+
goto out_addr;
1199+
}
1200+
12101201
if (flags & IGT_MMAP_MIGRATE_FILL) {
12111202
err = igt_fill_mappable(placements[0], &objects);
12121203
if (err)
1213-
goto out_put;
1204+
goto out_addr;
12141205
}
12151206

12161207
err = i915_gem_object_lock(obj, NULL);
12171208
if (err)
1218-
goto out_put;
1209+
goto out_addr;
12191210

12201211
err = i915_gem_object_pin_pages(obj);
12211212
if (err) {
12221213
i915_gem_object_unlock(obj);
1223-
goto out_put;
1214+
goto out_addr;
12241215
}
12251216

12261217
err = intel_context_migrate_clear(to_gt(i915)->migrate.context, NULL,
12271218
obj->mm.pages->sgl, obj->pat_index,
12281219
i915_gem_object_is_lmem(obj),
12291220
expand32(POISON_INUSE), &rq);
12301221
i915_gem_object_unpin_pages(obj);
1231-
if (rq) {
1222+
if (rq && !err) {
12321223
err = dma_resv_reserve_fences(obj->base.resv, 1);
12331224
if (!err)
12341225
dma_resv_add_fence(obj->base.resv, &rq->fence,
@@ -1237,24 +1228,24 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements,
12371228
}
12381229
i915_gem_object_unlock(obj);
12391230
if (err)
1240-
goto out_put;
1231+
goto out_addr;
12411232

12421233
if (flags & IGT_MMAP_MIGRATE_EVICTABLE)
12431234
igt_make_evictable(&objects);
12441235

12451236
if (flags & IGT_MMAP_MIGRATE_FAIL_GPU) {
12461237
err = i915_gem_object_lock(obj, NULL);
12471238
if (err)
1248-
goto out_put;
1239+
goto out_addr;
12491240

12501241
/*
1251-
* Ensure we only simulate the gpu failuire when faulting the
1242+
* Ensure we only simulate the gpu failure when faulting the
12521243
* pages.
12531244
*/
12541245
err = i915_gem_object_wait_moving_fence(obj, true);
12551246
i915_gem_object_unlock(obj);
12561247
if (err)
1257-
goto out_put;
1248+
goto out_addr;
12581249
i915_ttm_migrate_set_failure_modes(true, false);
12591250
}
12601251

@@ -1298,6 +1289,9 @@ static int __igt_mmap_migrate(struct intel_memory_region **placements,
12981289
}
12991290
}
13001291

1292+
out_addr:
1293+
vm_munmap(addr, obj->base.size);
1294+
13011295
out_put:
13021296
i915_gem_object_put(obj);
13031297
igt_close_objects(i915, &objects);

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

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -337,12 +337,26 @@ static void gen6_ctx_workarounds_init(struct intel_engine_cs *engine,
337337
struct i915_wa_list *wal)
338338
{
339339
wa_masked_en(wal, INSTPM, INSTPM_FORCE_ORDERING);
340+
341+
/* WaDisable_RenderCache_OperationalFlush:snb */
342+
wa_masked_dis(wal, CACHE_MODE_0, RC_OP_FLUSH_ENABLE);
340343
}
341344

342345
static void gen7_ctx_workarounds_init(struct intel_engine_cs *engine,
343346
struct i915_wa_list *wal)
344347
{
345348
wa_masked_en(wal, INSTPM, INSTPM_FORCE_ORDERING);
349+
/* WaDisable_RenderCache_OperationalFlush:ivb,vlv,hsw */
350+
wa_masked_dis(wal, CACHE_MODE_0_GEN7, RC_OP_FLUSH_ENABLE);
351+
352+
/*
353+
* BSpec says this must be set, even though
354+
* WaDisable4x2SubspanOptimization:ivb,hsw
355+
* WaDisable4x2SubspanOptimization isn't listed for VLV.
356+
*/
357+
wa_masked_en(wal,
358+
CACHE_MODE_1,
359+
PIXEL_SUBSPAN_COLLECT_OPT_DISABLE);
346360
}
347361

348362
static void gen8_ctx_workarounds_init(struct intel_engine_cs *engine,
@@ -634,6 +648,8 @@ static void cfl_ctx_workarounds_init(struct intel_engine_cs *engine,
634648
static void icl_ctx_workarounds_init(struct intel_engine_cs *engine,
635649
struct i915_wa_list *wal)
636650
{
651+
struct drm_i915_private *i915 = engine->i915;
652+
637653
/* Wa_1406697149 (WaDisableBankHangMode:icl) */
638654
wa_write(wal, GEN8_L3CNTLREG, GEN8_ERRDETBCTRL);
639655

@@ -669,6 +685,15 @@ static void icl_ctx_workarounds_init(struct intel_engine_cs *engine,
669685

670686
/* Wa_1406306137:icl,ehl */
671687
wa_mcr_masked_en(wal, GEN9_ROW_CHICKEN4, GEN11_DIS_PICK_2ND_EU);
688+
689+
if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915)) {
690+
/*
691+
* Disable Repacking for Compression (masked R/W access)
692+
* before rendering compressed surfaces for display.
693+
*/
694+
wa_masked_en(wal, CACHE_MODE_0_GEN7,
695+
DISABLE_REPACKING_FOR_COMPRESSION);
696+
}
672697
}
673698

674699
/*
@@ -2306,15 +2331,6 @@ rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
23062331
GEN8_RC_SEMA_IDLE_MSG_DISABLE);
23072332
}
23082333

2309-
if (IS_JASPERLAKE(i915) || IS_ELKHARTLAKE(i915)) {
2310-
/*
2311-
* "Disable Repacking for Compression (masked R/W access)
2312-
* before rendering compressed surfaces for display."
2313-
*/
2314-
wa_masked_en(wal, CACHE_MODE_0_GEN7,
2315-
DISABLE_REPACKING_FOR_COMPRESSION);
2316-
}
2317-
23182334
if (GRAPHICS_VER(i915) == 11) {
23192335
/* This is not an Wa. Enable for better image quality */
23202336
wa_masked_en(wal,
@@ -2565,18 +2581,6 @@ rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
25652581
RING_MODE_GEN7(RENDER_RING_BASE),
25662582
GFX_TLB_INVALIDATE_EXPLICIT | GFX_REPLAY_MODE);
25672583

2568-
/* WaDisable_RenderCache_OperationalFlush:ivb,vlv,hsw */
2569-
wa_masked_dis(wal, CACHE_MODE_0_GEN7, RC_OP_FLUSH_ENABLE);
2570-
2571-
/*
2572-
* BSpec says this must be set, even though
2573-
* WaDisable4x2SubspanOptimization:ivb,hsw
2574-
* WaDisable4x2SubspanOptimization isn't listed for VLV.
2575-
*/
2576-
wa_masked_en(wal,
2577-
CACHE_MODE_1,
2578-
PIXEL_SUBSPAN_COLLECT_OPT_DISABLE);
2579-
25802584
/*
25812585
* BSpec recommends 8x4 when MSAA is used,
25822586
* however in practice 16x4 seems fastest.
@@ -2643,9 +2647,6 @@ rcs_engine_wa_init(struct intel_engine_cs *engine, struct i915_wa_list *wal)
26432647
GEN6_WIZ_HASHING_MASK,
26442648
GEN6_WIZ_HASHING_16x4);
26452649

2646-
/* WaDisable_RenderCache_OperationalFlush:snb */
2647-
wa_masked_dis(wal, CACHE_MODE_0, RC_OP_FLUSH_ENABLE);
2648-
26492650
/*
26502651
* From the Sandybridge PRM, volume 1 part 3, page 24:
26512652
* "If this bit is set, STCunit will have LRA as replacement

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,8 @@ static void active_engine(struct kthread_work *work)
904904
arg->result = PTR_ERR(ce[count]);
905905
pr_err("[%s] Create context #%ld failed: %d!\n",
906906
engine->name, count, arg->result);
907+
if (!count)
908+
return;
907909
while (--count)
908910
intel_context_put(ce[count]);
909911
return;

drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "intel_guc_ct.h"
1414
#include "intel_guc_print.h"
1515

16-
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GUC)
16+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
1717
enum {
1818
CT_DEAD_ALIVE = 0,
1919
CT_DEAD_SETUP,
@@ -144,7 +144,7 @@ void intel_guc_ct_init_early(struct intel_guc_ct *ct)
144144
spin_lock_init(&ct->requests.lock);
145145
INIT_LIST_HEAD(&ct->requests.pending);
146146
INIT_LIST_HEAD(&ct->requests.incoming);
147-
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GUC)
147+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
148148
INIT_WORK(&ct->dead_ct_worker, ct_dead_ct_worker_func);
149149
#endif
150150
INIT_WORK(&ct->requests.worker, ct_incoming_request_worker_func);
@@ -373,7 +373,7 @@ int intel_guc_ct_enable(struct intel_guc_ct *ct)
373373

374374
ct->enabled = true;
375375
ct->stall_time = KTIME_MAX;
376-
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GUC)
376+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
377377
ct->dead_ct_reported = false;
378378
ct->dead_ct_reason = CT_DEAD_ALIVE;
379379
#endif
@@ -1377,7 +1377,7 @@ void intel_guc_ct_print_info(struct intel_guc_ct *ct,
13771377
ct->ctbs.recv.desc->tail);
13781378
}
13791379

1380-
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG_GUC)
1380+
#if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
13811381
static void ct_dead_ct_worker_func(struct work_struct *w)
13821382
{
13831383
struct intel_guc_ct *ct = container_of(w, struct intel_guc_ct, dead_ct_worker);
@@ -1386,6 +1386,9 @@ static void ct_dead_ct_worker_func(struct work_struct *w)
13861386
if (ct->dead_ct_reported)
13871387
return;
13881388

1389+
if (i915_error_injected())
1390+
return;
1391+
13891392
ct->dead_ct_reported = true;
13901393

13911394
guc_info(guc, "CTB is dead - reason=0x%X\n", ct->dead_ct_reason);

0 commit comments

Comments
 (0)