From patchwork Sun Aug 20 12:51:16 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: 9911129 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 10ACF600C8 for ; Sun, 20 Aug 2017 12:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0278F28720 for ; Sun, 20 Aug 2017 12:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB327287BF; Sun, 20 Aug 2017 12:51:30 +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 A46E028720 for ; Sun, 20 Aug 2017 12:51:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B26A6E0A7; Sun, 20 Aug 2017 12:51:28 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wr0-x241.google.com (mail-wr0-x241.google.com [IPv6:2a00:1450:400c:c0c::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CA476E0A7; Sun, 20 Aug 2017 12:51:27 +0000 (UTC) Received: by mail-wr0-x241.google.com with SMTP id 30so1051443wrk.0; Sun, 20 Aug 2017 05:51:27 -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; bh=sov5lf1HESeh7KusVu7Q4bK2AZ3uQ6mYPPWp4FY7Z2g=; b=vf9Po9j4mIpp4W+O7h8/XesEr4YTTcwXHqA5VUGI4J1clrDwTcqvZnmap+AGzCaoPk BoZmHGYOZGfO0lvvlIxd0FPdzl48bR0WC58GvuVgOzF1MxBQ4tPY2c1aKR1d7ibaFQBs WgzNPkr1OrOYG0FJ9l6032R6yFKBZECFbszgYcBTbzEMfuD1NMcZX4EO9sLVmwoA9AOx TIP9ialtLOGaUB7dTCjtQJiV9FRXBSzf6lrqfAsqQxi7DVijweiTjPZRtFO+kqNR8F3S 1CUQSMyrrqvbSQIDm45eaerAJPeM7UreLhC0KUKAm0xqf+YwY4+cmJhLAqfviceHOVNR CW8Q== 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; bh=sov5lf1HESeh7KusVu7Q4bK2AZ3uQ6mYPPWp4FY7Z2g=; b=VOiOHZ8Gbp1VG+yksnFF+5P8yz+a50kovvel+O4uAQDWkZynJAv1d9lL6W9Y2DwZeq uCqeHVyabwPyMW0C190WFqmIBN7Kt5HF3M295pPwyO/lvlEYP1nfjJqf7VXfrwDERUmA 4pg8jMuv0JOPtHdOA2KoWm8RUdxwOajF+0vuwTBmJXol7/6qizI6EAeIS7VbuQHMGr6S OFnioKJPFek6cLgKKzwtguu7nCaY6jLJt0wXEWi3mT9Uc8Iqak97PtFjBVnwx8oIORzW 8B7hlR4EYGMR+eSSOpRZWSeMtuq5dyuJmO0wA8Zlz4Qzva5xkTheK696QNHAH+RPIWJ7 T/Wg== X-Gm-Message-State: AHYfb5i8UM4GLpRFmnScudlDC99ZNoftITK+rn81PqUw40Wb6TEdkMGJ bDrJvH53gptEJg== X-Received: by 10.223.163.90 with SMTP id d26mr9968532wrb.82.1503233485916; Sun, 20 Aug 2017 05:51:25 -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 k45sm6163225wre.1.2017.08.20.05.51.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 20 Aug 2017 05:51:24 -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: Sun, 20 Aug 2017 14:51:16 +0200 Message-Id: <20170820125119.27210-1-hdegoede@redhat.com> X-Mailer: git-send-email 2.13.4 Cc: Hans de Goede , intel-gfx , dri-devel@lists.freedesktop.org Subject: [Intel-gfx] [PATCH v4 1/4] 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. 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 1d7b879cc68c..2d3aad319229 100644 --- a/drivers/gpu/drm/i915/intel_uncore.c +++ b/drivers/gpu/drm/i915/intel_uncore.c @@ -1171,8 +1171,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);