From 1099a4407d556fd912b21c0dc4575e8945265b09 Mon Sep 17 00:00:00 2001 From: Hridya Valsaraju Date: Wed, 3 Feb 2021 21:05:12 -0800 Subject: [PATCH] ANDROID: dma-heap: Let system heap report total pool size This information will be exposed as part of Android Bugreport[1]. [1]: https://android-review.googlesource.com/q/topic:%22b%252F167709539%22+(status:open%20OR%20status:merged) Bug: 167709539 Change-Id: I5b810bd18a495fe8e7f4907c047917ba4718796d Signed-off-by: Hridya Valsaraju --- drivers/dma-buf/heaps/system_heap.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c index c203eddfb772..15796bc4c033 100644 --- a/drivers/dma-buf/heaps/system_heap.c +++ b/drivers/dma-buf/heaps/system_heap.c @@ -500,8 +500,24 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap, return system_heap_do_allocate(heap, len, fd_flags, heap_flags, false); } +static long system_get_pool_size(struct dma_heap *heap) +{ + int i; + long num_pages = 0; + struct dmabuf_page_pool **pool; + + pool = pools; + for (i = 0; i < NUM_ORDERS; i++, pool++) { + num_pages += ((*pool)->count[POOL_LOWPAGE] + + (*pool)->count[POOL_HIGHPAGE]) << (*pool)->order; + } + + return num_pages << PAGE_SHIFT; +} + static const struct dma_heap_ops system_heap_ops = { .allocate = system_heap_allocate, + .get_pool_size = system_get_pool_size, }; static struct dma_buf *system_uncached_heap_allocate(struct dma_heap *heap,