Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3541865imu; Fri, 30 Nov 2018 01:59:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/VW1+kVyX3MbDG6ryHpas9746qpH9PGHczBVtA5oIL66JXxpiy1/i1DGoRodOgvMkrCoXlG X-Received: by 2002:a63:b94c:: with SMTP id v12mr4260028pgo.221.1543571951832; Fri, 30 Nov 2018 01:59:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543571951; cv=none; d=google.com; s=arc-20160816; b=hQwA2efVkz8ID7kWhMFs/vc/2r8CpCgeggkux5w+4acxdmw20AoOVIqQfTMzPF1KYV brraj3tHyPJKbIX4icGTyk8u46Y9++ReQMIC7CwIvDnvXxFcnWfVp4QmhQG6f9h2ptWs Z58Th5fRtmRkQPbUOpSwB5jRCLKslv0fWnV4dgYkljH1B8sgQ1q6T83QvGkWkzdbUKpu 9Eneu/7iMfk4eNxzxhPbr9CBCs8bfRj/oT8uMgMggjDTWVhh6jQOB1x3yiK4UZ9CdUQl q1UvrlBhjyh7Oxgs/YdfAxq5iT1xrp289sCJAKSRc1jPYLbcB9QgAb10PrF71kB4EGFO udDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=xsWvpoiNzFkkyUDs2PyrXiK8uWwRfCKCrs1xA7Sv64o=; b=sf7w8b0LaQPu+kN8A+NrLHih1UU7UG+QcxKEexTMXbs+B6D39JBOHJQq7fnTzGxZTk 9RLZdjm6aRcf/xH/0rAMDu5zMNK73GdAPMfFOoX2W94JYPwvKFTN3p9Co9Wuqtse9h0f AXkyRog6C4KWzxFtLz0FIF2yuF5zOPjLAcn3R1+5NFjR8o7aNWZA4luLITx+ObSFJ+/4 OfmUiRbxLLP5wY5OkP8JXp09o9ZZp9Th+kyfwIAEGO+Sj6I+I0ch+owizjl6M9jaxJGv ZKKGj8RPod/VH0RW4dgxdM5FGTuCb3S6ieRAcbxG2CNeBK9uUmSWgxhK2oGuNhxQzrKG WSfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si4722807pgw.151.2018.11.30.01.58.57; Fri, 30 Nov 2018 01:59:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727325AbeK3VGb (ORCPT + 99 others); Fri, 30 Nov 2018 16:06:31 -0500 Received: from mail.bootlin.com ([62.4.15.54]:48170 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbeK3VGa (ORCPT ); Fri, 30 Nov 2018 16:06:30 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id E25C220CFC; Fri, 30 Nov 2018 10:57:42 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-63-158.w90-88.abo.wanadoo.fr [90.88.18.158]) by mail.bootlin.com (Postfix) with ESMTPSA id A1E712072D; Fri, 30 Nov 2018 10:57:32 +0100 (CET) From: Paul Kocialkowski To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Eric Anholt , David Airlie , Maxime Ripard , Thomas Petazzoni , Boris Brezillon , Paul Kocialkowski Subject: [PATCH] drm/vc4: Add a debugfs entry to disable/enable the load tracker Date: Fri, 30 Nov 2018 10:56:58 +0100 Message-Id: <20181130095658.31062-1-paul.kocialkowski@bootlin.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to test whether the load tracker is working as expected, we need the ability to compare the commit result with the underrun indication. With the load tracker always enabled, commits that are expected to trigger an underrun are always rejected, so userspace cannot get the actual underrun indication from the hardware. Add a debugfs entry to disable/enable the load tracker, so that a DRM commit expected to trigger an underrun can go through with the load tracker disabled. The underrun indication is then available to userspace and can be checked against the commit result with the load tracker enabled. Signed-off-by: Paul Kocialkowski --- This patch is based on Boris Brezillion's series: drm/vc4: Add a load tracker. drivers/gpu/drm/vc4/vc4_debugfs.c | 8 +++++ drivers/gpu/drm/vc4/vc4_drv.c | 52 +++++++++++++++++++++++++++++++ drivers/gpu/drm/vc4/vc4_drv.h | 3 ++ drivers/gpu/drm/vc4/vc4_kms.c | 6 +++- 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vc4/vc4_debugfs.c b/drivers/gpu/drm/vc4/vc4_debugfs.c index 7a0003de71ab..250fee440aac 100644 --- a/drivers/gpu/drm/vc4/vc4_debugfs.c +++ b/drivers/gpu/drm/vc4/vc4_debugfs.c @@ -35,6 +35,14 @@ static const struct drm_info_list vc4_debugfs_list[] = { int vc4_debugfs_init(struct drm_minor *minor) { + struct dentry *dentry; + + dentry = debugfs_create_file("load_tracker", S_IRUGO | S_IWUSR, + minor->debugfs_root, minor->dev, + &vc4_debugfs_load_tracker_fops); + if (!dentry) + return -ENOMEM; + return drm_debugfs_create_files(vc4_debugfs_list, VC4_DEBUGFS_ENTRIES, minor->debugfs_root, minor); } diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 7195a0bcceb3..0ee75c71d8d8 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -46,6 +46,56 @@ #define DRIVER_MINOR 0 #define DRIVER_PATCHLEVEL 0 +static int vc4_debugfs_load_tracker_get(struct seq_file *m, void *data) +{ + struct drm_device *dev = m->private; + struct vc4_dev *vc4 = to_vc4_dev(dev); + + if (vc4->load_tracker_enabled) + seq_printf(m, "enabled\n"); + else + seq_printf(m, "disabled\n"); + + return 0; +} + +static ssize_t vc4_debugfs_load_tracker_set(struct file *file, + const char __user *ubuf, + size_t len, loff_t *offp) +{ + struct seq_file *m = file->private_data; + struct drm_device *dev = m->private; + struct vc4_dev *vc4 = to_vc4_dev(dev); + char buf[32] = {}; + + if (len >= sizeof(buf)) + return -EINVAL; + + if (copy_from_user(buf, ubuf, len)) + return -EFAULT; + + if (!strncasecmp(buf, "enable", 6)) + vc4->load_tracker_enabled = true; + else if (!strncasecmp(buf, "disable", 7)) + vc4->load_tracker_enabled = false; + else + return -EINVAL; + + return len; +} + +static int vc4_debugfs_load_tracker_open(struct inode *inode, struct file *file) +{ + return single_open(file, vc4_debugfs_load_tracker_get, inode->i_private); +} + +const struct file_operations vc4_debugfs_load_tracker_fops = { + .owner = THIS_MODULE, + .open = vc4_debugfs_load_tracker_open, + .read = seq_read, + .write = vc4_debugfs_load_tracker_set, +}; + /* Helper function for mapping the regs on a platform device. */ void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index) { @@ -290,6 +340,8 @@ static int vc4_drm_bind(struct device *dev) drm_fbdev_generic_setup(drm, 32); + vc4->load_tracker_enabled = true; + return 0; unbind_all: diff --git a/drivers/gpu/drm/vc4/vc4_drv.h b/drivers/gpu/drm/vc4/vc4_drv.h index 11369da944b6..1344c4d996c4 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.h +++ b/drivers/gpu/drm/vc4/vc4_drv.h @@ -188,6 +188,8 @@ struct vc4_dev { int power_refcount; + bool load_tracker_enabled; + /* Mutex controlling the power refcount. */ struct mutex power_lock; @@ -717,6 +719,7 @@ void vc4_crtc_txp_armed(struct drm_crtc_state *state); int vc4_debugfs_init(struct drm_minor *minor); /* vc4_drv.c */ +extern const struct file_operations vc4_debugfs_load_tracker_fops; void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index); /* vc4_dpi.c */ diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c index b905a19c1470..4b2509b1b8ed 100644 --- a/drivers/gpu/drm/vc4/vc4_kms.c +++ b/drivers/gpu/drm/vc4/vc4_kms.c @@ -473,6 +473,7 @@ static const struct drm_private_state_funcs vc4_load_tracker_state_funcs = { static int vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) { + struct vc4_dev *vc4 = to_vc4_dev(dev); int ret; ret = vc4_ctm_atomic_check(dev, state); @@ -483,7 +484,10 @@ vc4_atomic_check(struct drm_device *dev, struct drm_atomic_state *state) if (ret) return ret; - return vc4_load_tracker_atomic_check(state); + if (vc4->load_tracker_enabled) + return vc4_load_tracker_atomic_check(state); + + return 0; } static const struct drm_mode_config_funcs vc4_mode_funcs = { -- 2.19.1