Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 1 | /* |
| 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 Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 17 | #include <asm/page.h> |
| 18 | #include <linux/dma-mapping.h> |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 19 | #include <linux/err.h> |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 20 | #include <linux/highmem.h> |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 21 | #include <linux/mm.h> |
| 22 | #include <linux/scatterlist.h> |
| 23 | #include <linux/slab.h> |
| 24 | #include <linux/vmalloc.h> |
| 25 | #include "ion.h" |
| 26 | #include "ion_priv.h" |
| 27 | |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 28 | struct page_info { |
| 29 | struct page *page; |
| 30 | unsigned long order; |
| 31 | struct list_head list; |
| 32 | }; |
| 33 | |
Rebecca Schultz Zavin | b0599c0 | 2013-12-13 14:24:08 -0800 | [diff] [blame] | 34 | static unsigned int orders[] = {8, 4, 0}; |
| 35 | |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 36 | static struct page_info *alloc_largest_available(unsigned long size, |
Rebecca Schultz Zavin | ba96a2e | 2013-12-13 14:24:07 -0800 | [diff] [blame] | 37 | bool split_pages, |
| 38 | unsigned int max_order) |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 39 | { |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 40 | struct page *page; |
| 41 | struct page_info *info; |
| 42 | int i; |
| 43 | |
| 44 | for (i = 0; i < ARRAY_SIZE(orders); i++) { |
| 45 | if (size < (1 << orders[i]) * PAGE_SIZE) |
| 46 | continue; |
Rebecca Schultz Zavin | ba96a2e | 2013-12-13 14:24:07 -0800 | [diff] [blame] | 47 | if (max_order < orders[i]) |
| 48 | continue; |
Dima Zavin | fe65ec5 | 2013-12-13 14:23:53 -0800 | [diff] [blame] | 49 | page = alloc_pages(GFP_HIGHUSER | __GFP_ZERO | |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 50 | __GFP_NOWARN | __GFP_NORETRY, orders[i]); |
| 51 | if (!page) |
| 52 | continue; |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 53 | if (split_pages) |
| 54 | split_page(page, orders[i]); |
Rebecca Schultz Zavin | 708f0ca | 2013-12-13 14:23:59 -0800 | [diff] [blame] | 55 | info = kmalloc(sizeof(struct page_info *), GFP_KERNEL); |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 56 | info->page = page; |
| 57 | info->order = orders[i]; |
| 58 | return info; |
| 59 | } |
| 60 | return NULL; |
| 61 | } |
| 62 | |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 63 | static int ion_system_heap_allocate(struct ion_heap *heap, |
| 64 | struct ion_buffer *buffer, |
| 65 | unsigned long size, unsigned long align, |
| 66 | unsigned long flags) |
| 67 | { |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 68 | struct sg_table *table; |
| 69 | struct scatterlist *sg; |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 70 | int ret; |
| 71 | struct list_head pages; |
| 72 | struct page_info *info, *tmp_info; |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 73 | int i = 0; |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 74 | long size_remaining = PAGE_ALIGN(size); |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 75 | bool split_pages = ion_buffer_fault_user_mappings(buffer); |
| 76 | |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 77 | |
Rebecca Schultz Zavin | ba96a2e | 2013-12-13 14:24:07 -0800 | [diff] [blame] | 78 | unsigned int max_order = orders[0]; |
| 79 | |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 80 | INIT_LIST_HEAD(&pages); |
| 81 | while (size_remaining > 0) { |
Rebecca Schultz Zavin | ba96a2e | 2013-12-13 14:24:07 -0800 | [diff] [blame] | 82 | info = alloc_largest_available(size_remaining, split_pages, |
| 83 | max_order); |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 84 | if (!info) |
| 85 | goto err; |
| 86 | list_add_tail(&info->list, &pages); |
| 87 | size_remaining -= (1 << info->order) * PAGE_SIZE; |
Rebecca Schultz Zavin | ba96a2e | 2013-12-13 14:24:07 -0800 | [diff] [blame] | 88 | max_order = info->order; |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 89 | i++; |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 90 | } |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 91 | |
| 92 | table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); |
| 93 | if (!table) |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 94 | goto err; |
| 95 | |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 96 | if (split_pages) |
| 97 | ret = sg_alloc_table(table, PAGE_ALIGN(size) / PAGE_SIZE, |
| 98 | GFP_KERNEL); |
| 99 | else |
| 100 | ret = sg_alloc_table(table, i, GFP_KERNEL); |
| 101 | |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 102 | if (ret) |
| 103 | goto err1; |
| 104 | |
| 105 | sg = table->sgl; |
| 106 | list_for_each_entry_safe(info, tmp_info, &pages, list) { |
| 107 | struct page *page = info->page; |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 108 | |
| 109 | if (split_pages) { |
| 110 | for (i = 0; i < (1 << info->order); i++) { |
| 111 | sg_set_page(sg, page + i, PAGE_SIZE, 0); |
| 112 | sg = sg_next(sg); |
| 113 | } |
| 114 | } else { |
| 115 | sg_set_page(sg, page, (1 << info->order) * PAGE_SIZE, |
| 116 | 0); |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 117 | sg = sg_next(sg); |
| 118 | } |
| 119 | list_del(&info->list); |
Rebecca Schultz Zavin | 708f0ca | 2013-12-13 14:23:59 -0800 | [diff] [blame] | 120 | kfree(info); |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 121 | } |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 122 | |
| 123 | dma_sync_sg_for_device(NULL, table->sgl, table->nents, |
| 124 | DMA_BIDIRECTIONAL); |
| 125 | |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 126 | buffer->priv_virt = table; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 127 | return 0; |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 128 | err1: |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 129 | kfree(table); |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 130 | err: |
| 131 | list_for_each_entry(info, &pages, list) { |
Rebecca Schultz Zavin | 13ba780 | 2013-12-13 14:24:06 -0800 | [diff] [blame] | 132 | if (split_pages) |
| 133 | for (i = 0; i < (1 << info->order); i++) |
| 134 | __free_page(info->page + i); |
| 135 | else |
| 136 | __free_pages(info->page, info->order); |
| 137 | |
Rebecca Schultz Zavin | 708f0ca | 2013-12-13 14:23:59 -0800 | [diff] [blame] | 138 | kfree(info); |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 139 | } |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 140 | return -ENOMEM; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | void ion_system_heap_free(struct ion_buffer *buffer) |
| 144 | { |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 145 | int i; |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 146 | struct scatterlist *sg; |
| 147 | struct sg_table *table = buffer->priv_virt; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 148 | |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 149 | for_each_sg(table->sgl, sg, table->nents, i) |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 150 | __free_pages(sg_page(sg), get_order(sg_dma_len(sg))); |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 151 | if (buffer->sg_table) |
| 152 | sg_free_table(buffer->sg_table); |
| 153 | kfree(buffer->sg_table); |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 154 | } |
| 155 | |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 156 | struct sg_table *ion_system_heap_map_dma(struct ion_heap *heap, |
| 157 | struct ion_buffer *buffer) |
| 158 | { |
| 159 | return buffer->priv_virt; |
| 160 | } |
| 161 | |
| 162 | void ion_system_heap_unmap_dma(struct ion_heap *heap, |
| 163 | struct ion_buffer *buffer) |
| 164 | { |
| 165 | return; |
| 166 | } |
| 167 | |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 168 | void *ion_system_heap_map_kernel(struct ion_heap *heap, |
| 169 | struct ion_buffer *buffer) |
| 170 | { |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 171 | struct scatterlist *sg; |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 172 | int i, j; |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 173 | void *vaddr; |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 174 | pgprot_t pgprot; |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 175 | struct sg_table *table = buffer->priv_virt; |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 176 | int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; |
Rebecca Schultz Zavin | 98d5d5f | 2013-12-13 14:24:09 -0800 | [diff] [blame] | 177 | struct page **pages = vmalloc(sizeof(struct page *) * npages); |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 178 | struct page **tmp = pages; |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 179 | |
Rebecca Schultz Zavin | 98d5d5f | 2013-12-13 14:24:09 -0800 | [diff] [blame] | 180 | if (!pages) |
| 181 | return 0; |
| 182 | |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 183 | if (buffer->flags & ION_FLAG_CACHED) |
| 184 | pgprot = PAGE_KERNEL; |
| 185 | else |
| 186 | pgprot = pgprot_writecombine(PAGE_KERNEL); |
| 187 | |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 188 | for_each_sg(table->sgl, sg, table->nents, i) { |
| 189 | int npages_this_entry = PAGE_ALIGN(sg_dma_len(sg)) / PAGE_SIZE; |
| 190 | struct page *page = sg_page(sg); |
| 191 | BUG_ON(i >= npages); |
| 192 | for (j = 0; j < npages_this_entry; j++) { |
| 193 | *(tmp++) = page++; |
| 194 | } |
| 195 | } |
| 196 | vaddr = vmap(pages, npages, VM_MAP, pgprot); |
Rebecca Schultz Zavin | 98d5d5f | 2013-12-13 14:24:09 -0800 | [diff] [blame] | 197 | vfree(pages); |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 198 | |
| 199 | return vaddr; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void ion_system_heap_unmap_kernel(struct ion_heap *heap, |
| 203 | struct ion_buffer *buffer) |
| 204 | { |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 205 | vunmap(buffer->vaddr); |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | int ion_system_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, |
| 209 | struct vm_area_struct *vma) |
| 210 | { |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 211 | struct sg_table *table = buffer->priv_virt; |
| 212 | unsigned long addr = vma->vm_start; |
| 213 | unsigned long offset = vma->vm_pgoff; |
| 214 | struct scatterlist *sg; |
| 215 | int i; |
| 216 | |
| 217 | for_each_sg(table->sgl, sg, table->nents, i) { |
| 218 | if (offset) { |
| 219 | offset--; |
| 220 | continue; |
| 221 | } |
Rebecca Schultz Zavin | bd5d6bd | 2013-12-13 14:23:51 -0800 | [diff] [blame] | 222 | remap_pfn_range(vma, addr, page_to_pfn(sg_page(sg)), |
| 223 | sg_dma_len(sg), vma->vm_page_prot); |
| 224 | addr += sg_dma_len(sg); |
Rebecca Schultz Zavin | b823024 | 2013-12-13 14:23:58 -0800 | [diff] [blame] | 225 | if (addr >= vma->vm_end) |
| 226 | return 0; |
Rebecca Schultz Zavin | b15934b | 2013-12-13 14:23:41 -0800 | [diff] [blame] | 227 | } |
| 228 | return 0; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | static struct ion_heap_ops vmalloc_ops = { |
| 232 | .allocate = ion_system_heap_allocate, |
| 233 | .free = ion_system_heap_free, |
| 234 | .map_dma = ion_system_heap_map_dma, |
| 235 | .unmap_dma = ion_system_heap_unmap_dma, |
| 236 | .map_kernel = ion_system_heap_map_kernel, |
| 237 | .unmap_kernel = ion_system_heap_unmap_kernel, |
| 238 | .map_user = ion_system_heap_map_user, |
| 239 | }; |
| 240 | |
| 241 | struct ion_heap *ion_system_heap_create(struct ion_platform_heap *unused) |
| 242 | { |
| 243 | struct ion_heap *heap; |
| 244 | |
| 245 | heap = kzalloc(sizeof(struct ion_heap), GFP_KERNEL); |
| 246 | if (!heap) |
| 247 | return ERR_PTR(-ENOMEM); |
| 248 | heap->ops = &vmalloc_ops; |
| 249 | heap->type = ION_HEAP_TYPE_SYSTEM; |
| 250 | return heap; |
| 251 | } |
| 252 | |
| 253 | void ion_system_heap_destroy(struct ion_heap *heap) |
| 254 | { |
| 255 | kfree(heap); |
| 256 | } |
| 257 | |
| 258 | static int ion_system_contig_heap_allocate(struct ion_heap *heap, |
| 259 | struct ion_buffer *buffer, |
| 260 | unsigned long len, |
| 261 | unsigned long align, |
| 262 | unsigned long flags) |
| 263 | { |
| 264 | buffer->priv_virt = kzalloc(len, GFP_KERNEL); |
| 265 | if (!buffer->priv_virt) |
| 266 | return -ENOMEM; |
| 267 | return 0; |
| 268 | } |
| 269 | |
| 270 | void ion_system_contig_heap_free(struct ion_buffer *buffer) |
| 271 | { |
| 272 | kfree(buffer->priv_virt); |
| 273 | } |
| 274 | |
| 275 | static int ion_system_contig_heap_phys(struct ion_heap *heap, |
| 276 | struct ion_buffer *buffer, |
| 277 | ion_phys_addr_t *addr, size_t *len) |
| 278 | { |
| 279 | *addr = virt_to_phys(buffer->priv_virt); |
| 280 | *len = buffer->size; |
| 281 | return 0; |
| 282 | } |
| 283 | |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 284 | struct sg_table *ion_system_contig_heap_map_dma(struct ion_heap *heap, |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 285 | struct ion_buffer *buffer) |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 286 | { |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 287 | struct sg_table *table; |
| 288 | int ret; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 289 | |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 290 | table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); |
| 291 | if (!table) |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 292 | return ERR_PTR(-ENOMEM); |
Rebecca Schultz Zavin | 4d5ca32 | 2013-12-13 14:23:37 -0800 | [diff] [blame] | 293 | ret = sg_alloc_table(table, 1, GFP_KERNEL); |
| 294 | if (ret) { |
| 295 | kfree(table); |
| 296 | return ERR_PTR(ret); |
| 297 | } |
| 298 | sg_set_page(table->sgl, virt_to_page(buffer->priv_virt), buffer->size, |
| 299 | 0); |
| 300 | return table; |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 301 | } |
| 302 | |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 303 | void ion_system_contig_heap_unmap_dma(struct ion_heap *heap, |
| 304 | struct ion_buffer *buffer) |
| 305 | { |
| 306 | sg_free_table(buffer->sg_table); |
| 307 | kfree(buffer->sg_table); |
| 308 | } |
| 309 | |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 310 | int ion_system_contig_heap_map_user(struct ion_heap *heap, |
| 311 | struct ion_buffer *buffer, |
| 312 | struct vm_area_struct *vma) |
| 313 | { |
| 314 | unsigned long pfn = __phys_to_pfn(virt_to_phys(buffer->priv_virt)); |
| 315 | return remap_pfn_range(vma, vma->vm_start, pfn + vma->vm_pgoff, |
| 316 | vma->vm_end - vma->vm_start, |
| 317 | vma->vm_page_prot); |
| 318 | |
| 319 | } |
| 320 | |
| 321 | static struct ion_heap_ops kmalloc_ops = { |
| 322 | .allocate = ion_system_contig_heap_allocate, |
| 323 | .free = ion_system_contig_heap_free, |
| 324 | .phys = ion_system_contig_heap_phys, |
| 325 | .map_dma = ion_system_contig_heap_map_dma, |
Rebecca Schultz Zavin | 56a7c18 | 2013-12-13 14:23:50 -0800 | [diff] [blame] | 326 | .unmap_dma = ion_system_contig_heap_unmap_dma, |
Rebecca Schultz Zavin | c30707b | 2013-12-13 19:38:38 -0800 | [diff] [blame] | 327 | .map_kernel = ion_system_heap_map_kernel, |
| 328 | .unmap_kernel = ion_system_heap_unmap_kernel, |
| 329 | .map_user = ion_system_contig_heap_map_user, |
| 330 | }; |
| 331 | |
| 332 | struct ion_heap *ion_system_contig_heap_create(struct ion_platform_heap *unused) |
| 333 | { |
| 334 | struct ion_heap *heap; |
| 335 | |
| 336 | heap = kzalloc(sizeof(struct ion_heap), GFP_KERNEL); |
| 337 | if (!heap) |
| 338 | return ERR_PTR(-ENOMEM); |
| 339 | heap->ops = &kmalloc_ops; |
| 340 | heap->type = ION_HEAP_TYPE_SYSTEM_CONTIG; |
| 341 | return heap; |
| 342 | } |
| 343 | |
| 344 | void ion_system_contig_heap_destroy(struct ion_heap *heap) |
| 345 | { |
| 346 | kfree(heap); |
| 347 | } |
| 348 | |