[Intel-gfx] [RFC PATCH] drm/i915: fix potential dangling else problems in for_each_ macros

Chris Wilson chris at chris-wilson.co.uk
Wed Dec 2 06:58:01 PST 2015

On Wed, Dec 02, 2015 at 02:51:17PM +0000, Dave Gordon wrote:
> Or, put the active ones on a linked list, or keep a bitmask of which
> ones have been initialised inside the dev_priv structure, so you
> don't have to even dereference the engine[] array to work out
> whether a particular engine is initialised. Apropos which, wouldn't
> it be much more efficient to do that, because
> intel_ring_initialized() is quite heavyweight and the results surely
> don't change often, if at all, during normal operation. So we should
> only evaluate it when something has changed, and cache the bool
> result for use in all those for_each() loops!

commit b53cd50c19f9d3c6f3308165b3e26c47b19dd041
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Mar 31 00:25:20 2015 +0100

    drm/i915: intel_ring_initialized() must be simple and inline
    Fixes regression from
    commit 48d823878d64f93163f5a949623346748bbce1b4
    Author: Oscar Mateo <oscar.mateo at intel.com>
    Date:   Thu Jul 24 17:04:23 2014 +0100
        drm/i915/bdw: Generic logical ring init and cleanup
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>


-bool intel_ring_initialized(struct intel_engine_cs *ring);
+static inline bool
+intel_ring_initialized(struct intel_engine_cs *ring)
+       return ring->dev != NULL;

Just waiting to clear a massive backlog.

If we can use an array rather than a list (and a static assignment
certainly qualifies), use an array.

Chris Wilson, Intel Open Source Technology Centre

More information about the Intel-gfx mailing list