From patchwork Mon Jun 25 05:47:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dhinakaran Pandiyan X-Patchwork-Id: 10485087 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 A62806031B for ; Mon, 25 Jun 2018 05:47:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B5B2288AC for ; Mon, 25 Jun 2018 05:47:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C7C3288B4; Mon, 25 Jun 2018 05:47:55 +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=-5.2 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 E1A21288AC for ; Mon, 25 Jun 2018 05:47:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1DEA96E141; Mon, 25 Jun 2018 05:47:54 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pl0-x243.google.com (mail-pl0-x243.google.com [IPv6:2607:f8b0:400e:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id A90946E141 for ; Mon, 25 Jun 2018 05:47:52 +0000 (UTC) Received: by mail-pl0-x243.google.com with SMTP id w17-v6so6287546pll.9 for ; Sun, 24 Jun 2018 22:47:52 -0700 (PDT) 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:mime-version :content-transfer-encoding; bh=oOQc5kgyZDtw+Lw4xGBaiezwSkpoMZnInI5RsbbsMOA=; b=VpbpGkF4Rl0H+IKBih/IUVzQFY1ogQfj0czpt807mna4y9VCxX6Of+WjkFVxdnPwuO Csgqv3XCUDsLNYrROUX438eVFdftNA51YgMMjSoHP+nux5cNvMcOL3yVGzI8teEpFP6U UWhv6Cbw76eVBqYvlihZWrCTsJPl8dNvyOO8B33H/4AmRvW5b2akpL8ToRB9CCnWiQ8l vLz/Jzbm/qkiK06XETYfMiJ3QNXQqSOnL9fol4H4naEFJnCmyl9dYSGxJiy9Kt/aluO5 NSzkYc7b2BdjPA/X9z9aIoirWgeKQW1HcqXEKbvXdK6Bb9sXKnRBqllhHkhmw+6doixo mwmQ== X-Gm-Message-State: APt69E2hizcKvDeDzpN6J8mDe8y2iFUtr9tPkA8qRWq3frIx1cT9e1j5 2h+aFPQbfQ7xJ9WuJ/VvyDR8Rw== X-Google-Smtp-Source: ADUXVKL44iU5RZLbbKBsWN8Yl3aCJQuIGKPvQuKHEbIh9Axku9TU/X6NeNfFi1g8Pa1ySzKGH0wDdw== X-Received: by 2002:a17:902:8607:: with SMTP id f7-v6mr11143977plo.138.1529905671882; Sun, 24 Jun 2018 22:47:51 -0700 (PDT) Received: from dk-ThinkPad-X260.hsd1.or.comcast.net ([2601:1c0:6000:88e0:9890:201e:b8a1:a770]) by smtp.gmail.com with ESMTPSA id x17-v6sm18105818pgv.15.2018.06.24.22.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jun 2018 22:47:50 -0700 (PDT) From: Dhinakaran Pandiyan X-Google-Original-From: Dhinakaran Pandiyan To: intel-gfx@lists.freedesktop.org Date: Sun, 24 Jun 2018 22:47:40 -0700 Message-Id: <20180625054741.3919-1-dhinakaran.pandiyan@intel.com> X-Mailer: git-send-email 2.14.1 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] drm/i915/psr: Fix race in intel_psr_work() 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: Dhinakaran Pandiyan , Rodrigo Vivi Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Commit 5422b37c907e ("drm/i915/psr: Kill delays when activating psr back.") switched from delayed work to the plain variant and while doing so removed the check for work_busy() before scheduling a PSR activation. This appears to cause consecutive executions of psr_activate() in this scenario - after a worker picks up the PSR work item for execution and before the work function can acquire the PSR mutex, a psr_flush() can get hold of the mutex and schedule another PSR work. Without a psr_exit() between the two psr_activate() calls, warning messages get printed. Further, since we drop the mutex in the midst of psr_work() to wait for PSR to idle, another work item can also get scheduled. Fix this by returning if PSR was already active. Fixes: 5422b37c907e ("drm/i915/psr: Kill delays when activating psr back.") Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106948 Cc: Rodrigo Vivi Cc: Chris Wilson Cc: José Roberto de Souza Signed-off-by: Dhinakaran Pandiyan Reviewed-by: Chris Wilson Reviewed-by: Rodrigo Vivi --- drivers/gpu/drm/i915/intel_psr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_psr.c b/drivers/gpu/drm/i915/intel_psr.c index aea81ace854b..7aa324f0d1f7 100644 --- a/drivers/gpu/drm/i915/intel_psr.c +++ b/drivers/gpu/drm/i915/intel_psr.c @@ -811,7 +811,7 @@ static void intel_psr_work(struct work_struct *work) * recheck. Since psr_flush first clears this and then reschedules we * won't ever miss a flush when bailing out here. */ - if (dev_priv->psr.busy_frontbuffer_bits) + if (dev_priv->psr.busy_frontbuffer_bits || dev_priv->psr.active) goto unlock; intel_psr_activate(dev_priv->psr.enabled);