summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorKrishna Reddy <vdumpa@nvidia.com>2014-06-20 14:33:55 -0700
committerWinnie Hsu <whsu@nvidia.com>2014-08-08 14:47:09 -0700
commitef8fd8194d37cdfef1e02630a30e64da1c19750c (patch)
treef173afb1dc9e568269b0083ad90a2dfde3f7665b /drivers
parentcdfe41cc63e630168a2e7e256bd990c2110c5a4d (diff)
video: tegra: nvmap: unify debug stats code
Unify debug stats code for iovmm and carveouts. Bug 1529015 Change-Id: Ief800587870845ed6f566cb7afb2c91000d177ca Signed-off-by: Krishna Reddy <vdumpa@nvidia.com> Reviewed-on: http://git-master/r/426733 (cherry picked from commit 0c0f7e5a9ef459d7940cc66af0a00321bb54d389) Reviewed-on: http://git-master/r/448536 Tested-by: Winnie Hsu <whsu@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/tegra/nvmap/nvmap_dev.c153
-rw-r--r--drivers/video/tegra/nvmap/nvmap_handle.c5
-rw-r--r--drivers/video/tegra/nvmap/nvmap_priv.h1
3 files changed, 53 insertions, 106 deletions
diff --git a/drivers/video/tegra/nvmap/nvmap_dev.c b/drivers/video/tegra/nvmap/nvmap_dev.c
index c0281fd0fafc..332f92e2b69c 100644
--- a/drivers/video/tegra/nvmap/nvmap_dev.c
+++ b/drivers/video/tegra/nvmap/nvmap_dev.c
@@ -257,14 +257,6 @@ void nvmap_carveout_commit_subtract(struct nvmap_client *client,
spin_unlock(&node->clients_lock);
}
-static struct nvmap_client *get_client_from_carveout_commit(
- struct nvmap_carveout_node *node, struct nvmap_carveout_commit *commit)
-{
- struct nvmap_carveout_commit *first_commit = commit - node->index;
- return (void *)first_commit - offsetof(struct nvmap_client,
- carveout_commit);
-}
-
static
struct nvmap_heap_block *do_nvmap_carveout_alloc(struct nvmap_client *client,
struct nvmap_handle *handle,
@@ -807,7 +799,7 @@ static void client_stringify(struct nvmap_client *client, struct seq_file *s)
}
static void allocations_stringify(struct nvmap_client *client,
- struct seq_file *s, bool iovmm)
+ struct seq_file *s, u32 heap_type)
{
struct rb_node *n;
@@ -817,8 +809,8 @@ static void allocations_stringify(struct nvmap_client *client,
struct nvmap_handle_ref *ref =
rb_entry(n, struct nvmap_handle_ref, node);
struct nvmap_handle *handle = ref->handle;
- if (handle->alloc && handle->heap_pgalloc == iovmm) {
- phys_addr_t base = iovmm ? 0 :
+ if (handle->alloc && handle->heap_type == heap_type) {
+ phys_addr_t base = heap_type == NVMAP_HEAP_IOVMM ? 0 :
(handle->carveout->base);
seq_printf(s,
"%-18s %-18s %8llx %10zuK %8x %6u %6u %6u %6u %8p\n",
@@ -836,7 +828,7 @@ static void allocations_stringify(struct nvmap_client *client,
}
static void nvmap_get_client_mss(struct nvmap_client *client,
- u64 *total, bool iovmm)
+ u64 *total, u32 heap_type)
{
struct rb_node *n;
@@ -847,65 +839,15 @@ static void nvmap_get_client_mss(struct nvmap_client *client,
struct nvmap_handle_ref *ref =
rb_entry(n, struct nvmap_handle_ref, node);
struct nvmap_handle *handle = ref->handle;
- if (handle->alloc && handle->heap_pgalloc == iovmm)
+ if (handle->alloc && handle->heap_type == heap_type)
*total += handle->size /
atomic_read(&handle->share_count);
}
nvmap_ref_unlock(client);
}
-static int nvmap_debug_allocations_show(struct seq_file *s, void *unused)
-{
- struct nvmap_carveout_node *node = s->private;
- struct nvmap_carveout_commit *commit;
- unsigned int total = 0;
-
- spin_lock(&node->clients_lock);
- seq_printf(s, "%-18s %18s %8s %11s\n",
- "CLIENT", "PROCESS", "PID", "SIZE");
- seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %8s\n",
- "", "", "BASE", "SIZE", "FLAGS", "REFS",
- "DUPES", "PINS", "SHARE", "UID");
- list_for_each_entry(commit, &node->clients, list) {
- struct nvmap_client *client =
- get_client_from_carveout_commit(node, commit);
- client_stringify(client, s);
- seq_printf(s, " %10zuK\n", K(commit->commit));
- allocations_stringify(client, s, false);
- seq_printf(s, "\n");
- total += commit->commit;
- }
- seq_printf(s, "%-18s %-18s %8s %10uK\n", "total", "", "", K(total));
- spin_unlock(&node->clients_lock);
- return 0;
-}
-
-DEBUGFS_OPEN_FOPS(allocations);
-
-static int nvmap_debug_clients_show(struct seq_file *s, void *unused)
-{
- struct nvmap_carveout_node *node = s->private;
- struct nvmap_carveout_commit *commit;
- unsigned int total = 0;
-
- spin_lock(&node->clients_lock);
- seq_printf(s, "%-18s %18s %8s %11s\n",
- "CLIENT", "PROCESS", "PID", "SIZE");
- list_for_each_entry(commit, &node->clients, list) {
- struct nvmap_client *client =
- get_client_from_carveout_commit(node, commit);
- client_stringify(client, s);
- seq_printf(s, " %10zu\n", K(commit->commit));
- total += commit->commit;
- }
- seq_printf(s, "%-18s %18s %8s %10uK\n", "total", "", "", K(total));
- spin_unlock(&node->clients_lock);
- return 0;
-}
-
-DEBUGFS_OPEN_FOPS(clients);
-
-static void nvmap_iovmm_get_total_mss(u64 *pss, u64 *non_pss, u64 *total)
+static void nvmap_get_total_mss(u64 *pss, u64 *non_pss,
+ u64 *total, u32 heap_type)
{
int i;
struct rb_node *n;
@@ -924,7 +866,7 @@ static void nvmap_iovmm_get_total_mss(u64 *pss, u64 *non_pss, u64 *total)
struct nvmap_handle *h =
rb_entry(n, struct nvmap_handle, node);
- if (!h || !h->alloc || !h->heap_pgalloc)
+ if (!h || !h->alloc || h->heap_type != heap_type)
continue;
if (!non_pss) {
*total += h->size;
@@ -944,64 +886,64 @@ static void nvmap_iovmm_get_total_mss(u64 *pss, u64 *non_pss, u64 *total)
spin_unlock(&dev->handle_lock);
}
-#define PRINT_MEM_STATS_NOTE(x) \
-do { \
- seq_printf(s, "Note: total memory is precise account of pages " \
- "allocated by NvMap.\nIt doesn't match with all clients " \
- "\"%s\" accumulated as shared memory \nis accounted in " \
- "full in each clients \"%s\" that shared memory.\n", #x, #x); \
-} while (0)
-
-static int nvmap_debug_iovmm_clients_show(struct seq_file *s, void *unused)
+static int nvmap_debug_allocations_show(struct seq_file *s, void *unused)
{
u64 total;
struct nvmap_client *client;
- struct nvmap_device *dev = s->private;
+ u32 heap_type = (u32)(uintptr_t)s->private;
- spin_lock(&dev->clients_lock);
+ spin_lock(&nvmap_dev->clients_lock);
seq_printf(s, "%-18s %18s %8s %11s\n",
"CLIENT", "PROCESS", "PID", "SIZE");
- list_for_each_entry(client, &dev->clients, list) {
+ seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %6s %6s %8s\n",
+ "", "", "BASE", "SIZE", "FLAGS", "REFS",
+ "DUPES", "PINS", "KMAPS", "UMAPS", "SHARE", "UID");
+ list_for_each_entry(client, &nvmap_dev->clients, list) {
u64 client_total;
client_stringify(client, s);
- nvmap_get_client_mss(client, &client_total, true);
+ nvmap_get_client_mss(client, &client_total, heap_type);
seq_printf(s, " %10lluK\n", K(client_total));
+ allocations_stringify(client, s, heap_type);
+ seq_printf(s, "\n");
}
- spin_unlock(&dev->clients_lock);
- nvmap_iovmm_get_total_mss(NULL, NULL, &total);
- seq_printf(s, "%-18s %18s %8s %10lluK\n", "total", "", "", K(total));
+ spin_unlock(&nvmap_dev->clients_lock);
+ nvmap_get_total_mss(NULL, NULL, &total, heap_type);
+ seq_printf(s, "%-18s %-18s %8s %10lluK\n", "total", "", "", K(total));
return 0;
}
-DEBUGFS_OPEN_FOPS(iovmm_clients);
+DEBUGFS_OPEN_FOPS(allocations);
-static int nvmap_debug_iovmm_allocations_show(struct seq_file *s, void *unused)
+static int nvmap_debug_clients_show(struct seq_file *s, void *unused)
{
u64 total;
struct nvmap_client *client;
- struct nvmap_device *dev = s->private;
+ ulong heap_type = (ulong)s->private;
- spin_lock(&dev->clients_lock);
+ spin_lock(&nvmap_dev->clients_lock);
seq_printf(s, "%-18s %18s %8s %11s\n",
"CLIENT", "PROCESS", "PID", "SIZE");
- seq_printf(s, "%-18s %18s %8s %11s %8s %6s %6s %6s %6s %8s\n",
- "", "", "BASE", "SIZE", "FLAGS", "REFS",
- "DUPES", "PINS", "SHARE", "UID");
- list_for_each_entry(client, &dev->clients, list) {
+ list_for_each_entry(client, &nvmap_dev->clients, list) {
u64 client_total;
client_stringify(client, s);
- nvmap_get_client_mss(client, &client_total, true);
+ nvmap_get_client_mss(client, &client_total, heap_type);
seq_printf(s, " %10lluK\n", K(client_total));
- allocations_stringify(client, s, true);
- seq_printf(s, "\n");
}
- spin_unlock(&dev->clients_lock);
- nvmap_iovmm_get_total_mss(NULL, NULL, &total);
- seq_printf(s, "%-18s %-18s %8s %10lluK\n", "total", "", "", K(total));
+ spin_unlock(&nvmap_dev->clients_lock);
+ nvmap_get_total_mss(NULL, NULL, &total, heap_type);
+ seq_printf(s, "%-18s %18s %8s %10lluK\n", "total", "", "", K(total));
return 0;
}
-DEBUGFS_OPEN_FOPS(iovmm_allocations);
+DEBUGFS_OPEN_FOPS(clients);
+
+#define PRINT_MEM_STATS_NOTE(x) \
+do { \
+ seq_printf(s, "Note: total memory is precise account of pages " \
+ "allocated by NvMap.\nIt doesn't match with all clients " \
+ "\"%s\" accumulated as shared memory \nis accounted in " \
+ "full in each clients \"%s\" that shared memory.\n", #x, #x); \
+} while (0)
static void nvmap_iovmm_get_client_mss(struct nvmap_client *client, u64 *pss,
u64 *non_pss, u64 *total)
@@ -1050,7 +992,7 @@ static int nvmap_debug_iovmm_procrank_show(struct seq_file *s, void *unused)
}
spin_unlock(&dev->clients_lock);
- nvmap_iovmm_get_total_mss(&total_pss, &total_non_pss, &total_memory);
+ nvmap_get_total_mss(&total_pss, &total_non_pss, &total_memory, NVMAP_HEAP_IOVMM);
seq_printf(s, "%-18s %18s %8s %10lluK %10lluK %10lluK\n",
"total", "", "", K(total_pss),
K(total_non_pss), K(total_memory));
@@ -1064,7 +1006,7 @@ ulong nvmap_iovmm_get_used_pages(void)
{
u64 total;
- nvmap_iovmm_get_total_mss(NULL, NULL, &total);
+ nvmap_get_total_mss(NULL, NULL, &total, NVMAP_HEAP_IOVMM);
return total >> PAGE_SHIFT;
}
@@ -1254,9 +1196,12 @@ static int nvmap_probe(struct platform_device *pdev)
debugfs_create_dir(co->name, nvmap_debug_root);
if (!IS_ERR_OR_NULL(heap_root)) {
debugfs_create_file("clients", S_IRUGO,
- heap_root, node, &debug_clients_fops);
+ heap_root,
+ (void *)(uintptr_t)node->heap_bit,
+ &debug_clients_fops);
debugfs_create_file("allocations", S_IRUGO,
- heap_root, node,
+ heap_root,
+ (void *)(uintptr_t)node->heap_bit,
&debug_allocations_fops);
nvmap_heap_debugfs_init(heap_root,
node->carveout);
@@ -1268,9 +1213,11 @@ static int nvmap_probe(struct platform_device *pdev)
debugfs_create_dir("iovmm", nvmap_debug_root);
if (!IS_ERR_OR_NULL(iovmm_root)) {
debugfs_create_file("clients", S_IRUGO, iovmm_root,
- dev, &debug_iovmm_clients_fops);
+ (void *)(uintptr_t)NVMAP_HEAP_IOVMM,
+ &debug_clients_fops);
debugfs_create_file("allocations", S_IRUGO, iovmm_root,
- dev, &debug_iovmm_allocations_fops);
+ (void *)(uintptr_t)NVMAP_HEAP_IOVMM,
+ &debug_allocations_fops);
debugfs_create_file("procrank", S_IRUGO, iovmm_root,
dev, &debug_iovmm_procrank_fops);
}
diff --git a/drivers/video/tegra/nvmap/nvmap_handle.c b/drivers/video/tegra/nvmap/nvmap_handle.c
index c38af6a40233..d3f024480615 100644
--- a/drivers/video/tegra/nvmap/nvmap_handle.c
+++ b/drivers/video/tegra/nvmap/nvmap_handle.c
@@ -259,6 +259,7 @@ static void alloc_handle(struct nvmap_client *client,
b = nvmap_carveout_alloc(client, h, type);
if (b) {
+ h->heap_type = type;
h->heap_pgalloc = false;
/* barrier to ensure all handle alloc data
* is visible before alloc is seen by other
@@ -266,9 +267,6 @@ static void alloc_handle(struct nvmap_client *client,
*/
mb();
h->alloc = true;
- nvmap_carveout_commit_add(client,
- nvmap_heap_to_arg(nvmap_block_to_heap(b)),
- h->size);
}
} else if (type & iovmm_mask) {
int ret;
@@ -277,6 +275,7 @@ static void alloc_handle(struct nvmap_client *client,
h->userflags & NVMAP_HANDLE_PHYS_CONTIG);
if (ret)
return;
+ h->heap_type = NVMAP_HEAP_IOVMM;
h->heap_pgalloc = true;
mb();
h->alloc = true;
diff --git a/drivers/video/tegra/nvmap/nvmap_priv.h b/drivers/video/tegra/nvmap/nvmap_priv.h
index 6c630634e9a5..fefe949c88b1 100644
--- a/drivers/video/tegra/nvmap/nvmap_priv.h
+++ b/drivers/video/tegra/nvmap/nvmap_priv.h
@@ -132,6 +132,7 @@ struct nvmap_handle {
};
bool heap_pgalloc; /* handle is page allocated (sysmem / iovmm) */
bool alloc; /* handle has memory allocated */
+ u32 heap_type; /* handle heap is allocated from */
u32 userflags; /* flags passed from userspace */
void *vaddr; /* mapping used inside kernel */
struct list_head vmas; /* list of all user vma's */