From patchwork Mon Feb 12 21:37:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10214533 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 E82DF60153 for ; Mon, 12 Feb 2018 21:38:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D38AA28D3F for ; Mon, 12 Feb 2018 21:38:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C63A528D58; Mon, 12 Feb 2018 21:38:24 +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.2 required=2.0 tests=BAYES_00, 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 6974228D3F for ; Mon, 12 Feb 2018 21:38:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 289486E21C; Mon, 12 Feb 2018 21:38:23 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 85A5D6E21C for ; Mon, 12 Feb 2018 21:38:21 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 10664886-1500050 for multiple; Mon, 12 Feb 2018 21:37:28 +0000 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Mon, 12 Feb 2018 21:37:28 +0000 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Mon, 12 Feb 2018 21:37:27 +0000 Message-Id: <20180212213727.549-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH] RFC drm/i915: Only acquire vblank-irq when waiting for vblank evade 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Cc: Ville Syrjälä Cc: Maarten Lankhorst --- drivers/gpu/drm/i915/intel_sprite.c | 65 ++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c index e098e4b2c85c..dd8c1f24980f 100644 --- a/drivers/gpu/drm/i915/intel_sprite.c +++ b/drivers/gpu/drm/i915/intel_sprite.c @@ -74,6 +74,14 @@ int intel_usecs_to_scanlines(const struct drm_display_mode *adjusted_mode, #define VBLANK_EVASION_TIME_US 100 #endif +static inline bool scanline_in_vblank(struct intel_crtc *crtc, + int min, int max, + int *scanline) +{ + *scanline = intel_get_crtc_scanline(crtc); + return *scanline < min && *scanline > max; +} + /** * intel_pipe_update_start() - start update of a set of display registers * @new_crtc_state: the new crtc state @@ -91,12 +99,9 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state) struct intel_crtc *crtc = to_intel_crtc(new_crtc_state->base.crtc); struct drm_i915_private *dev_priv = to_i915(crtc->base.dev); const struct drm_display_mode *adjusted_mode = &new_crtc_state->base.adjusted_mode; - long timeout = msecs_to_jiffies_timeout(1); int scanline, min, max, vblank_start; - wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base); bool need_vlv_dsi_wa = (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) && intel_crtc_has_type(new_crtc_state, INTEL_OUTPUT_DSI); - DEFINE_WAIT(wait); vblank_start = adjusted_mode->crtc_vblank_start; if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) @@ -112,41 +117,46 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state) if (min <= 0 || max <= 0) return; - if (WARN_ON(drm_crtc_vblank_get(&crtc->base))) - return; - crtc->debug.min_vbl = min; crtc->debug.max_vbl = max; trace_i915_pipe_update_start(crtc); - for (;;) { - /* - * prepare_to_wait() has a memory barrier, which guarantees - * other CPUs can see the task state update by the time we - * read the scanline. - */ - prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE); + if (!scanline_in_vblank(crtc, min, max, &scanline)) { + wait_queue_head_t *wq = drm_crtc_vblank_waitqueue(&crtc->base); + long timeout = msecs_to_jiffies_timeout(1); + DEFINE_WAIT(wait); - scanline = intel_get_crtc_scanline(crtc); - if (scanline < min || scanline > max) - break; + if (WARN_ON(drm_crtc_vblank_get(&crtc->base))) + goto skip_evade; - if (timeout <= 0) { - DRM_ERROR("Potential atomic update failure on pipe %c\n", - pipe_name(crtc->pipe)); - break; - } + for (;;) { + /* + * prepare_to_wait() has a memory barrier, which + * guarantees other CPUs can see the task state update + * by the time we read the scanline. + */ + prepare_to_wait(wq, &wait, TASK_UNINTERRUPTIBLE); - local_irq_enable(); + if (scanline_in_vblank(crtc, min, max, &scanline)) + break; - timeout = schedule_timeout(timeout); + if (timeout <= 0) { + DRM_ERROR("Potential atomic update failure on pipe %c\n", + pipe_name(crtc->pipe)); + break; + } - local_irq_disable(); - } + local_irq_enable(); - finish_wait(wq, &wait); + timeout = schedule_timeout(timeout); - drm_crtc_vblank_put(&crtc->base); + local_irq_disable(); + } + + finish_wait(wq, &wait); + + drm_crtc_vblank_put(&crtc->base); + } /* * On VLV/CHV DSI the scanline counter would appear to @@ -166,6 +176,7 @@ void intel_pipe_update_start(const struct intel_crtc_state *new_crtc_state) while (need_vlv_dsi_wa && scanline == vblank_start) scanline = intel_get_crtc_scanline(crtc); +skip_evade: crtc->debug.scanline_start = scanline; crtc->debug.start_vbl_time = ktime_get(); crtc->debug.start_vbl_count = intel_crtc_get_vblank_counter(crtc);