From patchwork Wed Mar 15 20:40:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9626641 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 B8190604A9 for ; Wed, 15 Mar 2017 20:40:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A867822B27 for ; Wed, 15 Mar 2017 20:40:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D22F28637; Wed, 15 Mar 2017 20:40:38 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable 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 5FF3022B27 for ; Wed, 15 Mar 2017 20:40:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E16176E963; Wed, 15 Mar 2017 20:40:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 99FE26E92D; Wed, 15 Mar 2017 20:40:33 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id n11so6597037wma.0; Wed, 15 Mar 2017 13:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hPyOR9Y3eXQHHpKr6E0T3LvdPl/Nd4EKNxQB0upR88M=; b=PC/YnMkPyjpE46ESnb34xWXgx1VCa/HPuiS89MlL97g2sp7ES7Gibiv01GNhwb7dwd Mff5J989pSFqNfCqiTqPa+9pAOIZsLxxSWSdb/VJNd+VwphCGORE1sxYDpoLZ/3ySWjh u5sRWuhoXZTFaTAKI4yKAlyo5+uVL2Sb5cMz9CSvJgJtOh3K/z+S4x5Yvwdu4U7Sk/1v y+g9rEwrk+3B6BM4YZ4bCw7LFVLRnhgVdKwKVW1m6Q7MY3iyjR24LJ/Otfnz+KpPsr0e Psm74JA/rmKen2nB0E84KMMijN4rkjx0DNvpaby2yGNf4IBaEmkb9FMeZDi1LGu5dQIo 8goQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=hPyOR9Y3eXQHHpKr6E0T3LvdPl/Nd4EKNxQB0upR88M=; b=qNe5iPDmFMVzxgJkSd6rlA4XYbC0y++7EZz3/sfO4AyD9xi84LHSXWazHARvoXMShq 2Cx34cVtNFX4/MTvUKqiXANzovbtLbOJVguXwHLJeY/OhZqQX6qQzS1C13e8U9CbrQFY z3aff6uHojGrK66xQ1QtTryxs586fiFSDxKyxciYAtNdkERyXfYUjcswPgjP+KjxpRyy y2cXgbf67xAQLO46igYR/fdHvgNH7R1ap3Ju3Dk1WflId3TKk9Oqh4LplXDZhTM+sL7+ SYPM7J2OmZWS2pjFT25fcEp38GEqtM8EsB8f1ZHGOkvbj9vkaTD8cecgkFl5sLG+SisQ /Upg== X-Gm-Message-State: AFeK/H1tuL20HlQZDYpj4RqkyfVIkpvi9xCw5WbeA3Lqu0VkOxxZoWpzWRsYH31GouC03A== X-Received: by 10.28.181.80 with SMTP id e77mr21130352wmf.57.1489610432305; Wed, 15 Mar 2017 13:40:32 -0700 (PDT) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id z88sm3643199wrb.26.2017.03.15.13.40.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 13:40:31 -0700 (PDT) From: Chris Wilson To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm: Skip the waitqueue setup for vblank queries Date: Wed, 15 Mar 2017 20:40:26 +0000 Message-Id: <20170315204027.20160-2-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170315204027.20160-1-chris@chris-wilson.co.uk> References: <20170315204027.20160-1-chris@chris-wilson.co.uk> MIME-Version: 1.0 Cc: =?UTF-8?q?Michel=20D=C3=A4nzer?= , Laurent Pinchart , Dave Airlie , intel-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Avoid adding to the waitqueue and reprobing the current vblank if the caller is only querying the current vblank sequence and timestamp, where we know that the wait would return immediately. v2: Add CRTC identifier to debug messages Signed-off-by: Chris Wilson Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Michel Dänzer Cc: Laurent Pinchart Cc: Dave Airlie , Cc: Mario Kleiner Reviewed-by: Michel Dänzer Reviewed-and-tested-by: Mario Kleiner --- drivers/gpu/drm/drm_irq.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index e64b05ea95ea..53a526c7b24d 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -1610,7 +1610,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data, ret = drm_vblank_get(dev, pipe); if (ret) { - DRM_DEBUG("failed to acquire vblank counter, %d\n", ret); + DRM_DEBUG("crtc %d failed to acquire vblank counter, %d\n", pipe, ret); return ret; } seq = drm_vblank_count(dev, pipe); @@ -1638,13 +1638,15 @@ int drm_wait_vblank(struct drm_device *dev, void *data, return drm_queue_vblank_event(dev, pipe, vblwait, file_priv); } - DRM_DEBUG("waiting on vblank count %u, crtc %u\n", - vblwait->request.sequence, pipe); - DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, - (((drm_vblank_count(dev, pipe) - - vblwait->request.sequence) <= (1 << 23)) || - !vblank->enabled || - !dev->irq_enabled)); + if (vblwait->request.sequence != seq) { + DRM_DEBUG("waiting on vblank count %u, crtc %u\n", + vblwait->request.sequence, pipe); + DRM_WAIT_ON(ret, vblank->queue, 3 * HZ, + (((drm_vblank_count(dev, pipe) - + vblwait->request.sequence) <= (1 << 23)) || + !vblank->enabled || + !dev->irq_enabled)); + } if (ret != -EINTR) { struct timeval now; @@ -1653,10 +1655,10 @@ int drm_wait_vblank(struct drm_device *dev, void *data, vblwait->reply.tval_sec = now.tv_sec; vblwait->reply.tval_usec = now.tv_usec; - DRM_DEBUG("returning %u to client\n", - vblwait->reply.sequence); + DRM_DEBUG("crtc %d returning %u to client\n", + pipe, vblwait->reply.sequence); } else { - DRM_DEBUG("vblank wait interrupted by signal\n"); + DRM_DEBUG("crtc %d vblank wait interrupted by signal\n", pipe); } done: