diff --git a/drivers/gpu/ion/ion.c b/drivers/gpu/ion/ion.c index 4d7ae2e632b..f8a6d1a24e1 100644 --- a/drivers/gpu/ion/ion.c +++ b/drivers/gpu/ion/ion.c @@ -1493,30 +1493,8 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) client->pid, size); } } - if (heap->ops->get_allocated) { - seq_printf(s, "total bytes currently allocated: %lx\n", - heap->ops->get_allocated(heap)); - } - if (heap->ops->get_total) { - 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"); - } + if (heap->ops->print_debug) + heap->ops->print_debug(heap, s); return 0; } diff --git a/drivers/gpu/ion/ion_carveout_heap.c b/drivers/gpu/ion/ion_carveout_heap.c index d23cece76a9..0f195b12c87 100644 --- a/drivers/gpu/ion/ion_carveout_heap.c +++ b/drivers/gpu/ion/ion_carveout_heap.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "ion_priv.h" #include @@ -263,20 +264,16 @@ int ion_carveout_cache_ops(struct ion_heap *heap, struct ion_buffer *buffer, return 0; } -static unsigned long ion_carveout_get_allocated(struct ion_heap *heap) +static int ion_carveout_print_debug(struct ion_heap *heap, struct seq_file *s) { struct ion_carveout_heap *carveout_heap = container_of(heap, struct ion_carveout_heap, heap); - return carveout_heap->allocated_bytes; -} + seq_printf(s, "total bytes currently allocated: %lx\n", + carveout_heap->allocated_bytes); + seq_printf(s, "total heap size: %lx\n", carveout_heap->total_size); -static unsigned long ion_carveout_get_total(struct ion_heap *heap) -{ - struct ion_carveout_heap *carveout_heap = - container_of(heap, struct ion_carveout_heap, heap); - - return carveout_heap->total_size; + return 0; } int ion_carveout_heap_map_iommu(struct ion_buffer *buffer, @@ -392,8 +389,7 @@ static struct ion_heap_ops carveout_heap_ops = { .map_dma = ion_carveout_heap_map_dma, .unmap_dma = ion_carveout_heap_unmap_dma, .cache_op = ion_carveout_cache_ops, - .get_allocated = ion_carveout_get_allocated, - .get_total = ion_carveout_get_total, + .print_debug = ion_carveout_print_debug, .map_iommu = ion_carveout_heap_map_iommu, .unmap_iommu = ion_carveout_heap_unmap_iommu, }; diff --git a/drivers/gpu/ion/ion_cp_heap.c b/drivers/gpu/ion/ion_cp_heap.c index 531fdc626af..46b35b4ebbb 100644 --- a/drivers/gpu/ion/ion_cp_heap.c +++ b/drivers/gpu/ion/ion_cp_heap.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "ion_priv.h" @@ -465,77 +466,34 @@ int ion_cp_cache_ops(struct ion_heap *heap, struct ion_buffer *buffer, return 0; } -static unsigned long ion_cp_get_allocated(struct ion_heap *heap) +static int ion_cp_print_debug(struct ion_heap *heap, struct seq_file *s) { - struct ion_cp_heap *cp_heap = - container_of(heap, struct ion_cp_heap, heap); - unsigned long allocated_bytes; - - mutex_lock(&cp_heap->lock); - allocated_bytes = cp_heap->allocated_bytes; - mutex_unlock(&cp_heap->lock); - - return allocated_bytes; -} - -static unsigned long ion_cp_get_total(struct ion_heap *heap) -{ - struct ion_cp_heap *cp_heap = - container_of(heap, struct ion_cp_heap, heap); - - 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 total_alloc; + unsigned long total_size; 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) -{ + unsigned long umap_count; + unsigned long kmap_count; + unsigned long heap_secured; 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; + total_alloc = cp_heap->allocated_bytes; + total_size = cp_heap->total_size; + alloc_count = cp_heap->alloc_count; + umap_count = cp_heap->umap_count; + kmap_count = cp_heap->kmap_count; + heap_secured = cp_heap->heap_secured == SECURED_HEAP; mutex_unlock(&cp_heap->lock); - return secured_heap; + seq_printf(s, "total bytes currently allocated: %lx\n", total_alloc); + seq_printf(s, "total heap size: %lx\n", total_size); + seq_printf(s, "allocation count: %lx\n", alloc_count); + seq_printf(s, "umapping count: %lx\n", umap_count); + seq_printf(s, "kmapping count: %lx\n", kmap_count); + seq_printf(s, "secured heap: %s\n", heap_secured ? "Yes" : "No"); + + return 0; } int ion_cp_secure_heap(struct ion_heap *heap) @@ -572,12 +530,7 @@ static struct ion_heap_ops cp_heap_ops = { .map_dma = ion_cp_heap_map_dma, .unmap_dma = ion_cp_heap_unmap_dma, .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, + .print_debug = ion_cp_print_debug, .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 e2aca4b430d..8b02639b05d 100644 --- a/drivers/gpu/ion/ion_priv.h +++ b/drivers/gpu/ion/ion_priv.h @@ -24,6 +24,7 @@ #include #include #include +#include /** * struct ion_iommu_map - represents a mapping of an ion buffer to an iommu @@ -126,8 +127,6 @@ struct ion_heap_ops { int (*cache_op)(struct ion_heap *heap, struct ion_buffer *buffer, void *vaddr, unsigned int offset, unsigned int length, unsigned int cmd); - unsigned long (*get_allocated)(struct ion_heap *heap); - unsigned long (*get_total)(struct ion_heap *heap); int (*map_iommu)(struct ion_buffer *buffer, struct ion_iommu_map *map_data, unsigned int domain_num, @@ -136,10 +135,7 @@ struct ion_heap_ops { 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 (*print_debug)(struct ion_heap *heap, struct seq_file *s); int (*secure_heap)(struct ion_heap *heap); int (*unsecure_heap)(struct ion_heap *heap); }; diff --git a/drivers/gpu/ion/ion_system_heap.c b/drivers/gpu/ion/ion_system_heap.c index 6278c104835..6ab9daa6645 100644 --- a/drivers/gpu/ion/ion_system_heap.c +++ b/drivers/gpu/ion/ion_system_heap.c @@ -2,7 +2,7 @@ * drivers/gpu/ion/ion_system_heap.c * * Copyright (C) 2011 Google, Inc. - * Copyright (c) 2011, Code Aurora Forum. All rights reserved. + * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "ion_priv.h" #include @@ -218,9 +219,12 @@ int ion_system_heap_cache_ops(struct ion_heap *heap, struct ion_buffer *buffer, return 0; } -static unsigned long ion_system_heap_get_allocated(struct ion_heap *heap) +static int ion_system_print_debug(struct ion_heap *heap, struct seq_file *s) { - return atomic_read(&system_heap_allocated); + seq_printf(s, "total bytes currently allocated: %lx\n", + (unsigned long) atomic_read(&system_heap_allocated)); + + return 0; } int ion_system_heap_map_iommu(struct ion_buffer *buffer, @@ -303,7 +307,7 @@ static struct ion_heap_ops vmalloc_ops = { .unmap_kernel = ion_system_heap_unmap_kernel, .map_user = ion_system_heap_map_user, .cache_op = ion_system_heap_cache_ops, - .get_allocated = ion_system_heap_get_allocated, + .print_debug = ion_system_print_debug, .map_iommu = ion_system_heap_map_iommu, .unmap_iommu = ion_system_heap_unmap_iommu, }; @@ -421,9 +425,13 @@ int ion_system_contig_heap_cache_ops(struct ion_heap *heap, return 0; } -static unsigned long ion_system_contig_heap_get_allocated(struct ion_heap *heap) +static int ion_system_contig_print_debug(struct ion_heap *heap, + struct seq_file *s) { - return atomic_read(&system_contig_heap_allocated); + seq_printf(s, "total bytes currently allocated: %lx\n", + (unsigned long) atomic_read(&system_contig_heap_allocated)); + + return 0; } int ion_system_contig_heap_map_iommu(struct ion_buffer *buffer, @@ -504,7 +512,7 @@ static struct ion_heap_ops kmalloc_ops = { .unmap_kernel = ion_system_heap_unmap_kernel, .map_user = ion_system_contig_heap_map_user, .cache_op = ion_system_contig_heap_cache_ops, - .get_allocated = ion_system_contig_heap_get_allocated, + .print_debug = ion_system_contig_print_debug, .map_iommu = ion_system_contig_heap_map_iommu, .unmap_iommu = ion_system_heap_unmap_iommu, };