[PATCH] drm/vc4: Add a debugfs entry to disable/enable the load tracker
Boris Brezillon
boris.brezillon at bootlin.com
Fri Nov 30 10:04:41 UTC 2018
Hi Paul,
On Fri, 30 Nov 2018 10:56:58 +0100
Paul Kocialkowski <paul.kocialkowski at bootlin.com> wrote:
> 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,
> +};
> +
I'd put this code directly in vc4_debugfs.c so you can make
vc4_debugfs_load_tracker_fops static and you don't need the extern ...
definition in vc4_drv.h. But maybe you have a good reason to do that.
Regards,
Boris
More information about the dri-devel
mailing list