From patchwork Mon May 4 04:29:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 6323121 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 50CA39F374 for ; Mon, 4 May 2015 04:30:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 802F92026C for ; Mon, 4 May 2015 04:30:20 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 800CB20268 for ; Mon, 4 May 2015 04:30:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D04496E21F; Sun, 3 May 2015 21:30:18 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by gabe.freedesktop.org (Postfix) with ESMTP id 9EC5C6E21F for ; Sun, 3 May 2015 21:30:17 -0700 (PDT) Received: by wicmx19 with SMTP id mx19so68854368wic.1 for ; Sun, 03 May 2015 21:30:17 -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=nhxs8j501WDSMmgoRS/QsuqFQ4BS/SFXg4beJE160kc=; b=mktMIrWuZQdFy/8nhy+t6wGmCamCQvEWq9rdg8YLt8R5mPdQER5Tv1YNj4iHwdIQFX i5tMqJD2WiH9uzT7RonK4numZVACqLe13wdQoORf47nM73BN2c1sr8nS1OcblKkUoPNI 62QCBec0RTr/SsszciEP8rd1EGU8ZOJmPnvuwWHoH4/3gYjLqriCod/8PLa9pv3BfuSu 7eSk1PV6OrhtSO1OR64Uiuy7elgtkx6CD1Z12bkiAUZ7/qKBMzpmaNAgG8UayrUz5hUs i6cGEg3T4MfsMnY9hS8uNGsrfMPZsu1x/hMpfgMJuC+Lmlg3SWEjRHrtKK0yHLAd16Ha 2q0g== X-Received: by 10.180.37.3 with SMTP id u3mr16109421wij.43.1430713817059; Sun, 03 May 2015 21:30:17 -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.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 03 May 2015 21:30:16 -0700 (PDT) From: Mario Kleiner To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm: Prevent invalid use of vblank_disable_immediate. (v2) Date: Mon, 4 May 2015 06:29:45 +0200 Message-Id: <1430713787-29687-3-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 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. v2: Changed from DRM_ERROR to DRM_INFO and made message more clear, as suggested by Michel Dänzer. Signed-off-by: Mario Kleiner Reviewed-by: Michel Dänzer Cc: Dave Airlie --- drivers/gpu/drm/drm_irq.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 9c166b4..152d1de 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c @@ -352,6 +352,13 @@ 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_INFO("Setting vblank_disable_immediate to false because " + "get_vblank_timestamp == NULL\n"); + } + dev->vblank_disable_allowed = false; return 0;