video: tegra: host: Move debugfs inits
Arto Merilainen [Mon, 15 Apr 2013 12:31:39 +0000 (15:31 +0300)]
This patch moves creation of tickctrl and actmon debugfs entries
inside corresponding modules.

Change-Id: I834e7fa5bdae51ba858e647d7152234b0a17cfec
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/219376
Reviewed-by: Riham Haidar <rhaidar@nvidia.com>
Tested-by: Riham Haidar <rhaidar@nvidia.com>

drivers/video/tegra/host/bus_client.c
drivers/video/tegra/host/chip_support.h
drivers/video/tegra/host/debug.c
drivers/video/tegra/host/gr3d/scale3d_actmon.c
drivers/video/tegra/host/host1x/host1x_actmon.c
drivers/video/tegra/host/host1x/host1x_tickctrl.c

index dde3326..e007e83 100644 (file)
@@ -1080,6 +1080,9 @@ int nvhost_client_device_init(struct platform_device *dev)
        /* store the pointer to this device for channel */
        ch->dev = dev;
 
+       /* Create debugfs directory for the device */
+       nvhost_device_debug_init(dev);
+
        err = nvhost_channel_init(ch, nvhost_master, pdata->index);
        if (err)
                goto fail;
@@ -1098,8 +1101,6 @@ int nvhost_client_device_init(struct platform_device *dev)
        if (pdata->scaling_init)
                pdata->scaling_init(dev);
 
-       nvhost_device_debug_init(dev);
-
        /* reset syncpoint values for this unit */
        nvhost_module_busy(nvhost_master->dev);
        nvhost_syncpt_reset_client(dev);
