From patchwork Tue Sep 1 20:21:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Egbert Eich X-Patchwork-Id: 7106771 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0A3739F1CD for ; Tue, 1 Sep 2015 20:22:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1996A20531 for ; Tue, 1 Sep 2015 20:22:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 07CCF20414 for ; Tue, 1 Sep 2015 20:22:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 061896E7A2; Tue, 1 Sep 2015 13:22:33 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85EB86E78C for ; Tue, 1 Sep 2015 13:22:31 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0CE11ADC9; Tue, 1 Sep 2015 20:22:30 +0000 (UTC) Received: from sles12.fritz.box (sles12.fritz.box [192.168.178.37]) by debian (Postfix) with ESMTP id C3251E132C; Tue, 1 Sep 2015 22:22:08 +0200 (CEST) From: Egbert Eich To: intel-gfx@lists.freedesktop.org Date: Tue, 1 Sep 2015 22:21:35 +0200 Message-Id: <1441138895-23732-5-git-send-email-eich@suse.de> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1441138895-23732-1-git-send-email-eich@suse.de> References: <1441138895-23732-1-git-send-email-eich@suse.de> Cc: Egbert Eich , Daniel Vetter Subject: [Intel-gfx] [PATCH 4/4] drm/i915: Avoid race of intel_crt_detect_hotplug() with HPD interrupt 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 A HPD interrupt may fire during intel_crt_detect_hotplug() - especially when HPD interrupt storms occur. Since the interrupt handler changes the enabled interrupt lines when it detects a storm this races with intel_crt_detect_hotplug(). To avoid this, shiled the rmw cycles with IRQ save spinlocks. Signed-off-by: Egbert Eich --- drivers/gpu/drm/i915/intel_crt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c index af5e43b..685f3de 100644 --- a/drivers/gpu/drm/i915/intel_crt.c +++ b/drivers/gpu/drm/i915/intel_crt.c @@ -376,9 +376,10 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) { struct drm_device *dev = connector->dev; struct drm_i915_private *dev_priv = dev->dev_private; - u32 hotplug_en, orig, stat; + u32 hotplug_en, stat; bool ret = false; int i, tries = 0; + unsigned long irqflags; if (HAS_PCH_SPLIT(dev)) return intel_ironlake_crt_detect_hotplug(connector); @@ -395,12 +396,14 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) tries = 2; else tries = 1; - hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN); - hotplug_en |= CRT_HOTPLUG_FORCE_DETECT; for (i = 0; i < tries ; i++) { /* turn on the FORCE_DETECT */ - I915_WRITE(PORT_HOTPLUG_EN, hotplug_en); + spin_lock_irqsave(&dev_priv->irq_lock, irqflags); + hotplug_en = I915_READ(PORT_HOTPLUG_EN); + I915_WRITE(PORT_HOTPLUG_EN, hotplug_en | + CRT_HOTPLUG_FORCE_DETECT); + spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); /* wait for FORCE_DETECT to go off */ if (wait_for((I915_READ(PORT_HOTPLUG_EN) & CRT_HOTPLUG_FORCE_DETECT) == 0, @@ -416,7 +419,11 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector) I915_WRITE(PORT_HOTPLUG_STAT, CRT_HOTPLUG_INT_STATUS); /* and put the bits back */ - I915_WRITE(PORT_HOTPLUG_EN, orig); + spin_lock_irqsave(&dev_priv->irq_lock, irqflags); + hotplug_en = I915_READ(PORT_HOTPLUG_EN); + hotplug_en &= ~CRT_HOTPLUG_FORCE_DETECT; + I915_WRITE(PORT_HOTPLUG_EN, hotplug_en); + spin_unlock_irqrestore(&dev_priv->irq_lock, irqflags); return ret; }