From patchwork Mon Feb 8 01:13:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 8246111 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 E0556BEEE5 for ; Mon, 8 Feb 2016 01:14:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0AC0B201EC for ; Mon, 8 Feb 2016 01:14:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 30312201D3 for ; Mon, 8 Feb 2016 01:14:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B8616E327; Sun, 7 Feb 2016 17:14:40 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5D2456E327 for ; Sun, 7 Feb 2016 17:14:38 -0800 (PST) Received: by mail-wm0-f68.google.com with SMTP id 128so13219136wmz.3 for ; Sun, 07 Feb 2016 17:14: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; bh=JjOXS4NxN4s5YZRG69vgoW9UMZkmeF4gA9iqMFNQU70=; b=SY1jSuFt3g/45nYxCnTqYfS4GJNPGQRhwJsyO4xmTfDgdGgHlh0W5V12gFPs1M412O MyOYNGwNXkSmH2Jo/A2hEcCC4mGuFN7k9578ylXYgJncS365PZewQ+/LdWg4bY0c6MDX Ks9c7b/SOAHuhqWC0UeUhXnpAYesnXSbdAaOGeSSq+3l1rm//rCBDvnddMxaxvjH20lQ 2tX+GkNE+lqRMIuRhYNUQVdtVwFwt3YMsl28BT0y4TVZKyznFkk8JPC4rSgsoluT/FFm eIGRmT/7Y19Wo3nOtoicwO+I0zZYqAAU4BUGdGGypO6cFHXR3I3jiCmkI+U/o4zkG3H+ 8S2A== 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=JjOXS4NxN4s5YZRG69vgoW9UMZkmeF4gA9iqMFNQU70=; b=T5567wV5c/dsocdtOZYGyAJNfKzJCu9FZjbmNZX4keINk6lhXJ1Ba4iD1hcwMq3Lk1 bKL5hPMg61VSYuJd6YV4OejxIYNGCsl7z93ATCT/2N0cF+wVTENwC4R8m3zrsJJQPM2Y Dd9dox8T8wwwO8O8/M1ZbdnbKU0QTPLvPjBJWrgsyZ6CGWaIuf1ToVyW95QBZAc7VsVA XVxNI1sw/Q8vGPVdFnrtbX8RXq1Qv4gOer43h2zV+Ska/g8O32AeiRPvPpWLrRSmPkI4 TzStEJ6nSFf3Hdbk/MeA09FxYigVkl+Cf3UUNxeIvfp0S7MNlv8FN2bqH/vS1yIG1q9V FnLQ== X-Gm-Message-State: AG10YOT4gxPn5EwWcBw6XL/WqTAvRpM+9LAtPZRMxSazJUJi6eX6e5p6TIqQEkQBh7P5ZQ== X-Received: by 10.28.227.134 with SMTP id a128mr8336081wmh.67.1454894077013; Sun, 07 Feb 2016 17:14:37 -0800 (PST) Received: from twisty.fritz.box (x4d02db5e.dyn.telefonica.de. [77.2.219.94]) by smtp.gmail.com with ESMTPSA id b5sm9486380wmh.15.2016.02.07.17.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 07 Feb 2016 17:14:36 -0800 (PST) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/6] drm: No-Op redundant calls to drm_vblank_off() Date: Mon, 8 Feb 2016 02:13:24 +0100 Message-Id: <1454894009-15466-2-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1454894009-15466-1-git-send-email-mario.kleiner.de@gmail.com> References: <1454894009-15466-1-git-send-email-mario.kleiner.de@gmail.com> Cc: daniel.vetter@ffwll.ch, michel@daenzer.net, linux@bernd-steinhauser.de, 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.3 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. 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. Signed-off-by: Mario Kleiner 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 Reviewed-by: Daniel Vetter --- 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..bcb8528 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 (!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);