gpu: ion: Add more debug info
Add more debug information to ion_debug_heap_show:
-Get number of allocations from heap
-Get number of user space mappings.
-Get number of kernel space mappings.
-Get indicator whether heaps has been secured or not.
Change-Id: I05491b3dd8caccfc3bbe5a9e55642e5e2cd431c4
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c
index 00002ff..ae4dfcb 100644
--- a/drivers/gpu/ion/ion.c
+++ b/drivers/gpu/ion/ion.c
@@ -1576,6 +1576,22 @@
seq_printf(s, "total heap size: %lx\n",
heap->ops->get_total(heap));
}
+ if (heap->ops->get_alloc_cnt) {
+ seq_printf(s, "allocation count: %lx\n",
+ heap->ops->get_alloc_cnt(heap));
+ }
+ if (heap->ops->get_umap_cnt) {
+ seq_printf(s, "umapping count: %lx\n",
+ heap->ops->get_umap_cnt(heap));
+ }
+ if (heap->ops->get_kmap_cnt) {
+ seq_printf(s, "kmapping count: %lx\n",
+ heap->ops->get_kmap_cnt(heap));
+ }
+ if (heap->ops->get_secured) {
+ seq_printf(s, "secured heap: %s\n",
+ heap->ops->get_secured(heap) ? "Yes" : "No");
+ }
return 0;
}
diff --git a/drivers/gpu/ion/ion_cp_heap.c b/drivers/gpu/ion/ion_cp_heap.c
index 444f7c8..5c069ce 100644
--- a/drivers/gpu/ion/ion_cp_heap.c
+++ b/drivers/gpu/ion/ion_cp_heap.c
@@ -471,6 +471,58 @@
return cp_heap->total_size;
}
+static unsigned long ion_cp_get_umap_count(struct ion_heap *heap)
+{
+ struct ion_cp_heap *cp_heap =
+ container_of(heap, struct ion_cp_heap, heap);
+ unsigned long umap_count;
+
+ mutex_lock(&cp_heap->lock);
+ umap_count = cp_heap->umap_count;
+ mutex_unlock(&cp_heap->lock);
+
+ return umap_count;
+}
+
+static unsigned long ion_cp_get_kmap_count(struct ion_heap *heap)
+{
+ struct ion_cp_heap *cp_heap =
+ container_of(heap, struct ion_cp_heap, heap);
+ unsigned long kmap_count;
+
+ mutex_lock(&cp_heap->lock);
+ kmap_count = cp_heap->kmap_count;
+ mutex_unlock(&cp_heap->lock);
+
+ return kmap_count;
+}
+
+static unsigned long ion_cp_get_alloc_count(struct ion_heap *heap)
+{
+ struct ion_cp_heap *cp_heap =
+ container_of(heap, struct ion_cp_heap, heap);
+ unsigned long alloc_count;
+
+ mutex_lock(&cp_heap->lock);
+ alloc_count = cp_heap->alloc_count;
+ mutex_unlock(&cp_heap->lock);
+
+ return alloc_count;
+}
+
+static unsigned long ion_cp_get_secured(struct ion_heap *heap)
+{
+ struct ion_cp_heap *cp_heap =
+ container_of(heap, struct ion_cp_heap, heap);
+ unsigned long secured_heap = 0;
+
+ mutex_lock(&cp_heap->lock);
+ secured_heap = cp_heap->heap_secured == SECURED_HEAP;
+ mutex_unlock(&cp_heap->lock);
+
+ return secured_heap;
+}
+
int ion_cp_secure_heap(struct ion_heap *heap)
{
int ret_value;
@@ -507,6 +559,10 @@
.cache_op = ion_cp_cache_ops,
.get_allocated = ion_cp_get_allocated,
.get_total = ion_cp_get_total,
+ .get_umap_cnt = ion_cp_get_umap_count,
+ .get_kmap_cnt = ion_cp_get_kmap_count,
+ .get_alloc_cnt = ion_cp_get_alloc_count,
+ .get_secured = ion_cp_get_secured,
.secure_heap = ion_cp_secure_heap,
.unsecure_heap = ion_cp_unsecure_heap,
};
diff --git a/drivers/gpu/ion/ion_priv.h b/drivers/gpu/ion/ion_priv.h
index 9ad9d10..98709b6 100644
--- a/drivers/gpu/ion/ion_priv.h
+++ b/drivers/gpu/ion/ion_priv.h
@@ -149,6 +149,10 @@
unsigned long iova_length,
unsigned long flags);
void (*unmap_iommu)(struct ion_iommu_map *data);
+ unsigned long (*get_umap_cnt)(struct ion_heap *heap);
+ unsigned long (*get_kmap_cnt)(struct ion_heap *heap);
+ unsigned long (*get_alloc_cnt)(struct ion_heap *heap);
+ unsigned long (*get_secured)(struct ion_heap *heap);
int (*secure_heap)(struct ion_heap *heap);
int (*unsecure_heap)(struct ion_heap *heap);
};