diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 5fcb74eb0212..eb36caa58ead 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1275,8 +1275,13 @@ static const struct file_operations ion_fops = { .compat_ioctl = compat_ion_ioctl, }; +#ifdef CONFIG_AMLOGIC_MODIFY +static size_t ion_debug_heap_total(struct ion_client *client, + unsigned int id, struct seq_file *s) +#else static size_t ion_debug_heap_total(struct ion_client *client, unsigned int id) +#endif { size_t size = 0; struct rb_node *n; @@ -1286,9 +1291,22 @@ static size_t ion_debug_heap_total(struct ion_client *client, struct ion_handle *handle = rb_entry(n, struct ion_handle, node); +#ifdef CONFIG_AMLOGIC_MODIFY + if (handle->buffer->heap->id == id) { + seq_printf(s, "%8s %p %8s %p %8s %u %8s %zu\n", + "handle=", handle, + "buf=", handle->buffer, + "heap_id=", id, + "size=", handle->buffer->size); + size += handle->buffer->size; + } + } + seq_puts(s, "----------------------------------------------------\n"); +#else if (handle->buffer->heap->id == id) size += handle->buffer->size; } +#endif mutex_unlock(&client->lock); return size; } @@ -1300,14 +1318,48 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) struct rb_node *n; size_t total_size = 0; size_t total_orphaned_size = 0; - +#ifdef CONFIG_AMLOGIC_MODIFY + mutex_lock(&dev->buffer_lock); + seq_puts(s, "All allocated buffers listed:\n"); + for (n = rb_first(&dev->buffers); n; n = rb_next(n)) { + struct ion_buffer *buffer = rb_entry(n, struct ion_buffer, + node); + if (buffer->heap->id != heap->id) + continue; + seq_printf(s, "%s %p %8s %u %8s %zu %8s %d %8s %d\n", + "buf=", buffer, + "heap_id=", heap->id, + "size=", buffer->size, + "kmap=", buffer->kmap_cnt, + "dmap=", buffer->dmap_cnt); + } + seq_puts(s, "----------------------------------------------------\n"); + mutex_unlock(&dev->buffer_lock); +#else seq_printf(s, "%16s %16s %16s\n", "client", "pid", "size"); seq_puts(s, "----------------------------------------------------\n"); - +#endif mutex_lock(&debugfs_mutex); for (n = rb_first(&dev->clients); n; n = rb_next(n)) { struct ion_client *client = rb_entry(n, struct ion_client, node); +#ifdef CONFIG_AMLOGIC_MODIFY + if (client->task) { + char task_comm[TASK_COMM_LEN]; + + get_task_comm(task_comm, client->task); + seq_printf(s, "%s(%p) %16s %8s(%u)\n", + "client", client, task_comm, + "pid", client->pid); + } else { + seq_printf(s, "%s(%p) %16s %8s(%u)\n", + "client", client, client->name, + "pid", client->pid); + } + ion_debug_heap_total(client, heap->id, s); + } + mutex_unlock(&debugfs_mutex); +#else size_t size = ion_debug_heap_total(client, heap->id); if (!size) @@ -1326,6 +1378,7 @@ static int ion_debug_heap_show(struct seq_file *s, void *unused) mutex_unlock(&debugfs_mutex); seq_puts(s, "----------------------------------------------------\n"); +#endif seq_puts(s, "orphaned allocations (info is from last known client):\n"); mutex_lock(&dev->buffer_lock); for (n = rb_first(&dev->buffers); n; n = rb_next(n)) {