drm/i915: Use b->irq_enable() as predicate for mock engine
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 18 Jan 2019 11:22:25 +0000 (11:22 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 18 Jan 2019 12:05:29 +0000 (12:05 +0000)
Since commit  d4ccceb05591 ("drm/i915/icl: Ringbuffer interrupt handling")
we have required a mechanism to avoid touching the interrupt hardware
for breadcrumbs, superseding our mock interface for selftests.

The residual problem (ideas welcome) is in probing the mock ring
registers for ring_is_idle. Hmm, maybe we should just install
mock handlers for i915->uncore.mmio__write and friends? Only problem
being is that we would to truly mock some expected reads. :(

References: d4ccceb05591 ("drm/i915/icl: Ringbuffer interrupt handling")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190118112225.13780-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/intel_breadcrumbs.c
drivers/gpu/drm/i915/intel_engine_cs.c
drivers/gpu/drm/i915/intel_ringbuffer.h
drivers/gpu/drm/i915/selftests/mock_engine.c

index bfbff04c16aa5758e2a57d24bdf3d793a6410b6b..4fad93fe3678f61cd371847ba88eed76aa889afa 100644 (file)
@@ -287,25 +287,16 @@ static bool __intel_breadcrumbs_enable_irq(struct intel_breadcrumbs *b)
        if (b->irq_armed)
                return false;
 
-       /* The breadcrumb irq will be disarmed on the interrupt after the
+       /*
+        * The breadcrumb irq will be disarmed on the interrupt after the
         * waiters are signaled. This gives us a single interrupt window in
         * which we can add a new waiter and avoid the cost of re-enabling
         * the irq.
         */
        b->irq_armed = true;
 
-       if (I915_SELFTEST_ONLY(b->mock)) {
-               /* For our mock objects we want to avoid interaction
-                * with the real hardware (which is not set up). So
-                * we simply pretend we have enabled the powerwell
-                * and the irq, and leave it up to the mock
-                * implementation to call intel_engine_wakeup()
-                * itself when it wants to simulate a user interrupt,
-                */
-               return true;
-       }
-
-       /* Since we are waiting on a request, the GPU should be busy
+       /*
+        * Since we are waiting on a request, the GPU should be busy
         * and should have its own rpm reference. This is tracked
         * by i915->gt.awake, we can forgo holding our own wakref
         * for the interrupt as before i915->gt.awake is released (when
index cc6379422bc06d1d44be8c5521d71c766486c389..639bcd4cf3e90054de662213742c4ce10e2871a0 100644 (file)
@@ -917,6 +917,9 @@ static bool ring_is_idle(struct intel_engine_cs *engine)
        intel_wakeref_t wakeref;
        bool idle = true;
 
+       if (I915_SELFTEST_ONLY(!engine->mmio_base))
+               return true;
+
        /* If the whole device is asleep, the engine must be idle */
        wakeref = intel_runtime_pm_get_if_in_use(dev_priv);
        if (!wakeref)
@@ -955,9 +958,6 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
        if (!intel_engine_signaled(engine, intel_engine_last_submit(engine)))
                return false;
 
-       if (I915_SELFTEST_ONLY(engine->breadcrumbs.mock))
-               return true;
-
        /* Waiting to drain ELSP? */
        if (READ_ONCE(engine->execlists.active)) {
                struct tasklet_struct *t = &engine->execlists.tasklet;
@@ -983,10 +983,7 @@ bool intel_engine_is_idle(struct intel_engine_cs *engine)
                return false;
 
        /* Ring stopped? */
-       if (!ring_is_idle(engine))
-               return false;
-
-       return true;
+       return ring_is_idle(engine);
 }
 
 bool intel_engines_are_idle(struct drm_i915_private *dev_priv)
index 616f6bbb18ad74f64746c0c3cf6e3583846adc04..c3ef0f9bf321a442bba48fdd78b533c1e4d071bc 100644 (file)
@@ -398,7 +398,6 @@ struct intel_engine_cs {
                unsigned int irq_count;
 
                bool irq_armed : 1;
-               I915_SELFTEST_DECLARE(bool mock : 1);
        } breadcrumbs;
 
        struct {
index 50e1a0b1af7ea00036e233233d6db921b6277938..9fe5b2c8f8d466587757a4ef58719e2a97cc36fd 100644 (file)
@@ -201,7 +201,6 @@ struct intel_engine_cs *mock_engine(struct drm_i915_private *i915,
        i915_timeline_set_subclass(&engine->base.timeline, TIMELINE_ENGINE);
 
        intel_engine_init_breadcrumbs(&engine->base);
-       engine->base.breadcrumbs.mock = true; /* prevent touching HW for irqs */
 
        /* fake hw queue */
        spin_lock_init(&engine->hw_lock);