From patchwork Mon Sep 2 14:22:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2852865 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 209FD9F3DC for ; Mon, 2 Sep 2013 14:26:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E91D20336 for ; Mon, 2 Sep 2013 14:26:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 390E120334 for ; Mon, 2 Sep 2013 14:26:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 37656E69CD for ; Mon, 2 Sep 2013 07:26:16 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f44.google.com (mail-ee0-f44.google.com [74.125.83.44]) by gabe.freedesktop.org (Postfix) with ESMTP id 60F2CE69C7 for ; Mon, 2 Sep 2013 07:22:15 -0700 (PDT) Received: by mail-ee0-f44.google.com with SMTP id b47so2405965eek.31 for ; Mon, 02 Sep 2013 07:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=THXyvvzLcma0PQI/QzeLilhiWe/ZyTDbmR7c7UtGH7c=; b=kXPc0+9nh2yHv8PaEpCkTbaKLS5TfbJuV+R/7YSFBBQnUkRaiAVpFJLxd5CiCS/ymX EwbxGlGGokpna0qtPgCUSrYelWdvOlZQgMciPpMkMN9GvpMXKC/2zzRnnTJr/A36V7eZ gQ0RRYshiKimQ9ZmHTwPtrhvq9x5+exjKEsag= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=THXyvvzLcma0PQI/QzeLilhiWe/ZyTDbmR7c7UtGH7c=; b=YUp5yJboTmSU/7SS7w1XGQL0Cj4DHb3MbwF9GtHL7ONshXwsywmUvZs0yYEi8g54e3 /wTScB2UBtAYnyXZ6MoSrRh6WxyjCUafNJnxgWORhcecjtoqFQRMXT53UfpWPGoeTFHM e53t4GiIWfASAXhg1C5saxMSXCVLHAArJo3hAXbKVgVCQgk/iKhEPECZI6ml8a1APJ2b BeOJrCBjL/aVDY19DctTPymzhzqU/Y5q5JLupdrLWbDhw+vGChEIJzh7stDWRdkf09G+ lR9ZutUjPknsxkX7CANuDtsLFyUFXgHlWkdPRMZ+R4RFkGSU2Nl/BmXE/rBmnZHfPpQ7 47Ug== X-Gm-Message-State: ALoCoQm1V0im8ojBAIOhCfKbh6w5tuJNhKBtK9HmmS9T+SjyDdznsSX1ktr+4WhMYJIC6jFfGup2 X-Received: by 10.14.177.199 with SMTP id d47mr37512932eem.14.1378131734495; Mon, 02 Sep 2013 07:22:14 -0700 (PDT) Received: from phenom.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id r48sm22554906eev.14.1969.12.31.16.00.00 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Sep 2013 07:22:13 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Mon, 2 Sep 2013 16:22:25 +0200 Message-Id: <1378131745-26497-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.4.rc3 In-Reply-To: <20130902115205.GB6439@nuc-i3427.alporthouse.com> References: <20130902115205.GB6439@nuc-i3427.alporthouse.com> Cc: Daniel Vetter , stable@vger.kernel.org Subject: [Intel-gfx] [PATCH] drm/i915: fix hpd work vs. flush_work in the pageflip code deadlock X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Historically we've run our own driver hotplug handling in our own work-queue, which then launched the drm core hotplug handling in the system workqueue. This is important since we flush our own driver workqueue in the pageflip code while hodling modeset locks, and only the drm hotplug code grabbed these locks. But with commit 69787f7da6b2adc4054357a661aaa1701a9ca76f Author: Daniel Vetter Date: Tue Oct 23 18:23:34 2012 +0000 drm: run the hpd irq event code directly this was changed and now we could deadlock in our flip handler if there's a hotplug work blocking the progress of the crucial unpin works. So this broke the careful deadlock avoidance implemented in commit b4a98e57fc27854b5938fc8b08b68e5e68b91e1f Author: Chris Wilson Date: Thu Nov 1 09:26:26 2012 +0000 drm/i915: Flush outstanding unpin tasks before pageflipping Since the rule thus far has been that work items on our own workqueue may never grab modeset locks simply restore that rule again. v2: Add a comment to the declaration of dev_priv->wq to warn readers about the tricky implications of using it. Suggested by Chris Wilson. Cc: Chris Wilson Cc: Stuart Abercrombie Reported-by: Stuart Abercrombie References: http://permalink.gmane.org/gmane.comp.freedesktop.xorg.drivers.intel/26239 Cc: stable@vger.kernel.org Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_drv.h | 7 +++++++ drivers/gpu/drm/i915/i915_irq.c | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 4da1f86..7bd1370 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1248,6 +1248,13 @@ typedef struct drm_i915_private { unsigned int fsb_freq, mem_freq, is_ddr3; + /** + * wq - Driver workqueue for GEM. + * + * NOTE: Work items scheduled here are not allowed to grab any modeset + * locks, for otherwise the flushing done in the pageflip code will + * result in deadlocks. + */ struct workqueue_struct *wq; /* Display functions */ diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 4c6853f..39e4dd0 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -1027,8 +1027,7 @@ static inline void intel_hpd_irq_handler(struct drm_device *dev, dev_priv->display.hpd_irq_setup(dev); spin_unlock(&dev_priv->irq_lock); - queue_work(dev_priv->wq, - &dev_priv->hotplug_work); + schedule_work(&dev_priv->hotplug_work); } static void gmbus_irq_handler(struct drm_device *dev)