From: CMY Date: Thu, 6 Mar 2014 03:04:50 +0000 (+0800) Subject: rk: ion: to view the CMA heap debug information through bitmap X-Git-Tag: firefly_0821_release~6189 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b39b67de2e2e4112535f90c31f65ace9d29a44da;p=firefly-linux-kernel-4.4.55.git rk: ion: to view the CMA heap debug information through bitmap --- diff --git a/drivers/staging/android/ion/rockchip/rockchip_ion.c b/drivers/staging/android/ion/rockchip/rockchip_ion.c index 3f23567f941c..c5152e2ffd87 100755 --- a/drivers/staging/android/ion/rockchip/rockchip_ion.c +++ b/drivers/staging/android/ion/rockchip/rockchip_ion.c @@ -21,6 +21,7 @@ #include #include "../ion_priv.h" #include +#include #ifdef CONFIG_OF #include @@ -156,6 +157,52 @@ free_heaps: return ERR_PTR(ret); } +// struct "cma" quoted from drivers/base/dma-contiguous.c +struct cma { + unsigned long base_pfn; + unsigned long count; + unsigned long *bitmap; +}; + +// struct "ion_cma_heap" quoted from drivers/staging/android/ion/ion_cma_heap.c +struct ion_cma_heap { + struct ion_heap heap; + struct device *dev; +}; + +static int ion_cma_heap_debug_show(struct ion_heap *heap, struct seq_file *s, + void *unused) +{ + + struct ion_cma_heap *cma_heap = container_of(heap, + struct ion_cma_heap, + heap); + struct device *dev = cma_heap->dev; + struct cma *cma = dev_get_cma_area(dev); + unsigned long bit_nr; + int i; + + dev_dbg(dev, "%s: %p(%d,%d,%p)\n", __func__, cma, cma->base_pfn, cma->count, cma->bitmap); + + bit_nr = (cma->count/sizeof(unsigned long))>>3; + + for(i = (bit_nr>>3) - 1; i>= 0; i--){ + seq_printf(s, "%.3uM> Bits[%.3d - %.3d]: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n", + i+1, i*8 + 7, i*8, + cma->bitmap[i*8 + 7], + cma->bitmap[i*8 + 6], + cma->bitmap[i*8 + 5], + cma->bitmap[i*8 + 4], + cma->bitmap[i*8 + 3], + cma->bitmap[i*8 + 2], + cma->bitmap[i*8 + 1], + cma->bitmap[i*8]); + } + seq_printf(s, "Heap size: %luM, heap base: 0x%lx\n", (cma->count)>>8, cma->base_pfn); + + return 0; +} + struct ion_client *rockchip_ion_client_create(const char *name) { return ion_client_create(idev, name); @@ -278,6 +325,8 @@ static int rockchip_ion_probe(struct platform_device *pdev) err = PTR_ERR(heaps[i]); goto err; } + if (ION_HEAP_TYPE_DMA==heap_data->type) + heaps[i]->debug_show = ion_cma_heap_debug_show; ion_device_add_heap(idev, heaps[i]); } platform_set_drvdata(pdev, idev);