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

Dave Gordon david.s.gordon at intel.com
Wed Dec 2 10:18:43 PST 2015


On 02/12/15 14:58, Chris Wilson wrote:
> 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

Aha! That looks useful, but it didn't apply cleanly, so I've reworked it 
somewhat. Here's the patch (UNTESTED) for your comments ...

.Dave.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-drm-i915-intel_ring_initialized-must-be-simple-and-i.patch
Type: text/x-patch
Size: 6019 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/intel-gfx/attachments/20151202/8a8677f3/attachment-0001.bin>


More information about the Intel-gfx mailing list