From 37305ede63c7e5a696b74b64ffb7c62cbe0ecd2f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 11 Feb 2020 20:56:15 +0000 Subject: drm/i915/selftests: Sabotague the RING_HEAD Apply vast quantities of poison and not tell anyone to see if we fall for the trap of using a stale RING_HEAD. References: 42827350f75c ("drm/i915/gt: Avoid resetting ring->head outside of its timeline mutex") Signed-off-by: Chris Wilson Cc: Andi Shyti Cc: Mika Kuoppala Reviewed-by: Mika Kuoppala Link: https://patchwork.freedesktop.org/patch/msgid/20200211205615.1190127-2-chris@chris-wilson.co.uk --- drivers/gpu/drm/i915/gt/selftest_lrc.c | 79 ++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'drivers/gpu') diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c index e53bfedeb97e..26d39c111d16 100644 --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c @@ -300,6 +300,84 @@ static int live_unlite_preempt(void *arg) return live_unlite_restore(arg, I915_USER_PRIORITY(I915_PRIORITY_MAX)); } +static int live_pin_rewind(void *arg) +{ + struct intel_gt *gt = arg; + struct intel_engine_cs *engine; + enum intel_engine_id id; + int err = 0; + + /* + * We have to be careful not to trust intel_ring too much, for example + * ring->head is updated upon retire which is out of sync with pinning + * the context. Thus we cannot use ring->head to set CTX_RING_HEAD, + * or else we risk writing an older, stale value. + * + * To simulate this, let's apply a bit of deliberate sabotague. + */ + + for_each_engine(engine, gt, id) { + struct intel_context *ce; + struct i915_request *rq; + struct intel_ring *ring; + struct igt_live_test t; + + if (igt_live_test_begin(&t, gt->i915, __func__, engine->name)) { + err = -EIO; + break; + } + + ce = intel_context_create(engine); + if (IS_ERR(ce)) { + err = PTR_ERR(ce); + break; + } + + err = intel_context_pin(ce); + if (err) { + intel_context_put(ce); + break; + } + + /* Keep the context awake while we play games */ + err = i915_active_acquire(&ce->active); + if (err) { + intel_context_unpin(ce); + intel_context_put(ce); + break; + } + ring = ce->ring; + + /* Poison the ring, and offset the next request from HEAD */ + memset32(ring->vaddr, STACK_MAGIC, ring->size / sizeof(u32)); + ring->emit = ring->size / 2; + ring->tail = ring->emit; + GEM_BUG_ON(ring->head); + + intel_context_unpin(ce); + + /* Submit a simple nop request */ + GEM_BUG_ON(intel_context_is_pinned(ce)); + rq = intel_context_create_request(ce); + i915_active_release(&ce->active); /* e.g. async retire */ + intel_context_put(ce); + if (IS_ERR(rq)) { + err = PTR_ERR(rq); + break; + } + GEM_BUG_ON(!rq->head); + i915_request_add(rq); + + /* Expect not to hang! */ + if (igt_live_test_end(&t)) { + err = -EIO; + break; + } + } + + return err; +} + static int live_hold_reset(void *arg) { struct intel_gt *gt = arg; @@ -3629,6 +3707,7 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915) SUBTEST(live_sanitycheck), SUBTEST(live_unlite_switch), SUBTEST(live_unlite_preempt), + SUBTEST(live_pin_rewind), SUBTEST(live_hold_reset), SUBTEST(live_error_interrupt), SUBTEST(live_timeslice_preempt), -- cgit v1.2.3 >AuthorFilesLines 2025-10-07selftests: drv-net: make linters happy with our importsJakub Kicinski2-11/+33 2025-10-07net: sparx5/lan969x: fix flooding configuration on bridge join/leaveDaniel Machon3-10/+17 2025-10-07net: mdio: mdio-i2c: Hold the i2c bus lock during smbus transactionsMaxime Chevallier1-14/+25 2025-10-06selftests: net: unify the Makefile formatsJakub Kicinski17-242/+383 2025-10-06selftests: net: sort configsJakub Kicinski11-150/+150 2025-10-06tcp: take care of zero tp->window_clamp in tcp_set_rcvlowat()Eric Dumazet1-1/+4 2025-10-06page_pool: Fix PP_MAGIC_MASK to avoid crashing on some 32-bit archesToke Høiland-Jørgensen2-32/+66 2025-10-06net: fsl_pq_mdio: Fix device node reference leak in fsl_pq_mdio_probeErick Karanja1-0/+2 2025-10-06ice: ice_adapter: release xa entry on adapter allocation failureHaotian Zhang1-4/+6 2025-10-06selftest: net: ovpn: Fix uninit return valuesSidharth Seela1-0/+2 2025-10-06net: mscc: ocelot: Fix use-after-free caused by cyclic delayed workDuoming Zhou1-1/+1 2025-10-06tcp: Don't call reqsk_fastopen_remove() in tcp_conn_request().Kuniyuki Iwashima1-1/+0 2025-10-06net: wwan: t7xx: add support for HP DRMR-H01Sammy Hsu1-0/+1 2025-10-06net/sctp: fix a null dereference in sctp_disposition sctp_sf_do_5_1D_ce()Alexandr Sapozhnikov1-1/+2 2025-10-03net: doc: Fix typos in docsBhanu Seshu Kumar Valluri3-5/+5 2025-10-03net: psp: don't assume reply skbs will have a socketJakub Kicinski4-6/+6 2025-10-03net/mlx4: prevent potential use after free in mlx4_en_do_uc_filter()Dan Carpenter1-1/+1 2025-10-03net: usb: lan78xx: Fix lost EEPROM read timeout error(-ETIMEDOUT) in lan78xx_...Bhanu Seshu Kumar Valluri1-4/+7 2025-10-01ARM: versatile: clock: convert from round_rate() to determine_rate()Brian Masney1-4/+5 2025-10-01ARM: configs: u8500: Set NFC_SHDLC as built-inJihed Chaibi1-1/+1 2025-10-01mfd: simple-mfd-i2c: Add compatible string for LX2160ARDBIoana Ciornei1-0/+1 2025-10-01mfd: simple-mfd-i2c: Keep compatible strings in alphabetical orderIoana Ciornei1-3/+3 2025-10-01dt-bindings: mfd: twl: Add missing sub-nodes for TWL4030 & TWL603xJihed Chaibi4-128/+273 2025-10-01dt-bindings: watchdog: Add SMARC-sAM67 supportMichael Walle1-1/+6 2025-10-01dt-bindings: mfd: tps6594: Allow gpio-line-namesMichael Walle1-0/+1 2025-10-01mfd: intel-lpss: Add Intel Wildcat Lake LPSS PCI IDsIlpo Järvinen1-0/+13 2025-10-01mfd: 88pm886: Add GPADC cellDuje Mihanović1-0/+1 2025-10-01mfd: vexpress-sysreg: Use more common syntax for compound literalsBartosz Golaszewski1-1/+1 2025-10-01mfd: rz-mtu3: Fix MTU5 NFCR register offsetCosmin Tanislav1-1/+1 2025-10-01mfd: max77705: Setup the core driver as an interrupt controllerDzmitry Sankouski1-21/+14 2025-10-01mfd: cs42l43: Remove IRQ masking in suspendCharles Keepax1-26/+0 2025-10-01mfd: cs42l43: Move IRQ enable/disable to encompass force suspendCharles Keepax1-4/+4 2025-10-01mfd: ls2kbmc: Add Loongson-2K BMC reset function supportBinbin Zhou1-0/+339 2025-10-01mfd: ls2kbmc: Introduce Loongson-2K BMC core driverBinbin Zhou4-0/+210 2025-10-01mfd: bd71828, bd71815: Prepare for power-supply supportMatti Vaittinen2-9/+98 2025-10-01dt-bindings: mfd: aspeed: Add AST2700 SCU compatiblesRyan Chen1-0/+4 2025-10-01dt-bindings: mfd: Convert aspeed,ast2400-p2a-ctrl to DT schemaRob Herring (Arm)2-47/+32 2025-10-01dt-bindings: mfd: fsl,mc13xxx: Add buttons nodeAlexander Kurz1-0/+70 2025-10-01dt-bindings: mfd: fsl,mc13xxx: Convert txt to DT schemaAlexander Kurz2-156/+218 2025-10-01mfd: macsmc: Add "apple,t8103-smc" compatibleJanne Grunau1-0/+1 2025-10-01mfd: core: Increment of_node's refcount before linking it to the platform deviceBastien Curutchet1-0/+1 2025-10-01dt-bindings: mfd: syscon: Document the control-scb syscon on PolarFire SoCConor Dooley1-0/+2 2025-10-01mfd: simple-mfd-i2c: Add SpacemiT P1 supportAlex Elder2-0/+30