From patchwork Wed Nov 6 15:56:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3148181 Return-Path: X-Original-To: patchwork-intel-gfx@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 E8AAEBEEB2 for ; Wed, 6 Nov 2013 15:58:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFC67201B7 for ; Wed, 6 Nov 2013 15:58:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 95A6B2016D for ; Wed, 6 Nov 2013 15:58:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C593AF05B6 for ; Wed, 6 Nov 2013 07:58:31 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42]) by gabe.freedesktop.org (Postfix) with ESMTP id A5CA5F0585 for ; Wed, 6 Nov 2013 07:56:40 -0800 (PST) Received: by mail-qa0-f42.google.com with SMTP id ii20so1738050qab.8 for ; Wed, 06 Nov 2013 07:56:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=TavhI3yMzTrkTmA54yHdBZoRExS5woXHFTYz6M+KLng=; b=TKNEYoC4PZgKBw90gDAbqlXR6nLLTve9O8nJOPosUJgzVUKHrl4mHBbkb6HFxephtm yXYKqkAbS2kRUXiUFFWR6Tat/PqyoPGPxiGLHaGwjmtwR18iY95z8iPHEHL6Z+5GP5Lz 0+MjXgrAHZfZ9buS3W26Iph1k8LmbpZkkTirSJZ86kC55Cwwu10FhURls8dcRoP/Woh0 mdjUXgXH5ePHCviEqXarw2EY2JsaMNtDRsJT6iGPOGkC/N8BeZyGO6kkPZfmpgMLu/Ua MrLwZEVzvc0LJMKvSMz7XwLGhtEPQxcZgyJ6DLblcW5lkXrz1GdS6atu593OVi4g46bD gqrA== X-Received: by 10.236.41.133 with SMTP id h5mr2574890yhb.22.1383753400275; Wed, 06 Nov 2013 07:56:40 -0800 (PST) Received: from localhost.localdomain ([177.140.135.10]) by mx.google.com with ESMTPSA id v45sm45670680yha.2.2013.11.06.07.56.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Nov 2013 07:56:39 -0800 (PST) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Wed, 6 Nov 2013 13:56:27 -0200 Message-Id: <1383753389-12763-4-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1383753389-12763-1-git-send-email-rodrigo.vivi@gmail.com> References: <1383753389-12763-1-git-send-email-rodrigo.vivi@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 3/5] drm/i915: Fix gen3/4 vblank counter wraparound 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: , 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=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 From: Ville Syrjälä When the hardware frame counter reads 0xffffff and we're already past vblank start, we'd return 0x1000000 as the vblank counter value. Once we'd cross into the next frame's active portion, the vblank counter would wrap to 0. So we're reporting two different vblank counter values for the same frame. Fix the problem by masking the cooked value by 0xffffff to make sure the counter wraps already after vblank start. Signed-off-by: Ville Syrjälä Signed-off-by: Rodrigo Vivi Reviewed-by: Imre Deak --- drivers/gpu/drm/i915/i915_irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 2a44816..c474dac 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c @@ -583,7 +583,7 @@ static u32 i915_get_vblank_counter(struct drm_device *dev, int pipe) * Cook up a vblank counter by also checking the pixel * counter against vblank start. */ - return ((high1 << 8) | low) + (pixel >= vbl_start); + return (((high1 << 8) | low) + (pixel >= vbl_start)) & 0xffffff; } static u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)