• Tvrtko Ursulin's avatar
    drm/i915/pmu: Work around compiler warnings on some kernel configs · ad055fb8
    Tvrtko Ursulin authored
    Arnd Bergman reports:
    """
    The conditional spinlock confuses gcc into thinking the 'flags' value
    might contain uninitialized data:
    
    drivers/gpu/drm/i915/i915_pmu.c: In function '__i915_pmu_event_read':
    arch/x86/include/asm/paravirt_types.h:573:3: error: 'flags' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    
    The code is correct, but it's easy to see how the compiler gets confused
    here. This avoids the problem by pulling the lock outside of the function
    into its only caller.
    """
    
    On deeper look it seems this is caused by paravirt spinlocks
    implementation when CONFIG_PARAVIRT_DEBUG is set, which by being
    complicated, manages to convince gcc locked parameter can be changed
    externally (impossible).
    
    Work around it by removing the conditional locking parameters altogether.
    (It was never the most elegant code anyway.)
    
    Slight penalty we now pay is an additional irqsave spin lock/unlock cycle
    on the event enable path. But since enable is not a fast path, that is
    preferrable to the alternative solution which was doing MMIO under irqsave
    spinlock.
    Signed-off-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
    Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
    Fixes: 1fe699e3 ("drm/i915/pmu: Fix sleep under atomic in RC6 readout")
    Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Imre Deak <imre.deak@intel.com>
    Cc: Jani Nikula <jani.nikula@linux.intel.com>
    Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
    Cc: David Airlie <airlied@linux.ie>
    Cc: intel-gfx@lists.freedesktop.org
    Cc: dri-devel@lists.freedesktop.org
    Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
    Link: https://patchwork.freedesktop.org/patch/msgid/20180314080535.17490-1-tvrtko.ursulin@linux.intel.com
    ad055fb8
i915_pmu.c 24.7 KB