From f8ce869fed930928694f87a75be27d6a56193944 Mon Sep 17 00:00:00 2001 From: CMY Date: Wed, 9 Apr 2014 09:30:39 +0800 Subject: [PATCH] rk: ion: output iommu map info in /d/ion/clients/xx --- drivers/staging/android/ion/ion.c | 30 +++++++++++++++++-- .../staging/android/ion/ion_carveout_heap.c | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 00497a8671b5..d53172eecf1d 100755 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -116,7 +116,7 @@ struct ion_handle { int id; }; -static void ion_iommu_force_unmap(struct ion_buffer *buffer); +void ion_iommu_force_unmap(struct ion_buffer *buffer); bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer) { @@ -893,6 +893,29 @@ out: EXPORT_SYMBOL(ion_unmap_iommu); #endif +static int ion_debug_client_show_buffer_map(struct seq_file *s, struct ion_buffer *buffer) +{ + struct ion_iommu_map *iommu_map; + struct rb_node *node; + const struct rb_root *rb = &(buffer->iommu_maps); + + pr_debug("%s: (%p)\n", __func__, buffer); + + mutex_lock(&buffer->lock); + + while ((node = rb_first(rb)) != 0) { + iommu_map = rb_entry(node, struct ion_iommu_map, node); + /* set ref count to 1 to force release */ + seq_printf(s, "\t%08x@%08lx : %d\n", iommu_map->mapped_size, + iommu_map->iova_addr, + atomic_read(&iommu_map->ref.refcount)); + } + + mutex_unlock(&buffer->lock); + + return 0; +} + static int ion_debug_client_show_buffer(struct seq_file *s, void *unused) { struct ion_client *client = s->private; @@ -901,7 +924,7 @@ static int ion_debug_client_show_buffer(struct seq_file *s, void *unused) size_t len; seq_printf(s, "----------------------------------------------------\n"); - seq_printf(s, "%16.s: %12.s %8.s %4.s %4.s %4.s\n", "heap_name", "addr", + seq_printf(s, "%16.s: %12.s %8.s %4.s %4.s %4.s\n", "heap_name", "addr", "size", "HC", "IBR", "IHR"); mutex_lock(&client->lock); for (n = rb_first(&client->handles); n; n = rb_next(n)) { @@ -911,9 +934,10 @@ static int ion_debug_client_show_buffer(struct seq_file *s, void *unused) buffer->heap->ops->phys(buffer->heap, buffer, &addr, &len); seq_printf(s, "%16.16s: 0x%08lx %8zuKB %4d %4d %4d\n", buffer->heap->name, addr, len>>10, buffer->handle_count, - atomic_read(&buffer->ref.refcount), + atomic_read(&buffer->ref.refcount), atomic_read(&handle->ref.refcount)); } + ion_debug_client_show_buffer_map(s, buffer); } mutex_unlock(&client->lock); diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c index 2bd0e51aba86..d957a22ba218 100644 --- a/drivers/staging/android/ion/ion_carveout_heap.c +++ b/drivers/staging/android/ion/ion_carveout_heap.c @@ -158,7 +158,7 @@ struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *heap_data) page = pfn_to_page(PFN_DOWN(heap_data->base)); size = heap_data->size; - printk("base:%x size:%x page:%p\n", heap_data->base, size, page); + printk("%s: %x@%lx\n", __func__, size, heap_data->base); ion_pages_sync_for_device(NULL, page, size, DMA_BIDIRECTIONAL); -- 2.34.1