| /* SPDX-License-Identifier: GPL-2.0 */ |
| /* |
| * ION Page Pool kernel interface header |
| * |
| * Copyright (C) 2011 Google, Inc. |
| */ |
| |
| #ifndef _ION_PAGE_POOL_H |
| #define _ION_PAGE_POOL_H |
| |
| #include <linux/mm_types.h> |
| #include <linux/mutex.h> |
| #include <linux/shrinker.h> |
| #include <linux/types.h> |
| |
| /** |
| * functions for creating and destroying a heap pool -- allows you |
| * to keep a pool of pre allocated memory to use from your heap. Keeping |
| * a pool of memory that is ready for dma, ie any cached mapping have been |
| * invalidated from the cache, provides a significant performance benefit on |
| * many systems |
| */ |
| |
| /** |
| * struct ion_page_pool - pagepool struct |
| * @high_count: number of highmem items in the pool |
| * @low_count: number of lowmem items in the pool |
| * @high_items: list of highmem items |
| * @low_items: list of lowmem items |
| * @mutex: lock protecting this struct and especially the count |
| * item list |
| * @gfp_mask: gfp_mask to use from alloc |
| * @order: order of pages in the pool |
| * @list: plist node for list of pools |
| * |
| * Allows you to keep a pool of pre allocated pages to use from your heap. |
| * Keeping a pool of pages that is ready for dma, ie any cached mapping have |
| * been invalidated from the cache, provides a significant performance benefit |
| * on many systems |
| */ |
| struct ion_page_pool { |
| int high_count; |
| int low_count; |
| struct list_head high_items; |
| struct list_head low_items; |
| struct mutex mutex; |
| gfp_t gfp_mask; |
| unsigned int order; |
| struct plist_node list; |
| }; |
| |
| struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order); |
| void ion_page_pool_destroy(struct ion_page_pool *pool); |
| struct page *ion_page_pool_alloc(struct ion_page_pool *pool); |
| void ion_page_pool_free(struct ion_page_pool *pool, struct page *page); |
| int ion_page_pool_nr_pages(struct ion_page_pool *pool); |
| |
| /** ion_page_pool_shrink - shrinks the size of the memory cached in the pool |
| * @pool: the pool |
| * @gfp_mask: the memory type to reclaim |
| * @nr_to_scan: number of items to shrink in pages |
| * |
| * returns the number of items freed in pages |
| */ |
| int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, |
| int nr_to_scan); |
| #endif /* _ION_PAGE_POOL_H */ |