drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
Subsystems (2)
PATCH 1/1 drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
The hardware needs some time to process the information received in the ExecList Submission Port, and expects us to don't write anything new until it has 'acknowledged' this new execlist by sending an IDLE_ACTIVE or PREEMPTED CSB event.
If we do not follow this, the driver could write new data into the ELSP before HW had finishing fetching the previous one, putting us in 'undefined behaviour' space.
This seems to be the problem causing the spurious PREEMPTED & COMPLETE events after a COMPLETE like the one below:
[] vcs0: sw rd pointer = 2, hw wr pointer = 0, current 'head' = 3.
[] vcs0: Execlist CSB[0]: 0x00000018 _ 0x00000007 [] vcs0: Execlist CSB[1]: 0x00000001 _ 0x00000000 [] vcs0: Execlist CSB[2]: 0x00000018 _ 0x00000007 <<< COMPLETE [] vcs0: Execlist CSB[3]: 0x00000012 _ 0x00000007 <<< PREEMPTED & COMPLETE [] vcs0: Execlist CSB[4]: 0x00008002 _ 0x00000006 [] vcs0: Execlist CSB[5]: 0x00000014 _ 0x00000006
The ELSP writes that lead to this CSB sequence show that the HW hadn't started executing the previous execlist (the one with only ctx 0x6) by the time the new one was submitted; this is a bit more clear in the data show in the EXECLIST_STATUS register at the time of the ELSP write.
[] vcs0: ELSP[0] = 0x0_0 [execlist1] - status_reg = 0x0_302
[] vcs0: ELSP[1] = 0x6_fedb2119 [execlist0] - status_reg = 0x0_8302
[] vcs0: ELSP[2] = 0x7_fedaf119 [execlist1] - status_reg = 0x0_8308 [] vcs0: ELSP[3] = 0x6_fedb2119 [execlist0] - status_reg = 0x7_8308
Note that having to wait for this ack does not disable lite-restores, although it may reduce their numbers.
And take this as a RFC, since there are probably better ways to still respect this HW requirement.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102035
--- drivers/gpu/drm/i915/intel_lrc.c | 16 +++++++++++++++- drivers/gpu/drm/i915/intel_ringbuffer.h | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_lrc.c +15 -1
@@ -449,11 +449,16 @@ static inline void elsp_write(u64 desc, u32 __iomem *elsp)static void execlists_submit_ports (struct intel_engine_cs *engine) { +struct intel_engine_execlists *const execlists = &engine->execlists;struct execlist_port *port = engine->execlists.port;u32 __iomem *elsp = engine->i915->regs +i915_mmio_reg_offset (RING_ELSP (engine));unsigned int n; +if (wait_for_atomic (!READ_ONCE (execlists->outstanding_submission),10 )) +GEM_TRACE ("%s outstanding submission stuck\n" , + engine->name); +for (n =execlists_num_ports (&engine->execlists); n--; ) {struct drm_i915_gem_request *rq;unsigned int count;
@@ -479,6 +484,8 @@ static void execlists_submit_ports(struct intel_engine_cs *engine)elsp_write (desc, elsp); } + +WRITE_ONCE (execlists->outstanding_submission,1 ); }static bool ctx_single_port_submission (const struct i915_gem_context *ctx)
@@ -889,6 +896,11 @@ static void execlists_submission_tasklet(unsigned long data)GEM_TRACE ("%s csb[%dd]: status=0x%08x:0x%08x\n" , engine->name, head, status, buf[2 *head +1 ]); + +if ((status &GEN8_CTX_STATUS_IDLE_ACTIVE ) || + (status &GEN8_CTX_STATUS_PREEMPTED )) +WRITE_ONCE (execlists->outstanding_submission,0 ); +if (!(status &GEN8_CTX_STATUS_COMPLETED_MASK ))continue ;
@@ -944,9 +956,11 @@ static void execlists_submission_tasklet(unsigned long data)/* After the final element, the hw should be idle */ GEM_BUG_ON (port_count (port) ==0 && !(status &GEN8_CTX_STATUS_ACTIVE_IDLE )); -if (port_count (port) ==0 ) +if (port_count (port) ==0 ) {execlists_clear_active (execlists,EXECLISTS_ACTIVE_USER ); +WRITE_ONCE (execlists->outstanding_submission,0 ); + } }if (head != execlists->csb_head) {
drivers/gpu/drm/i915/intel_ringbuffer.h +6 -0
@@ -288,6 +288,12 @@ struct intel_engine_execlists {* @csb_use_mmio: access csb through mmio, instead of hwsp */ bool csb_use_mmio; + +/** +* @outstanding_submission: prevent further ELSP writes until HW +* has ack'd one (with IDLE_ACTIVE or PREEMPT CSB events) +*/ +bool outstanding_submission; };#define INTEL_ENGINE_CS_MAX_NAME 8
Signature · 6 lines
2.15.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoting Michel Thierry (2017-11-18 00:30:38)
Quoted 52 lines
The hardware needs some time to process the information received in the ExecList Submission Port, and expects us to don't write anything new until it has 'acknowledged' this new execlist by sending an
IDLE_ACTIVEor PREEMPTED CSB event.If we do not follow this, the driver could write new data into the ELSP before HW had finishing fetching the previous one, putting us in 'undefined behaviour' space.
This seems to be the problem causing the spurious PREEMPTED & COMPLETE events after a COMPLETE like the one below:
[] vcs0: sw rd pointer = 2, hw wr pointer = 0, current 'head' = 3.
[] vcs0: Execlist CSB[0]: 0x00000018 _ 0x00000007 [] vcs0: Execlist CSB[1]: 0x00000001 _ 0x00000000 [] vcs0: Execlist CSB[2]: 0x00000018 _ 0x00000007 <<< COMPLETE [] vcs0: Execlist CSB[3]: 0x00000012 _ 0x00000007 <<< PREEMPTED & COMPLETE [] vcs0: Execlist CSB[4]: 0x00008002 _ 0x00000006 [] vcs0: Execlist CSB[5]: 0x00000014 _ 0x00000006The ELSP writes that lead to this CSB sequence show that the HW hadn't started executing the previous execlist (the one with only ctx
0x6) by the time the new one was submitted; this is a bit more clear in the data show in theEXECLIST_STATUSregister at the time of the ELSP write.[] vcs0: ELSP[0] = 0x0_0 [execlist1] -
status_reg= 0x0_302
[] vcs0: ELSP[1] = 0x6_fedb2119 [execlist0] -status_reg= 0x0_8302[] vcs0: ELSP[2] = 0x7_fedaf119 [execlist1] -
status_reg= 0x0_8308 [] vcs0: ELSP[3] = 0x6_fedb2119 [execlist0] -status_reg= 0x7_8308Note that having to wait for this ack does not disable lite-restores, although it may reduce their numbers.
And take this as a RFC, since there are probably better ways to still respect this HW requirement.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102035
Signed-off-by Michel Thierry <[email protected]>Cc Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/intel_lrc.c | 16 +++++++++++++++- drivers/gpu/drm/i915/intel_ringbuffer.h | 6 ++++++ 2 files changed, 21 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/intel_lrc.c +0
-0@@ -449,11 +449,16 @@ static inline void elsp_write(u64 desc, u32 __iomem *elsp)static void execlists_submit_ports (struct intel_engine_cs *engine)
drivers/gpu/drm/i915/intel_lrc.c static inline void elsp_write(u64 desc, u32 __iomem *elsp) · line 460
Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +4
-0{ +struct intel_engine_execlists *const execlists = &engine->execlists;struct execlist_port *port = engine->execlists.port;u32 __iomem *elsp = engine->i915->regs +i915_mmio_reg_offset (RING_ELSP (engine));unsigned int n; +if (wait_for_atomic (!READ_ONCE (execlists->outstanding_submission),10 )) +GEM_TRACE ("%s outstanding submission stuck\n" , + engine->name);
That can never succeed. Processing events and submitting ports is serialised to the same thread. All the READ_ONCE/WRITE_ONCE are incorrect.
I actually did try tracking something like this; the problem is that we do not always get the IDLE_ACTIVE indicator so actually tracking when the hw is awake is tricky.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
In reply to Michel Thierry== Series Details ==
== Series Details ==
Series: drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
URL : https://patchwork.freedesktop.org/series/34043/
State : success
== Summary ==
Series 34043v1 drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
https://patchwork.freedesktop.org/api/1.0/series/34043/revisions/1/mbox/
fi-bdw-5557u total:289 pass:268 dwarn:0 dfail:0 fail:0 skip:21 time:446s fi-bdw-gvtdvm total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:453s fi-blb-e6850 total:289 pass:223 dwarn:1 dfail:0 fail:0 skip:65 time:383s fi-bsw-n3050 total:289 pass:243 dwarn:0 dfail:0 fail:0 skip:46 time:549s fi-bwr-2160 total:289 pass:183 dwarn:0 dfail:0 fail:0 skip:106 time:279s fi-bxt-dsi total:289 pass:259 dwarn:0 dfail:0 fail:0 skip:30 time:542s fi-bxt-j4205 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:545s fi-byt-j1900 total:289 pass:254 dwarn:0 dfail:0 fail:0 skip:35 time:505s fi-byt-n2820 total:289 pass:250 dwarn:0 dfail:0 fail:0 skip:39 time:488s fi-elk-e7500 total:289 pass:229 dwarn:0 dfail:0 fail:0 skip:60 time:428s fi-gdg-551 total:289 pass:178 dwarn:1 dfail:0 fail:1 skip:109 time:267s fi-glk-1 total:289 pass:261 dwarn:0 dfail:0 fail:0 skip:28 time:581s fi-hsw-4770 total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:435s fi-hsw-4770r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:440s fi-ilk-650 total:289 pass:228 dwarn:0 dfail:0 fail:0 skip:61 time:430s fi-ivb-3520m total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:495s fi-ivb-3770 total:289 pass:260 dwarn:0 dfail:0 fail:0 skip:29 time:464s fi-kbl-7500u total:289 pass:264 dwarn:1 dfail:0 fail:0 skip:24 time:525s fi-kbl-7560u total:289 pass:270 dwarn:0 dfail:0 fail:0 skip:19 time:588s fi-kbl-7567u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:531s fi-kbl-r total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:573s fi-pnv-d510 total:289 pass:222 dwarn:1 dfail:0 fail:0 skip:66 time:579s fi-skl-6260u total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:506s fi-skl-6600u total:289 pass:262 dwarn:0 dfail:0 fail:0 skip:27 time:590s fi-skl-6700hq total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:605s fi-skl-6700k total:289 pass:265 dwarn:0 dfail:0 fail:0 skip:24 time:568s fi-skl-6770hq total:289 pass:269 dwarn:0 dfail:0 fail:0 skip:20 time:539s fi-skl-gvtdvm total:289 pass:266 dwarn:0 dfail:0 fail:0 skip:23 time:513s fi-snb-2520m total:246 pass:212 dwarn:0 dfail:0 fail:0 skip:33 fi-snb-2600 total:289 pass:249 dwarn:0 dfail:0 fail:0 skip:40 time:427s Blacklisted hosts: fi-cfl-s2 total:289 pass:263 dwarn:0 dfail:0 fail:0 skip:26 time:650s fi-cnl-y total:241 pass:216 dwarn:0 dfail:0 fail:0 skip:24 fi-glk-dsi total:289 pass:258 dwarn:0 dfail:0 fail:1 skip:30 time:533s
72ffd011e980c8131f0c63e08c576d09977a2c54 drm-tip: 2017y-11m-17d-18h-38m-47s UTC integration manifest 1012245361ae drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7182/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: warning for drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
In reply to Michel Thierry== Series Details ==
== Series Details ==
Series: drm/i915/lrc: Stop writing to ELSP until HW has processed the previous write
URL : https://patchwork.freedesktop.org/series/34043/
State : warning
== Summary ==
Warning: bzip CI_DRM_3359/shard-glkb6/results1.json.bz2 wasn't in correct JSON format Test kms_flip:
Subgroup flip-vs-modeset-interruptible:
dmesg-warn -> PASS (shard-hsw)
Test kms_cursor_crc:
Subgroup cursor-128x128-sliding:
pass -> SKIP (shard-hsw)
Test pm_rpm:
Subgroup basic-rte:
pass -> SKIP (shard-hsw)shard-hsw total:2585 pass:1473 dwarn:1 dfail:1 fail:9 skip:1101 time:9405s shard-snb total:2585 pass:1261 dwarn:1 dfail:1 fail:11 skip:1311 time:8013s Blacklisted hosts: shard-apl total:2547 pass:1591 dwarn:2 dfail:0 fail:23 skip:929 time:13018s shard-kbl total:2442 pass:1629 dwarn:4 dfail:0 fail:23 skip:783 time:10521s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7182/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx