diff options
author | Krishna Reddy <vdumpa@nvidia.com> | 2011-08-04 15:14:49 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:48:06 -0800 |
commit | 7a6f12f8b139d1106d506937cb4767bb5728ca7e (patch) | |
tree | 84822825f1becc636847d32c6e204a48db748858 /drivers/video/tegra/nvmap/nvmap_dev.c | |
parent | 0808725d368aec51f30ebe76b0c461a6dfd6da63 (diff) |
video: tegra: nvmap: Add debugfs for iovmm allocations.
Original-Change-Id: Ic50111924d7adf7838926cb534bbf841b7e8003a
Reviewed-on: http://git-master/r/45358
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
Rebase-Id: R6399e487b817aa16c39e685d3f7860d1eefa8b09
Diffstat (limited to 'drivers/video/tegra/nvmap/nvmap_dev.c')
-rw-r--r-- | drivers/video/tegra/nvmap/nvmap_dev.c | 114 |
1 files changed, 109 insertions, 5 deletions
diff --git a/drivers/video/tegra/nvmap/nvmap_dev.c b/drivers/video/tegra/nvmap/nvmap_dev.c index 1ebb1f4dcf82..d30100d3625c 100644 --- a/drivers/video/tegra/nvmap/nvmap_dev.c +++ b/drivers/video/tegra/nvmap/nvmap_dev.c @@ -79,6 +79,8 @@ struct nvmap_device { struct nvmap_carveout_node *heaps; int nr_carveouts; struct nvmap_share iovmm_master; + struct list_head clients; + spinlock_t clients_lock; }; struct nvmap_device *nvmap_dev; @@ -652,6 +654,9 @@ struct nvmap_client *nvmap_create_client(struct nvmap_device *dev, mutex_init(&client->ref_lock); atomic_set(&client->count, 1); + spin_lock(&dev->clients_lock); + list_add(&client->list, &dev->clients); + spin_unlock(&dev->clients_lock); return client; } @@ -699,6 +704,9 @@ static void destroy_client(struct nvmap_client *client) if (client->task) put_task_struct(client->task); + spin_lock(&client->dev->clients_lock); + list_del(&client->list); + spin_unlock(&client->dev->clients_lock); kfree(client); } @@ -956,17 +964,18 @@ static void client_stringify(struct nvmap_client *client, struct seq_file *s) { char task_comm[TASK_COMM_LEN]; if (!client->task) { - seq_printf(s, "%-16s %16s %8u", client->name, "kernel", 0); + seq_printf(s, "%-18s %18s %8u", client->name, "kernel", 0); return; } get_task_comm(task_comm, client->task); - seq_printf(s, "%-16s %16s %8u", client->name, task_comm, + seq_printf(s, "%-18s %18s %8u", client->name, task_comm, client->task->pid); } static void allocations_stringify(struct nvmap_client *client, struct seq_file *s) { + unsigned long base = 0; struct rb_node *n = rb_first(&client->handle_refs); for (; n != NULL; n = rb_next(n)) { @@ -974,9 +983,12 @@ static void allocations_stringify(struct nvmap_client *client, rb_entry(n, struct nvmap_handle_ref, node); struct nvmap_handle *handle = ref->handle; if (handle->alloc && !handle->heap_pgalloc) { - seq_printf(s, "%-16s %-16s %8lx %10u\n", "", "", + seq_printf(s, "%-18s %-18s %8lx %10u\n", "", "", (unsigned long)(handle->carveout->base), handle->size); + } else if (handle->alloc && handle->heap_pgalloc) { + seq_printf(s, "%-18s %-18s %8lx %10u\n", "", "", + base, handle->size); } } } @@ -989,6 +1001,10 @@ static int nvmap_debug_allocations_show(struct seq_file *s, void *unused) unsigned int total = 0; spin_lock_irqsave(&node->clients_lock, flags); + seq_printf(s, "%-18s %18s %8s %10s\n", "CLIENT", "PROCESS", "PID", + "SIZE"); + seq_printf(s, "%-18s %18s %8s %10s\n", "", "", + "BASE", "SIZE"); list_for_each_entry(commit, &node->clients, list) { struct nvmap_client *client = get_client_from_carveout_commit(node, commit); @@ -998,7 +1014,7 @@ static int nvmap_debug_allocations_show(struct seq_file *s, void *unused) seq_printf(s, "\n"); total += commit->commit; } - seq_printf(s, "%-16s %-16s %8u %10u\n", "total", "", 0, total); + seq_printf(s, "%-18s %-18s %8u %10u\n", "total", "", 0, total); spin_unlock_irqrestore(&node->clients_lock, flags); return 0; @@ -1025,6 +1041,8 @@ static int nvmap_debug_clients_show(struct seq_file *s, void *unused) unsigned int total = 0; spin_lock_irqsave(&node->clients_lock, flags); + seq_printf(s, "%-18s %18s %8s %10s\n", "CLIENT", "PROCESS", "PID", + "SIZE"); list_for_each_entry(commit, &node->clients, list) { struct nvmap_client *client = get_client_from_carveout_commit(node, commit); @@ -1032,7 +1050,7 @@ static int nvmap_debug_clients_show(struct seq_file *s, void *unused) seq_printf(s, " %10u\n", commit->commit); total += commit->commit; } - seq_printf(s, "%-16s %-16s %8u %10u\n", "total", "", 0, total); + seq_printf(s, "%-18s %18s %8u %10u\n", "total", "", 0, total); spin_unlock_irqrestore(&node->clients_lock, flags); return 0; @@ -1050,6 +1068,80 @@ static struct file_operations debug_clients_fops = { .release = single_release, }; +static int nvmap_debug_iovmm_clients_show(struct seq_file *s, void *unused) +{ + unsigned long flags; + unsigned int total = 0; + struct nvmap_client *client; + struct nvmap_device *dev = s->private; + + spin_lock_irqsave(&dev->clients_lock, flags); + seq_printf(s, "%-18s %18s %8s %10s\n", "CLIENT", "PROCESS", "PID", + "SIZE"); + list_for_each_entry(client, &dev->clients, list) { + client_stringify(client, s); + seq_printf(s, " %10u\n", atomic_read(&client->iovm_commit)); + total += atomic_read(&client->iovm_commit); + } + seq_printf(s, "%-18s %18s %8u %10u\n", "total", "", 0, total); + spin_unlock_irqrestore(&dev->clients_lock, flags); + + return 0; +} + +static int nvmap_debug_iovmm_clients_open(struct inode *inode, + struct file *file) +{ + return single_open(file, nvmap_debug_iovmm_clients_show, + inode->i_private); +} + +static const struct file_operations debug_iovmm_clients_fops = { + .open = nvmap_debug_iovmm_clients_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + +static int nvmap_debug_iovmm_allocations_show(struct seq_file *s, void *unused) +{ + unsigned long flags; + unsigned int total = 0; + struct nvmap_client *client; + struct nvmap_device *dev = s->private; + + spin_lock_irqsave(&dev->clients_lock, flags); + seq_printf(s, "%-18s %18s %8s %10s\n", "CLIENT", "PROCESS", "PID", + "SIZE"); + seq_printf(s, "%-18s %18s %8s %10s\n", "", "", + "BASE", "SIZE"); + list_for_each_entry(client, &dev->clients, list) { + client_stringify(client, s); + seq_printf(s, " %10u\n", atomic_read(&client->iovm_commit)); + allocations_stringify(client, s); + seq_printf(s, "\n"); + total += atomic_read(&client->iovm_commit); + } + seq_printf(s, "%-18s %-18s %8u %10u\n", "total", "", 0, total); + spin_unlock_irqrestore(&dev->clients_lock, flags); + + return 0; +} + +static int nvmap_debug_iovmm_allocations_open(struct inode *inode, + struct file *file) +{ + return single_open(file, nvmap_debug_iovmm_allocations_show, + inode->i_private); +} + +static const struct file_operations debug_iovmm_allocations_fops = { + .open = nvmap_debug_iovmm_allocations_open, + .read = seq_read, + .llseek = seq_lseek, + .release = single_release, +}; + static int nvmap_probe(struct platform_device *pdev) { struct nvmap_platform_data *plat = pdev->dev.platform_data; @@ -1112,6 +1204,8 @@ static int nvmap_probe(struct platform_device *pdev) spin_lock_init(&dev->ptelock); spin_lock_init(&dev->handle_lock); + INIT_LIST_HEAD(&dev->clients); + spin_lock_init(&dev->clients_lock); for (i = 0; i < NVMAP_NUM_PTES; i++) { unsigned long addr; @@ -1204,6 +1298,16 @@ static int nvmap_probe(struct platform_device *pdev) } } } + if (!IS_ERR_OR_NULL(nvmap_debug_root)) { + struct dentry *iovmm_root = + debugfs_create_dir("iovmm", nvmap_debug_root); + if (!IS_ERR_OR_NULL(iovmm_root)) { + debugfs_create_file("clients", 0664, iovmm_root, + dev, &debug_iovmm_clients_fops); + debugfs_create_file("allocations", 0664, iovmm_root, + dev, &debug_iovmm_allocations_fops); + } + } platform_set_drvdata(pdev, dev); nvmap_dev = dev; |