From patchwork Mon May 4 04:29:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 6323131 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6CE1DBEEE1 for ; Mon, 4 May 2015 04:30:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C6E6202B8 for ; Mon, 4 May 2015 04:30:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D75CD202AE for ; Mon, 4 May 2015 04:30:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BD826E223; Sun, 3 May 2015 21:30:23 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f49.google.com (mail-wg0-f49.google.com [74.125.82.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 6E7706E223 for ; Sun, 3 May 2015 21:30:21 -0700 (PDT) Received: by wgyo15 with SMTP id o15so138281121wgy.2 for ; Sun, 03 May 2015 21:30:20 -0700 (PDT) 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=X9FGR+rXJ+RsPcWjTkeHRlCe1eS/turHfEtylLi9Fis=; b=QX9RscI6A0JE+1WBTgFvnwsiz0V6vR8WuRQcZ2uPV+sJYaQXU5U0h7duNPLvkgPbAd JQSoBuimY7b+FYcvQDD8eyij0U31VD51zOq6Gkx4jCz/RT/RAT3JEB20EitjpQOHCi7B cLdoSAtvjZYMB1KI1DsqS8f7vgKjV85t0RHlaEo25ys9BRcXRveaDphW/XEdZIdhQDAK A1XpAht4YO69PXQheDwprxdoE3wBnSRrP8n6kY6uTti3hxIJGB5tFRaT0SdkTJW8XZkR CC92mtLmeksr3r0Q6LDvbwoPoB3c0tN7nAibfHS9a7qCIrB4g7LwxFWbhHdY4JgC98P+ D9UA== X-Received: by 10.180.216.40 with SMTP id on8mr16432628wic.55.1430713820602; Sun, 03 May 2015 21:30:20 -0700 (PDT) Received: from twisty.fritz.box (x5f72bba3.dyn.telefonica.de. [95.114.187.163]) by mx.google.com with ESMTPSA id ub1sm18634482wjc.43.2015.05.03.21.30.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 May 2015 21:30:19 -0700 (PDT) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm: Zero out invalid vblank timestamp in drm_update_vblank_count. (v2) Date: Mon, 4 May 2015 06:29:46 +0200 Message-Id: <1430713787-29687-4-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430713787-29687-1-git-send-email-mario.kleiner.de@gmail.com> References: <1430713787-29687-1-git-send-email-mario.kleiner.de@gmail.com> MIME-Version: 1.0 Cc: Dave Airlie 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-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 Since commit 844b03f27739135fe1fed2fef06da0ffc4c7a081 we make sure that after vblank irq off, we return the last valid (vblank count, vblank timestamp) pair to clients, e.g., during modesets, which is good. An overlooked side effect of that commit for kms drivers without support for precise vblank timestamping is that at vblank irq enable, when we update the vblank counter from the hw counter, we can't update the corresponding vblank timestamp, so now we have a totally mismatched timestamp for the new count to confuse clients. Restore old client visible behaviour from before Linux 3.18, but zero out the timestamp at vblank counter update (instead of disable as in original implementation) if we can't generate a meaningful timestamp immediately for the new vblank counter. This will fix this regression, so callers know they need to retry again later if they need a valid timestamp, but at the same time preserves the improvements made in the commit mentioned above. v2: Rebased on top of Daniel Vetter's fixup and documentation patch for timestamp updates. Drop request for stable kernel backport as this would be more difficult, unless the original patch would get applied to stable kernels. Signed-off-by: Mario Kleiner Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Dave Airlie --- drivers/gpu/drm/drm_irq.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 152d1de..44e6a20b 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -161,10 +161,13 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc) /* * Only reinitialize corresponding vblank timestamp if high-precision query - * available and didn't fail. Will reinitialize delayed at next vblank - * interrupt in that case. + * available and didn't fail. Otherwise reinitialize delayed at next vblank + * interrupt and assign 0 for now, to mark the vblanktimestamp as invalid. */ - store_vblank(dev, crtc, diff, rc ? &t_vblank : NULL); + if (!rc) + t_vblank = (struct timeval) {0, 0}; + + store_vblank(dev, crtc, diff, &t_vblank); } /*