From patchwork Thu Oct 19 08:34:42 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: 10016187 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 28798600CC for ; Thu, 19 Oct 2017 08:35:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17C3528B30 for ; Thu, 19 Oct 2017 08:35:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C7FD28B5B; Thu, 19 Oct 2017 08:35:00 +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 A346628B30 for ; Thu, 19 Oct 2017 08:34:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A96C6EA09; Thu, 19 Oct 2017 08:34:56 +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 BD4EB6E9D9; Thu, 19 Oct 2017 08:34:52 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id u138so14847056wmu.4; Thu, 19 Oct 2017 01:34:52 -0700 (PDT) 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=OnMUoBmfoswyR1Y9x9ugtlno6EpLFPqEN7gg9/NycZ8=; b=M3oMCSkZs7jzz74NdEx1EYnHULo1+8bkq5LEGHPXn53j8iPoD1uvssnoYRqPhHY7zW WIKH0057EW4zVZEpQCNlEbC8nydENHq9kndTapimiiiQ0nfA6gf6stqiOroZzZbQd/EI MIRjR/fNNk+X7wJ5LXIEDPu+NJ3IUc3UkSAoDiqptHNyA66r6mI5vZ0pU/1un2s0g0jX x+9FEHx1EiSulKnpsSVfWpT5sWiXiGbY/ALy2zsmIXx3shBwjKamW8g80BDkchUp9NWU UJsMU0pjsesbj4eWHHtEqCuJ4H828vYo9ZZyBUjE298gMk2uQTFt8cKTzkgoQicebPKW oe8w== 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=OnMUoBmfoswyR1Y9x9ugtlno6EpLFPqEN7gg9/NycZ8=; b=gZ7X5z0KxYU/LuCjnkLW9gosM/HgOjwUTihjz6NvojRXE+Dgg825UoY3fJZ2cWlRam 5tD1YXvvASgAtgZTd/Pv2D7VN5m0Ysi+Lr3ZEoH7qQQXlbC/MJEwwCtvnI/tZ0OE2G38 mZhT60KnvmUuLUlVKPtrKnux3fRgswESjR3Vq0efEq2mifLYBXo8+URgQzGbRqjnganr lK7liWfkTATYqxqwfzfPGYkjlGt60I7XsBQmKzaXfO5MY8taJSq6cMRkh+8iXohUDpVB GE9flyEut1Rnj7Q7FpTY6CP/bMm1TN6Uwslv8Fp6Kf6Is/GvAIa8+D/TvkUIsASHgSjt UE+A== X-Gm-Message-State: AMCzsaUpsSXgOgCF734QVl+/ViADYX9e+6DrsG7hIGGV+Kis4edESNBo /dj6A4/cyYPixPMTiKeDv0k= X-Google-Smtp-Source: ABhQp+QxEMuz3um4bPou8WmH2cIPYKqe6jgywx3ljwjAVBTjYwXJZKw6kBxGphSzRcmSekiZ7bAqOw== X-Received: by 10.28.100.212 with SMTP id y203mr966854wmb.64.1508402091260; Thu, 19 Oct 2017 01:34:51 -0700 (PDT) Received: from shalem.localdomain.com (546A5441.cm-12-3b.dynamic.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id h8sm1074864wme.30.2017.10.19.01.34.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2017 01:34:50 -0700 (PDT) From: Hans de Goede X-Google-Original-From: Hans de Goede To: Daniel Vetter , Jani Nikula , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Imre Deak Date: Thu, 19 Oct 2017 10:34:42 +0200 Message-Id: <20171019083444.8425-2-hdegoede@redhat.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171019083444.8425-1-hdegoede@redhat.com> References: <20171019083444.8425-1-hdegoede@redhat.com> Cc: Hans de Goede , intel-gfx , stable@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH resend v3 1/3] drm/i915: Fix false-positive assert_rpm_wakelock_held in i915_pmic_bus_access_notifier 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. Cc: stable@vger.kernel.org Reported-by: FKr Signed-off-by: Hans de Goede Reviewed-by: Imre Deak --- Changes in v2: -Rebase on current (July 6th 2017) drm-next Changes in v3: -Reword comment explaining why disabling the wakeref asserts is ok and necessary -Add Imre's Reviewed-by --- 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 20e3c65c0999..cb48c8b92aa3 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -1240,8 +1240,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);