blob: 62a07ec7d5bf40ddcfcd5be28bd490605de5e5da [file] [log] [blame]
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -08001/*
2 * drivers/staging/android/ion/ion_system_heap.c
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
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -080017#include <asm/page.h>
18#include <linux/dma-mapping.h>
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -080019#include <linux/err.h>
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -080020#include <linux/highmem.h>
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -080021#include <linux/mm.h>
22#include <linux/scatterlist.h>
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080023#include <linux/seq_file.h>
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -080024#include <linux/slab.h>
25#include <linux/vmalloc.h>
26#include "ion.h"
27#include "ion_priv.h"
28
Rebecca Schultz Zavinee4a4982013-12-13 14:24:12 -080029static unsigned int high_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO |
Arve Hjønnevåg1584f402013-12-13 14:24:41 -080030 __GFP_NOWARN | __GFP_NORETRY) &
31 ~__GFP_WAIT;
Rebecca Schultz Zavinee4a4982013-12-13 14:24:12 -080032static unsigned int low_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO |
33 __GFP_NOWARN);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080034static const unsigned int orders[] = {8, 4, 0};
35static const int num_orders = ARRAY_SIZE(orders);
36static int order_to_index(unsigned int order)
37{
38 int i;
39 for (i = 0; i < num_orders; i++)
40 if (order == orders[i])
41 return i;
42 BUG();
43 return -1;
44}
45
46static unsigned int order_to_size(int order)
47{
48 return PAGE_SIZE << order;
49}
50
51struct ion_system_heap {
52 struct ion_heap heap;
53 struct ion_page_pool **pools;
54};
55
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -080056struct page_info {
57 struct page *page;
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080058 unsigned int order;
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -080059 struct list_head list;
60};
61
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080062static struct page *alloc_buffer_page(struct ion_system_heap *heap,
63 struct ion_buffer *buffer,
64 unsigned long order)
65{
66 bool cached = ion_buffer_cached(buffer);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080067 struct ion_page_pool *pool = heap->pools[order_to_index(order)];
68 struct page *page;
Rebecca Schultz Zavinb0599c02013-12-13 14:24:08 -080069
Rebecca Schultz Zavinee4a4982013-12-13 14:24:12 -080070 if (!cached) {
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080071 page = ion_page_pool_alloc(pool);
Rebecca Schultz Zavinee4a4982013-12-13 14:24:12 -080072 } else {
73 gfp_t gfp_flags = low_order_gfp_flags;
74
75 if (order > 4)
76 gfp_flags = high_order_gfp_flags;
Rebecca Schultz Zavinc13bd1c2013-12-13 14:24:45 -080077 page = ion_heap_alloc_pages(buffer, gfp_flags, order);
Rebecca Schultz Zavin8fae8312013-12-13 14:24:18 -080078 if (!page)
79 return 0;
Colin Crosse946b202013-12-13 14:25:01 -080080 ion_pages_sync_for_device(NULL, page, PAGE_SIZE << order,
81 DMA_BIDIRECTIONAL);
Rebecca Schultz Zavinee4a4982013-12-13 14:24:12 -080082 }
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080083 if (!page)
84 return 0;
Rebecca Schultz Zavin8fae8312013-12-13 14:24:18 -080085
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080086 return page;
87}
88
89static void free_buffer_page(struct ion_system_heap *heap,
90 struct ion_buffer *buffer, struct page *page,
Rebecca Schultz Zavin0b6b2cd2013-12-13 14:24:32 -080091 unsigned int order)
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080092{
93 bool cached = ion_buffer_cached(buffer);
94 bool split_pages = ion_buffer_fault_user_mappings(buffer);
95 int i;
96
97 if (!cached) {
98 struct ion_page_pool *pool = heap->pools[order_to_index(order)];
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -080099 ion_page_pool_free(pool, page);
100 } else if (split_pages) {
101 for (i = 0; i < (1 << order); i++)
102 __free_page(page + i);
103 } else {
104 __free_pages(page, order);
105 }
106}
107
108
109static struct page_info *alloc_largest_available(struct ion_system_heap *heap,
110 struct ion_buffer *buffer,
111 unsigned long size,
Rebecca Schultz Zavinba96a2e2013-12-13 14:24:07 -0800112 unsigned int max_order)
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800113{
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800114 struct page *page;
115 struct page_info *info;
116 int i;
117
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800118 for (i = 0; i < num_orders; i++) {
119 if (size < order_to_size(orders[i]))
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800120 continue;
Rebecca Schultz Zavinba96a2e2013-12-13 14:24:07 -0800121 if (max_order < orders[i])
122 continue;
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800123
124 page = alloc_buffer_page(heap, buffer, orders[i]);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800125 if (!page)
126 continue;
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800127
128 info = kmalloc(sizeof(struct page_info), GFP_KERNEL);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800129 info->page = page;
130 info->order = orders[i];
131 return info;
132 }
133 return NULL;
134}
135
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800136static int ion_system_heap_allocate(struct ion_heap *heap,
137 struct ion_buffer *buffer,
138 unsigned long size, unsigned long align,
139 unsigned long flags)
140{
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800141 struct ion_system_heap *sys_heap = container_of(heap,
142 struct ion_system_heap,
143 heap);
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800144 struct sg_table *table;
145 struct scatterlist *sg;
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800146 int ret;
147 struct list_head pages;
148 struct page_info *info, *tmp_info;
Rebecca Schultz Zavin13ba7802013-12-13 14:24:06 -0800149 int i = 0;
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800150 long size_remaining = PAGE_ALIGN(size);
Rebecca Schultz Zavinba96a2e2013-12-13 14:24:07 -0800151 unsigned int max_order = orders[0];
152
Colin Crossc13d1df2013-12-13 14:25:03 -0800153 if (align > PAGE_SIZE)
154 return -EINVAL;
155
156 if (ion_buffer_fault_user_mappings(buffer))
157 return -EINVAL;
158
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800159 INIT_LIST_HEAD(&pages);
160 while (size_remaining > 0) {
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800161 info = alloc_largest_available(sys_heap, buffer, size_remaining, max_order);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800162 if (!info)
163 goto err;
164 list_add_tail(&info->list, &pages);
165 size_remaining -= (1 << info->order) * PAGE_SIZE;
Rebecca Schultz Zavinba96a2e2013-12-13 14:24:07 -0800166 max_order = info->order;
Rebecca Schultz Zavin13ba7802013-12-13 14:24:06 -0800167 i++;
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800168 }
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800169
170 table = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
171 if (!table)
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800172 goto err;
173
Rebecca Schultz Zavinc13bd1c2013-12-13 14:24:45 -0800174 ret = sg_alloc_table(table, i, GFP_KERNEL);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800175 if (ret)
176 goto err1;
177
178 sg = table->sgl;
179 list_for_each_entry_safe(info, tmp_info, &pages, list) {
180 struct page *page = info->page;
Rebecca Schultz Zavinc13bd1c2013-12-13 14:24:45 -0800181 sg_set_page(sg, page, (1 << info->order) * PAGE_SIZE, 0);
182 sg = sg_next(sg);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800183 list_del(&info->list);
Rebecca Schultz Zavin708f0ca2013-12-13 14:23:59 -0800184 kfree(info);
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800185 }
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800186
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800187 buffer->priv_virt = table;
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800188 return 0;
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800189err1:
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800190 kfree(table);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800191err:
192 list_for_each_entry(info, &pages, list) {
Rebecca Schultz Zavin0b6b2cd2013-12-13 14:24:32 -0800193 free_buffer_page(sys_heap, buffer, info->page, info->order);
Rebecca Schultz Zavin708f0ca2013-12-13 14:23:59 -0800194 kfree(info);
Rebecca Schultz Zavinbd5d6bd2013-12-13 14:23:51 -0800195 }
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800196 return -ENOMEM;
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800197}
198
199void ion_system_heap_free(struct ion_buffer *buffer)
200{
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800201 struct ion_heap *heap = buffer->heap;
202 struct ion_system_heap *sys_heap = container_of(heap,
203 struct ion_system_heap,
204 heap);
Rebecca Schultz Zavin88982272013-12-13 14:24:26 -0800205 struct sg_table *table = buffer->sg_table;
Rebecca Schultz Zavin0b6b2cd2013-12-13 14:24:32 -0800206 bool cached = ion_buffer_cached(buffer);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800207 struct scatterlist *sg;
208 LIST_HEAD(pages);
209 int i;
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800210
Rebecca Schultz Zavin0b6b2cd2013-12-13 14:24:32 -0800211 /* uncached pages come from the page pools, zero them before returning
212 for security purposes (other allocations are zerod at alloc time */
213 if (!cached)
214 ion_heap_buffer_zero(buffer);
Rebecca Schultz Zavin77cbe822013-12-13 14:24:31 -0800215
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800216 for_each_sg(table->sgl, sg, table->nents, i)
Rebecca Schultz Zavin77cbe822013-12-13 14:24:31 -0800217 free_buffer_page(sys_heap, buffer, sg_page(sg),
Colin Cross06e0dca2013-12-13 14:25:02 -0800218 get_order(sg->length));
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800219 sg_free_table(table);
220 kfree(table);
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800221}
222
Rebecca Schultz Zavinb15934b2013-12-13 14:23:41 -0800223struct sg_table *ion_system_heap_map_dma(struct ion_heap *heap,
224 struct ion_buffer *buffer)
225{
226 return buffer->priv_virt;
227}
228
229void ion_system_heap_unmap_dma(struct ion_heap *heap,
230 struct ion_buffer *buffer)
231{
232 return;
233}
234
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800235static struct ion_heap_ops system_heap_ops = {
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800236 .allocate = ion_system_heap_allocate,
237 .free = ion_system_heap_free,
238 .map_dma = ion_system_heap_map_dma,
239 .unmap_dma = ion_system_heap_unmap_dma,
Rebecca Schultz Zavin88982272013-12-13 14:24:26 -0800240 .map_kernel = ion_heap_map_kernel,
241 .unmap_kernel = ion_heap_unmap_kernel,
242 .map_user = ion_heap_map_user,
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800243};
244
Rebecca Schultz Zavinea313b52013-12-13 14:24:39 -0800245static int ion_system_heap_shrink(struct shrinker *shrinker,
246 struct shrink_control *sc) {
247
248 struct ion_heap *heap = container_of(shrinker, struct ion_heap,
249 shrinker);
250 struct ion_system_heap *sys_heap = container_of(heap,
251 struct ion_system_heap,
252 heap);
253 int nr_total = 0;
254 int nr_freed = 0;
255 int i;
256
257 if (sc->nr_to_scan == 0)
258 goto end;
259
260 /* shrink the free list first, no point in zeroing the memory if
261 we're just going to reclaim it */
262 nr_freed += ion_heap_freelist_drain(heap, sc->nr_to_scan * PAGE_SIZE) /
263 PAGE_SIZE;
264
265 if (nr_freed >= sc->nr_to_scan)
266 goto end;
267
268 for (i = 0; i < num_orders; i++) {
269 struct ion_page_pool *pool = sys_heap->pools[i];
270
271 nr_freed += ion_page_pool_shrink(pool, sc->gfp_mask,
272 sc->nr_to_scan);
273 if (nr_freed >= sc->nr_to_scan)
274 break;
275 }
276
277end:
278 /* total number of items is whatever the page pools are holding
279 plus whatever's in the freelist */
280 for (i = 0; i < num_orders; i++) {
281 struct ion_page_pool *pool = sys_heap->pools[i];
282 nr_total += ion_page_pool_shrink(pool, sc->gfp_mask, 0);
283 }
284 nr_total += ion_heap_freelist_size(heap) / PAGE_SIZE;
285 return nr_total;
286
287}
288
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800289static int ion_system_heap_debug_show(struct ion_heap *heap, struct seq_file *s,
290 void *unused)
291{
292
293 struct ion_system_heap *sys_heap = container_of(heap,
294 struct ion_system_heap,
295 heap);
296 int i;
297 for (i = 0; i < num_orders; i++) {
298 struct ion_page_pool *pool = sys_heap->pools[i];
Rebecca Schultz Zavin0fb9b812013-12-13 14:24:13 -0800299 seq_printf(s, "%d order %u highmem pages in pool = %lu total\n",
300 pool->high_count, pool->order,
301 (1 << pool->order) * PAGE_SIZE * pool->high_count);
302 seq_printf(s, "%d order %u lowmem pages in pool = %lu total\n",
303 pool->low_count, pool->order,
304 (1 << pool->order) * PAGE_SIZE * pool->low_count);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800305 }
306 return 0;
307}
308
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800309struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused)
310{
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800311 struct ion_system_heap *heap;
312 int i;
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800313
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800314 heap = kzalloc(sizeof(struct ion_system_heap), GFP_KERNEL);
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800315 if (!heap)
316 return ERR_PTR(-ENOMEM);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800317 heap->heap.ops = &system_heap_ops;
318 heap->heap.type = ION_HEAP_TYPE_SYSTEM;
Rebecca Schultz Zavinfe2faea2013-12-13 14:24:35 -0800319 heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800320 heap->pools = kzalloc(sizeof(struct ion_page_pool *) * num_orders,
321 GFP_KERNEL);
322 if (!heap->pools)
323 goto err_alloc_pools;
324 for (i = 0; i < num_orders; i++) {
325 struct ion_page_pool *pool;
Rebecca Schultz Zavinee4a4982013-12-13 14:24:12 -0800326 gfp_t gfp_flags = low_order_gfp_flags;
327
328 if (orders[i] > 4)
329 gfp_flags = high_order_gfp_flags;
330 pool = ion_page_pool_create(gfp_flags, orders[i]);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800331 if (!pool)
332 goto err_create_pool;
333 heap->pools[i] = pool;
334 }
Rebecca Schultz Zavinea313b52013-12-13 14:24:39 -0800335
336 heap->heap.shrinker.shrink = ion_system_heap_shrink;
337 heap->heap.shrinker.seeks = DEFAULT_SEEKS;
338 heap->heap.shrinker.batch = 0;
339 register_shrinker(&heap->heap.shrinker);
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800340 heap->heap.debug_show = ion_system_heap_debug_show;
341 return &heap->heap;
342err_create_pool:
343 for (i = 0; i < num_orders; i++)
344 if (heap->pools[i])
345 ion_page_pool_destroy(heap->pools[i]);
346 kfree(heap->pools);
347err_alloc_pools:
348 kfree(heap);
349 return ERR_PTR(-ENOMEM);
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800350}
351
352void ion_system_heap_destroy(struct ion_heap *heap)
353{
Rebecca Schultz Zavin45b17a82013-12-13 14:24:11 -0800354 struct ion_system_heap *sys_heap = container_of(heap,
355 struct ion_system_heap,
356 heap);
357 int i;
358
359 for (i = 0; i < num_orders; i++)
360 ion_page_pool_destroy(sys_heap->pools[i]);
361 kfree(sys_heap->pools);
362 kfree(sys_heap);
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800363}
364
365static int ion_system_contig_heap_allocate(struct ion_heap *heap,
366 struct ion_buffer *buffer,
367 unsigned long len,
368 unsigned long align,
369 unsigned long flags)
370{
Colin Crossc13d1df2013-12-13 14:25:03 -0800371 int order = get_order(len);
372
373 if (align > (PAGE_SIZE << order))
374 return -EINVAL;
375
376 if (ion_buffer_fault_user_mappings(buffer))
377 return -EINVAL;
378
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800379 buffer->priv_virt = kzalloc(len, GFP_KERNEL);
380 if (!buffer->priv_virt)
381 return -ENOMEM;
382 return 0;
383}
384
385void ion_system_contig_heap_free(struct ion_buffer *buffer)
386{
387 kfree(buffer->priv_virt);
388}
389
390static int ion_system_contig_heap_phys(struct ion_heap *heap,
391 struct ion_buffer *buffer,
392 ion_phys_addr_t *addr, size_t *len)
393{
394 *addr = virt_to_phys(buffer->priv_virt);
395 *len = buffer->size;
396 return 0;
397}
398
Rebecca Schultz Zavin4d5ca322013-12-13 14:23:37 -0800399struct sg_table *ion_system_contig_heap_map_dma(struct ion_heap *heap,
Rebecca Schultz Zavin56a7c182013-12-13 14:23:50 -0800400 struct ion_buffer *buffer)
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800401{
Rebecca Schultz Zavin4d5ca322013-12-13 14:23:37 -0800402 struct sg_table *table;
403 int ret;
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800404
Rebecca Schultz Zavin4d5ca322013-12-13 14:23:37 -0800405 table = kzalloc(sizeof(struct sg_table), GFP_KERNEL);
406 if (!table)
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800407 return ERR_PTR(-ENOMEM);
Rebecca Schultz Zavin4d5ca322013-12-13 14:23:37 -0800408 ret = sg_alloc_table(table, 1, GFP_KERNEL);
409 if (ret) {
410 kfree(table);
411 return ERR_PTR(ret);
412 }
413 sg_set_page(table->sgl, virt_to_page(buffer->priv_virt), buffer->size,
414 0);
415 return table;
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800416}
417
Rebecca Schultz Zavin56a7c182013-12-13 14:23:50 -0800418void ion_system_contig_heap_unmap_dma(struct ion_heap *heap,
419 struct ion_buffer *buffer)
420{
421 sg_free_table(buffer->sg_table);
422 kfree(buffer->sg_table);
423}
424
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800425int ion_system_contig_heap_map_user(struct ion_heap *heap,
426 struct ion_buffer *buffer,
427 struct vm_area_struct *vma)
428{
429 unsigned long pfn = __phys_to_pfn(virt_to_phys(buffer->priv_virt));
430 return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff,
431 vma->vm_end - vma->vm_start,
432 vma->vm_page_prot);
433
434}
435
436static struct ion_heap_ops kmalloc_ops = {
437 .allocate = ion_system_contig_heap_allocate,
438 .free = ion_system_contig_heap_free,
439 .phys = ion_system_contig_heap_phys,
440 .map_dma = ion_system_contig_heap_map_dma,
Rebecca Schultz Zavin56a7c182013-12-13 14:23:50 -0800441 .unmap_dma = ion_system_contig_heap_unmap_dma,
Rebecca Schultz Zavin88982272013-12-13 14:24:26 -0800442 .map_kernel = ion_heap_map_kernel,
443 .unmap_kernel = ion_heap_unmap_kernel,
Rebecca Schultz Zavinc30707b2013-12-13 19:38:38 -0800444 .map_user = ion_system_contig_heap_map_user,
445};
446
447struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *unused)
448{
449 struct ion_heap *heap;
450
451 heap = kzalloc(sizeof(struct ion_heap), GFP_KERNEL);
452 if (!heap)
453 return ERR_PTR(-ENOMEM);
454 heap->ops = &kmalloc_ops;
455 heap->type = ION_HEAP_TYPE_SYSTEM_CONTIG;
456 return heap;
457}
458
459void ion_system_contig_heap_destroy(struct ion_heap *heap)
460{
461 kfree(heap);
462}
463