diff options
Diffstat (limited to 'drivers/video/tegra/host/debug.c')
| -rw-r--r-- | drivers/video/tegra/host/debug.c | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/drivers/video/tegra/host/debug.c b/drivers/video/tegra/host/debug.c new file mode 100644 index 00000000000..91436c903fc --- /dev/null +++ b/drivers/video/tegra/host/debug.c | |||
| @@ -0,0 +1,167 @@ | |||
| 1 | /* | ||
| 2 | * drivers/video/tegra/host/debug.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 2010 Google, Inc. | ||
| 5 | * Author: Erik Gilling <konkers@android.com> | ||
| 6 | * | ||
| 7 | * Copyright (C) 2011 NVIDIA Corporation | ||
| 8 | * | ||
| 9 | * This software is licensed under the terms of the GNU General Public | ||
| 10 | * License version 2, as published by the Free Software Foundation, and | ||
| 11 | * may be copied, distributed, and modified under those terms. | ||
| 12 | * | ||
| 13 | * This program is distributed in the hope that it will be useful, | ||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 16 | * GNU General Public License for more details. | ||
| 17 | * | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include <linux/debugfs.h> | ||
| 21 | #include <linux/seq_file.h> | ||
| 22 | |||
| 23 | #include <linux/io.h> | ||
| 24 | |||
| 25 | #include "dev.h" | ||
| 26 | #include "debug.h" | ||
| 27 | |||
| 28 | pid_t nvhost_debug_null_kickoff_pid; | ||
| 29 | unsigned int nvhost_debug_trace_cmdbuf; | ||
| 30 | |||
| 31 | pid_t nvhost_debug_force_timeout_pid; | ||
| 32 | u32 nvhost_debug_force_timeout_val; | ||
| 33 | u32 nvhost_debug_force_timeout_channel; | ||
| 34 | |||
| 35 | void nvhost_debug_output(struct output *o, const char* fmt, ...) | ||
| 36 | { | ||
| 37 | va_list args; | ||
| 38 | int len; | ||
| 39 | |||
| 40 | va_start(args, fmt); | ||
| 41 | len = vsnprintf(o->buf, sizeof(o->buf), fmt, args); | ||
| 42 | va_end(args); | ||
| 43 | o->fn(o->ctx, o->buf, len); | ||
| 44 | } | ||
| 45 | |||
| 46 | static int show_channels(struct device *dev, void *data) | ||
| 47 | { | ||
| 48 | struct nvhost_channel *ch; | ||
| 49 | struct nvhost_device *nvdev = to_nvhost_device(dev); | ||
| 50 | struct output *o = data; | ||
| 51 | struct nvhost_master *m; | ||
| 52 | |||
| 53 | if (nvdev == NULL) | ||
| 54 | return 0; | ||
| 55 | |||
| 56 | m = nvhost_get_host(nvdev); | ||
| 57 | ch = nvdev->channel; | ||
| 58 | if (ch) { | ||
| 59 | mutex_lock(&ch->reflock); | ||
| 60 | if (ch->refcount) { | ||
| 61 | mutex_lock(&ch->cdma.lock); | ||
| 62 | m->op.debug.show_channel_fifo(m, ch, o, nvdev->index); | ||
| 63 | m->op.debug.show_channel_cdma(m, ch, o, nvdev->index); | ||
| 64 | mutex_unlock(&ch->cdma.lock); | ||
| 65 | } | ||
| 66 | mutex_unlock(&ch->reflock); | ||
| 67 | } | ||
| 68 | |||
| 69 | return 0; | ||
| 70 | } | ||
| 71 | |||
| 72 | static void show_syncpts(struct nvhost_master *m, struct output *o) | ||
| 73 | { | ||
| 74 | int i; | ||
| 75 | BUG_ON(!m->op.syncpt.name); | ||
| 76 | nvhost_debug_output(o, "---- syncpts ----\n"); | ||
| 77 | for (i = 0; i < m->syncpt.nb_pts; i++) { | ||
| 78 | u32 max = nvhost_syncpt_read_max(&m->syncpt, i); | ||
| 79 | u32 min = nvhost_syncpt_update_min(&m->syncpt, i); | ||
| 80 | if (!min && !max) | ||
| 81 | continue; | ||
| 82 | nvhost_debug_output(o, "id %d (%s) min %d max %d\n", | ||
| 83 | i, m->op.syncpt.name(&m->syncpt, i), | ||
| 84 | min, max); | ||
| 85 | } | ||
| 86 | |||
| 87 | for (i = 0; i < m->syncpt.nb_bases; i++) { | ||
| 88 | u32 base_val; | ||
| 89 | base_val = nvhost_syncpt_read_wait_base(&m->syncpt, i); | ||
| 90 | if (base_val) | ||
| 91 | nvhost_debug_output(o, "waitbase id %d val %d\n", | ||
| 92 | i, base_val); | ||
| 93 | } | ||
| 94 | |||
| 95 | nvhost_debug_output(o, "\n"); | ||
| 96 | } | ||
| 97 | |||
| 98 | static void show_all(struct nvhost_master *m, struct output *o) | ||
| 99 | { | ||
| 100 | nvhost_module_busy(m->dev); | ||
| 101 | |||
| 102 | m->op.debug.show_mlocks(m, o); | ||
| 103 | show_syncpts(m, o); | ||
| 104 | nvhost_debug_output(o, "---- channels ----\n"); | ||
| 105 | bus_for_each_dev(&nvhost_bus_type, NULL, o, show_channels); | ||
| 106 | |||
| 107 | nvhost_module_idle(m->dev); | ||
| 108 | } | ||
| 109 | |||
| 110 | #ifdef CONFIG_DEBUG_FS | ||
| 111 | static int nvhost_debug_show(struct seq_file *s, void *unused) | ||
| 112 | { | ||
| 113 | struct output o = { | ||
| 114 | .fn = write_to_seqfile, | ||
| 115 | .ctx = s | ||
| 116 | }; | ||
| 117 | show_all(s->private, &o); | ||
| 118 | return 0; | ||
| 119 | } | ||
| 120 | |||
| 121 | static int nvhost_debug_open(struct inode *inode, struct file *file) | ||
| 122 | { | ||
| 123 | return single_open(file, nvhost_debug_show, inode->i_private); | ||
| 124 | } | ||
| 125 | |||
| 126 | static const struct file_operations nvhost_debug_fops = { | ||
| 127 | .open = nvhost_debug_open, | ||
| 128 | .read = seq_read, | ||
| 129 | .llseek = seq_lseek, | ||
| 130 | .release = single_release, | ||
| 131 | }; | ||
| 132 | |||
| 133 | void nvhost_debug_init(struct nvhost_master *master) | ||
| 134 | { | ||
| 135 | struct dentry *de = debugfs_create_dir("tegra_host", NULL); | ||
| 136 | |||
| 137 | debugfs_create_file("status", S_IRUGO, de, | ||
| 138 | master, &nvhost_debug_fops); | ||
| 139 | |||
| 140 | debugfs_create_u32("null_kickoff_pid", S_IRUGO|S_IWUSR, de, | ||
| 141 | &nvhost_debug_null_kickoff_pid); | ||
| 142 | debugfs_create_u32("trace_cmdbuf", S_IRUGO|S_IWUSR, de, | ||
| 143 | &nvhost_debug_trace_cmdbuf); | ||
| 144 | |||
| 145 | if (master->op.debug.debug_init) | ||
| 146 | master->op.debug.debug_init(de); | ||
| 147 | |||
| 148 | debugfs_create_u32("force_timeout_pid", S_IRUGO|S_IWUSR, de, | ||
| 149 | &nvhost_debug_force_timeout_pid); | ||
| 150 | debugfs_create_u32("force_timeout_val", S_IRUGO|S_IWUSR, de, | ||
| 151 | &nvhost_debug_force_timeout_val); | ||
| 152 | debugfs_create_u32("force_timeout_channel", S_IRUGO|S_IWUSR, de, | ||
| 153 | &nvhost_debug_force_timeout_channel); | ||
| 154 | } | ||
| 155 | #else | ||
| 156 | void nvhost_debug_init(struct nvhost_master *master) | ||
| 157 | { | ||
| 158 | } | ||
| 159 | #endif | ||
| 160 | |||
| 161 | void nvhost_debug_dump(struct nvhost_master *master) | ||
| 162 | { | ||
| 163 | struct output o = { | ||
| 164 | .fn = write_to_printk | ||
| 165 | }; | ||
| 166 | show_all(master, &o); | ||
| 167 | } | ||
