drm/i915: Assert that the context pin_counts do not overflow
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 16 Mar 2017 17:16:28 +0000 (17:16 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Thu, 16 Mar 2017 20:48:58 +0000 (20:48 +0000)
This should be impossible, but let's assert that we do not pin a context
4 billion times before retiring!

v2: Fix the assertion -- the patch had just one job to do!

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170316171628.3228-1-chris@chris-wilson.co.uk
Reviewed-by: Mika Kuoppala <mika.kuoppala@intel.com>
drivers/gpu/drm/i915/intel_lrc.c
drivers/gpu/drm/i915/intel_ringbuffer.c

index 0e847d7ee0f3ccdcb0eb526ff3310e9030076371..becde55b02a3bfbabbc118e75ed0e60f53d68e65 100644 (file)
@@ -742,6 +742,7 @@ static int execlists_context_pin(struct intel_engine_cs *engine,
 
        if (ce->pin_count++)
                return 0;
+       GEM_BUG_ON(!ce->pin_count); /* no overflow please! */
 
        if (!ce->state) {
                ret = execlists_context_deferred_alloc(ctx, engine);
index 1befcdf9b646a7349d25770fee001c31b53634d0..d9b8d17c3fc679b54bfef38542d2f1e2723f9dbe 100644 (file)
@@ -1445,6 +1445,7 @@ static int intel_ring_context_pin(struct intel_engine_cs *engine,
 
        if (ce->pin_count++)
                return 0;
+       GEM_BUG_ON(!ce->pin_count); /* no overflow please! */
 
        if (ce->state) {
                ret = context_pin(ctx);