From patchwork Tue Apr 14 17:41:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 6217251 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 472EC9F1C4 for ; Tue, 14 Apr 2015 17:42:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B573820274 for ; Tue, 14 Apr 2015 17:42:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A75352021F for ; Tue, 14 Apr 2015 17:42:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BDDE16E731; Tue, 14 Apr 2015 10:42:25 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by gabe.freedesktop.org (Postfix) with ESMTP id EEA266E731 for ; Tue, 14 Apr 2015 10:42:23 -0700 (PDT) Received: by wiun10 with SMTP id n10so31002788wiu.1 for ; Tue, 14 Apr 2015 10:42:23 -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:mime-version:content-type :content-transfer-encoding; bh=6Ds8enCSsjkf2SJ66bqg2E9TUEEtuiGCP2LPOSiXYdE=; b=0ybk7pN80cKH9adJR6DWgpoUGATv/EgRzKnj3jmhri3UnQqwYKeTUuprnFbeKrR/co 321nXI9RlTOHqsBVIzZVepHs/yv+qwnqwwMvlsMzs/KCpkK1TIfMlT98Y6dCSAeuNYsg LkZ/ZoFdaeZwYGOySRHQSUh6ZMsn2aO9pZ+d0WOAKIAlcqJsVq4u+cQg4Cl4BB1eYdc/ faxMip6agsrNDrbPWCQOQbAmfibS4twqd3AIXDMh9sas+XMuWYELlfuUS4JhH5hvDPPW PAN2Juzh0AOTtEIlJarHJ6UXcSWEmmnmC0J+yl7IcR6pk8hpqPtZ3oGo4/nbFHuaHPFh riog== X-Received: by 10.180.109.136 with SMTP id hs8mr34129412wib.73.1429033343204; Tue, 14 Apr 2015 10:42:23 -0700 (PDT) Received: from twisty.fritz.box (x4d02f99b.dyn.telefonica.de. [77.2.249.155]) by mx.google.com with ESMTPSA id fs9sm2473603wjc.34.2015.04.14.10.42.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Apr 2015 10:42:22 -0700 (PDT) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/3] drm: Zero out invalid vblank timestamp in drm_update_vblank_count. Date: Tue, 14 Apr 2015 19:41:40 +0200 Message-Id: <1429033302-16353-1-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Cc: stable@vger.kernel.org, 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.17, 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. Signed-off-by: Mario Kleiner Cc: #v3.17+ Cc: Ville Syrjälä Cc: Daniel Vetter Cc: Dave Airlie --- drivers/gpu/drm/drm_irq.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index c8a3447..af9662e 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -131,12 +131,11 @@ static void drm_update_vblank_count(struct drm_device *dev, int crtc) /* Reinitialize corresponding vblank timestamp if high-precision query * available. Skip this step if query unsupported or failed. Will - * reinitialize delayed at next vblank interrupt in that case. + * reinitialize delayed at next vblank interrupt in that case and + * assign 0 for now, to mark the vblanktimestamp as invalid. */ - if (rc) { - tslot = atomic_read(&vblank->count) + diff; - vblanktimestamp(dev, crtc, tslot) = t_vblank; - } + tslot = atomic_read(&vblank->count) + diff; + vblanktimestamp(dev, crtc, tslot) = rc ? t_vblank : (struct timeval) {0, 0}; smp_mb__before_atomic(); atomic_add(diff, &vblank->count);