From: CMY Date: Mon, 14 Apr 2014 02:10:29 +0000 (+0800) Subject: rk: ion: Add ion snapshot function for debug X-Git-Tag: firefly_0821_release~5564 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c934f4e7a2a1a1879b8ebbd30910ed5c474bf101;p=firefly-linux-kernel-4.4.55.git rk: ion: Add ion snapshot function for debug currently supported features: buffer allocation failure in time to save the current ion each heap and client status, etc. --- diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 885cb60530bf..72d8b337696b 100755 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -2022,3 +2022,59 @@ void __init ion_reserve(struct ion_platform_data *data) data->heaps[i].size); } } + +#define ION_SNAPSHOT_BUFFER_LEN 1<<18 +int ion_snapshot_save(struct ion_device *idev) +{ + static struct seq_file seqf; + struct ion_heap *heap; + struct rb_node *n; + + if (!seqf.buf) { + seqf.size = ION_SNAPSHOT_BUFFER_LEN; + seqf.buf = kmalloc(seqf.size, GFP_KERNEL); + if (!seqf.buf) + return -ENOMEM; + printk("%s: create snapshot 0x%x@0x%lx\n", __func__, seqf.size, + __pa(seqf.buf)); + } else { + printk("%s: save snapshot 0x%x@0x%lx\n", __func__, seqf.size, + __pa(seqf.buf)); + memset(seqf.buf, 0, seqf.size); + seqf.count = 0; + } + + down_read(&idev->lock); + + plist_for_each_entry(heap, &idev->heaps, node) { + seqf.private = (void*)heap; + seq_printf(&seqf, "++++++++++++++++ HEAP: %s ++++++++++++++++\n", + heap->name); + ion_debug_heap_show(&seqf, NULL); + seq_printf(&seqf, "\n"); + if (ION_HEAP_TYPE_DMA==heap->type) + ion_cma_heap_debug_show(&seqf, NULL); + } + + for (n = rb_first(&idev->clients); n; n = rb_next(n)) { + struct ion_client *client = rb_entry(n, struct ion_client, node); + seqf.private = (void*)client; + if (client->task) { + char task_comm[TASK_COMM_LEN]; + + get_task_comm(task_comm, client->task); + seq_printf(&seqf, "++++++++++++++++ CLIENT: %s(PID-%d) ++++++++++++++++\n", + task_comm, client->pid); + } else { + seq_printf(&seqf, "++++++++++++++++ CLIENT: %s(PID-%d) ++++++++++++++++\n", + client->display_name, client->pid); + } + + ion_debug_client_show(&seqf, NULL); + seq_printf(&seqf, "\n"); + } + + up_read(&idev->lock); + + return 0; +} diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index 6cae791d881c..e70869e3172d 100755 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -120,6 +120,7 @@ free_mem: dma_free_coherent(dev, len, info->cpu_addr, info->handle); err: kfree(info); + ion_snapshot_save(heap->dev); return ION_CMA_ALLOCATE_FAILED; } diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h index cb00d1b2e02c..e7a4ec923221 100755 --- a/drivers/staging/android/ion/ion_priv.h +++ b/drivers/staging/android/ion/ion_priv.h @@ -436,4 +436,6 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, void ion_pages_sync_for_device(struct device *dev, struct page *page, size_t size, enum dma_data_direction dir); +int ion_snapshot_save(struct ion_device *idev); + #endif /* _ION_PRIV_H */ diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index e61993d3c2c4..5dccc34ecc3a 100755 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -193,6 +193,7 @@ err: free_buffer_page(sys_heap, buffer, info->page, info->order); kfree(info); } + ion_snapshot_save(heap->dev); return -ENOMEM; }