From patchwork Mon Sep 15 12:35:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 4905591 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CC3DFBEEA5 for ; Mon, 15 Sep 2014 14:02:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2DE5E202B4 for ; Mon, 15 Sep 2014 14:02:44 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id B829D201BF for ; Mon, 15 Sep 2014 14:02:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B5696E374; Mon, 15 Sep 2014 07:02:41 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com [209.85.212.175]) by gabe.freedesktop.org (Postfix) with ESMTP id 43F386E21F for ; Mon, 15 Sep 2014 07:02:38 -0700 (PDT) Received: by mail-wi0-f175.google.com with SMTP id cc10so4288679wib.2 for ; Mon, 15 Sep 2014 07:02:36 -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=dJWf6FX4gXSOwclE2csHO3a4wJPGkR2Gyi8NVx3rTtU=; b=Ih49DNgc8FQxpzzZiZyKXJUBA0w1SgAF9KVQs3FA9L1sNY/GhQ6W4WTtWDwhwgZhAB 02nv6307ediffA2ldJgWPRS+Q4Ch6UQzq4FBQERCxwdsH4XQOPgwCWiPLzI1FyPhlf1f b49KMV2e1jntsoyHjsaFE/NVt+1GM1qg0Y8EU= 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=dJWf6FX4gXSOwclE2csHO3a4wJPGkR2Gyi8NVx3rTtU=; b=ZzLK1fYLBlPc9rk4OsOOZEd5+K0umxwL/7Ymxfj8JqACOf36CQRaD8aw4xW0KkNRm9 WYz6qfAPlD+3USWFU3M7WgyhZvCV67dAi57fFjnfQxvKoJGJ5VUi7zg1eUJQcKp0lSO6 QHD5WD3nbUuDyJOqMCW/aXLvpzif6LbEFeQKl99z7u3lZ5oWqmaG01M2QHLysFGNmRc7 lUPuu2Js9Egpf5k+bwfnytYsaDxDFS3gQYTLLCmj1764lRRX02Q1IlPFIKtOdwV2cep1 S7X5uBlYqAo8PRWzYNluDb0fbwSQY9IKzCbU/Ro54rYQ99VZ1TWYlhGjABvcTmR/8HFv 7bPA== X-Gm-Message-State: ALoCoQnrebK7gB+gvFtE1gBM2dzF0IXcbUUVoHlKEnLICdYwRCUojLqlROu1DcZ8bXB1O36KxYhQ X-Received: by 10.180.103.234 with SMTP id fz10mr24101974wib.76.1410789756783; Mon, 15 Sep 2014 07:02:36 -0700 (PDT) Received: from wespe.ffwll.local (84-73-67-144.dclient.hispeed.ch. [84.73.67.144]) by mx.google.com with ESMTPSA id v9sm13754504wjy.14.2014.09.15.07.02.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Sep 2014 07:02:35 -0700 (PDT) From: Daniel Vetter To: DRI Development Subject: [PATCH 02/11] drm/i915: Clarify event_lock locking, irq&mixed context Date: Mon, 15 Sep 2014 14:35:02 +0200 Message-Id: <1410784511-18460-3-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1410784511-18460-1-git-send-email-daniel.vetter@ffwll.ch> References: <1410784511-18460-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 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 Now we tackle the functions also called from interrupt handlers. - intel_check_page_flip is exclusively called from irq handlers, so a plain spin_lock is all we need. In i915_irq.c we have the convention to give all such functions an _irq_handler postfix, but that would look strange and als be a bit a misleading name. I've opted for a WARN_ON(!in_irq()) instead. - The other two places left are called both from interrupt handlers and from our reset work, so need the full irqsave dance. Annotate them with a short comment. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/i915/intel_display.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index dcbefe510a2a..d120dfff3841 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -9385,6 +9385,10 @@ static void do_intel_finish_page_flip(struct drm_device *dev, if (intel_crtc == NULL) return; + /* + * This is called both by irq handlers and the reset code (to complete + * lost pageflips) so needs the full irqsave spinlocks. + */ spin_lock_irqsave(&dev->event_lock, flags); work = intel_crtc->unpin_work; @@ -9466,7 +9470,12 @@ void intel_prepare_page_flip(struct drm_device *dev, int plane) to_intel_crtc(dev_priv->plane_to_crtc_mapping[plane]); unsigned long flags; - /* NB: An MMIO update of the plane base pointer will also + + /* + * This is called both by irq handlers and the reset code (to complete + * lost pageflips) so needs the full irqsave spinlocks. + * + * NB: An MMIO update of the plane base pointer will also * generate a page-flip completion irq, i.e. every modeset * is also accompanied by a spurious intel_prepare_page_flip(). */ @@ -9923,18 +9932,19 @@ void intel_check_page_flip(struct drm_device *dev, int pipe) struct drm_i915_private *dev_priv = dev->dev_private; struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe]; struct intel_crtc *intel_crtc = to_intel_crtc(crtc); - unsigned long flags; + + WARN_ON(!in_irq()); if (crtc == NULL) return; - spin_lock_irqsave(&dev->event_lock, flags); + spin_lock(&dev->event_lock); if (intel_crtc->unpin_work && __intel_pageflip_stall_check(dev, crtc)) { WARN_ONCE(1, "Kicking stuck page flip: queued at %d, now %d\n", intel_crtc->unpin_work->flip_queued_vblank, drm_vblank_count(dev, pipe)); page_flip_completed(intel_crtc); } - spin_unlock_irqrestore(&dev->event_lock, flags); + spin_unlock(&dev->event_lock); } static int intel_crtc_page_flip(struct drm_crtc *crtc,