[Intel-gfx] [PATCH 1/3] drm/i915/pmu: avoid an maybe-uninitialized warning
Chris Wilson
chris at chris-wilson.co.uk
Wed May 27 15:42:04 UTC 2020
Quoting Arnd Bergmann (2020-05-27 15:05:08)
> Conditional spinlocks make it hard for gcc and for lockdep to
> follow the code flow. This one causes a warning with at least
> gcc-9 and higher:
>
> In file included from include/linux/irq.h:14,
> from drivers/gpu/drm/i915/i915_pmu.c:7:
> drivers/gpu/drm/i915/i915_pmu.c: In function 'i915_sample':
> include/linux/spinlock.h:289:3: error: 'flags' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 289 | _raw_spin_unlock_irqrestore(lock, flags); \
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/gpu/drm/i915/i915_pmu.c:288:17: note: 'flags' was declared here
> 288 | unsigned long flags;
> | ^~~~~
>
> Split out the part between the locks into a separate function
> for readability and to let the compiler figure out what the
> logic actually is.
>
> Fixes: d79e1bd676f0 ("drm/i915/pmu: Only use exclusive mmio access for gen7")
> Signed-off-by: Arnd Bergmann <arnd at arndb.de>
> ---
> I have no idea why I see three separate issues like this pop up in i915,
> there are not a lot of them elsewhere.
gcc v8:
add/remove: 1/0 grow/shrink: 0/1 up/down: 99/-164 (-65)
Function old new delta
engine_sample - 99 +99
i915_sample 871 707 -164
Which is compelling. Is gcc 9 simliar?
Given the above reduction, I find it hard to argue with.
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
-Chris
More information about the Intel-gfx
mailing list