Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 1 | /* |
Laura Abbott | 60c92c7 | 2012-10-10 13:12:52 -0700 | [diff] [blame] | 2 | * Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | */ |
| 13 | #include <linux/err.h> |
| 14 | #include <linux/io.h> |
Mitchel Humpherys | af2e5c5 | 2012-09-06 12:16:36 -0700 | [diff] [blame] | 15 | #include <linux/msm_ion.h> |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 16 | #include <linux/mm.h> |
| 17 | #include <linux/scatterlist.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/vmalloc.h> |
| 20 | #include <linux/iommu.h> |
| 21 | #include <linux/pfn.h> |
Laura Abbott | 60c92c7 | 2012-10-10 13:12:52 -0700 | [diff] [blame] | 22 | #include <linux/dma-mapping.h> |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 23 | #include "ion_priv.h" |
| 24 | |
| 25 | #include <asm/mach/map.h> |
| 26 | #include <asm/page.h> |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 27 | #include <asm/cacheflush.h> |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 28 | #include <mach/iommu_domains.h> |
| 29 | |
| 30 | struct ion_iommu_heap { |
| 31 | struct ion_heap heap; |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 32 | unsigned int has_outer_cache; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | struct ion_iommu_priv_data { |
| 36 | struct page **pages; |
| 37 | int nrpages; |
| 38 | unsigned long size; |
| 39 | }; |
| 40 | |
| 41 | static int ion_iommu_heap_allocate(struct ion_heap *heap, |
| 42 | struct ion_buffer *buffer, |
| 43 | unsigned long size, unsigned long align, |
| 44 | unsigned long flags) |
| 45 | { |
| 46 | int ret, i; |
| 47 | struct ion_iommu_priv_data *data = NULL; |
| 48 | |
| 49 | if (msm_use_iommu()) { |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 50 | struct scatterlist *sg; |
| 51 | struct sg_table *table; |
| 52 | unsigned int i; |
| 53 | |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 54 | data = kmalloc(sizeof(*data), GFP_KERNEL); |
| 55 | if (!data) |
| 56 | return -ENOMEM; |
| 57 | |
| 58 | data->size = PFN_ALIGN(size); |
| 59 | data->nrpages = data->size >> PAGE_SHIFT; |
| 60 | data->pages = kzalloc(sizeof(struct page *)*data->nrpages, |
| 61 | GFP_KERNEL); |
| 62 | if (!data->pages) { |
| 63 | ret = -ENOMEM; |
| 64 | goto err1; |
| 65 | } |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 66 | |
| 67 | table = buffer->sg_table = |
| 68 | kzalloc(sizeof(struct sg_table), GFP_KERNEL); |
| 69 | |
| 70 | if (!table) { |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 71 | ret = -ENOMEM; |
| 72 | goto err1; |
| 73 | } |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 74 | ret = sg_alloc_table(table, data->nrpages, GFP_KERNEL); |
| 75 | if (ret) |
| 76 | goto err2; |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 77 | |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 78 | for_each_sg(table->sgl, sg, table->nents, i) { |
Olav Haugan | c6ac87c | 2012-12-12 18:07:13 -0800 | [diff] [blame] | 79 | data->pages[i] = alloc_page( |
| 80 | GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 81 | if (!data->pages[i]) |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 82 | goto err3; |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 83 | |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 84 | sg_set_page(sg, data->pages[i], PAGE_SIZE, 0); |
Laura Abbott | 60c92c7 | 2012-10-10 13:12:52 -0700 | [diff] [blame] | 85 | sg_dma_address(sg) = sg_phys(sg); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Laura Abbott | 60c92c7 | 2012-10-10 13:12:52 -0700 | [diff] [blame] | 88 | if (!ION_IS_CACHED(flags)) |
| 89 | dma_sync_sg_for_device(NULL, table->sgl, table->nents, |
| 90 | DMA_BIDIRECTIONAL); |
| 91 | |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 92 | buffer->priv_virt = data; |
| 93 | return 0; |
| 94 | |
| 95 | } else { |
| 96 | return -ENOMEM; |
| 97 | } |
| 98 | |
| 99 | |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 100 | err3: |
| 101 | sg_free_table(buffer->sg_table); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 102 | err2: |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 103 | kfree(buffer->sg_table); |
| 104 | buffer->sg_table = 0; |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 105 | |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 106 | for (i = 0; i < data->nrpages; i++) { |
| 107 | if (data->pages[i]) |
| 108 | __free_page(data->pages[i]); |
| 109 | } |
| 110 | kfree(data->pages); |
| 111 | err1: |
| 112 | kfree(data); |
| 113 | return ret; |
| 114 | } |
| 115 | |
| 116 | static void ion_iommu_heap_free(struct ion_buffer *buffer) |
| 117 | { |
| 118 | struct ion_iommu_priv_data *data = buffer->priv_virt; |
| 119 | int i; |
| 120 | |
| 121 | if (!data) |
| 122 | return; |
| 123 | |
| 124 | for (i = 0; i < data->nrpages; i++) |
| 125 | __free_page(data->pages[i]); |
| 126 | |
| 127 | kfree(data->pages); |
| 128 | kfree(data); |
| 129 | } |
| 130 | |
| 131 | void *ion_iommu_heap_map_kernel(struct ion_heap *heap, |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 132 | struct ion_buffer *buffer) |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 133 | { |
| 134 | struct ion_iommu_priv_data *data = buffer->priv_virt; |
| 135 | pgprot_t page_prot = PAGE_KERNEL; |
| 136 | |
| 137 | if (!data) |
| 138 | return NULL; |
| 139 | |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 140 | if (!ION_IS_CACHED(buffer->flags)) |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 141 | page_prot = pgprot_noncached(page_prot); |
| 142 | |
| 143 | buffer->vaddr = vmap(data->pages, data->nrpages, VM_IOREMAP, page_prot); |
| 144 | |
| 145 | return buffer->vaddr; |
| 146 | } |
| 147 | |
| 148 | void ion_iommu_heap_unmap_kernel(struct ion_heap *heap, |
| 149 | struct ion_buffer *buffer) |
| 150 | { |
| 151 | if (!buffer->vaddr) |
| 152 | return; |
| 153 | |
| 154 | vunmap(buffer->vaddr); |
| 155 | buffer->vaddr = NULL; |
| 156 | } |
| 157 | |
| 158 | int ion_iommu_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 159 | struct vm_area_struct *vma) |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 160 | { |
| 161 | struct ion_iommu_priv_data *data = buffer->priv_virt; |
| 162 | int i; |
Olav Haugan | dbec7db | 2012-02-25 10:32:41 -0800 | [diff] [blame] | 163 | unsigned long curr_addr; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 164 | if (!data) |
| 165 | return -EINVAL; |
| 166 | |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 167 | if (!ION_IS_CACHED(buffer->flags)) |
Olav Haugan | de074a7 | 2012-02-22 15:39:54 -0800 | [diff] [blame] | 168 | vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 169 | |
Olav Haugan | dbec7db | 2012-02-25 10:32:41 -0800 | [diff] [blame] | 170 | curr_addr = vma->vm_start; |
| 171 | for (i = 0; i < data->nrpages && curr_addr < vma->vm_end; i++) { |
| 172 | if (vm_insert_page(vma, curr_addr, data->pages[i])) { |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 173 | /* |
| 174 | * This will fail the mmap which will |
| 175 | * clean up the vma space properly. |
| 176 | */ |
| 177 | return -EINVAL; |
Olav Haugan | dbec7db | 2012-02-25 10:32:41 -0800 | [diff] [blame] | 178 | } |
| 179 | curr_addr += PAGE_SIZE; |
| 180 | } |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 181 | return 0; |
| 182 | } |
| 183 | |
| 184 | int ion_iommu_heap_map_iommu(struct ion_buffer *buffer, |
| 185 | struct ion_iommu_map *data, |
| 186 | unsigned int domain_num, |
| 187 | unsigned int partition_num, |
| 188 | unsigned long align, |
| 189 | unsigned long iova_length, |
| 190 | unsigned long flags) |
| 191 | { |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 192 | struct iommu_domain *domain; |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 193 | int ret = 0; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 194 | unsigned long extra; |
Olav Haugan | f310cf2 | 2012-05-08 08:42:49 -0700 | [diff] [blame] | 195 | int prot = IOMMU_WRITE | IOMMU_READ; |
| 196 | prot |= ION_IS_CACHED(flags) ? IOMMU_CACHE : 0; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 197 | |
| 198 | BUG_ON(!msm_use_iommu()); |
| 199 | |
| 200 | data->mapped_size = iova_length; |
| 201 | extra = iova_length - buffer->size; |
| 202 | |
Laura Abbott | d01221b | 2012-05-16 17:52:49 -0700 | [diff] [blame] | 203 | ret = msm_allocate_iova_address(domain_num, partition_num, |
| 204 | data->mapped_size, align, |
| 205 | &data->iova_addr); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 206 | |
Laura Abbott | e27cdcd | 2012-06-21 07:58:41 -0700 | [diff] [blame] | 207 | if (ret) |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 208 | goto out; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 209 | |
| 210 | domain = msm_get_iommu_domain(domain_num); |
| 211 | |
| 212 | if (!domain) { |
| 213 | ret = -ENOMEM; |
| 214 | goto out1; |
| 215 | } |
| 216 | |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 217 | ret = iommu_map_range(domain, data->iova_addr, |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 218 | buffer->sg_table->sgl, |
| 219 | buffer->size, prot); |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 220 | if (ret) { |
| 221 | pr_err("%s: could not map %lx in domain %p\n", |
| 222 | __func__, data->iova_addr, domain); |
| 223 | goto out1; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 224 | } |
| 225 | |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 226 | if (extra) { |
| 227 | unsigned long extra_iova_addr = data->iova_addr + buffer->size; |
Olav Haugan | 8726caf | 2012-05-10 15:11:35 -0700 | [diff] [blame] | 228 | ret = msm_iommu_map_extra(domain, extra_iova_addr, extra, SZ_4K, |
| 229 | prot); |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 230 | if (ret) |
| 231 | goto out2; |
| 232 | } |
| 233 | return ret; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 234 | |
| 235 | out2: |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 236 | iommu_unmap_range(domain, data->iova_addr, buffer->size); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 237 | out1: |
| 238 | msm_free_iova_address(data->iova_addr, domain_num, partition_num, |
| 239 | buffer->size); |
| 240 | |
| 241 | out: |
| 242 | |
| 243 | return ret; |
| 244 | } |
| 245 | |
| 246 | void ion_iommu_heap_unmap_iommu(struct ion_iommu_map *data) |
| 247 | { |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 248 | unsigned int domain_num; |
| 249 | unsigned int partition_num; |
| 250 | struct iommu_domain *domain; |
| 251 | |
| 252 | BUG_ON(!msm_use_iommu()); |
| 253 | |
| 254 | domain_num = iommu_map_domain(data); |
| 255 | partition_num = iommu_map_partition(data); |
| 256 | |
| 257 | domain = msm_get_iommu_domain(domain_num); |
| 258 | |
| 259 | if (!domain) { |
| 260 | WARN(1, "Could not get domain %d. Corruption?\n", domain_num); |
| 261 | return; |
| 262 | } |
| 263 | |
Olav Haugan | 16cdb41 | 2012-03-27 13:02:17 -0700 | [diff] [blame] | 264 | iommu_unmap_range(domain, data->iova_addr, data->mapped_size); |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 265 | msm_free_iova_address(data->iova_addr, domain_num, partition_num, |
| 266 | data->mapped_size); |
| 267 | |
| 268 | return; |
| 269 | } |
| 270 | |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 271 | static int ion_iommu_cache_ops(struct ion_heap *heap, struct ion_buffer *buffer, |
| 272 | void *vaddr, unsigned int offset, unsigned int length, |
| 273 | unsigned int cmd) |
| 274 | { |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 275 | void (*outer_cache_op)(phys_addr_t, phys_addr_t); |
| 276 | struct ion_iommu_heap *iommu_heap = |
| 277 | container_of(heap, struct ion_iommu_heap, heap); |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 278 | |
| 279 | switch (cmd) { |
| 280 | case ION_IOC_CLEAN_CACHES: |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 281 | dmac_clean_range(vaddr, vaddr + length); |
| 282 | outer_cache_op = outer_clean_range; |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 283 | break; |
| 284 | case ION_IOC_INV_CACHES: |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 285 | dmac_inv_range(vaddr, vaddr + length); |
| 286 | outer_cache_op = outer_inv_range; |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 287 | break; |
| 288 | case ION_IOC_CLEAN_INV_CACHES: |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 289 | dmac_flush_range(vaddr, vaddr + length); |
| 290 | outer_cache_op = outer_flush_range; |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 291 | break; |
| 292 | default: |
| 293 | return -EINVAL; |
| 294 | } |
| 295 | |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 296 | if (iommu_heap->has_outer_cache) { |
| 297 | unsigned long pstart; |
| 298 | unsigned int i; |
| 299 | struct ion_iommu_priv_data *data = buffer->priv_virt; |
| 300 | if (!data) |
| 301 | return -ENOMEM; |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 302 | |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 303 | for (i = 0; i < data->nrpages; ++i) { |
| 304 | pstart = page_to_phys(data->pages[i]); |
| 305 | outer_cache_op(pstart, pstart + PAGE_SIZE); |
| 306 | } |
| 307 | } |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 308 | return 0; |
| 309 | } |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 310 | |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 311 | static struct sg_table *ion_iommu_heap_map_dma(struct ion_heap *heap, |
Olav Haugan | ab804b8 | 2012-03-05 14:41:16 -0800 | [diff] [blame] | 312 | struct ion_buffer *buffer) |
| 313 | { |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 314 | return buffer->sg_table; |
Olav Haugan | ab804b8 | 2012-03-05 14:41:16 -0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static void ion_iommu_heap_unmap_dma(struct ion_heap *heap, |
| 318 | struct ion_buffer *buffer) |
| 319 | { |
Laura Abbott | b14ed96 | 2012-01-30 14:18:08 -0800 | [diff] [blame] | 320 | if (buffer->sg_table) |
| 321 | sg_free_table(buffer->sg_table); |
| 322 | kfree(buffer->sg_table); |
| 323 | buffer->sg_table = 0; |
Olav Haugan | ab804b8 | 2012-03-05 14:41:16 -0800 | [diff] [blame] | 324 | } |
| 325 | |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 326 | static struct ion_heap_ops iommu_heap_ops = { |
| 327 | .allocate = ion_iommu_heap_allocate, |
| 328 | .free = ion_iommu_heap_free, |
| 329 | .map_user = ion_iommu_heap_map_user, |
| 330 | .map_kernel = ion_iommu_heap_map_kernel, |
| 331 | .unmap_kernel = ion_iommu_heap_unmap_kernel, |
| 332 | .map_iommu = ion_iommu_heap_map_iommu, |
| 333 | .unmap_iommu = ion_iommu_heap_unmap_iommu, |
Olav Haugan | ef01071 | 2012-03-05 14:19:46 -0800 | [diff] [blame] | 334 | .cache_op = ion_iommu_cache_ops, |
Olav Haugan | ab804b8 | 2012-03-05 14:41:16 -0800 | [diff] [blame] | 335 | .map_dma = ion_iommu_heap_map_dma, |
| 336 | .unmap_dma = ion_iommu_heap_unmap_dma, |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 337 | }; |
| 338 | |
| 339 | struct ion_heap *ion_iommu_heap_create(struct ion_platform_heap *heap_data) |
| 340 | { |
| 341 | struct ion_iommu_heap *iommu_heap; |
| 342 | |
| 343 | iommu_heap = kzalloc(sizeof(struct ion_iommu_heap), GFP_KERNEL); |
| 344 | if (!iommu_heap) |
| 345 | return ERR_PTR(-ENOMEM); |
| 346 | |
| 347 | iommu_heap->heap.ops = &iommu_heap_ops; |
| 348 | iommu_heap->heap.type = ION_HEAP_TYPE_IOMMU; |
Olav Haugan | 85c9540 | 2012-05-30 17:32:37 -0700 | [diff] [blame] | 349 | iommu_heap->has_outer_cache = heap_data->has_outer_cache; |
Laura Abbott | 8c01736 | 2011-09-22 20:59:12 -0700 | [diff] [blame] | 350 | |
| 351 | return &iommu_heap->heap; |
| 352 | } |
| 353 | |
| 354 | void ion_iommu_heap_destroy(struct ion_heap *heap) |
| 355 | { |
| 356 | struct ion_iommu_heap *iommu_heap = |
| 357 | container_of(heap, struct ion_iommu_heap, heap); |
| 358 | |
| 359 | kfree(iommu_heap); |
| 360 | iommu_heap = NULL; |
| 361 | } |