From patchwork Tue Nov 19 02:32:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rodrigo Vivi X-Patchwork-Id: 3199661 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B23659F43F for ; Tue, 19 Nov 2013 02:32:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED6B62034C for ; Tue, 19 Nov 2013 02:32:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 213E220218 for ; Tue, 19 Nov 2013 02:32:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 228A2FBCB6; Mon, 18 Nov 2013 18:32:42 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by gabe.freedesktop.org (Postfix) with ESMTP id EB82FFBCB6 for ; Mon, 18 Nov 2013 18:32:38 -0800 (PST) Received: by mail-pb0-f44.google.com with SMTP id rq2so1178134pbb.31 for ; Mon, 18 Nov 2013 18:32:38 -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=dPcf/lDG4pDgU1nRokzZ4O5Nsve0yR4vtM9Y5GvcD+2WexgUSGe3dDzLoXywfB5P1y b017m8GocWNuvP6JZQ8VlEH1Rp4GEKoOyFxepcKxKZx+9XYDJuW0V8LOFsEfDXFkgGye qNgD77fjbMYDwFMJWLsYrFa41rzWKBEHuxdrBnQhkELIvifPmqQJaU9v2Pby8Enj2Wja 1aspetSAl1eGq2YFva+04d1PaGfQAI9ziOgDsUkEJKnY8fsAC8mTEky4jrrRsD6dSr4D 4eHTFb8bhu6/KOIg/qVrZ+JjPsLcbAgCsValDRSizKxmGsH1HNnz1KZS5yRd3Ke+Md2K TpTQ== X-Received: by 10.66.129.141 with SMTP id nw13mr79760pab.167.1384828358845; Mon, 18 Nov 2013 18:32:38 -0800 (PST) Received: from localhost (jfdmzpr05-ext.jf.intel.com. [134.134.139.74]) by mx.google.com with ESMTPSA id bp5sm26639484pbb.18.2013.11.18.18.32.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Nov 2013 18:32:38 -0800 (PST) From: Rodrigo Vivi To: intel-gfx@lists.freedesktop.org Date: Mon, 18 Nov 2013 18:32:31 -0800 Message-Id: <1384828358-31563-3-git-send-email-rodrigo.vivi@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1384828358-31563-1-git-send-email-rodrigo.vivi@gmail.com> References: <1384828358-31563-1-git-send-email-rodrigo.vivi@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 2/9] 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@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 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 --- 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)