drm/i915/pmu: avoid an maybe-uninitialized warning
authorArnd Bergmann <arnd@arndb.de>
Wed, 27 May 2020 14:05:08 +0000 (16:05 +0200)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 27 May 2020 16:07:24 +0000 (17:07 +0100)
commit6ec81b82732e2b4a5ac0853fd33919ff1ca94238
tree5876b3f40baab0fc341fda1fa2ccf8ee276f10f2
parent0109a16ef391b2ebfbfdf08250c1dfb5dbf83d1e
drm/i915/pmu: avoid an maybe-uninitialized warning

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@arndb.de>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200527140526.1458215-1-arnd@arndb.de
drivers/gpu/drm/i915/i915_pmu.c