mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 09:25:22 +02:00
ANDROID: dma-buf: add dma_heap_try_get_pool_size_kb for vendor hook
We'd like to get total dma-heap pool size via vendor hooks such as meminfo_proc_show or show_mem. Bug: 351175506 Change-Id: I3f7b14a07768f941c91b3e05d8776d4238565e37 Signed-off-by: Sooyong Suk <s.suk@samsung.corp-partner.google.com>
This commit is contained in:
parent
d4474bddf8
commit
66c7ba200c
|
@ -390,6 +390,24 @@ static char *dma_heap_devnode(const struct device *dev, umode_t *mode)
|
|||
return kasprintf(GFP_KERNEL, "dma_heap/%s", dev_name(dev));
|
||||
}
|
||||
|
||||
long dma_heap_try_get_pool_size_kb(void)
|
||||
{
|
||||
struct dma_heap *heap;
|
||||
u64 total_pool_size = 0;
|
||||
|
||||
if (!mutex_trylock(&heap_list_lock))
|
||||
return -1;
|
||||
|
||||
list_for_each_entry(heap, &heap_list, list) {
|
||||
if (heap->ops->get_pool_size)
|
||||
total_pool_size += heap->ops->get_pool_size(heap);
|
||||
}
|
||||
mutex_unlock(&heap_list_lock);
|
||||
|
||||
return (long)(total_pool_size / 1024);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(dma_heap_try_get_pool_size_kb);
|
||||
|
||||
static ssize_t total_pools_kb_show(struct kobject *kobj,
|
||||
struct kobj_attribute *attr, char *buf)
|
||||
{
|
||||
|
|
|
@ -121,4 +121,11 @@ void dma_heap_buffer_free(struct dma_buf *);
|
|||
int dma_heap_bufferfd_alloc(struct dma_heap *heap, size_t len,
|
||||
u32 fd_flags,
|
||||
u64 heap_flags);
|
||||
|
||||
/**
|
||||
* dma_heap_try_get_pool_size_kb - Returns total dma-heap pool size in kb
|
||||
* if there is no lock contention. The pool size will always be 0 if no heaps
|
||||
* use pools, or do not implement get_pool_size.
|
||||
**/
|
||||
long dma_heap_try_get_pool_size_kb(void);
|
||||
#endif /* _DMA_HEAPS_H */
|
||||
|
|
Loading…
Reference in New Issue
Block a user