From patchwork Tue Mar 13 16:19:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10279955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 160756038F for ; Tue, 13 Mar 2018 16:33:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06B0628B22 for ; Tue, 13 Mar 2018 16:33:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF27C29085; Tue, 13 Mar 2018 16:33:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D5AB2904C for ; Tue, 13 Mar 2018 16:33:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9159A6E5A5; Tue, 13 Mar 2018 16:33:07 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) by gabe.freedesktop.org (Postfix) with ESMTPS id 155B96E5A5 for ; Tue, 13 Mar 2018 16:33:04 +0000 (UTC) Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue105 [212.227.15.145]) with ESMTPA (Nemesis) id 0LgXtF-1eGd0T0wNx-00nzzh; Tue, 13 Mar 2018 17:19:56 +0100 From: Arnd Bergmann To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie Date: Tue, 13 Mar 2018 17:19:31 +0100 Message-Id: <20180313161952.552083-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:u65WKnmySMO/FelMrDXo7VnOyCqGV8M3jI0/A5LNAT6pJqaUZE0 wcUi2Wr0wQ7+FbaU3A5pcUFwLUqjd2464PjfemppuaVVIyhmTwWAAfRbE29D+O1S1KgPCZ/ Sv1rP1MzDm9vkV5BU+nb/M5YcxKYIPoWlGLHc5U+qTcA9qhKY4BUO7lY+HouW9SAZFZmUgT tmZ1YGFWQ2or4DjeM2MHw== X-UI-Out-Filterresults: notjunk:1; V01:K0:9K3e9TJB8r0=:26wJpj08wNOe9EFjZpEsXE Tm7dmlE7OERfiWUDf8Y4WNgzhMG4ovhiqW4ulB5RgqbMq7znHDttXslORAgOFpz/DZSPd4cOC zHpmxKM041+XZaRdhXNWdqbYPpv59FdlEkvs0sSdHJdQSKm2jN6qnmRj+6NmwX7Bt3+F8dW5f qaBdWKuzV/SHRBCl7KIt+mgTvjJEf0qSUqSAGZIeoRoAFYY81m73tDzQ5TinmfwuyQ0BSRl9d hffLpQR5RiRVrljcrAvGSnwAx6U86s+ggSlv4/NKnerFrUlXJaZ/Qrlj1+PH37N1GoezInDkw WPNYUvCoOnisH0fKWI3Al01SX83Uu3/acAqK56IuTN3V1Tv3/gQ+hpxekyUxS4h+bO0KklfZ3 x7JHO+vrQVqBbNMlls5rp/edMaWfmairTCbt2anme9WcH8cK+JWaqfGJeJMtb75rvy/1oyNvc kqFwix+/f1/x6OuNyzZTZLTCNKzuSpu3e8dn64myEzqTatmUYdkGuRYzVu7C+E+P7BIG5y06m 0WagsiCu8ZTRh+8c7k913Whk6xpsZZMuHnBfFFRaAd65aob3cx77Y1H0LZNF+jhgRKBtxBr6P Tp0lL4MAgUyetbaO+TVI5y0HSA2lXHJ6PYjFqE+v7rGN8sdMMvq8FvnvJvz8uY0hAbyskuYd0 0ix/DJWxfG52kkcvhLMYcbLrbaTxQvisEAMqswgP37QmXRw3jh/GabW6yPHVVQ8gsor8gQtnf P2JOH5+y/EzbNlc3XMypNxtH9CO5Sx3Q9iYF+w== Subject: [Intel-gfx] [PATCH] [v2] drm/i915/pmu: avoid -Wmaybe-uninitialized warning X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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. Fixes: 1fe699e30113 ("drm/i915/pmu: Fix sleep under atomic in RC6 readout") Signed-off-by: Arnd Bergmann Reviewed-by: Chris Wilson --- v2: removed unused function argument, fixed 'break' statement. --- drivers/gpu/drm/i915/i915_pmu.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index 4bc7aefa9541..d6b9b6b5fb98 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c @@ -412,10 +412,9 @@ static u64 __get_rc6(struct drm_i915_private *i915) return val; } -static u64 get_rc6(struct drm_i915_private *i915, bool locked) +static u64 get_rc6(struct drm_i915_private *i915) { #if IS_ENABLED(CONFIG_PM) - unsigned long flags; u64 val; if (intel_runtime_pm_get_if_in_use(i915)) { @@ -428,18 +427,12 @@ static u64 get_rc6(struct drm_i915_private *i915, bool locked) * previously. */ - if (!locked) - spin_lock_irqsave(&i915->pmu.lock, flags); - if (val >= i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) { i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = 0; i915->pmu.sample[__I915_SAMPLE_RC6].cur = val; } else { val = i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur; } - - if (!locked) - spin_unlock_irqrestore(&i915->pmu.lock, flags); } else { struct pci_dev *pdev = i915->drm.pdev; struct device *kdev = &pdev->dev; @@ -452,9 +445,6 @@ static u64 get_rc6(struct drm_i915_private *i915, bool locked) * on top of the last known real value, as the approximated RC6 * counter value. */ - if (!locked) - spin_lock_irqsave(&i915->pmu.lock, flags); - spin_lock_irqsave(&kdev->power.lock, flags2); if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) @@ -470,9 +460,6 @@ static u64 get_rc6(struct drm_i915_private *i915, bool locked) val = jiffies_to_nsecs(val); val += i915->pmu.sample[__I915_SAMPLE_RC6].cur; i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val; - - if (!locked) - spin_unlock_irqrestore(&i915->pmu.lock, flags); } return val; @@ -519,7 +506,15 @@ static u64 __i915_pmu_event_read(struct perf_event *event, bool locked) val = count_interrupts(i915); break; case I915_PMU_RC6_RESIDENCY: - val = get_rc6(i915, locked); + if (!locked) { + unsigned long flags; + + spin_lock_irqsave(&i915->pmu.lock, flags); + val = get_rc6(i915); + spin_unlock_irqrestore(&i915->pmu.lock, flags); + } else { + val = get_rc6(i915); + } break; } }