drm/i915: Drop posting reads to flush master interrupts
Subsystems (2)
PATCH 1/9 drm/i915: Drop posting reads to flush master interrupts
We do not need to do a posting read of our uncached mmio write to re-enable the master interrupt lines after handling an interrupt, so don't. This saves us a slow UC read before we can process the interrupt, most noticeable in execlists where any stalls imposes extra latency on GPU command execution.
--- drivers/gpu/drm/i915/i915_irq.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +1 -8
@@ -2183,7 +2183,6 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)I915_WRITE (VLV_IER , ier);I915_WRITE (VLV_MASTER_IER ,MASTER_INTERRUPT_ENABLE ); -POSTING_READ (VLV_MASTER_IER );if (gt_iir)snb_gt_irq_handler (dev_priv, gt_iir);
@@ -2268,7 +2267,6 @@ static irqreturn_t cherryview_irq_handler(int irq, void *arg)I915_WRITE (VLV_IER , ier);I915_WRITE (GEN8_MASTER_IRQ ,GEN8_MASTER_IRQ_CONTROL ); -POSTING_READ (GEN8_MASTER_IRQ );gen8_gt_irq_handler (dev_priv, master_ctl, gt_iir);
@@ -2637,7 +2635,6 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)/* disable master interrupt before clearing iir */ de_ier =I915_READ (DEIER );I915_WRITE (DEIER , de_ier & ~DE_MASTER_IRQ_CONTROL ); -POSTING_READ (DEIER );/* Disable south interrupts. We'll only write to SDEIIR once, so further * interrupts will will be stored on its back queue, and then we'll be
@@ -2647,7 +2644,6 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)if (!HAS_PCH_NOP (dev_priv)) { sde_ier =I915_READ (SDEIER );I915_WRITE (SDEIER ,0 ); -POSTING_READ (SDEIER ); }/* Find, clear, then process each source of interrupt */
@@ -2682,11 +2678,8 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg) }I915_WRITE (DEIER , de_ier); -POSTING_READ (DEIER ); -if (!HAS_PCH_NOP (dev_priv)) { +if (!HAS_PCH_NOP (dev_priv))I915_WRITE (SDEIER , sde_ier); -POSTING_READ (SDEIER ); - }/* IRQs are synced during runtime_suspend, we don't require a wakeref */ enable_rpm_wakeref_asserts (dev_priv);
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/9 drm/i915/execlists: Pull submit after dequeue under timeline lock
In the next patch, we will begin processing the CSB from inside the submission path (underneath an irqsoff section, and even from inside interrupt handlers). This means that updating the execlists->port[] will no longer be serialised by the tasklet but needs to be locked by the engine->timeline.lock instead. Pull dequeue and submit under the same lock for protection. (An alternate future plan is to keep the in/out arrays separate for concurrent processing and reduced lock coverage.)
--- drivers/gpu/drm/i915/intel_lrc.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +12 -20
@@ -567,7 +567,7 @@ static void complete_preempt_context(struct intel_engine_execlists *execlists)execlists_clear_active (execlists,EXECLISTS_ACTIVE_PREEMPT ); } -static bool __execlists_dequeue (struct intel_engine_cs *engine) +static void __execlists_dequeue (struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists;struct execlist_port *port = execlists->port;
@@ -622,11 +622,11 @@ static bool __execlists_dequeue(struct intel_engine_cs *engine)* the HW to indicate that it has had a chance to respond. */ if (!execlists_is_active (execlists,EXECLISTS_ACTIVE_HWACK )) -return false; +return ;if (need_preempt (engine, last, execlists->queue_priority)) {inject_preempt_context (engine); -return false; +return ; }/*
@@ -651,7 +651,7 @@ static bool __execlists_dequeue(struct intel_engine_cs *engine)* priorities of the ports haven't been switch. */ if (port_count (&port[1 ])) -return false; +return ;/* * WaIdleLiteRestore:bdw,skl
@@ -751,8 +751,10 @@ static bool __execlists_dequeue(struct intel_engine_cs *engine) port != execlists->port ?rq_prio (last) :INT_MIN ; execlists->first = rb; -if (submit) +if (submit) {port_assign (port, last); +execlists_submit_ports (engine); + }/* We must always keep the beast fed if we have work piled up */ GEM_BUG_ON (execlists->first && !port_isset (execlists->port));
@@ -761,24 +763,19 @@ static bool __execlists_dequeue(struct intel_engine_cs *engine)if (last)execlists_user_begin (execlists, execlists->port); -return submit; +/* If the engine is now idle, so should be the flag; and vice versa. */ +GEM_BUG_ON (execlists_is_active (&engine->execlists, +EXECLISTS_ACTIVE_USER ) == + !port_isset (engine->execlists.port)); }static void execlists_dequeue (struct intel_engine_cs *engine) { -struct intel_engine_execlists *const execlists = &engine->execlists;unsigned long flags; -bool submit;spin_lock_irqsave (&engine->timeline.lock, flags); - submit =__execlists_dequeue (engine); +__execlists_dequeue (engine);spin_unlock_irqrestore (&engine->timeline.lock, flags); - -if (submit) -execlists_submit_ports (engine); - -GEM_BUG_ON (port_isset (execlists->port) && - !execlists_is_active (execlists,EXECLISTS_ACTIVE_USER )); }void
@@ -1161,11 +1158,6 @@ static void execlists_submission_tasklet(unsigned long data)if (!execlists_is_active (&engine->execlists,EXECLISTS_ACTIVE_PREEMPT ))execlists_dequeue (engine); - -/* If the engine is now idle, so should be the flag; and vice versa. */ -GEM_BUG_ON (execlists_is_active (&engine->execlists, -EXECLISTS_ACTIVE_USER ) == - !port_isset (engine->execlists.port)); } static void queue_request(struct intel_engine_cs *engine,
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/9 drm/i915/execlists: Pull CSB reset under the timeline.lock
In reply to Chris WilsonIn the following patch, we will process the CSB events under the timeline.lock and not serialised by the tasklet. This also means that we will need to protect access to common variables such as execlists->csb_head with the timeline.lock during reset.
v2: Move sync_irq to avoid deadlocks between taking timeline.lock from our interrupt handler.
v3: Kill off the synchronize_hardirq as it raises more questions than answered; now we use the timeline.lock entirely for CSB serialisation between the irq and elsewhere, we don't need to be so heavy handed with flushing
v4: Treat request cancellation (wedging after failed reset) similarly
--- drivers/gpu/drm/i915/intel_lrc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +4 -12
@@ -871,7 +871,6 @@ static void reset_irq(struct intel_engine_cs *engine) {/* Mark all CS interrupts as complete */ smp_store_mb (engine->execlists.active,0 ); -synchronize_hardirq (engine->i915->drm.irq);clear_gtiir (engine);
@@ -908,14 +907,12 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine)* submission's irq state, we also wish to remind ourselves that * it is irq state.) */ -local_irq_save (flags); +spin_lock_irqsave (&engine->timeline.lock, flags);/* Cancel the requests on the HW and clear the ELSP tracker. */ execlists_cancel_port_requests (execlists);reset_irq (engine); -spin_lock (&engine->timeline.lock); -/* Mark all executing requests as skipped. */ list_for_each_entry (rq, &engine->timeline.requests, link) {GEM_BUG_ON (!rq->global_seqno);
@@ -949,9 +946,7 @@ static void execlists_cancel_requests(struct intel_engine_cs *engine) execlists->first =NULL ;GEM_BUG_ON (port_isset (execlists->port)); -spin_unlock (&engine->timeline.lock); - -local_irq_restore (flags); +spin_unlock_irqrestore (&engine->timeline.lock, flags); }static void process_csb (struct intel_engine_cs *engine)
@@ -1969,8 +1964,7 @@ static void execlists_reset(struct intel_engine_cs *engine, engine->name, request ? request->global_seqno :0 , intel_engine_get_seqno(engine)); -/* See execlists_cancel_requests() for the irq/spinlock split. */ -local_irq_save (flags); +spin_lock_irqsave (&engine->timeline.lock, flags);/* * Catch up with any missed context-switch interrupts.
@@ -1985,14 +1979,12 @@ static void execlists_reset(struct intel_engine_cs *engine,reset_irq (engine);/* Push back any incomplete requests for replay after the reset. */ -spin_lock (&engine->timeline.lock);__unwind_incomplete_requests (engine); -spin_unlock (&engine->timeline.lock);/* Following the reset, we need to reload the CSB read/write pointers */ engine->execlists.csb_head =GEN8_CSB_ENTRIES -1 ; -local_irq_restore (flags); +spin_unlock_irqrestore (&engine->timeline.lock, flags);/* * If the request was innocent, we leave the request in the ELSP
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/9 drm/i915/execlists: Process one CSB update at a time
In reply to Chris WilsonIn the next patch, we will process the CSB events directly from the submission path, rather than only after a CS interrupt. Hence, we will no longer have the need for a loop until the has-interrupt bit is clear, and in the meantime can remove that small optimisation.
v2: Tvrtko pointed out it was safer to unconditionally kick the tasklet after each irq, when assuming that the tasklet is called for each irq.
--- drivers/gpu/drm/i915/i915_irq.c | 7 +- drivers/gpu/drm/i915/intel_lrc.c | 278 +++++++++++++++---------------- 2 files changed, 141 insertions(+), 144 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +4 -3
@@ -1497,9 +1497,10 @@ gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir)bool tasklet = false;if (iir >_CONTEXT_SWITCH_INTERRUPT ) { -if (READ_ONCE (engine->execlists.active)) - tasklet = !test_and_set_bit (ENGINE_IRQ_EXECLIST , - &engine->irq_posted); +if (READ_ONCE (engine->execlists.active)) { +set_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted); + tasklet = true; + } }if (iir >_RENDER_USER_INTERRUPT ) {
drivers/gpu/drm/i915/intel_lrc.c +137 -141
303 lines not on this page · raw message
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/9 drm/i915/execlists: Unify CSB access pointers
In reply to Chris WilsonFollowing the removal of the last workarounds, the only CSB mmio access is for the old vGPU interface. The mmio registers presented by vGPU do not require forcewake and can be treated as ordinary volatile memory, i.e. they behave just like the HWSP access just at a different location. We can reduce the CSB access to a set of read/write/buffer pointers and treat the various paths identically and not worry about forcewake. (Forcewake is nightmare for worstcase latency, and we want to process this all with irqsoff -- no latency allowed!)
v2: Comments, comments, comments. Well, 2 bonus comments.
--- drivers/gpu/drm/i915/intel_engine_cs.c | 12 --- drivers/gpu/drm/i915/intel_lrc.c | 133 ++++++++++++------------ drivers/gpu/drm/i915/intel_ringbuffer.h | 23 ++-- 3 files changed, 82 insertions(+), 86 deletions(-)
drivers/gpu/drm/i915/intel_engine_cs.c +0 -12
@@ -25,7 +25,6 @@#include <drm/drm_print.h> #include "i915_drv.h" -#include "i915_vgpu.h" #include "intel_ringbuffer.h" #include "intel_lrc.h"
@@ -456,21 +455,10 @@ static void intel_engine_init_batch_pool(struct intel_engine_cs *engine)i915_gem_batch_pool_init (&engine->batch_pool, engine); } -static bool csb_force_mmio (struct drm_i915_private *i915) -{ -/* Older GVT emulation depends upon intercepting CSB mmio */ -if (intel_vgpu_active (i915) && !intel_vgpu_has_hwsp_emulation (i915)) -return true; - -return false; -} -static void intel_engine_init_execlist (struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists; - execlists->csb_use_mmio =csb_force_mmio (engine->i915); - execlists->port_mask =1 ;BUILD_BUG_ON_NOT_POWER_OF_2 (execlists_num_ports (execlists));GEM_BUG_ON (execlists_num_ports (execlists) >EXECLIST_MAX_PORTS );
drivers/gpu/drm/i915/intel_lrc.c +65 -68
205 lines not on this page · raw message
drivers/gpu/drm/i915/intel_ringbuffer.h +17 -6
@@ -300,24 +300,35 @@ struct intel_engine_execlists {struct rb_node *first;/** -* @fw_domains: forcewake domains for irq tasklet +* @csb_read: control register for Context Switch buffer +* +* Note this register is always in mmio. */ -unsigned int fw_domains; +u32 __iomem *csb_read;/** -* @csb_head: context status buffer head +* @csb_write: control register for Context Switch buffer +* +* Note this register may be either mmio or HWSP shadow. */ -unsigned int csb_head; +u32 *csb_write;/** -* @csb_use_mmio: access csb through mmio, instead of hwsp +* @csb_status: status array for Context Switch buffer +* +* Note these register may be either mmio or HWSP shadow. */ -bool csb_use_mmio; +u32 *csb_status;/** * @preempt_complete_status: expected CSB upon completing preemption */ u32 preempt_complete_status; + +/** +* @csb_head: context status buffer head +*/ +u8 csb_head; };#define INTEL_ENGINE_CS_MAX_NAME 8
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/9 drm/i915/execlists: Reset CSB write pointer after reset
In reply to Chris WilsonOn HW reset, the HW clears the write pointer (to 0). But since it also writes its first CSB entry to slot 0, we need to reset the write pointer back to the element before (so the first entry we read is 0).
This is required for the next patch, where we trust the CSB completely!
v2: Use _MASKED_FIELD
v3: Store the reset value, so that we differentiate between mmio/hwsp transparently and without pretense.
--- drivers/gpu/drm/i915/intel_lrc.c | 23 +++++++++++++++++++++-- drivers/gpu/drm/i915/intel_ringbuffer.h | 9 +++++++++ 2 files changed, 30 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +21 -2
@@ -884,6 +884,21 @@ static void reset_irq(struct intel_engine_cs *engine)clear_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted); } +static void reset_csb_pointers (struct intel_engine_execlists *execlists) +{ +/* +* After a reset, the HW starts writing into CSB entry [0]. We +* therefore have to set our HEAD pointer back one entry so that +* the *first* entry we check is entry 0. To complicate this further, +* as we don't wait for the first interrupt after reset, we have to +* fake the HW write to point back to the last entry so that our +* inline comparison of our cached head position against the last HW +* write works even before the first interrupt. +*/ + execlists->csb_head = execlists->csb_write_reset; +WRITE_ONCE (*execlists->csb_write, execlists->csb_write_reset); +} +static void execlists_cancel_requests (struct intel_engine_cs *engine) {struct intel_engine_execlists *const execlists = &engine->execlists;
@@ -1970,7 +1985,7 @@ static void execlists_reset(struct intel_engine_cs *engine,__unwind_incomplete_requests (engine);/* Following the reset, we need to reload the CSB read/write pointers */ - engine->execlists.csb_head =GEN8_CSB_ENTRIES -1 ; +reset_csb_pointers (&engine->execlists);spin_unlock_irqrestore (&engine->timeline.lock, flags);
@@ -2469,7 +2484,6 @@ static int logical_ring_init(struct intel_engine_cs *engine)upper_32_bits (ce->lrc_desc); } - execlists->csb_head =GEN8_CSB_ENTRIES -1 ; execlists->csb_read = i915->regs +i915_mmio_reg_offset (RING_CONTEXT_STATUS_PTR (engine));if (csb_force_mmio (i915)) {
@@ -2477,13 +2491,18 @@ static int logical_ring_init(struct intel_engine_cs *engine) (i915->regs +i915_mmio_reg_offset (RING_CONTEXT_STATUS_BUF_LO (engine,0 ))); execlists->csb_write = (u32 __force *)execlists->csb_read; + execlists->csb_write_reset = +_MASKED_FIELD (GEN8_CSB_WRITE_PTR_MASK , +GEN8_CSB_ENTRIES -1 ); }else { execlists->csb_status = &engine->status_page.page_addr[I915_HWS_CSB_BUF0_INDEX ]; execlists->csb_write = &engine->status_page.page_addr[intel_hws_csb_write_index (i915)]; + execlists->csb_write_reset =GEN8_CSB_ENTRIES -1 ; } +reset_csb_pointers (execlists);return 0 ;
drivers/gpu/drm/i915/intel_ringbuffer.h +9 -0
@@ -325,6 +325,15 @@ struct intel_engine_execlists {*/ u32 preempt_complete_status; +/** +* @csb_write_reset: reset value for CSB write pointer +* +* As the CSB write pointer maybe either in HWSP or as a field +* inside an mmio register, we want to reprogram it slightly +* differently to avoid later confusion. +*/ +u32 csb_write_reset; +/** * @csb_head: context status buffer head */
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/9 drm/i915/execlists: Stop storing the CSB read pointer in the mmio register
In reply to Chris WilsonAs we now never read back our current head position from the CSB pointers register, and the HW itself doesn't use it to prevent overwriting unread CSB entries, we do not need to keep updating the register. As it turns out this register is not listed as being shadowed, and so requires forcewake -- but we haven't been taking forcewake around it so the writes has probably been regularly dropped. Fortuitously, we only read the value after a reset where it did not matter, and zero was the right answer (well, close enough).
Mika pointed out that this was how we used to do it (accidentally!) before he fixed it in commit cc53699b25b5 ("drm/i915: Use masked write for Context Status Buffer Pointer").
References: cc53699b25b5 ("drm/i915: Use masked write for Context Status Buffer Pointer")
--- drivers/gpu/drm/i915/intel_lrc.c | 2 -- 1 file changed, 2 deletions(-)
drivers/gpu/drm/i915/intel_lrc.c +0 -2
@@ -1117,8 +1117,6 @@ static void process_csb(struct intel_engine_cs *engine) } }while (head != tail); -writel (_MASKED_FIELD (GEN8_CSB_READ_PTR_MASK , head <<8 ), - execlists->csb_read); execlists->csb_head = head; }
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/9 drm/i915/execlists: Trust the CSB
In reply to Chris WilsonNow that we use the CSB stored in the CPU friendly HWSP, we do not need to track interrupts for when the mmio CSB registers are valid and can just check where we read up to last from the cached HWSP. This means we can forgo the atomic bit tracking from interrupt, and in the next patch it means we can check the CSB at any time.
v2: Change the splitting inside reset_prepare, we only want to lose testing the interrupt in this patch, the next patch requires the change in locking
--- drivers/gpu/drm/i915/i915_irq.c | 11 +++------- drivers/gpu/drm/i915/intel_engine_cs.c | 8 ++----- drivers/gpu/drm/i915/intel_lrc.c | 29 ++++--------------------- drivers/gpu/drm/i915/intel_ringbuffer.h | 1 - 4 files changed, 9 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/i915_irq.c +3 -8
@@ -1493,15 +1493,10 @@ static void snb_gt_irq_handler(struct drm_i915_private *dev_priv,static void gen8_cs_irq_handler (struct intel_engine_cs *engine,u32 iir) { -struct intel_engine_execlists *const execlists = &engine->execlists;bool tasklet = false; -if (iir >_CONTEXT_SWITCH_INTERRUPT ) { -if (READ_ONCE (engine->execlists.active)) { -set_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted); - tasklet = true; - } - } +if (iir >_CONTEXT_SWITCH_INTERRUPT ) + tasklet = true;if (iir >_RENDER_USER_INTERRUPT ) {notify_ring (engine);
@@ -1509,7 +1504,7 @@ gen8_cs_irq_handler(struct intel_engine_cs *engine, u32 iir) }if (tasklet) -tasklet_hi_schedule (&execlists->tasklet); +tasklet_hi_schedule (&engine->execlists.tasklet); } static void gen8_gt_irq_ack(struct drm_i915_private *i915,
drivers/gpu/drm/i915/intel_engine_cs.c +2 -6
@@ -1353,12 +1353,10 @@ static void intel_engine_print_registers(const struct intel_engine_cs *engine, ptr =I915_READ (RING_CONTEXT_STATUS_PTR (engine)); read =GEN8_CSB_READ_PTR (ptr); write =GEN8_CSB_WRITE_PTR (ptr); -drm_printf (m,"\tExeclist CSB read %d [%d cached], write %d [%d from hws], interrupt posted? %s, tasklet queued? %s (%s)\n" , +drm_printf (m,"\tExeclist CSB read %d [%d cached], write %d [%d from hws], tasklet queued? %s (%s)\n" , read, execlists->csb_head, write,intel_read_status_page (engine,intel_hws_csb_write_index (engine->i915)), -yesno (test_bit (ENGINE_IRQ_EXECLIST , - &engine->irq_posted)),yesno (test_bit (TASKLET_STATE_SCHED , &engine->execlists.tasklet.state)),enableddisabled (!atomic_read (&engine->execlists.tasklet.count)));
@@ -1570,11 +1568,9 @@ void intel_engine_dump(struct intel_engine_cs *engine,spin_unlock (&b->rb_lock);local_irq_restore (flags); -drm_printf (m,"IRQ? 0x%lx (breadcrumbs? %s) (execlists? %s)\n" , +drm_printf (m,"IRQ? 0x%lx (breadcrumbs? %s)\n" , engine->irq_posted,yesno (test_bit (ENGINE_IRQ_BREADCRUMB , - &engine->irq_posted)), -yesno (test_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted)));drm_printf (m,"HWSP:\n" );
drivers/gpu/drm/i915/intel_lrc.c +4 -25
@@ -874,14 +874,6 @@ static void reset_irq(struct intel_engine_cs *engine)smp_store_mb (engine->execlists.active,0 );clear_gtiir (engine); - -/* -* The port is checked prior to scheduling a tasklet, but -* just in case we have suspended the tasklet to do the -* wedging make sure that when it wakes, it decides there -* is no work to do by clearing the irq_posted bit. -*/ -clear_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted); }static void reset_csb_pointers (struct intel_engine_execlists *execlists)
@@ -972,10 +964,6 @@ static void process_csb(struct intel_engine_cs *engine)const u32 *const buf = execlists->csb_status;u8 head, tail; -/* Clear before reading to catch new interrupts */ -clear_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted); -smp_mb__after_atomic (); -/* * Note that csb_write, csb_status may be either in HWSP or mmio. * When reading from the csb_write mmio register, we have to be
@@ -1128,11 +1116,10 @@ static void execlists_submission_tasklet(unsigned long data) {struct intel_engine_cs *const engine = (struct intel_engine_cs *)data; -GEM_TRACE ("%s awake?=%d, active=%x, irq-posted?=%d\n" , +GEM_TRACE ("%s awake?=%d, active=%x\n" , engine->name, engine->i915->gt.awake, - engine->execlists.active, -test_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted)); + engine->execlists.active);/* * We can skip acquiring intel_runtime_pm_get() here as it was taken
@@ -1144,14 +1131,7 @@ static void execlists_submission_tasklet(unsigned long data)*/ GEM_BUG_ON (!engine->i915->gt.awake); -/* -* Prefer doing test_and_clear_bit() as a two stage operation to avoid -* imposing the cost of a locked atomic transaction when submitting a -* new request (outside of the context-switch interrupt). -*/ -if (test_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted)) -process_csb (engine); - +process_csb (engine);if (!execlists_is_active (&engine->execlists,EXECLISTS_ACTIVE_PREEMPT ))execlists_dequeue (engine); }
@@ -1919,8 +1899,7 @@ execlists_reset_prepare(struct intel_engine_cs *engine)* and avoid blaming an innocent request if the stall was due to the * preemption itself. */ -if (test_bit (ENGINE_IRQ_EXECLIST , &engine->irq_posted)) -process_csb (engine); +process_csb (engine);/* * The last active request can then be no later than the last request
drivers/gpu/drm/i915/intel_ringbuffer.h +0 -1
@@ -367,7 +367,6 @@ struct intel_engine_cs {unsigned long irq_posted;#define ENGINE_IRQ_BREADCRUMB 0 -#define ENGINE_IRQ_EXECLIST 1/* Rather than have every client wait upon all user interrupts, * with the herd waking after every interrupt and each doing the
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/9 drm/i915/execlists: Direct submission of new requests (avoid tasklet/ksoftirqd)
In reply to Chris WilsonBack in commit 27af5eea54d1 ("drm/i915: Move execlists irq handler to a bottom half"), we came to the conclusion that running our CSB processing and ELSP submission from inside the irq handler was a bad idea. A really bad idea as we could impose nearly 1s latency on other users of the system, on average! Deferring our work to a tasklet allowed us to do the processing with irqs enabled, reducing the impact to an average of about 50us.
We have since eradicated the use of forcewaked mmio from inside the CSB processing and ELSP submission, bringing the impact down to around 5us (on Kabylake); an order of magnitude better than our measurements 2 years ago on Broadwell and only about 2x worse on average than the gem_syslatency on an unladen system.
In this iteration of the tasklet-vs-direct submission debate, we seek a compromise where by we submit new requests immediately to the HW but defer processing the CS interrupt onto a tasklet. We gain the advantage of low-latency and ksoftirqd avoidance when waking up the HW, while avoiding the system-wide starvation of our CS irq-storms.
Comparing the impact on the maximum latency observed (that is the time stolen from an RT process) over a 120s interval, repeated several times (using gem_syslatency, similar to RT's cyclictest) while the system is fully laden with i915 nops, we see that direct submission an actually improve the worse case.
Maximum latency in microseconds of a third party RT thread (gem_syslatency -t 120 -f 2)
x Always using tasklets (a couple of >1000us outliers removed)
+ Only using tasklets from CS irq, direct submission of requests
+------------------------------------------------------------------------+
| + |
| + |
| + |
| + + |
| + + + |
| + + + + x x x |
| +++ + + + x x x x x x |
| +++ + ++ + + *x x x x x x |
| +++ + ++ + * *x x * x x x |
| + +++ + ++ * * +*xxx * x x xx |
| * +++ + ++++* *x+**xx+ * x x xxxx x |
| **x++++*++**+*x*x****x+ * +x xx xxxx x x |
|x* ******+***************++*+***xxxxxx* xx*x xxx + x+|
| |__________MA___________| |
| |______M__A________| |
+------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 118 91 186 124 125.28814 16.279137
+ 120 92 187 109 112.00833 13.458617
Difference at 95.0% confidence
-13.2798 +/- 3.79219
-10.5994% +/- 3.02677%
(Student's t, pooled s = 14.9237)However the mean latency is adversely affected:
Mean latency in microseconds of a third party RT thread (gem_syslatency -t 120 -f 1)
x Always using tasklets
+ Only using tasklets from CS irq, direct submission of requests
+------------------------------------------------------------------------+
| xxxxxx + ++ |
| xxxxxx + ++ |
| xxxxxx + +++ ++ |
| xxxxxxx +++++ ++ |
| xxxxxxx +++++ ++ |
| xxxxxxx +++++ +++ |
| xxxxxxx + ++++++++++ |
| xxxxxxxx ++ ++++++++++ |
| xxxxxxxx ++ ++++++++++ |
| xxxxxxxxxx +++++++++++++++ |
| xxxxxxxxxxx x +++++++++++++++ |
|x xxxxxxxxxxxxx x + + ++++++++++++++++++ +|
| |__A__| |
| |____A___| |
+------------------------------------------------------------------------+
N Min Max Median Avg Stddev
x 120 3.506 3.727 3.631 3.6321417 0.02773109
+ 120 3.834 4.149 4.039 4.0375167 0.041221676
Difference at 95.0% confidence
0.405375 +/- 0.00888913
11.1608% +/- 0.244735%
(Student's t, pooled s = 0.03513)However, since the mean latency corresponds to the amount of irqsoff processing we have to do for a CS interrupt, we only need to speed that up to benefit not just system latency but our own throughput.
v2: Remember to defer submissions when under reset.
v4: Only use direct submission for new requests
v5: Be aware that with mixing direct tasklet evaluation and deferred tasklets, we may end up idling before running the deferred tasklet.
v6: Remove the redudant likely() from tasklet_is_enabled(), restrict the annotation to reset_in_progress().
v7: Take the full timeline.lock when enabling perf_pmu stats as the tasklet is no longer a valid guard. A consequence is that the stats are now only valid for engines also using the timeline.lock to process state.
Testcase: igt/gem_exec_latency/*rthog*
References: 27af5eea54d1 ("drm/i915: Move execlists irq handler to a bottom half")
--- drivers/gpu/drm/i915/i915_gem.h | 5 ++ drivers/gpu/drm/i915/intel_engine_cs.c | 8 +- drivers/gpu/drm/i915/intel_lrc.c | 102 ++++++++++++++++--------- 3 files changed, 75 insertions(+), 40 deletions(-)
drivers/gpu/drm/i915/i915_gem.h +5 -0
@@ -88,4 +88,9 @@ static inline void __tasklet_enable_sync_once(struct tasklet_struct *t) tasklet_kill(t); } +static inline bool __tasklet_is_enabled (const struct tasklet_struct *t) +{ +return !atomic_read (&t->count); +} +#endif /* __I915_GEM_H__ */
drivers/gpu/drm/i915/intel_engine_cs.c +4 -4
@@ -1619,8 +1619,8 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine)if (!intel_engine_supports_stats (engine))return -ENODEV ; -tasklet_disable (&execlists->tasklet); -write_seqlock_irqsave (&engine->stats.lock, flags); +spin_lock_irqsave (&engine->timeline.lock, flags); +write_seqlock (&engine->stats.lock);if (unlikely (engine->stats.enabled == ~0 )) { err = -EBUSY ;
@@ -1644,8 +1644,8 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine) } unlock: -write_sequnlock_irqrestore (&engine->stats.lock, flags); -tasklet_enable (&execlists->tasklet); +write_sequnlock (&engine->stats.lock); +spin_unlock_irqrestore (&engine->timeline.lock, flags);return err; }
drivers/gpu/drm/i915/intel_lrc.c +66 -36
203 lines not on this page · raw message
Signature · 6 lines
2.18.0 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.CHECKPATCH: warning for series starting with [CI,1/9] drm/i915: Drop posting reads to flush master interrupts
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [CI,1/9] drm/i915: Drop posting reads to flush master interrupts
URL : https://patchwork.freedesktop.org/series/45613/
State : warning
== Summary ==
$ dim checkpatch origin/drm-tip 189a3386ae4e drm/i915: Drop posting reads to flush master interrupts ef70a1cacfa4 drm/i915/execlists: Pull submit after dequeue under timeline lock 32aec9f2f3a1 drm/i915/execlists: Pull CSB reset under the timeline.lock 118ab98625f3 drm/i915/execlists: Process one CSB update at a time -:68: WARNING:MEMORY_BARRIER: memory barrier without comment #68: FILE: drivers/gpu/drm/i915/intel_lrc.c:966: + smp_mb__after_atomic();
-:114: WARNING:LONG_LINE: line over 100 characters #114: FILE: drivers/gpu/drm/i915/intel_lrc.c:990:
+ head, GEN8_CSB_READ_PTR(readl(i915->regs + i915_mmio_reg_offset(RING_CONTEXT_STATUS_PTR(engine)))), fw ? "" : "?",
-:115: WARNING:LONG_LINE: line over 100 characters #115: FILE: drivers/gpu/drm/i915/intel_lrc.c:991:
+ tail, GEN8_CSB_WRITE_PTR(readl(i915->regs + i915_mmio_reg_offset(RING_CONTEXT_STATUS_PTR(engine)))), fw ? "" : "?");
-:183: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #183: FILE: drivers/gpu/drm/i915/intel_lrc.c:1022:
+ status, buf[2*head + 1],
^
-:211: CHECK:SPACING: spaces preferred around that '*' (ctx:VxV) #211: FILE: drivers/gpu/drm/i915/intel_lrc.c:1040:
+ buf[2*head + 1] == execlists->preempt_complete_status) {
^
total: 0 errors, 3 warnings, 2 checks, 316 lines checked0c5bf9353a8b drm/i915/execlists: Unify CSB access pointersa9c89ed64bcf drm/i915/execlists: Reset CSB write pointer after reset4ac487b638b6 drm/i915/execlists: Stop storing the CSB read pointer in the mmio register -:20: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #20:
References: cc53699b25b5 ("drm/i915: Use masked write for Context Status Buffer Pointer")
-:20: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit cc53699b25b5 ("drm/i915: Use masked write for Context Status Buffer Pointer")' #20:
References: cc53699b25b5 ("drm/i915: Use masked write for Context Status Buffer Pointer")
total: 1 errors, 1 warnings, 0 checks, 8 lines checked5ec3673a6266 drm/i915/execlists: Trust the CSB2a18ba3a331b drm/i915/execlists: Direct submission of new requests (avoid tasklet/ksoftirqd) -:108: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #108:
References: 27af5eea54d1 ("drm/i915: Move execlists irq handler to a bottom half")
-:108: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 27af5eea54d1 ("drm/i915: Move execlists irq handler to a bottom half")' #108:
References: 27af5eea54d1 ("drm/i915: Move execlists irq handler to a bottom half")
total: 1 errors, 1 warnings, 0 checks, 232 lines checked
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [CI,1/9] drm/i915: Drop posting reads to flush master interrupts
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [CI,1/9] drm/i915: Drop posting reads to flush master interrupts
URL : https://patchwork.freedesktop.org/series/45613/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4400 -> Patchwork_9477 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/45613/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_9477 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@debugfs_test@read_all_entries:
fi-snb-2520m: PASS -> INCOMPLETE (fdo#103713)
igt@drv_module_reload@basic-reload-inject:
fi-kbl-7500u: PASS -> DMESG-WARN (fdo#105604)
==== Possible fixes ====
igt@gem_exec_gttfill@basic:
fi-byt-n2820: FAIL (fdo#106744) -> PASS fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#105604 https://bugs.freedesktop.org/show_bug.cgi?id=105604
fdo#106744 https://bugs.freedesktop.org/show_bug.cgi?id=106744
== Participating hosts (44 -> 39) ==
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-hsw-4200u
== Build changes ==
* Linux: CI_DRM_4400 -> Patchwork_9477
CI_DRM_4400: 5b5204e784a9d519a52b68bb9c8d68d240765aaf @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4530: 0e98bf69f146eb72fe3a7c3b19a049b5786f0ca3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9477: 2a18ba3a331b516fe436eb85f53d8c7158319881 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
2a18ba3a331b drm/i915/execlists: Direct submission of new requests (avoid tasklet/ksoftirqd) 5ec3673a6266 drm/i915/execlists: Trust the CSB4ac487b638b6 drm/i915/execlists: Stop storing the CSB read pointer in the mmio register a9c89ed64bcf drm/i915/execlists: Reset CSB write pointer after reset 0c5bf9353a8b drm/i915/execlists: Unify CSB access pointers118ab98625f3 drm/i915/execlists: Process one CSB update at a time 32aec9f2f3a1 drm/i915/execlists: Pull CSB reset under the timeline.lock ef70a1cacfa4 drm/i915/execlists: Pull submit after dequeue under timeline lock 189a3386ae4e drm/i915: Drop posting reads to flush master interrupts
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9477/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [CI,1/9] drm/i915: Drop posting reads to flush master interrupts
In reply to Chris Wilson== Series Details ==
== Series Details ==
Series: series starting with [CI,1/9] drm/i915: Drop posting reads to flush master interrupts
URL : https://patchwork.freedesktop.org/series/45613/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4400_full -> Patchwork_9477_full =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_9477_full need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_9477_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_9477_full:
=== IGT changes ===
==== Warnings ====
igt@gem_mocs_settings@mocs-rc6-blt:
shard-kbl: PASS -> SKIP +1== Known issues ==
Here are the changes found in Patchwork_9477_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_selftest@live_evict:
shard-apl: PASS -> INCOMPLETE (fdo#103927)
igt@drv_selftest@live_gtt:
shard-apl: PASS -> FAIL (fdo#105347)
igt@kms_flip@2x-plain-flip-fb-recreate:
shard-hsw: PASS -> FAIL (fdo#100368)
igt@kms_flip@flip-vs-expired-vblank:
shard-glk: PASS -> FAIL (fdo#105189)
igt@kms_flip@flip-vs-expired-vblank-interruptible:
shard-glk: PASS -> FAIL (fdo#105363)
igt@kms_flip@plain-flip-fb-recreate:
shard-glk: PASS -> FAIL (fdo#100368) +1
igt@kms_flip_tiling@flip-y-tiled:
shard-glk: PASS -> FAIL (fdo#104724)
==== Possible fixes ====
igt@drv_selftest@live_gtt:
shard-kbl: FAIL (fdo#105347) -> PASS
shard-glk: FAIL (fdo#105347) -> PASS
igt@drv_selftest@live_hangcheck:
shard-kbl: DMESG-FAIL (fdo#106560, fdo#106947) -> PASS
igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
shard-glk: FAIL (fdo#106509, fdo#105454) -> PASS
igt@kms_flip@dpms-vs-vblank-race:
shard-hsw: FAIL (fdo#103060) -> PASS
igt@kms_flip@plain-flip-ts-check-interruptible:
shard-glk: FAIL (fdo#100368) -> PASS
igt@kms_flip_tiling@flip-to-y-tiled:
shard-glk: FAIL (fdo#104724) -> PASS
igt@kms_flip_tiling@flip-x-tiled:
shard-glk: FAIL (fdo#103822, fdo#104724) -> PASS +1
igt@kms_setmode@basic:
shard-kbl: FAIL (fdo#99912) -> PASS
igt@kms_vblank@pipe-a-wait-forked-busy-hang:
shard-glk: DMESG-WARN -> PASS fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105189 https://bugs.freedesktop.org/show_bug.cgi?id=105189
fdo#105347 https://bugs.freedesktop.org/show_bug.cgi?id=105347
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4400 -> Patchwork_9477
CI_DRM_4400: 5b5204e784a9d519a52b68bb9c8d68d240765aaf @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4530: 0e98bf69f146eb72fe3a7c3b19a049b5786f0ca3 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9477: 2a18ba3a331b516fe436eb85f53d8c7158319881 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9477/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx