From patchwork Fri Feb 12 19:30:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 8296641 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 A02229F6E4 for ; Fri, 12 Feb 2016 19:31:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BAEC12044B for ; Fri, 12 Feb 2016 19:31:41 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 88D8720452 for ; Fri, 12 Feb 2016 19:31:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CAFD76EA53; Fri, 12 Feb 2016 11:31:38 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by gabe.freedesktop.org (Postfix) with ESMTPS id EE2936EA53 for ; Fri, 12 Feb 2016 11:31:36 -0800 (PST) Received: by mail-wm0-f66.google.com with SMTP id p63so4399735wmp.1 for ; Fri, 12 Feb 2016 11:31:36 -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; bh=SEPZucW6gXXq/672LWnW+WMCTPLkLusp0W9D7tBmB64=; b=nDKMDuYoMslJoru+xHp+jk9flOQakUx/URTfs6g3+cWGlnSQn5B1TFa1ZutYvbRxsF DNqeMDo1ltbZxA0FhgcVcKRM+cvd56FQUeeo5PXPlVAKz5unyZ0ft7fev+UriupfesFD QbeNlliTtdYIcUwyhsZhoh4qaBlPrTV8wsL0+/AbQ6k+GjVrrMLIPV/gmKj2GMG2Z25m 3W0OMNKA2vJ9dQoq0Juvc01lSQHfcyj/Su96F5qCwfBEaPIi0CPNld19cwYkC/twq4L+ FHnpDWt9bckdxvLz5FCsQC8rnFo7sHaI8qVc6wlUi4XBxaY+ktT2oIa/g3yifDX2h+B7 t9ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SEPZucW6gXXq/672LWnW+WMCTPLkLusp0W9D7tBmB64=; b=GiHMUifVX5nZtDayXtPAyNFy0Og1tYMTSyCn4XAt998YN1dsNbyi9AuNMgzYgYA/Sh bfKNchNys5G1G80hhLpoXn+HlQFxdfhrwGKjp3u9uo3MX+55QJv9jgjKfN2+9NIarggd cpDIPAPPEnw4K1QuMFmMycoOnGLMek05ZeiM418LCzOvv8R2H25XzlU6mS7uAUL8nmaS axCue3rxA4XvRiEedzSkD0QMyLL7sP8nxK4Gk+HH7al+OOIET46p5cpBNNOQTTpTLUeb AVuJQbY98tdKfpSg3AAyt4T+2fVdot161Lm4Rv0xkmMhvcPaX3iLHJAj3QW/QcmFMDs8 mA4Q== X-Gm-Message-State: AG10YOTkqzf8986UaF3cYSRImcKXtALQeMGnMZOnzIEKMTFgz+/L3wON27QmDByAXaAMkA== X-Received: by 10.194.203.5 with SMTP id km5mr3813963wjc.172.1455305450579; Fri, 12 Feb 2016 11:30:50 -0800 (PST) Received: from twisty.cin.medizin.uni-tuebingen.de (cin-11.medizin.uni-tuebingen.de. [134.2.118.242]) by smtp.gmail.com with ESMTPSA id v78sm3637797wmv.23.2016.02.12.11.30.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Feb 2016 11:30:49 -0800 (PST) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/6] drm: No-Op redundant calls to drm_vblank_off() (v2) Date: Fri, 12 Feb 2016 20:30:27 +0100 Message-Id: <1455305432-28770-2-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455305432-28770-1-git-send-email-mario.kleiner.de@gmail.com> References: <1455305432-28770-1-git-send-email-mario.kleiner.de@gmail.com> Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, stable@vger.kernel.org, alexander.deucher@amd.com, christian.koenig@amd.com, vbabka@suse.cz 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: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 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 Otherwise if a kms driver calls into drm_vblank_off() more than once before calling drm_vblank_on() again, the redundant calls to vblank_disable_and_save() will call drm_update_vblank_count() while hw vblank counters and vblank timestamping are in a undefined state during modesets, dpms off etc. At least with the legacy drm helpers it is not unusual to get multiple calls to drm_vblank_off and drm_vblank_on, e.g., half a dozen calls to drm_vblank_off and two calls to drm_vblank_on were observed on radeon-kms during dpms-off -> dpms-on transition. We don't no-op calls from atomic modesetting drivers, as they should do a proper job of tracking hw state. Fixes large jumps of the software maintained vblank counter due to the hardware vblank counter resetting to zero during dpms off or modeset, e.g., if radeon-kms is modified to use drm_vblank_off/on instead of drm_vblank_pre/post_modeset(). This fixes a regression caused by the changes made to drm_update_vblank_count() in Linux 4.4. v2: Don't no-op on atomic modesetting drivers, per suggestion of Daniel Vetter. Signed-off-by: Mario Kleiner Reviewed-by: Daniel Vetter Cc: # 4.4+ Cc: michel@daenzer.net Cc: vbabka@suse.cz Cc: ville.syrjala@linux.intel.com Cc: daniel.vetter@ffwll.ch Cc: dri-devel@lists.freedesktop.org Cc: alexander.deucher@amd.com Cc: christian.koenig@amd.com --- drivers/gpu/drm/drm_irq.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 607f493..1a18033 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -1313,7 +1313,13 @@ void drm_vblank_off(struct drm_device *dev, unsigned int pipe) spin_lock_irqsave(&dev->event_lock, irqflags); spin_lock(&dev->vbl_lock); - vblank_disable_and_save(dev, pipe); + DRM_DEBUG_VBL("crtc %d, vblank enabled %d, inmodeset %d\n", + pipe, vblank->enabled, vblank->inmodeset); + + /* Avoid redundant vblank disables without previous drm_vblank_on(). */ + if (drm_core_check_feature(dev, DRIVER_ATOMIC) || !vblank->inmodeset) + vblank_disable_and_save(dev, pipe); + wake_up(&vblank->queue); /* @@ -1415,6 +1421,9 @@ void drm_vblank_on(struct drm_device *dev, unsigned int pipe) return; spin_lock_irqsave(&dev->vbl_lock, irqflags); + DRM_DEBUG_VBL("crtc %d, vblank enabled %d, inmodeset %d\n", + pipe, vblank->enabled, vblank->inmodeset); + /* Drop our private "prevent drm_vblank_get" refcount */ if (vblank->inmodeset) { atomic_dec(&vblank->refcount);