From patchwork Fri Nov 10 15:03:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 10053313 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 E834760365 for ; Fri, 10 Nov 2017 15:03:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8F3D2B2FA for ; Fri, 10 Nov 2017 15:03:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDCD82B307; Fri, 10 Nov 2017 15:03:12 +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.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham 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 595E52B2FE for ; Fri, 10 Nov 2017 15:03:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60CF16EAB4; Fri, 10 Nov 2017 15:03:11 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C18D6E1C7; Fri, 10 Nov 2017 15:03:09 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id b9so3355063wmh.0; Fri, 10 Nov 2017 07:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9YPSCGc5/TU/r1a2BMjPdM493KkOAUd+53Ee4gmfP+c=; b=lEmUGwndhn7opWzG+ygRD/oTRKwJSW5ICyhb6jjOCF1Yxiy7IqKwR+OSTG70AU5Jaq SUX29fYCiyvhsgleyjhrsyaCJhiF/o2Q4r178FcDeMeLvIxgJG0UXLUPgY2u8O51mKE7 q1YsDgIHT1nWV/y/3Ijt59q5X4mWFpNOiZ7atPSJoMfhPAWE0Ib/Km4c2pkvgNmLk+WJ kvGmHg2ZmxkF2/7t+Br4TopngyDOAi9a2Ovin9MwX04QcFpvHHG9uMOegn6uoPoc2MTd p+3EcNzdxsjboaEuc29axS2VsnLjfgcGc1ropbr0NHg/paXFuNcsajYH3hXyiSV0vnYQ hRjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9YPSCGc5/TU/r1a2BMjPdM493KkOAUd+53Ee4gmfP+c=; b=DJG+/dR12W5oVuyxWfyHJ8XYqZX78XPIZc0u4XuiAQ4G40QkyrKKBJFAR/3mbiL/Xq 44QiCd08SfefFfee5kC0wT3kQM28Ni0DCzxs6G/2cKPEF4xAY5sv/l1hy+Lx2fKqaInP PsZVhqTRGoqt6xnKS743gR1566R6GLicig9HnFQPYRvE+F4Vzl7xfmXpCxV1R8vBXnWQ ApQxBHXSwpSxDX5eH6euSzfGPjQu0WqhQ4FlHExfO6aNzjjBGOJ4EIm7Uv6dhQBSc0OC wW3OuNfyeKBUggBJv9x+9jgv9kkUbdLiziM8Nofqz07xjUqcSvIPaLLFXWTrFfNboS50 nLxQ== X-Gm-Message-State: AJaThX7oR4yVWrlMMg4yhLbIGa0VeXmnBO6hjN3xbfofQ4yLiWPlvKcY j2knJghMs1Uj6Qy//3gZrDJ2QWID X-Google-Smtp-Source: AGs4zMaTHsHw1N8gI72S0ZoUVPeQ+HQFrqMlCkZpUJ5f6HBeVyk7xAbuHY2Skk3+XRG+s3DzF0z0Qg== X-Received: by 10.28.218.14 with SMTP id r14mr456535wmg.14.1510326187683; Fri, 10 Nov 2017 07:03:07 -0800 (PST) Received: from shalem.localdomain.com (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id d4sm2532436wmh.35.2017.11.10.07.03.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Nov 2017 07:03:06 -0800 (PST) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Daniel Vetter , Jani Nikula , Rodrigo Vivi , Mika Kuoppala , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Imre Deak Date: Fri, 10 Nov 2017 16:03:01 +0100 Message-Id: <20171110150301.9601-2-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171110150301.9601-1-hdegoede@redhat.com> References: <20171110150301.9601-1-hdegoede@redhat.com> Cc: Hans de Goede , intel-gfx , stable@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH] drm/i915: Fix false-positive assert_rpm_wakelock_held in i915_pmic_bus_access_notifier v2 X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP assert_rpm_wakelock_held is triggered from i915_pmic_bus_access_notifier even though it gets unregistered on (runtime) suspend, this is caused by a race happening under the following circumstances: intel_runtime_pm_put does: atomic_dec(&dev_priv->pm.wakeref_count); pm_runtime_mark_last_busy(kdev); pm_runtime_put_autosuspend(kdev); And pm_runtime_put_autosuspend calls intel_runtime_suspend from a workqueue, so there is ample of time between the atomic_dec() and intel_runtime_suspend() unregistering the notifier. If the notifier gets called in this windowd assert_rpm_wakelock_held falsely triggers (at this point we're not runtime-suspended yet). This commit adds disable_rpm_wakeref_asserts and enable_rpm_wakeref_asserts calls around the intel_uncore_forcewake_get(FORCEWAKE_ALL) call in i915_pmic_bus_access_notifier fixing the false-positive WARN_ON. Changes in v2: -Reword comment explaining why disabling the wakeref asserts is ok and necessary Cc: stable@vger.kernel.org Reported-by: FKr Reviewed-by: Imre Deak Signed-off-by: Hans de Goede --- drivers/gpu/drm/i915/intel_uncore.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c index 211acee7c31d..dbc5cc309cbc 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -1364,8 +1364,15 @@ static int i915_pmic_bus_access_notifier(struct notifier_block *nb, * bus, which will be busy after this notification, leading to: * "render: timed out waiting for forcewake ack request." * errors. + * + * The notifier is unregistered during intel_runtime_suspend(), + * so it's ok to access the HW here without holding a RPM + * wake reference -> disable wakeref asserts for the time of + * the access. */ + disable_rpm_wakeref_asserts(dev_priv); intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); + enable_rpm_wakeref_asserts(dev_priv); break; case MBI_PMIC_BUS_ACCESS_END: intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);