index 668e002..d709ba3 100644 (file)
@@ -175,7 +175,7 @@ struct nvhost_actmon_ops {
        long (*get_sample_period)(struct nvhost_master *host);
        void (*set_k)(struct nvhost_master *host, u32 k);
        u32 (*get_k)(struct nvhost_master *host);
-
+       void (*debug_init)(struct nvhost_master *host, struct dentry *de);
 };
 
 struct nvhost_tickctrl_ops {
index 51341b5..4a40752 100644 (file)
@@ -199,304 +199,10 @@ static const struct file_operations nvhost_debug_fops = {
        .release        = single_release,
 };
 
-static int actmon_below_wmark_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       seq_printf(s, "%d\n", actmon_op().below_wmark_count(host));
-       return 0;
-}
-
-static int actmon_below_wmark_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, actmon_below_wmark_show, inode->i_private);
-}
-
-static const struct file_operations actmon_below_wmark_fops = {
-       .open           = actmon_below_wmark_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int actmon_above_wmark_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       seq_printf(s, "%d\n", actmon_op().above_wmark_count(host));
-       return 0;
-}
-
-static int actmon_above_wmark_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, actmon_above_wmark_show, inode->i_private);
-}
-
-static const struct file_operations actmon_above_wmark_fops = {
-       .open           = actmon_above_wmark_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int actmon_avg_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       u32 avg;
-       int err;
-
-       err = actmon_op().read_avg(host, &avg);
-       if (!err)
-               seq_printf(s, "%d\n", avg);
-       return err;
-}
-
-static int actmon_avg_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, actmon_avg_show, inode->i_private);
-}
-
-static const struct file_operations actmon_avg_fops = {
-       .open           = actmon_avg_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int actmon_avg_norm_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       u32 avg;
-       int err;
-
-       err = actmon_op().read_avg_norm(host, &avg);
-       if (!err)
-               seq_printf(s, "%d\n", avg);
-       return err;
-}
-
-static int actmon_avg_norm_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, actmon_avg_norm_show, inode->i_private);
-}
-
-static const struct file_operations actmon_avg_norm_fops = {
-       .open           = actmon_avg_norm_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int actmon_sample_period_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       long period = actmon_op().get_sample_period(host);
-       seq_printf(s, "%ld\n", period);
-       return 0;
-}
-
-static int actmon_sample_period_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, actmon_sample_period_show, inode->i_private);
-}
-
-static const struct file_operations actmon_sample_period_fops = {
-       .open           = actmon_sample_period_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int actmon_sample_period_norm_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       long period = actmon_op().get_sample_period_norm(host);
-       seq_printf(s, "%ld\n", period);
-       return 0;
-}
-
-static int actmon_sample_period_norm_open(struct inode *inode,
-                                               struct file *file)
-{
-       return single_open(file, actmon_sample_period_norm_show,
-               inode->i_private);
-}
-
-static int actmon_sample_period_norm_write(struct file *file,
-                               const char __user *user_buf,
-                               size_t count, loff_t *ppos)
-{
-       struct seq_file *s = file->private_data;
-       struct nvhost_master *host = s->private;
-       char buffer[40];
-       int buf_size;
-       unsigned long period;
-
-       memset(buffer, 0, sizeof(buffer));
-       buf_size = min(count, (sizeof(buffer)-1));
-
-       if (copy_from_user(buffer, user_buf, buf_size))
-               return -EFAULT;
-
-       if (kstrtoul(buffer, 10, &period))
-               return -EINVAL;
-
-       actmon_op().set_sample_period_norm(host, period);
-
-       return count;
-}
-
-static const struct file_operations actmon_sample_period_norm_fops = {
-       .open           = actmon_sample_period_norm_open,
-       .read           = seq_read,
-       .write          = actmon_sample_period_norm_write,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-
-
-static int actmon_k_show(struct seq_file *s, void *unused)
-{
-       struct nvhost_master *host = s->private;
-       long period = actmon_op().get_k(host);
-       seq_printf(s, "%ld\n", period);
-       return 0;
-}
-
-static int actmon_k_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, actmon_k_show, inode->i_private);
-}
-
-static int actmon_k_write(struct file *file,
-                               const char __user *user_buf,
-                               size_t count, loff_t *ppos)
-{
-       struct seq_file *s = file->private_data;
-       struct nvhost_master *host = s->private;
-       char buffer[40];
-       int buf_size;
-       unsigned long k;
-
-       memset(buffer, 0, sizeof(buffer));
-       buf_size = min(count, (sizeof(buffer)-1));
-
-       if (copy_from_user(buffer, user_buf, buf_size))
-               return -EFAULT;
-
-       if (kstrtoul(buffer, 10, &k))
-               return -EINVAL;
-
-       actmon_op().set_k(host, k);
-
-       return count;
-}
-
-static const struct file_operations actmon_k_fops = {
-       .open           = actmon_k_open,
-       .read           = seq_read,
-       .write          = actmon_k_write,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-
-static int tickcount_show(struct seq_file *s, void *unused)
-{
-       struct platform_device *dev = s->private;
-       u64 cnt;
-       int err;
-
-       err = tickctrl_op().tickcount(dev, &cnt);
-       if (!err)
-               seq_printf(s, "%lld\n", cnt);
-       return err;
-}
-
-static int tickcount_open(struct inode *inode, struct file *file)
-{
-       if (!tickctrl_op().tickcount)
-               return -ENODEV;
-
-       return single_open(file, tickcount_show, inode->i_private);
-}
-
-static const struct file_operations tickcount_fops = {
-       .open           = tickcount_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int stallcount_show(struct seq_file *s, void *unused)
-{
-       struct platform_device *dev = s->private;
-       u64 cnt;
-       int err;
-
-       err = tickctrl_op().stallcount(dev, &cnt);
-       if (!err)
-               seq_printf(s, "%lld\n", cnt);
-       return err;
-}
-
-static int stallcount_open(struct inode *inode, struct file *file)
-{
-       if (!tickctrl_op().stallcount)
-               return -ENODEV;
-
-       return single_open(file, stallcount_show, inode->i_private);
-}
-
-static const struct file_operations stallcount_fops = {
-       .open           = stallcount_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
-static int xfercount_show(struct seq_file *s, void *unused)
-{
-       struct platform_device *dev = s->private;
-       u64 cnt;
-       int err;
-
-       err = tickctrl_op().xfercount(dev, &cnt);
-       if (!err)
-               seq_printf(s, "%lld\n", cnt);
-       return err;
-}
-
-static int xfercount_open(struct inode *inode, struct file *file)
-{
-       if (!tickctrl_op().xfercount)
-               return -ENODEV;
-
-       return single_open(file, xfercount_show, inode->i_private);
-}
-
-static const struct file_operations xfercount_fops = {
-       .open           = xfercount_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
-
 void nvhost_device_debug_init(struct platform_device *dev)
 {
-       struct dentry *de = NULL;
        struct nvhost_device_data *pdata = platform_get_drvdata(dev);
-
-       if (tickctrl_op().init_channel) {
-               de = debugfs_create_dir(dev->name, de);
-               debugfs_create_file("stallcount", S_IRUGO, de, dev,
-                               &stallcount_fops);
-               debugfs_create_file("xfercount", S_IRUGO, de, dev,
-                               &xfercount_fops);
-               debugfs_create_file("tickcount", S_IRUGO, de, dev,
-                               &tickcount_fops);
-       }
-
-       pdata->debugfs = de;
+       pdata->debugfs = debugfs_create_dir(dev->name, pdata->debugfs);
 }
 
 void nvhost_debug_init(struct nvhost_master *master)
@@ -534,23 +240,6 @@ void nvhost_debug_init(struct nvhost_master *master)
        debugfs_create_u32("force_timeout_dump", S_IRUGO|S_IWUSR, de,
                        &nvhost_debug_force_timeout_dump);
        nvhost_debug_force_timeout_dump = 0;
-
-       if (actmon_op().init) {
-               debugfs_create_file("3d_actmon_k", S_IRUGO, de,
-                               master, &actmon_k_fops);
-               debugfs_create_file("3d_actmon_sample_period", S_IRUGO, de,
-                               master, &actmon_sample_period_fops);
-               debugfs_create_file("3d_actmon_sample_period_norm", S_IRUGO, de,
-                               master, &actmon_sample_period_norm_fops);
-               debugfs_create_file("3d_actmon_avg_norm", S_IRUGO, de,
-                               master, &actmon_avg_norm_fops);
-               debugfs_create_file("3d_actmon_avg", S_IRUGO, de,
-                               master, &actmon_avg_fops);
-               debugfs_create_file("3d_actmon_above_wmark", S_IRUGO, de,
-                               master, &actmon_above_wmark_fops);
-               debugfs_create_file("3d_actmon_below_wmark", S_IRUGO, de,
-                               master, &actmon_below_wmark_fops);
-       }
 }
 #else
 void nvhost_debug_init(struct nvhost_master *master)
index 1af94d1..7e729a0 100644 (file)
@@ -411,6 +411,9 @@ void nvhost_scale3d_actmon_init(struct platform_device *dev)
 
        nvhost_scale3d_calibrate_emc();
 
+       /* Initialize actmon */
+       actmon_op().debug_init(nvhost_get_host(dev), pdata->debugfs);
+
        /* Start using devfreq */
        pdata->power_manager = devfreq_add_device(&dev->dev,
                                &nvhost_scale3d_devfreq_profile,
index 4b456ae..6360869 100644 (file)
@@ -20,6 +20,9 @@
 
 #include <linux/nvhost.h>
 #include <linux/io.h>
+#include <linux/debugfs.h>
+#include <linux/uaccess.h>
+
 #include "dev.h"
 #include "chip_support.h"
 
@@ -265,6 +268,225 @@ static long host1x_actmon_get_sample_period_norm(struct nvhost_master *host)
        return actmon_status.usecs_per_sample;
 }
 
+static int actmon_below_wmark_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       seq_printf(s, "%d\n", actmon_op().below_wmark_count(host));
+       return 0;
+}
+
+static int actmon_below_wmark_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, actmon_below_wmark_show, inode->i_private);
+}
+
+static const struct file_operations actmon_below_wmark_fops = {
+       .open           = actmon_below_wmark_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int actmon_above_wmark_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       seq_printf(s, "%d\n", actmon_op().above_wmark_count(host));
+       return 0;
+}
+
+static int actmon_above_wmark_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, actmon_above_wmark_show, inode->i_private);
+}
+
+static const struct file_operations actmon_above_wmark_fops = {
+       .open           = actmon_above_wmark_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int actmon_avg_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       u32 avg;
+       int err;
+
+       err = actmon_op().read_avg(host, &avg);
+       if (!err)
+               seq_printf(s, "%d\n", avg);
+       return err;
+}
+
+static int actmon_avg_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, actmon_avg_show, inode->i_private);
+}
+
+static const struct file_operations actmon_avg_fops = {
+       .open           = actmon_avg_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int actmon_avg_norm_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       u32 avg;
+       int err;
+
+       err = actmon_op().read_avg_norm(host, &avg);
+       if (!err)
+               seq_printf(s, "%d\n", avg);
+       return err;
+}
+
+static int actmon_avg_norm_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, actmon_avg_norm_show, inode->i_private);
+}
+
+static const struct file_operations actmon_avg_norm_fops = {
+       .open           = actmon_avg_norm_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int actmon_sample_period_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       long period = actmon_op().get_sample_period(host);
+       seq_printf(s, "%ld\n", period);
+       return 0;
+}
+
+static int actmon_sample_period_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, actmon_sample_period_show, inode->i_private);
+}
+
+static const struct file_operations actmon_sample_period_fops = {
+       .open           = actmon_sample_period_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int actmon_sample_period_norm_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       long period = actmon_op().get_sample_period_norm(host);
+       seq_printf(s, "%ld\n", period);
+       return 0;
+}
+
+static int actmon_sample_period_norm_open(struct inode *inode,
+                                               struct file *file)
+{
+       return single_open(file, actmon_sample_period_norm_show,
+               inode->i_private);
+}
+
+static int actmon_sample_period_norm_write(struct file *file,
+                               const char __user *user_buf,
+                               size_t count, loff_t *ppos)
+{
+       struct seq_file *s = file->private_data;
+       struct nvhost_master *host = s->private;
+       char buffer[40];
+       int buf_size;
+       unsigned long period;
+
+       memset(buffer, 0, sizeof(buffer));
+       buf_size = min(count, (sizeof(buffer)-1));
+
+       if (copy_from_user(buffer, user_buf, buf_size))
+               return -EFAULT;
+
+       if (kstrtoul(buffer, 10, &period))
+               return -EINVAL;
+
+       actmon_op().set_sample_period_norm(host, period);
+
+       return count;
+}
+
+static const struct file_operations actmon_sample_period_norm_fops = {
+       .open           = actmon_sample_period_norm_open,
+       .read           = seq_read,
+       .write          = actmon_sample_period_norm_write,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+
+
+static int actmon_k_show(struct seq_file *s, void *unused)
+{
+       struct nvhost_master *host = s->private;
+       long period = actmon_op().get_k(host);
+       seq_printf(s, "%ld\n", period);
+       return 0;
+}
+
+static int actmon_k_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, actmon_k_show, inode->i_private);
+}
+
+static int actmon_k_write(struct file *file,
+                               const char __user *user_buf,
+                               size_t count, loff_t *ppos)
+{
+       struct seq_file *s = file->private_data;
+       struct nvhost_master *host = s->private;
+       char buffer[40];
+       int buf_size;
+       unsigned long k;
+
+       memset(buffer, 0, sizeof(buffer));
+       buf_size = min(count, (sizeof(buffer)-1));
+
+       if (copy_from_user(buffer, user_buf, buf_size))
+               return -EFAULT;
+
+       if (kstrtoul(buffer, 10, &k))
+               return -EINVAL;
+
+       actmon_op().set_k(host, k);
+
+       return count;
+}
+
+static const struct file_operations actmon_k_fops = {
+       .open           = actmon_k_open,
+       .read           = seq_read,
+       .write          = actmon_k_write,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static void host1x_actmon_debug_init(struct nvhost_master *master,
+                                    struct dentry *de)
+{
+       debugfs_create_file("3d_actmon_k", S_IRUGO, de,
+                       master, &actmon_k_fops);
+       debugfs_create_file("3d_actmon_sample_period", S_IRUGO, de,
+                       master, &actmon_sample_period_fops);
+       debugfs_create_file("3d_actmon_sample_period_norm", S_IRUGO, de,
+                       master, &actmon_sample_period_norm_fops);
+       debugfs_create_file("3d_actmon_avg_norm", S_IRUGO, de,
+                       master, &actmon_avg_norm_fops);
+       debugfs_create_file("3d_actmon_avg", S_IRUGO, de,
+                       master, &actmon_avg_fops);
+       debugfs_create_file("3d_actmon_above_wmark", S_IRUGO, de,
+                       master, &actmon_above_wmark_fops);
+       debugfs_create_file("3d_actmon_below_wmark", S_IRUGO, de,
+                       master, &actmon_below_wmark_fops);
+}
+
 static const struct nvhost_actmon_ops host1x_actmon_ops = {
        .init = host1x_actmon_init,
        .deinit = host1x_actmon_deinit,
@@ -278,4 +500,5 @@ static const struct nvhost_actmon_ops host1x_actmon_ops = {
        .get_sample_period = host1x_actmon_get_sample_period,
        .get_k = host1x_actmon_get_k,
        .set_k = host1x_actmon_set_k,
+       .debug_init = host1x_actmon_debug_init,
 };
index 963ae32..ea31f5e 100644 (file)
 
 #include <linux/nvhost.h>
 #include <linux/io.h>
+#include <linux/debugfs.h>
 #include "dev.h"
 #include "chip_support.h"
 
+static void host1x_tickctrl_debug_init(struct platform_device *dev);
+
 static int host1x_tickctrl_init_channel(struct platform_device *dev)
 {
        struct nvhost_device_data *pdata = platform_get_drvdata(dev);
@@ -47,6 +50,8 @@ static int host1x_tickctrl_init_channel(struct platform_device *dev)
 
        nvhost_module_idle(nvhost_get_parent(dev));
 
+       host1x_tickctrl_debug_init(dev);
+
        return 0;
 }
 
@@ -121,6 +126,99 @@ static int host1x_tickctrl_xfercount(struct platform_device *dev, u64 *val)
        return 0;
 }
 
+static int tickcount_show(struct seq_file *s, void *unused)
+{
+       struct platform_device *dev = s->private;
+       u64 cnt;
+       int err;
+
+       err = tickctrl_op().tickcount(dev, &cnt);
+       if (!err)
+               seq_printf(s, "%lld\n", cnt);
+       return err;
+}
+
+static int tickcount_open(struct inode *inode, struct file *file)
+{
+       if (!tickctrl_op().tickcount)
+               return -ENODEV;
+
+       return single_open(file, tickcount_show, inode->i_private);
+}
+
+static const struct file_operations tickcount_fops = {
+       .open           = tickcount_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int stallcount_show(struct seq_file *s, void *unused)
+{
+       struct platform_device *dev = s->private;
+       u64 cnt;
+       int err;
+
+       err = tickctrl_op().stallcount(dev, &cnt);
+       if (!err)
+               seq_printf(s, "%lld\n", cnt);
+       return err;
+}
+
+static int stallcount_open(struct inode *inode, struct file *file)
+{
+       if (!tickctrl_op().stallcount)
+               return -ENODEV;
+
+       return single_open(file, stallcount_show, inode->i_private);
+}
+
+static const struct file_operations stallcount_fops = {
+       .open           = stallcount_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static int xfercount_show(struct seq_file *s, void *unused)
+{
+       struct platform_device *dev = s->private;
+       u64 cnt;
+       int err;
+
+       err = tickctrl_op().xfercount(dev, &cnt);
+       if (!err)
+               seq_printf(s, "%lld\n", cnt);
+       return err;
+}
+
+static int xfercount_open(struct inode *inode, struct file *file)
+{
+       if (!tickctrl_op().xfercount)
+               return -ENODEV;
+
+       return single_open(file, xfercount_show, inode->i_private);
+}
+
+static const struct file_operations xfercount_fops = {
+       .open           = xfercount_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
+static void host1x_tickctrl_debug_init(struct platform_device *dev)
+{
+       struct nvhost_device_data *pdata = platform_get_drvdata(dev);
+
+       debugfs_create_file("stallcount", S_IRUGO, pdata->debugfs, dev,
+                       &stallcount_fops);
+       debugfs_create_file("xfercount", S_IRUGO, pdata->debugfs, dev,
+                       &xfercount_fops);
+       debugfs_create_file("tickcount", S_IRUGO, pdata->debugfs, dev,
+                       &tickcount_fops);
+}
+
 static const struct nvhost_tickctrl_ops host1x_tickctrl_ops = {
        .init_channel = host1x_tickctrl_init_channel,
        .deinit_channel = host1x_tickctrl_deinit_channel,