Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * drivers/staging/android/ion/ion_priv.h |
| 3 | * |
| 4 | * Copyright (C) 2011 Google, Inc. |
| 5 | * |
| 6 | * This software is licensed under the terms of the GNU General Public |
| 7 | * License version 2, as published by the Free Software Foundation, and |
| 8 | * may be copied, distributed, and modified under those terms. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #ifndef _ION_PRIV_H |
| 18 | #define _ION_PRIV_H |
| 19 | |
Colin Cross | e946b20 | 2013-12-13 14:25:01 -0800 | [diff] [blame] | 20 | #include <linux/dma-direction.h> |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 21 | #include <linux/kref.h> |
| 22 | #include <linux/mm_types.h> |
| 23 | #include <linux/mutex.h> |
| 24 | #include <linux/rbtree.h> |
Rebecca Schultz Zavin | 5ad7bc3 | 2013-12-13 14:24:03 -0800 | [diff] [blame] | 25 | #include <linux/sched.h> |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 26 | #include <linux/shrinker.h> |
| 27 | #include <linux/types.h> |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 28 | |
| 29 | #include "ion.h" |
| 30 | |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 31 | struct ion_buffer *ion_handle_buffer(struct ion_handle *handle); |
| 32 | |
| 33 | /** |
| 34 | * struct ion_buffer - metadata for a particular buffer |
| 35 | * @ref: refernce count |
| 36 | * @node: node in the ion_device buffers tree |
| 37 | * @dev: back pointer to the ion_device |
| 38 | * @heap: back pointer to the heap the buffer came from |
| 39 | * @flags: buffer specific flags |
| 40 | * @size: size of the buffer |
| 41 | * @priv_virt: private data to the buffer representable as |
| 42 | * a void * |
| 43 | * @priv_phys: private data to the buffer representable as |
| 44 | * an ion_phys_addr_t (and someday a phys_addr_t) |
| 45 | * @lock: protects the buffers cnt fields |
| 46 | * @kmap_cnt: number of times the buffer is mapped to the kernel |
| 47 | * @vaddr: the kenrel mapping if kmap_cnt is not zero |
| 48 | * @dmap_cnt: number of times the buffer is mapped for dma |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 49 | * @sg_table: the sg table for the buffer if dmap_cnt is not zero |
Rebecca Schultz Zavin | c13bd1c | 2013-12-13 14:24:45 -0800 | [diff] [blame] | 50 | * @pages: flat array of pages in the buffer -- used by fault |
| 51 | * handler and only valid for buffers that are faulted in |
Rebecca Schultz Zavin | 5ad7bc3 | 2013-12-13 14:24:03 -0800 | [diff] [blame] | 52 | * @vmas: list of vma's mapping this buffer |
| 53 | * @handle_count: count of handles referencing this buffer |
| 54 | * @task_comm: taskcomm of last client to reference this buffer in a |
| 55 | * handle, used for debugging |
| 56 | * @pid: pid of last client to reference this buffer in a |
| 57 | * handle, used for debugging |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 58 | */ |
| 59 | struct ion_buffer { |
| 60 | struct kref ref; |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 61 | union { |
| 62 | struct rb_node node; |
| 63 | struct list_head list; |
| 64 | }; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 65 | struct ion_device *dev; |
| 66 | struct ion_heap *heap; |
| 67 | unsigned long flags; |
| 68 | size_t size; |
| 69 | union { |
| 70 | void *priv_virt; |
| 71 | ion_phys_addr_t priv_phys; |
| 72 | }; |
| 73 | struct mutex lock; |
| 74 | int kmap_cnt; |
| 75 | void *vaddr; |
| 76 | int dmap_cnt; |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 77 | struct sg_table *sg_table; |
Rebecca Schultz Zavin | c13bd1c | 2013-12-13 14:24:45 -0800 | [diff] [blame] | 78 | struct page **pages; |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 79 | struct list_head vmas; |
Rebecca Schultz Zavin | 5ad7bc3 | 2013-12-13 14:24:03 -0800 | [diff] [blame] | 80 | /* used to track orphaned buffers */ |
| 81 | int handle_count; |
| 82 | char task_comm[TASK_COMM_LEN]; |
| 83 | pid_t pid; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 84 | }; |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 85 | void ion_buffer_destroy(struct ion_buffer *buffer); |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 86 | |
| 87 | /** |
| 88 | * struct ion_heap_ops - ops to operate on a given heap |
| 89 | * @allocate: allocate memory |
| 90 | * @free: free memory |
| 91 | * @phys get physical address of a buffer (only define on |
| 92 | * physically contiguous heaps) |
| 93 | * @map_dma map the memory for dma to a scatterlist |
| 94 | * @unmap_dma unmap the memory for dma |
| 95 | * @map_kernel map memory to the kernel |
| 96 | * @unmap_kernel unmap memory to the kernel |
| 97 | * @map_user map memory to userspace |
Colin Cross | 9e90765 | 2013-12-13 14:24:49 -0800 | [diff] [blame] | 98 | * |
| 99 | * allocate, phys, and map_user return 0 on success, -errno on error. |
| 100 | * map_dma and map_kernel return pointer on success, ERR_PTR on error. |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 101 | */ |
| 102 | struct ion_heap_ops { |
| 103 | int (*allocate) (struct ion_heap *heap, |
| 104 | struct ion_buffer *buffer, unsigned long len, |
| 105 | unsigned long align, unsigned long flags); |
| 106 | void (*free) (struct ion_buffer *buffer); |
| 107 | int (*phys) (struct ion_heap *heap, struct ion_buffer *buffer, |
| 108 | ion_phys_addr_t *addr, size_t *len); |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 109 | struct sg_table *(*map_dma) (struct ion_heap *heap, |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 110 | struct ion_buffer *buffer); |
| 111 | void (*unmap_dma) (struct ion_heap *heap, struct ion_buffer *buffer); |
| 112 | void * (*map_kernel) (struct ion_heap *heap, struct ion_buffer *buffer); |
| 113 | void (*unmap_kernel) (struct ion_heap *heap, struct ion_buffer *buffer); |
| 114 | int (*map_user) (struct ion_heap *mapper, struct ion_buffer *buffer, |
| 115 | struct vm_area_struct *vma); |
| 116 | }; |
| 117 | |
| 118 | /** |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 119 | * heap flags - flags between the heaps and core ion code |
| 120 | */ |
| 121 | #define ION_HEAP_FLAG_DEFER_FREE (1 << 0) |
| 122 | |
| 123 | /** |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 124 | * struct ion_heap - represents a heap in the system |
| 125 | * @node: rb node to put the heap on the device's tree of heaps |
| 126 | * @dev: back pointer to the ion_device |
| 127 | * @type: type of heap |
| 128 | * @ops: ops struct as above |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 129 | * @flags: flags |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 130 | * @id: id of heap, also indicates priority of this heap when |
| 131 | * allocating. These are specified by platform data and |
| 132 | * MUST be unique |
| 133 | * @name: used for debugging |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 134 | * @shrinker: a shrinker for the heap, if the heap caches system |
| 135 | * memory, it must define a shrinker to return it on low |
| 136 | * memory conditions, this includes system memory cached |
| 137 | * in the deferred free lists for heaps that support it |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 138 | * @free_list: free list head if deferred free is used |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 139 | * @free_list_size size of the deferred free list in bytes |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 140 | * @lock: protects the free list |
| 141 | * @waitqueue: queue to wait on from deferred free thread |
| 142 | * @task: task struct of deferred free thread |
Rebecca Schultz Zavin | 45b17a8 | 2013-12-13 14:24:11 -0800 | [diff] [blame] | 143 | * @debug_show: called when heap debug file is read to add any |
| 144 | * heap specific debug info to output |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 145 | * |
| 146 | * Represents a pool of memory from which buffers can be made. In some |
| 147 | * systems the only heap is regular system memory allocated via vmalloc. |
| 148 | * On others, some blocks might require large physically contiguous buffers |
| 149 | * that are allocated from a specially reserved heap. |
| 150 | */ |
| 151 | struct ion_heap { |
Rebecca Schultz Zavin | cd69488 | 2013-12-13 14:24:25 -0800 | [diff] [blame] | 152 | struct plist_node node; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 153 | struct ion_device *dev; |
| 154 | enum ion_heap_type type; |
| 155 | struct ion_heap_ops *ops; |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 156 | unsigned long flags; |
Rebecca Schultz Zavin | cd69488 | 2013-12-13 14:24:25 -0800 | [diff] [blame] | 157 | unsigned int id; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 158 | const char *name; |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 159 | struct shrinker shrinker; |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 160 | struct list_head free_list; |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 161 | size_t free_list_size; |
Rebecca Schultz Zavin | fe2faea | 2013-12-13 14:24:35 -0800 | [diff] [blame] | 162 | struct rt_mutex lock; |
| 163 | wait_queue_head_t waitqueue; |
| 164 | struct task_struct *task; |
Rebecca Schultz Zavin | 45b17a8 | 2013-12-13 14:24:11 -0800 | [diff] [blame] | 165 | int (*debug_show)(struct ion_heap *heap, struct seq_file *, void *); |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | /** |
Rebecca Schultz Zavin | 45b17a8 | 2013-12-13 14:24:11 -0800 | [diff] [blame] | 169 | * ion_buffer_cached - this ion buffer is cached |
| 170 | * @buffer: buffer |
| 171 | * |
| 172 | * indicates whether this ion buffer is cached |
| 173 | */ |
| 174 | bool ion_buffer_cached(struct ion_buffer *buffer); |
| 175 | |
| 176 | /** |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 177 | * ion_buffer_fault_user_mappings - fault in user mappings of this buffer |
| 178 | * @buffer: buffer |
| 179 | * |
| 180 | * indicates whether userspace mappings of this buffer will be faulted |
| 181 | * in, this can affect how buffers are allocated from the heap. |
| 182 | */ |
| 183 | bool ion_buffer_fault_user_mappings(struct ion_buffer *buffer); |
| 184 | |
| 185 | /** |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 186 | * ion_device_create - allocates and returns an ion device |
| 187 | * @custom_ioctl: arch specific ioctl function if applicable |
| 188 | * |
| 189 | * returns a valid device or -PTR_ERR |
| 190 | */ |
| 191 | struct ion_device *ion_device_create(long (*custom_ioctl) |
| 192 | (struct ion_client *client, |
| 193 | unsigned int cmd, |
| 194 | unsigned long arg)); |
| 195 | |
| 196 | /** |
| 197 | * ion_device_destroy - free and device and it's resource |
| 198 | * @dev: the device |
| 199 | */ |
| 200 | void ion_device_destroy(struct ion_device *dev); |
| 201 | |
| 202 | /** |
| 203 | * ion_device_add_heap - adds a heap to the ion device |
| 204 | * @dev: the device |
| 205 | * @heap: the heap to add |
| 206 | */ |
| 207 | void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap); |
| 208 | |
| 209 | /** |
Rebecca Schultz Zavin | 8898227 | 2013-12-13 14:24:26 -0800 | [diff] [blame] | 210 | * some helpers for common operations on buffers using the sg_table |
| 211 | * and vaddr fields |
| 212 | */ |
| 213 | void *ion_heap_map_kernel(struct ion_heap *, struct ion_buffer *); |
| 214 | void ion_heap_unmap_kernel(struct ion_heap *, struct ion_buffer *); |
| 215 | int ion_heap_map_user(struct ion_heap *, struct ion_buffer *, |
| 216 | struct vm_area_struct *); |
Rebecca Schultz Zavin | 0b6b2cd | 2013-12-13 14:24:32 -0800 | [diff] [blame] | 217 | int ion_heap_buffer_zero(struct ion_buffer *buffer); |
Rebecca Schultz Zavin | 8898227 | 2013-12-13 14:24:26 -0800 | [diff] [blame] | 218 | |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 219 | /** |
Rebecca Schultz Zavin | c13bd1c | 2013-12-13 14:24:45 -0800 | [diff] [blame] | 220 | * ion_heap_alloc_pages - allocate pages from alloc_pages |
| 221 | * @buffer: the buffer to allocate for, used to extract the flags |
| 222 | * @gfp_flags: the gfp_t for the allocation |
| 223 | * @order: the order of the allocatoin |
| 224 | * |
| 225 | * This funciton allocations from alloc pages and also does any other |
| 226 | * necessary operations based on the buffer->flags. For buffers which |
| 227 | * will be faulted in the pages are split using split_page |
| 228 | */ |
| 229 | struct page *ion_heap_alloc_pages(struct ion_buffer *buffer, gfp_t gfp_flags, |
| 230 | unsigned int order); |
| 231 | |
| 232 | /** |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 233 | * ion_heap_init_deferred_free -- initialize deferred free functionality |
| 234 | * @heap: the heap |
| 235 | * |
| 236 | * If a heap sets the ION_HEAP_FLAG_DEFER_FREE flag this function will |
| 237 | * be called to setup deferred frees. Calls to free the buffer will |
| 238 | * return immediately and the actual free will occur some time later |
| 239 | */ |
| 240 | int ion_heap_init_deferred_free(struct ion_heap *heap); |
| 241 | |
| 242 | /** |
| 243 | * ion_heap_freelist_add - add a buffer to the deferred free list |
| 244 | * @heap: the heap |
| 245 | * @buffer: the buffer |
| 246 | * |
| 247 | * Adds an item to the deferred freelist. |
| 248 | */ |
| 249 | void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer); |
| 250 | |
| 251 | /** |
| 252 | * ion_heap_freelist_drain - drain the deferred free list |
| 253 | * @heap: the heap |
| 254 | * @size: ammount of memory to drain in bytes |
| 255 | * |
| 256 | * Drains the indicated amount of memory from the deferred freelist immediately. |
| 257 | * Returns the total amount freed. The total freed may be higher depending |
| 258 | * on the size of the items in the list, or lower if there is insufficient |
| 259 | * total memory on the freelist. |
| 260 | */ |
| 261 | size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size); |
| 262 | |
| 263 | /** |
| 264 | * ion_heap_freelist_size - returns the size of the freelist in bytes |
| 265 | * @heap: the heap |
| 266 | */ |
| 267 | size_t ion_heap_freelist_size(struct ion_heap *heap); |
| 268 | |
Rebecca Schultz Zavin | 8898227 | 2013-12-13 14:24:26 -0800 | [diff] [blame] | 269 | |
| 270 | /** |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 271 | * functions for creating and destroying the built in ion heaps. |
| 272 | * architectures can add their own custom architecture specific |
| 273 | * heaps as appropriate. |
| 274 | */ |
| 275 | |
| 276 | struct ion_heap *ion_heap_create(struct ion_platform_heap *); |
| 277 | void ion_heap_destroy(struct ion_heap *); |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 278 | struct ion_heap *ion_system_heap_create(struct ion_platform_heap *); |
| 279 | void ion_system_heap_destroy(struct ion_heap *); |
| 280 | |
| 281 | struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *); |
| 282 | void ion_system_contig_heap_destroy(struct ion_heap *); |
| 283 | |
| 284 | struct ion_heap *ion_carveout_heap_create(struct ion_platform_heap *); |
| 285 | void ion_carveout_heap_destroy(struct ion_heap *); |
Rebecca Schultz Zavin | e3c2eb7 | 2013-12-13 14:24:27 -0800 | [diff] [blame] | 286 | |
| 287 | struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *); |
| 288 | void ion_chunk_heap_destroy(struct ion_heap *); |
Benjamin Gaignard | 349c9e1 | 2013-12-13 14:24:44 -0800 | [diff] [blame] | 289 | struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *); |
| 290 | void ion_cma_heap_destroy(struct ion_heap *); |
| 291 | |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 292 | /** |
| 293 | * kernel api to allocate/free from carveout -- used when carveout is |
| 294 | * used to back an architecture specific custom heap |
| 295 | */ |
| 296 | ion_phys_addr_t ion_carveout_allocate(struct ion_heap *heap, unsigned long size, |
| 297 | unsigned long align); |
| 298 | void ion_carveout_free(struct ion_heap *heap, ion_phys_addr_t addr, |
| 299 | unsigned long size); |
| 300 | /** |
| 301 | * The carveout heap returns physical addresses, since 0 may be a valid |
| 302 | * physical address, this is used to indicate allocation failed |
| 303 | */ |
| 304 | #define ION_CARVEOUT_ALLOCATE_FAIL -1 |
| 305 | |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 306 | /** |
| 307 | * functions for creating and destroying a heap pool -- allows you |
| 308 | * to keep a pool of pre allocated memory to use from your heap. Keeping |
| 309 | * a pool of memory that is ready for dma, ie any cached mapping have been |
| 310 | * invalidated from the cache, provides a significant peformance benefit on |
| 311 | * many systems */ |
| 312 | |
| 313 | /** |
| 314 | * struct ion_page_pool - pagepool struct |
Rebecca Schultz Zavin | 0fb9b81 | 2013-12-13 14:24:13 -0800 | [diff] [blame] | 315 | * @high_count: number of highmem items in the pool |
| 316 | * @low_count: number of lowmem items in the pool |
| 317 | * @high_items: list of highmem items |
| 318 | * @low_items: list of lowmem items |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 319 | * @shrinker: a shrinker for the items |
| 320 | * @mutex: lock protecting this struct and especially the count |
| 321 | * item list |
| 322 | * @alloc: function to be used to allocate pageory when the pool |
| 323 | * is empty |
| 324 | * @free: function to be used to free pageory back to the system |
| 325 | * when the shrinker fires |
| 326 | * @gfp_mask: gfp_mask to use from alloc |
| 327 | * @order: order of pages in the pool |
Rebecca Schultz Zavin | 797a95c | 2013-12-13 14:24:15 -0800 | [diff] [blame] | 328 | * @list: plist node for list of pools |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 329 | * |
| 330 | * Allows you to keep a pool of pre allocated pages to use from your heap. |
| 331 | * Keeping a pool of pages that is ready for dma, ie any cached mapping have |
| 332 | * been invalidated from the cache, provides a significant peformance benefit |
| 333 | * on many systems |
| 334 | */ |
| 335 | struct ion_page_pool { |
Rebecca Schultz Zavin | 0fb9b81 | 2013-12-13 14:24:13 -0800 | [diff] [blame] | 336 | int high_count; |
| 337 | int low_count; |
| 338 | struct list_head high_items; |
| 339 | struct list_head low_items; |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 340 | struct mutex mutex; |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 341 | gfp_t gfp_mask; |
| 342 | unsigned int order; |
Rebecca Schultz Zavin | 797a95c | 2013-12-13 14:24:15 -0800 | [diff] [blame] | 343 | struct plist_node list; |
Rebecca Schultz Zavin | 0214c7f | 2013-12-13 14:24:10 -0800 | [diff] [blame] | 344 | }; |
| 345 | |
| 346 | struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order); |
| 347 | void ion_page_pool_destroy(struct ion_page_pool *); |
| 348 | void *ion_page_pool_alloc(struct ion_page_pool *); |
| 349 | void ion_page_pool_free(struct ion_page_pool *, struct page *); |
| 350 | |
Rebecca Schultz Zavin | ea313b5 | 2013-12-13 14:24:39 -0800 | [diff] [blame] | 351 | /** ion_page_pool_shrink - shrinks the size of the memory cached in the pool |
| 352 | * @pool: the pool |
| 353 | * @gfp_mask: the memory type to reclaim |
| 354 | * @nr_to_scan: number of items to shrink in pages |
| 355 | * |
| 356 | * returns the number of items freed in pages |
| 357 | */ |
| 358 | int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, |
| 359 | int nr_to_scan); |
| 360 | |
Colin Cross | e946b20 | 2013-12-13 14:25:01 -0800 | [diff] [blame] | 361 | /** |
| 362 | * ion_pages_sync_for_device - cache flush pages for use with the specified |
| 363 | * device |
| 364 | * @dev: the device the pages will be used with |
| 365 | * @page: the first page to be flushed |
| 366 | * @size: size in bytes of region to be flushed |
| 367 | * @dir: direction of dma transfer |
| 368 | */ |
| 369 | void ion_pages_sync_for_device(struct device *dev, struct page *page, |
| 370 | size_t size, enum dma_data_direction dir); |
| 371 | |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 372 | #endif /* _ION_PRIV_H */ |