From patchwork Tue Apr 14 17:41:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 6217261 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 A031A9F1C4 for ; Tue, 14 Apr 2015 17:42:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C547E20274 for ; Tue, 14 Apr 2015 17:42:40 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6ABA72021F for ; Tue, 14 Apr 2015 17:42:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CDF316E732; Tue, 14 Apr 2015 10:42:38 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 14E956E732 for ; Tue, 14 Apr 2015 10:42:38 -0700 (PDT) Received: by wgin8 with SMTP id n8so20333345wgi.0 for ; Tue, 14 Apr 2015 10:42:37 -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=VHeptt2qGf3lT4taYXfizYgzRI8m4PNNYLb7MRdz6Lc=; b=gKswHX5Iq0WngCOrCgwIGRoPfp0hCUkvE/rx3Rms59aY43rzimTu3e8xqoiuE9BS01 h+Qtydouu5KAE8rIUZHXGgMPJd8dqmipLjy+6ZDEHJ70oT3RaE29lrCNSxPH8BQ49paV zmf7t1Gbi/K9Y/BgK9xcekgg/BzgNj9M3W/wVLxhhzy5xLb0S49sGZ0UXln5b2aIi/6O fPC/6IktAjVkiKJ45K1M0RXs6kqHGyl/v6qyN6lZsPtMJqOzhNkbWhq7P3k+g6T9xlTb AX1aSmpMUkBmPovqzIhSaTHxL3LDhHomB5BfNruksYtTM9fpBYX3lyey6lcidnyWm4jW aU8A== X-Received: by 10.180.21.178 with SMTP id w18mr34143080wie.90.1429033357451; Tue, 14 Apr 2015 10:42:37 -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.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Apr 2015 10:42:36 -0700 (PDT) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/3] drm: Prevent invalid use of vblank_disable_immediate. Date: Tue, 14 Apr 2015 19:41:41 +0200 Message-Id: <1429033302-16353-2-git-send-email-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1429033302-16353-1-git-send-email-mario.kleiner.de@gmail.com> References: <1429033302-16353-1-git-send-email-mario.kleiner.de@gmail.com> MIME-Version: 1.0 Cc: Dave Airlie , Thierry Reding , =?UTF-8?q?Michel=20D=C3=A4nzer?= 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 For a kms driver to support immediate disable of vblank irq's reliably without introducing off by one errors or other mayhem for clients, it must not only support a hardware vblank counter query, but also high precision vblank timestamping, so vblank count and timestamp can be instantaneously reinitialzed to valid values. Additionally the exposed hardware counter must behave as if it is incrementing at leading edge of vblank to avoid off by one errors during reinitialization of the counter while the display happens to be inside or close to vblank. Check during drm_vblank_init that a driver which claims to be capable of vblank_disable_immediate at least supports high precision timestamping and prevent use of instant disable if that isn't present as a minimum requirement. Signed-off-by: Mario Kleiner Cc: Ville Syrjälä Cc: Michel Dänzer Cc: Thierry Reding Cc: Dave Airlie --- drivers/gpu/drm/drm_irq.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index af9662e..6efe822 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -336,6 +336,12 @@ int drm_vblank_init(struct drm_device *dev, int num_crtcs) else DRM_INFO("No driver support for vblank timestamp query.\n"); + /* Must have precise timestamping for reliable vblank instant disable */ + if (dev->vblank_disable_immediate && !dev->driver->get_vblank_timestamp) { + dev->vblank_disable_immediate = false; + DRM_ERROR("Set vblank_disable_immediate, but not supported.\n"); + } + dev->vblank_disable_allowed = false; return 0;