diff mbox series

[v3] drm/vc4: Add a debugfs entry to disable/enable the load tracker

Message ID 20181207134757.32437-1-paul.kocialkowski@bootlin.com (mailing list archive)
State New, archived
Headers show
Series [v3] drm/vc4: Add a debugfs entry to disable/enable the load tracker | expand

Commit Message

Paul Kocialkowski Dec. 7, 2018, 1:47 p.m. UTC
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 <paul.kocialkowski@bootlin.com>
---
This patch is based upon Boris Brezillon's series:
  drm/vc4: Add a load tracker

Changes since v2:
* Used the standard debugfs_create_bool instead of reinventing it.

Changes since v1:
* Moved all the debugfs-related functions and structure to vc4_debugfs.c.

 drivers/gpu/drm/vc4/vc4_debugfs.c | 9 +++++++++
 drivers/gpu/drm/vc4/vc4_drv.c     | 2 ++
 drivers/gpu/drm/vc4/vc4_drv.h     | 2 ++
 drivers/gpu/drm/vc4/vc4_kms.c     | 6 +++++-
 4 files changed, 18 insertions(+), 1 deletion(-)

Comments

Boris Brezillon Dec. 11, 2018, 1:12 p.m. UTC | #1
On Fri,  7 Dec 2018 14:47:57 +0100
Paul Kocialkowski <paul.kocialkowski@bootlin.com> wrote:


> diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
> index f3fd34faa812..e80b1ad5c938 100644
> --- a/drivers/gpu/drm/vc4/vc4_kms.c
> +++ b/drivers/gpu/drm/vc4/vc4_kms.c
> @@ -479,6 +479,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);
> @@ -489,7 +490,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);

Even if we don't return an error when ->load_tracker_enabled is false,
we should keep updating the ->{hvs,membus}_load state, otherwise those
fields will contain bad values if we activate the load tracker after
the planes have been enabled.

I suggest moving this test in vc4_load_tracker_atomic_check() just
before

	if (load_state->membus_load > SZ_1G + SZ_512M)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vc4/vc4_debugfs.c b/drivers/gpu/drm/vc4/vc4_debugfs.c
index 7a0003de71ab..7c23f5209f6d 100644
--- a/drivers/gpu/drm/vc4/vc4_debugfs.c
+++ b/drivers/gpu/drm/vc4/vc4_debugfs.c
@@ -35,6 +35,15 @@  static const struct drm_info_list vc4_debugfs_list[] = {
 int
 vc4_debugfs_init(struct drm_minor *minor)
 {
+	struct vc4_dev *vc4 = to_vc4_dev(minor->dev);
+	struct dentry *dentry;
+
+	dentry = debugfs_create_bool("load_tracker", S_IRUGO | S_IWUSR,
+				     minor->debugfs_root,
+				     &vc4->load_tracker_enabled);
+	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..12ac971d24d6 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -290,6 +290,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 a0fb888604d6..8837d2416aae 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;
 
diff --git a/drivers/gpu/drm/vc4/vc4_kms.c b/drivers/gpu/drm/vc4/vc4_kms.c
index f3fd34faa812..e80b1ad5c938 100644
--- a/drivers/gpu/drm/vc4/vc4_kms.c
+++ b/drivers/gpu/drm/vc4/vc4_kms.c
@@ -479,6 +479,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);
@@ -489,7 +490,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 = {