Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2002,2007-2013, The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/export.h> |
| 15 | #include <linux/vmalloc.h> |
| 16 | #include <linux/memory_alloc.h> |
| 17 | #include <asm/cacheflush.h> |
| 18 | #include <linux/slab.h> |
| 19 | #include <linux/kmemleak.h> |
| 20 | #include <linux/highmem.h> |
| 21 | |
| 22 | #include "kgsl.h" |
| 23 | #include "kgsl_sharedmem.h" |
| 24 | #include "kgsl_cffdump.h" |
| 25 | #include "kgsl_device.h" |
| 26 | |
| 27 | DEFINE_MUTEX(kernel_map_global_lock); |
| 28 | |
| 29 | /* An attribute for showing per-process memory statistics */ |
| 30 | struct kgsl_mem_entry_attribute { |
| 31 | struct attribute attr; |
| 32 | int memtype; |
| 33 | ssize_t (*show)(struct kgsl_process_private *priv, |
| 34 | int type, char *buf); |
| 35 | }; |
| 36 | |
| 37 | #define to_mem_entry_attr(a) \ |
| 38 | container_of(a, struct kgsl_mem_entry_attribute, attr) |
| 39 | |
| 40 | #define __MEM_ENTRY_ATTR(_type, _name, _show) \ |
| 41 | { \ |
| 42 | .attr = { .name = __stringify(_name), .mode = 0444 }, \ |
| 43 | .memtype = _type, \ |
| 44 | .show = _show, \ |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * A structure to hold the attributes for a particular memory type. |
| 49 | * For each memory type in each process we store the current and maximum |
| 50 | * memory usage and display the counts in sysfs. This structure and |
| 51 | * the following macro allow us to simplify the definition for those |
| 52 | * adding new memory types |
| 53 | */ |
| 54 | |
| 55 | struct mem_entry_stats { |
| 56 | int memtype; |
| 57 | struct kgsl_mem_entry_attribute attr; |
| 58 | struct kgsl_mem_entry_attribute max_attr; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | #define MEM_ENTRY_STAT(_type, _name) \ |
| 63 | { \ |
| 64 | .memtype = _type, \ |
| 65 | .attr = __MEM_ENTRY_ATTR(_type, _name, mem_entry_show), \ |
| 66 | .max_attr = __MEM_ENTRY_ATTR(_type, _name##_max, \ |
| 67 | mem_entry_max_show), \ |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Given a kobj, find the process structure attached to it |
| 72 | */ |
| 73 | |
| 74 | static struct kgsl_process_private * |
| 75 | _get_priv_from_kobj(struct kobject *kobj) |
| 76 | { |
| 77 | struct kgsl_process_private *private; |
| 78 | unsigned long name; |
| 79 | |
| 80 | if (!kobj) |
| 81 | return NULL; |
| 82 | |
| 83 | if (sscanf(kobj->name, "%ld", &name) != 1) |
| 84 | return NULL; |
| 85 | |
| 86 | list_for_each_entry(private, &kgsl_driver.process_list, list) { |
| 87 | if (private->pid == name) |
| 88 | return private; |
| 89 | } |
| 90 | |
| 91 | return NULL; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Show the current amount of memory allocated for the given memtype |
| 96 | */ |
| 97 | |
| 98 | static ssize_t |
| 99 | mem_entry_show(struct kgsl_process_private *priv, int type, char *buf) |
| 100 | { |
| 101 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->stats[type].cur); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Show the maximum memory allocated for the given memtype through the life of |
| 106 | * the process |
| 107 | */ |
| 108 | |
| 109 | static ssize_t |
| 110 | mem_entry_max_show(struct kgsl_process_private *priv, int type, char *buf) |
| 111 | { |
| 112 | return snprintf(buf, PAGE_SIZE, "%d\n", priv->stats[type].max); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | static void mem_entry_sysfs_release(struct kobject *kobj) |
| 117 | { |
| 118 | } |
| 119 | |
| 120 | static ssize_t mem_entry_sysfs_show(struct kobject *kobj, |
| 121 | struct attribute *attr, char *buf) |
| 122 | { |
| 123 | struct kgsl_mem_entry_attribute *pattr = to_mem_entry_attr(attr); |
| 124 | struct kgsl_process_private *priv; |
| 125 | ssize_t ret; |
| 126 | |
| 127 | mutex_lock(&kgsl_driver.process_mutex); |
| 128 | priv = _get_priv_from_kobj(kobj); |
| 129 | |
| 130 | if (priv && pattr->show) |
| 131 | ret = pattr->show(priv, pattr->memtype, buf); |
| 132 | else |
| 133 | ret = -EIO; |
| 134 | |
| 135 | mutex_unlock(&kgsl_driver.process_mutex); |
| 136 | return ret; |
| 137 | } |
| 138 | |
| 139 | static const struct sysfs_ops mem_entry_sysfs_ops = { |
| 140 | .show = mem_entry_sysfs_show, |
| 141 | }; |
| 142 | |
| 143 | static struct kobj_type ktype_mem_entry = { |
| 144 | .sysfs_ops = &mem_entry_sysfs_ops, |
| 145 | .default_attrs = NULL, |
| 146 | .release = mem_entry_sysfs_release |
| 147 | }; |
| 148 | |
| 149 | static struct mem_entry_stats mem_stats[] = { |
| 150 | MEM_ENTRY_STAT(KGSL_MEM_ENTRY_KERNEL, kernel), |
| 151 | MEM_ENTRY_STAT(KGSL_MEM_ENTRY_PMEM, pmem), |
| 152 | #ifdef CONFIG_ASHMEM |
| 153 | MEM_ENTRY_STAT(KGSL_MEM_ENTRY_ASHMEM, ashmem), |
| 154 | #endif |
| 155 | MEM_ENTRY_STAT(KGSL_MEM_ENTRY_USER, user), |
| 156 | #ifdef CONFIG_ION |
| 157 | MEM_ENTRY_STAT(KGSL_MEM_ENTRY_ION, ion), |
| 158 | #endif |
| 159 | }; |
| 160 | |
| 161 | void |
| 162 | kgsl_process_uninit_sysfs(struct kgsl_process_private *private) |
| 163 | { |
| 164 | int i; |
| 165 | |
| 166 | for (i = 0; i < ARRAY_SIZE(mem_stats); i++) { |
| 167 | sysfs_remove_file(&private->kobj, &mem_stats[i].attr.attr); |
| 168 | sysfs_remove_file(&private->kobj, |
| 169 | &mem_stats[i].max_attr.attr); |
| 170 | } |
| 171 | |
| 172 | kobject_put(&private->kobj); |
| 173 | } |
| 174 | |
| 175 | /** |
| 176 | * kgsl_process_init_sysfs() - Initialize and create sysfs files for a process |
| 177 | * |
| 178 | * @device: Pointer to kgsl device struct |
| 179 | * @private: Pointer to the structure for the process |
| 180 | * |
| 181 | * @returns: 0 on success, error code otherwise |
| 182 | * |
| 183 | * kgsl_process_init_sysfs() is called at the time of creating the |
| 184 | * process struct when a process opens the kgsl device for the first time. |
| 185 | * This function creates the sysfs files for the process. |
| 186 | */ |
| 187 | int |
| 188 | kgsl_process_init_sysfs(struct kgsl_device *device, |
| 189 | struct kgsl_process_private *private) |
| 190 | { |
| 191 | unsigned char name[16]; |
| 192 | int i, ret = 0; |
| 193 | |
| 194 | snprintf(name, sizeof(name), "%d", private->pid); |
| 195 | |
| 196 | ret = kobject_init_and_add(&private->kobj, &ktype_mem_entry, |
| 197 | kgsl_driver.prockobj, name); |
| 198 | |
| 199 | if (ret) |
| 200 | return ret; |
| 201 | |
| 202 | for (i = 0; i < ARRAY_SIZE(mem_stats); i++) { |
| 203 | /* We need to check the value of sysfs_create_file, but we |
| 204 | * don't really care if it passed or not */ |
| 205 | |
| 206 | ret = sysfs_create_file(&private->kobj, |
| 207 | &mem_stats[i].attr.attr); |
| 208 | ret = sysfs_create_file(&private->kobj, |
| 209 | &mem_stats[i].max_attr.attr); |
| 210 | } |
| 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | static int kgsl_drv_memstat_show(struct device *dev, |
| 215 | struct device_attribute *attr, |
| 216 | char *buf) |
| 217 | { |
| 218 | unsigned int val = 0; |
| 219 | |
| 220 | if (!strncmp(attr->attr.name, "vmalloc", 7)) |
| 221 | val = kgsl_driver.stats.vmalloc; |
| 222 | else if (!strncmp(attr->attr.name, "vmalloc_max", 11)) |
| 223 | val = kgsl_driver.stats.vmalloc_max; |
| 224 | else if (!strncmp(attr->attr.name, "page_alloc", 10)) |
| 225 | val = kgsl_driver.stats.page_alloc; |
| 226 | else if (!strncmp(attr->attr.name, "page_alloc_max", 14)) |
| 227 | val = kgsl_driver.stats.page_alloc_max; |
| 228 | else if (!strncmp(attr->attr.name, "coherent", 8)) |
| 229 | val = kgsl_driver.stats.coherent; |
| 230 | else if (!strncmp(attr->attr.name, "coherent_max", 12)) |
| 231 | val = kgsl_driver.stats.coherent_max; |
| 232 | else if (!strncmp(attr->attr.name, "mapped", 6)) |
| 233 | val = kgsl_driver.stats.mapped; |
| 234 | else if (!strncmp(attr->attr.name, "mapped_max", 10)) |
| 235 | val = kgsl_driver.stats.mapped_max; |
| 236 | |
| 237 | return snprintf(buf, PAGE_SIZE, "%u\n", val); |
| 238 | } |
| 239 | |
| 240 | static int kgsl_drv_histogram_show(struct device *dev, |
| 241 | struct device_attribute *attr, |
| 242 | char *buf) |
| 243 | { |
| 244 | int len = 0; |
| 245 | int i; |
| 246 | |
| 247 | for (i = 0; i < 16; i++) |
| 248 | len += snprintf(buf + len, PAGE_SIZE - len, "%d ", |
| 249 | kgsl_driver.stats.histogram[i]); |
| 250 | |
| 251 | len += snprintf(buf + len, PAGE_SIZE - len, "\n"); |
| 252 | return len; |
| 253 | } |
| 254 | |
| 255 | static int kgsl_drv_full_cache_threshold_store(struct device *dev, |
| 256 | struct device_attribute *attr, |
| 257 | const char *buf, size_t count) |
| 258 | { |
| 259 | int ret; |
| 260 | unsigned int thresh; |
| 261 | ret = sscanf(buf, "%d", &thresh); |
| 262 | if (ret != 1) |
| 263 | return count; |
| 264 | |
| 265 | kgsl_driver.full_cache_threshold = thresh; |
| 266 | |
| 267 | return count; |
| 268 | } |
| 269 | |
| 270 | static int kgsl_drv_full_cache_threshold_show(struct device *dev, |
| 271 | struct device_attribute *attr, |
| 272 | char *buf) |
| 273 | { |
| 274 | return snprintf(buf, PAGE_SIZE, "%d\n", |
| 275 | kgsl_driver.full_cache_threshold); |
| 276 | } |
| 277 | |
| 278 | DEVICE_ATTR(vmalloc, 0444, kgsl_drv_memstat_show, NULL); |
| 279 | DEVICE_ATTR(vmalloc_max, 0444, kgsl_drv_memstat_show, NULL); |
| 280 | DEVICE_ATTR(page_alloc, 0444, kgsl_drv_memstat_show, NULL); |
| 281 | DEVICE_ATTR(page_alloc_max, 0444, kgsl_drv_memstat_show, NULL); |
| 282 | DEVICE_ATTR(coherent, 0444, kgsl_drv_memstat_show, NULL); |
| 283 | DEVICE_ATTR(coherent_max, 0444, kgsl_drv_memstat_show, NULL); |
| 284 | DEVICE_ATTR(mapped, 0444, kgsl_drv_memstat_show, NULL); |
| 285 | DEVICE_ATTR(mapped_max, 0444, kgsl_drv_memstat_show, NULL); |
| 286 | DEVICE_ATTR(histogram, 0444, kgsl_drv_histogram_show, NULL); |
| 287 | DEVICE_ATTR(full_cache_threshold, 0644, |
| 288 | kgsl_drv_full_cache_threshold_show, |
| 289 | kgsl_drv_full_cache_threshold_store); |
| 290 | |
| 291 | static const struct device_attribute *drv_attr_list[] = { |
| 292 | &dev_attr_vmalloc, |
| 293 | &dev_attr_vmalloc_max, |
| 294 | &dev_attr_page_alloc, |
| 295 | &dev_attr_page_alloc_max, |
| 296 | &dev_attr_coherent, |
| 297 | &dev_attr_coherent_max, |
| 298 | &dev_attr_mapped, |
| 299 | &dev_attr_mapped_max, |
| 300 | &dev_attr_histogram, |
| 301 | &dev_attr_full_cache_threshold, |
| 302 | NULL |
| 303 | }; |
| 304 | |
| 305 | void |
| 306 | kgsl_sharedmem_uninit_sysfs(void) |
| 307 | { |
| 308 | kgsl_remove_device_sysfs_files(&kgsl_driver.virtdev, drv_attr_list); |
| 309 | } |
| 310 | |
| 311 | int |
| 312 | kgsl_sharedmem_init_sysfs(void) |
| 313 | { |
| 314 | return kgsl_create_device_sysfs_files(&kgsl_driver.virtdev, |
| 315 | drv_attr_list); |
| 316 | } |
| 317 | |
| 318 | #ifdef CONFIG_OUTER_CACHE |
| 319 | static void _outer_cache_range_op(int op, unsigned long addr, size_t size) |
| 320 | { |
| 321 | switch (op) { |
| 322 | case KGSL_CACHE_OP_FLUSH: |
| 323 | outer_flush_range(addr, addr + size); |
| 324 | break; |
| 325 | case KGSL_CACHE_OP_CLEAN: |
| 326 | outer_clean_range(addr, addr + size); |
| 327 | break; |
| 328 | case KGSL_CACHE_OP_INV: |
| 329 | outer_inv_range(addr, addr + size); |
| 330 | break; |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | static void outer_cache_range_op_sg(struct scatterlist *sg, int sglen, int op) |
| 335 | { |
| 336 | struct scatterlist *s; |
| 337 | int i; |
| 338 | |
| 339 | for_each_sg(sg, s, sglen, i) { |
| 340 | unsigned int paddr = kgsl_get_sg_pa(s); |
| 341 | _outer_cache_range_op(op, paddr, s->length); |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | #else |
| 346 | static void outer_cache_range_op_sg(struct scatterlist *sg, int sglen, int op) |
| 347 | { |
| 348 | } |
| 349 | #endif |
| 350 | |
| 351 | static int kgsl_page_alloc_vmfault(struct kgsl_memdesc *memdesc, |
| 352 | struct vm_area_struct *vma, |
| 353 | struct vm_fault *vmf) |
| 354 | { |
| 355 | int i, pgoff; |
| 356 | struct scatterlist *s = memdesc->sg; |
| 357 | unsigned int offset; |
| 358 | |
| 359 | offset = ((unsigned long) vmf->virtual_address - vma->vm_start); |
| 360 | |
| 361 | if (offset >= memdesc->size) |
| 362 | return VM_FAULT_SIGBUS; |
| 363 | |
| 364 | pgoff = offset >> PAGE_SHIFT; |
| 365 | |
| 366 | /* |
| 367 | * The sglist might be comprised of mixed blocks of memory depending |
| 368 | * on how many 64K pages were allocated. This means we have to do math |
| 369 | * to find the actual 4K page to map in user space |
| 370 | */ |
| 371 | |
| 372 | for (i = 0; i < memdesc->sglen; i++) { |
| 373 | int npages = s->length >> PAGE_SHIFT; |
| 374 | |
| 375 | if (pgoff < npages) { |
| 376 | struct page *page = sg_page(s); |
| 377 | |
| 378 | page = nth_page(page, pgoff); |
| 379 | |
| 380 | get_page(page); |
| 381 | vmf->page = page; |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | pgoff -= npages; |
| 387 | s = sg_next(s); |
| 388 | } |
| 389 | |
| 390 | return VM_FAULT_SIGBUS; |
| 391 | } |
| 392 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 393 | /* |
| 394 | * kgsl_page_alloc_unmap_kernel() - Unmap the memory in memdesc |
| 395 | * |
| 396 | * @memdesc: The memory descriptor which contains information about the memory |
| 397 | * |
| 398 | * Unmaps the memory mapped into kernel address space |
| 399 | */ |
| 400 | static void kgsl_page_alloc_unmap_kernel(struct kgsl_memdesc *memdesc) |
| 401 | { |
| 402 | mutex_lock(&kernel_map_global_lock); |
| 403 | if (!memdesc->hostptr) { |
| 404 | BUG_ON(memdesc->hostptr_count); |
| 405 | goto done; |
| 406 | } |
| 407 | memdesc->hostptr_count--; |
| 408 | if (memdesc->hostptr_count) |
| 409 | goto done; |
| 410 | vunmap(memdesc->hostptr); |
| 411 | kgsl_driver.stats.vmalloc -= memdesc->size; |
| 412 | memdesc->hostptr = NULL; |
| 413 | done: |
| 414 | mutex_unlock(&kernel_map_global_lock); |
| 415 | } |
| 416 | |
| 417 | static void kgsl_page_alloc_free(struct kgsl_memdesc *memdesc) |
| 418 | { |
| 419 | int i = 0; |
| 420 | struct scatterlist *sg; |
| 421 | int sglen = memdesc->sglen; |
| 422 | |
| 423 | kgsl_driver.stats.page_alloc -= memdesc->size; |
| 424 | |
| 425 | kgsl_page_alloc_unmap_kernel(memdesc); |
| 426 | /* we certainly do not expect the hostptr to still be mapped */ |
| 427 | BUG_ON(memdesc->hostptr); |
| 428 | |
| 429 | if (memdesc->sg) |
| 430 | for_each_sg(memdesc->sg, sg, sglen, i) |
| 431 | __free_pages(sg_page(sg), get_order(sg->length)); |
| 432 | } |
| 433 | |
| 434 | /* |
| 435 | * kgsl_page_alloc_map_kernel - Map the memory in memdesc to kernel address |
| 436 | * space |
| 437 | * |
| 438 | * @memdesc - The memory descriptor which contains information about the memory |
| 439 | * |
| 440 | * Return: 0 on success else error code |
| 441 | */ |
| 442 | static int kgsl_page_alloc_map_kernel(struct kgsl_memdesc *memdesc) |
| 443 | { |
| 444 | int ret = 0; |
| 445 | |
| 446 | mutex_lock(&kernel_map_global_lock); |
| 447 | if (!memdesc->hostptr) { |
| 448 | pgprot_t page_prot = pgprot_writecombine(PAGE_KERNEL); |
| 449 | struct page **pages = NULL; |
| 450 | struct scatterlist *sg; |
| 451 | int npages = PAGE_ALIGN(memdesc->size) >> PAGE_SHIFT; |
| 452 | int sglen = memdesc->sglen; |
| 453 | int i, count = 0; |
| 454 | |
| 455 | /* create a list of pages to call vmap */ |
| 456 | pages = vmalloc(npages * sizeof(struct page *)); |
| 457 | if (!pages) { |
| 458 | KGSL_CORE_ERR("vmalloc(%d) failed\n", |
| 459 | npages * sizeof(struct page *)); |
| 460 | ret = -ENOMEM; |
| 461 | goto done; |
| 462 | } |
| 463 | |
| 464 | for_each_sg(memdesc->sg, sg, sglen, i) { |
| 465 | struct page *page = sg_page(sg); |
| 466 | int j; |
| 467 | |
| 468 | for (j = 0; j < sg->length >> PAGE_SHIFT; j++) |
| 469 | pages[count++] = page++; |
| 470 | } |
| 471 | |
| 472 | |
| 473 | memdesc->hostptr = vmap(pages, count, |
| 474 | VM_IOREMAP, page_prot); |
| 475 | if (memdesc->hostptr) |
| 476 | KGSL_STATS_ADD(memdesc->size, kgsl_driver.stats.vmalloc, |
| 477 | kgsl_driver.stats.vmalloc_max); |
| 478 | else |
| 479 | ret = -ENOMEM; |
| 480 | vfree(pages); |
| 481 | } |
| 482 | if (memdesc->hostptr) |
| 483 | memdesc->hostptr_count++; |
| 484 | done: |
| 485 | mutex_unlock(&kernel_map_global_lock); |
| 486 | |
| 487 | return ret; |
| 488 | } |
| 489 | |
| 490 | static int kgsl_contiguous_vmfault(struct kgsl_memdesc *memdesc, |
| 491 | struct vm_area_struct *vma, |
| 492 | struct vm_fault *vmf) |
| 493 | { |
| 494 | unsigned long offset, pfn; |
| 495 | int ret; |
| 496 | |
| 497 | offset = ((unsigned long) vmf->virtual_address - vma->vm_start) >> |
| 498 | PAGE_SHIFT; |
| 499 | |
| 500 | pfn = (memdesc->physaddr >> PAGE_SHIFT) + offset; |
| 501 | ret = vm_insert_pfn(vma, (unsigned long) vmf->virtual_address, pfn); |
| 502 | |
| 503 | if (ret == -ENOMEM || ret == -EAGAIN) |
| 504 | return VM_FAULT_OOM; |
| 505 | else if (ret == -EFAULT) |
| 506 | return VM_FAULT_SIGBUS; |
| 507 | |
| 508 | return VM_FAULT_NOPAGE; |
| 509 | } |
| 510 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 511 | static void kgsl_coherent_free(struct kgsl_memdesc *memdesc) |
| 512 | { |
| 513 | kgsl_driver.stats.coherent -= memdesc->size; |
| 514 | dma_free_coherent(NULL, memdesc->size, |
| 515 | memdesc->hostptr, memdesc->physaddr); |
| 516 | } |
| 517 | |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 518 | static void kgsl_cma_coherent_free(struct kgsl_memdesc *memdesc) |
| 519 | { |
| 520 | if (memdesc->hostptr) { |
| 521 | kgsl_driver.stats.coherent -= memdesc->size; |
| 522 | dma_free_coherent(memdesc->dev, memdesc->size, |
| 523 | memdesc->hostptr, memdesc->physaddr); |
| 524 | } |
| 525 | } |
| 526 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 527 | /* Global - also used by kgsl_drm.c */ |
| 528 | struct kgsl_memdesc_ops kgsl_page_alloc_ops = { |
| 529 | .free = kgsl_page_alloc_free, |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 530 | .vmflags = VM_NODUMP | VM_DONTEXPAND | VM_DONTCOPY, |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 531 | .vmfault = kgsl_page_alloc_vmfault, |
| 532 | .map_kernel = kgsl_page_alloc_map_kernel, |
| 533 | .unmap_kernel = kgsl_page_alloc_unmap_kernel, |
| 534 | }; |
| 535 | EXPORT_SYMBOL(kgsl_page_alloc_ops); |
| 536 | |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 537 | /* CMA ops - used during NOMMU mode */ |
| 538 | static struct kgsl_memdesc_ops kgsl_cma_ops = { |
| 539 | .free = kgsl_cma_coherent_free, |
| 540 | .vmflags = VM_NODUMP | VM_PFNMAP | VM_DONTEXPAND | VM_DONTCOPY, |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 541 | .vmfault = kgsl_contiguous_vmfault, |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 542 | }; |
| 543 | |
| 544 | static struct kgsl_memdesc_ops kgsl_coherent_ops = { |
| 545 | .free = kgsl_coherent_free, |
| 546 | }; |
| 547 | |
| 548 | void kgsl_cache_range_op(struct kgsl_memdesc *memdesc, int op) |
| 549 | { |
| 550 | /* |
| 551 | * If the buffer is mapped in the kernel operate on that address |
| 552 | * otherwise use the user address |
| 553 | */ |
| 554 | |
| 555 | void *addr = (memdesc->hostptr) ? |
| 556 | memdesc->hostptr : (void *) memdesc->useraddr; |
| 557 | |
| 558 | int size = memdesc->size; |
| 559 | |
| 560 | if (addr != NULL) { |
| 561 | switch (op) { |
| 562 | case KGSL_CACHE_OP_FLUSH: |
| 563 | dmac_flush_range(addr, addr + size); |
| 564 | break; |
| 565 | case KGSL_CACHE_OP_CLEAN: |
| 566 | dmac_clean_range(addr, addr + size); |
| 567 | break; |
| 568 | case KGSL_CACHE_OP_INV: |
| 569 | dmac_inv_range(addr, addr + size); |
| 570 | break; |
| 571 | } |
| 572 | } |
| 573 | outer_cache_range_op_sg(memdesc->sg, memdesc->sglen, op); |
| 574 | } |
| 575 | EXPORT_SYMBOL(kgsl_cache_range_op); |
| 576 | |
| 577 | static int |
| 578 | _kgsl_sharedmem_page_alloc(struct kgsl_memdesc *memdesc, |
| 579 | struct kgsl_pagetable *pagetable, |
| 580 | size_t size) |
| 581 | { |
| 582 | int pcount = 0, order, ret = 0; |
| 583 | int j, len, page_size, sglen_alloc, sglen = 0; |
| 584 | struct page **pages = NULL; |
| 585 | pgprot_t page_prot = pgprot_writecombine(PAGE_KERNEL); |
| 586 | void *ptr; |
| 587 | unsigned int align; |
| 588 | int step = ((VMALLOC_END - VMALLOC_START)/8) >> PAGE_SHIFT; |
| 589 | |
| 590 | align = (memdesc->flags & KGSL_MEMALIGN_MASK) >> KGSL_MEMALIGN_SHIFT; |
| 591 | |
| 592 | page_size = (align >= ilog2(SZ_64K) && size >= SZ_64K) |
| 593 | ? SZ_64K : PAGE_SIZE; |
| 594 | /* update align flags for what we actually use */ |
| 595 | if (page_size != PAGE_SIZE) |
| 596 | kgsl_memdesc_set_align(memdesc, ilog2(page_size)); |
| 597 | |
| 598 | /* |
| 599 | * There needs to be enough room in the sg structure to be able to |
| 600 | * service the allocation entirely with PAGE_SIZE sized chunks |
| 601 | */ |
| 602 | |
| 603 | sglen_alloc = PAGE_ALIGN(size) >> PAGE_SHIFT; |
| 604 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 605 | memdesc->pagetable = pagetable; |
| 606 | memdesc->ops = &kgsl_page_alloc_ops; |
| 607 | |
| 608 | memdesc->sglen_alloc = sglen_alloc; |
| 609 | memdesc->sg = kgsl_sg_alloc(memdesc->sglen_alloc); |
| 610 | |
| 611 | if (memdesc->sg == NULL) { |
| 612 | ret = -ENOMEM; |
| 613 | goto done; |
| 614 | } |
| 615 | |
| 616 | /* |
| 617 | * Allocate space to store the list of pages to send to vmap. |
| 618 | * This is an array of pointers so we can t rack 1024 pages per page |
| 619 | * of allocation. Since allocations can be as large as the user dares, |
| 620 | * we have to use the kmalloc/vmalloc trick here to make sure we can |
| 621 | * get the memory we need. |
| 622 | */ |
| 623 | |
| 624 | if ((memdesc->sglen_alloc * sizeof(struct page *)) > PAGE_SIZE) |
| 625 | pages = vmalloc(memdesc->sglen_alloc * sizeof(struct page *)); |
| 626 | else |
| 627 | pages = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 628 | |
| 629 | if (pages == NULL) { |
| 630 | ret = -ENOMEM; |
| 631 | goto done; |
| 632 | } |
| 633 | |
| 634 | kmemleak_not_leak(memdesc->sg); |
| 635 | |
| 636 | sg_init_table(memdesc->sg, memdesc->sglen_alloc); |
| 637 | |
| 638 | len = size; |
| 639 | |
| 640 | while (len > 0) { |
| 641 | struct page *page; |
| 642 | unsigned int gfp_mask = __GFP_HIGHMEM; |
| 643 | int j; |
| 644 | |
| 645 | /* don't waste space at the end of the allocation*/ |
| 646 | if (len < page_size) |
| 647 | page_size = PAGE_SIZE; |
| 648 | |
| 649 | /* |
| 650 | * Don't do some of the more aggressive memory recovery |
| 651 | * techniques for large order allocations |
| 652 | */ |
| 653 | if (page_size != PAGE_SIZE) |
| 654 | gfp_mask |= __GFP_COMP | __GFP_NORETRY | |
| 655 | __GFP_NO_KSWAPD | __GFP_NOWARN; |
| 656 | else |
| 657 | gfp_mask |= GFP_KERNEL; |
| 658 | |
| 659 | page = alloc_pages(gfp_mask, get_order(page_size)); |
| 660 | |
| 661 | if (page == NULL) { |
| 662 | if (page_size != PAGE_SIZE) { |
| 663 | page_size = PAGE_SIZE; |
| 664 | continue; |
| 665 | } |
| 666 | |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 667 | /* |
| 668 | * Update sglen and memdesc size,as requested allocation |
| 669 | * not served fully. So that they can be correctly freed |
| 670 | * in kgsl_sharedmem_free(). |
| 671 | */ |
| 672 | memdesc->sglen = sglen; |
| 673 | memdesc->size = (size - len); |
| 674 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 675 | KGSL_CORE_ERR( |
| 676 | "Out of memory: only allocated %dKB of %dKB requested\n", |
| 677 | (size - len) >> 10, size >> 10); |
| 678 | |
| 679 | ret = -ENOMEM; |
| 680 | goto done; |
| 681 | } |
| 682 | |
| 683 | for (j = 0; j < page_size >> PAGE_SHIFT; j++) |
| 684 | pages[pcount++] = nth_page(page, j); |
| 685 | |
| 686 | sg_set_page(&memdesc->sg[sglen++], page, page_size, 0); |
| 687 | len -= page_size; |
| 688 | } |
| 689 | |
| 690 | memdesc->sglen = sglen; |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 691 | memdesc->size = size; |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 692 | |
| 693 | /* |
| 694 | * All memory that goes to the user has to be zeroed out before it gets |
| 695 | * exposed to userspace. This means that the memory has to be mapped in |
| 696 | * the kernel, zeroed (memset) and then unmapped. This also means that |
| 697 | * the dcache has to be flushed to ensure coherency between the kernel |
| 698 | * and user pages. We used to pass __GFP_ZERO to alloc_page which mapped |
| 699 | * zeroed and unmaped each individual page, and then we had to turn |
| 700 | * around and call flush_dcache_page() on that page to clear the caches. |
| 701 | * This was killing us for performance. Instead, we found it is much |
| 702 | * faster to allocate the pages without GFP_ZERO, map a chunk of the |
| 703 | * range ('step' pages), memset it, flush it and then unmap |
| 704 | * - this results in a factor of 4 improvement for speed for large |
| 705 | * buffers. There is a small decrease in speed for small buffers, |
| 706 | * but only on the order of a few microseconds at best. The 'step' |
| 707 | * size is based on a guess at the amount of free vmalloc space, but |
| 708 | * will scale down if there's not enough free space. |
| 709 | */ |
| 710 | for (j = 0; j < pcount; j += step) { |
| 711 | step = min(step, pcount - j); |
| 712 | |
| 713 | ptr = vmap(&pages[j], step, VM_IOREMAP, page_prot); |
| 714 | |
| 715 | if (ptr != NULL) { |
| 716 | memset(ptr, 0, step * PAGE_SIZE); |
| 717 | dmac_flush_range(ptr, ptr + step * PAGE_SIZE); |
| 718 | vunmap(ptr); |
| 719 | } else { |
| 720 | int k; |
| 721 | /* Very, very, very slow path */ |
| 722 | |
| 723 | for (k = j; k < j + step; k++) { |
| 724 | ptr = kmap_atomic(pages[k]); |
| 725 | memset(ptr, 0, PAGE_SIZE); |
| 726 | dmac_flush_range(ptr, ptr + PAGE_SIZE); |
| 727 | kunmap_atomic(ptr); |
| 728 | } |
| 729 | /* scale down the step size to avoid this path */ |
| 730 | if (step > 1) |
| 731 | step >>= 1; |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | outer_cache_range_op_sg(memdesc->sg, memdesc->sglen, |
| 736 | KGSL_CACHE_OP_FLUSH); |
| 737 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 738 | order = get_order(size); |
| 739 | |
| 740 | if (order < 16) |
| 741 | kgsl_driver.stats.histogram[order]++; |
| 742 | |
| 743 | done: |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 744 | KGSL_STATS_ADD(memdesc->size, kgsl_driver.stats.page_alloc, |
| 745 | kgsl_driver.stats.page_alloc_max); |
| 746 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 747 | if ((memdesc->sglen_alloc * sizeof(struct page *)) > PAGE_SIZE) |
| 748 | vfree(pages); |
| 749 | else |
| 750 | kfree(pages); |
| 751 | |
| 752 | if (ret) |
| 753 | kgsl_sharedmem_free(memdesc); |
| 754 | |
| 755 | return ret; |
| 756 | } |
| 757 | |
| 758 | int |
| 759 | kgsl_sharedmem_page_alloc(struct kgsl_memdesc *memdesc, |
| 760 | struct kgsl_pagetable *pagetable, size_t size) |
| 761 | { |
| 762 | int ret = 0; |
| 763 | BUG_ON(size == 0); |
| 764 | |
| 765 | size = ALIGN(size, PAGE_SIZE * 2); |
| 766 | if (size == 0) |
| 767 | return -EINVAL; |
| 768 | |
| 769 | ret = _kgsl_sharedmem_page_alloc(memdesc, pagetable, size); |
| 770 | if (!ret) |
| 771 | ret = kgsl_page_alloc_map_kernel(memdesc); |
| 772 | if (ret) |
| 773 | kgsl_sharedmem_free(memdesc); |
| 774 | return ret; |
| 775 | } |
| 776 | EXPORT_SYMBOL(kgsl_sharedmem_page_alloc); |
| 777 | |
| 778 | int |
| 779 | kgsl_sharedmem_page_alloc_user(struct kgsl_memdesc *memdesc, |
| 780 | struct kgsl_pagetable *pagetable, |
| 781 | size_t size) |
| 782 | { |
| 783 | size = PAGE_ALIGN(size); |
| 784 | if (size == 0) |
| 785 | return -EINVAL; |
| 786 | |
| 787 | return _kgsl_sharedmem_page_alloc(memdesc, pagetable, size); |
| 788 | } |
| 789 | EXPORT_SYMBOL(kgsl_sharedmem_page_alloc_user); |
| 790 | |
| 791 | int |
| 792 | kgsl_sharedmem_alloc_coherent(struct kgsl_memdesc *memdesc, size_t size) |
| 793 | { |
| 794 | int result = 0; |
| 795 | |
| 796 | size = ALIGN(size, PAGE_SIZE); |
| 797 | if (size == 0) |
| 798 | return -EINVAL; |
| 799 | |
| 800 | memdesc->size = size; |
| 801 | memdesc->ops = &kgsl_coherent_ops; |
| 802 | |
| 803 | memdesc->hostptr = dma_alloc_coherent(NULL, size, &memdesc->physaddr, |
| 804 | GFP_KERNEL); |
| 805 | if (memdesc->hostptr == NULL) { |
| 806 | KGSL_CORE_ERR("dma_alloc_coherent(%d) failed\n", size); |
| 807 | result = -ENOMEM; |
| 808 | goto err; |
| 809 | } |
| 810 | |
| 811 | result = memdesc_sg_phys(memdesc, memdesc->physaddr, size); |
| 812 | if (result) |
| 813 | goto err; |
| 814 | |
| 815 | /* Record statistics */ |
| 816 | |
| 817 | KGSL_STATS_ADD(size, kgsl_driver.stats.coherent, |
| 818 | kgsl_driver.stats.coherent_max); |
| 819 | |
| 820 | err: |
| 821 | if (result) |
| 822 | kgsl_sharedmem_free(memdesc); |
| 823 | |
| 824 | return result; |
| 825 | } |
| 826 | EXPORT_SYMBOL(kgsl_sharedmem_alloc_coherent); |
| 827 | |
| 828 | void kgsl_sharedmem_free(struct kgsl_memdesc *memdesc) |
| 829 | { |
| 830 | if (memdesc == NULL || memdesc->size == 0) |
| 831 | return; |
| 832 | |
| 833 | if (memdesc->gpuaddr) { |
| 834 | kgsl_mmu_unmap(memdesc->pagetable, memdesc); |
| 835 | kgsl_mmu_put_gpuaddr(memdesc->pagetable, memdesc); |
| 836 | } |
| 837 | |
| 838 | if (memdesc->ops && memdesc->ops->free) |
| 839 | memdesc->ops->free(memdesc); |
| 840 | |
| 841 | kgsl_sg_free(memdesc->sg, memdesc->sglen_alloc); |
| 842 | |
| 843 | memset(memdesc, 0, sizeof(*memdesc)); |
| 844 | } |
| 845 | EXPORT_SYMBOL(kgsl_sharedmem_free); |
| 846 | |
Steve Kondik | f7652b3 | 2013-11-26 15:20:51 -0800 | [diff] [blame] | 847 | int |
| 848 | kgsl_sharedmem_readl(const struct kgsl_memdesc *memdesc, |
| 849 | uint32_t *dst, |
| 850 | unsigned int offsetbytes) |
| 851 | { |
| 852 | uint32_t *src; |
| 853 | BUG_ON(memdesc == NULL || memdesc->hostptr == NULL || dst == NULL); |
| 854 | WARN_ON(offsetbytes % sizeof(uint32_t) != 0); |
| 855 | if (offsetbytes % sizeof(uint32_t) != 0) |
| 856 | return -EINVAL; |
| 857 | |
| 858 | WARN_ON(offsetbytes + sizeof(uint32_t) > memdesc->size); |
| 859 | if (offsetbytes + sizeof(uint32_t) > memdesc->size) |
| 860 | return -ERANGE; |
| 861 | src = (uint32_t *)(memdesc->hostptr + offsetbytes); |
| 862 | *dst = *src; |
| 863 | return 0; |
| 864 | } |
| 865 | EXPORT_SYMBOL(kgsl_sharedmem_readl); |
| 866 | |
| 867 | int |
| 868 | kgsl_sharedmem_writel(struct kgsl_device *device, |
| 869 | const struct kgsl_memdesc *memdesc, |
| 870 | unsigned int offsetbytes, |
| 871 | uint32_t src) |
| 872 | { |
| 873 | uint32_t *dst; |
| 874 | BUG_ON(memdesc == NULL || memdesc->hostptr == NULL); |
| 875 | WARN_ON(offsetbytes % sizeof(uint32_t) != 0); |
| 876 | if (offsetbytes % sizeof(uint32_t) != 0) |
| 877 | return -EINVAL; |
| 878 | |
| 879 | WARN_ON(offsetbytes + sizeof(uint32_t) > memdesc->size); |
| 880 | if (offsetbytes + sizeof(uint32_t) > memdesc->size) |
| 881 | return -ERANGE; |
| 882 | kgsl_cffdump_setmem(device, |
| 883 | memdesc->gpuaddr + offsetbytes, |
| 884 | src, sizeof(uint32_t)); |
| 885 | dst = (uint32_t *)(memdesc->hostptr + offsetbytes); |
| 886 | *dst = src; |
| 887 | return 0; |
| 888 | } |
| 889 | EXPORT_SYMBOL(kgsl_sharedmem_writel); |
| 890 | |
| 891 | int |
| 892 | kgsl_sharedmem_set(struct kgsl_device *device, |
| 893 | const struct kgsl_memdesc *memdesc, unsigned int offsetbytes, |
| 894 | unsigned int value, unsigned int sizebytes) |
| 895 | { |
| 896 | BUG_ON(memdesc == NULL || memdesc->hostptr == NULL); |
| 897 | BUG_ON(offsetbytes + sizebytes > memdesc->size); |
| 898 | |
| 899 | kgsl_cffdump_setmem(device, |
| 900 | memdesc->gpuaddr + offsetbytes, value, |
| 901 | sizebytes); |
| 902 | memset(memdesc->hostptr + offsetbytes, value, sizebytes); |
| 903 | return 0; |
| 904 | } |
| 905 | EXPORT_SYMBOL(kgsl_sharedmem_set); |
| 906 | |
| 907 | /* |
| 908 | * kgsl_sharedmem_map_vma - Map a user vma to physical memory |
| 909 | * |
| 910 | * @vma - The user vma to map |
| 911 | * @memdesc - The memory descriptor which contains information about the |
| 912 | * physical memory |
| 913 | * |
| 914 | * Return: 0 on success else error code |
| 915 | */ |
| 916 | int |
| 917 | kgsl_sharedmem_map_vma(struct vm_area_struct *vma, |
| 918 | const struct kgsl_memdesc *memdesc) |
| 919 | { |
| 920 | unsigned long addr = vma->vm_start; |
| 921 | unsigned long size = vma->vm_end - vma->vm_start; |
| 922 | int ret, i = 0; |
| 923 | |
| 924 | if (!memdesc->sg || (size != memdesc->size) || |
| 925 | (memdesc->sglen != (size / PAGE_SIZE))) |
| 926 | return -EINVAL; |
| 927 | |
| 928 | for (; addr < vma->vm_end; addr += PAGE_SIZE, i++) { |
| 929 | ret = vm_insert_page(vma, addr, sg_page(&memdesc->sg[i])); |
| 930 | if (ret) |
| 931 | return ret; |
| 932 | } |
| 933 | return 0; |
| 934 | } |
| 935 | EXPORT_SYMBOL(kgsl_sharedmem_map_vma); |
| 936 | |
| 937 | static const char * const memtype_str[] = { |
| 938 | [KGSL_MEMTYPE_OBJECTANY] = "any(0)", |
| 939 | [KGSL_MEMTYPE_FRAMEBUFFER] = "framebuffer", |
| 940 | [KGSL_MEMTYPE_RENDERBUFFER] = "renderbuffer", |
| 941 | [KGSL_MEMTYPE_ARRAYBUFFER] = "arraybuffer", |
| 942 | [KGSL_MEMTYPE_ELEMENTARRAYBUFFER] = "elementarraybuffer", |
| 943 | [KGSL_MEMTYPE_VERTEXARRAYBUFFER] = "vertexarraybuffer", |
| 944 | [KGSL_MEMTYPE_TEXTURE] = "texture", |
| 945 | [KGSL_MEMTYPE_SURFACE] = "surface", |
| 946 | [KGSL_MEMTYPE_EGL_SURFACE] = "egl_surface", |
| 947 | [KGSL_MEMTYPE_GL] = "gl", |
| 948 | [KGSL_MEMTYPE_CL] = "cl", |
| 949 | [KGSL_MEMTYPE_CL_BUFFER_MAP] = "cl_buffer_map", |
| 950 | [KGSL_MEMTYPE_CL_BUFFER_NOMAP] = "cl_buffer_nomap", |
| 951 | [KGSL_MEMTYPE_CL_IMAGE_MAP] = "cl_image_map", |
| 952 | [KGSL_MEMTYPE_CL_IMAGE_NOMAP] = "cl_image_nomap", |
| 953 | [KGSL_MEMTYPE_CL_KERNEL_STACK] = "cl_kernel_stack", |
| 954 | [KGSL_MEMTYPE_COMMAND] = "command", |
| 955 | [KGSL_MEMTYPE_2D] = "2d", |
| 956 | [KGSL_MEMTYPE_EGL_IMAGE] = "egl_image", |
| 957 | [KGSL_MEMTYPE_EGL_SHADOW] = "egl_shadow", |
| 958 | [KGSL_MEMTYPE_MULTISAMPLE] = "egl_multisample", |
| 959 | /* KGSL_MEMTYPE_KERNEL handled below, to avoid huge array */ |
| 960 | }; |
| 961 | |
| 962 | void kgsl_get_memory_usage(char *name, size_t name_size, unsigned int memflags) |
| 963 | { |
| 964 | unsigned char type; |
| 965 | |
| 966 | type = (memflags & KGSL_MEMTYPE_MASK) >> KGSL_MEMTYPE_SHIFT; |
| 967 | if (type == KGSL_MEMTYPE_KERNEL) |
| 968 | strlcpy(name, "kernel", name_size); |
| 969 | else if (type < ARRAY_SIZE(memtype_str) && memtype_str[type] != NULL) |
| 970 | strlcpy(name, memtype_str[type], name_size); |
| 971 | else |
| 972 | snprintf(name, name_size, "unknown(%3d)", type); |
| 973 | } |
| 974 | EXPORT_SYMBOL(kgsl_get_memory_usage); |
Ethan Chen | 7b18590 | 2014-11-16 16:48:31 -0800 | [diff] [blame^] | 975 | |
| 976 | int kgsl_cma_alloc_coherent(struct kgsl_device *device, |
| 977 | struct kgsl_memdesc *memdesc, |
| 978 | struct kgsl_pagetable *pagetable, size_t size) |
| 979 | { |
| 980 | int result = 0; |
| 981 | |
| 982 | if (size == 0) |
| 983 | return -EINVAL; |
| 984 | |
| 985 | memdesc->size = size; |
| 986 | memdesc->pagetable = pagetable; |
| 987 | memdesc->ops = &kgsl_cma_ops; |
| 988 | memdesc->dev = device->dev->parent; |
| 989 | |
| 990 | memdesc->hostptr = dma_alloc_coherent(memdesc->dev, size, |
| 991 | &memdesc->physaddr, GFP_KERNEL); |
| 992 | |
| 993 | if (memdesc->hostptr == NULL) { |
| 994 | result = -ENOMEM; |
| 995 | goto err; |
| 996 | } |
| 997 | |
| 998 | result = memdesc_sg_phys(memdesc, memdesc->physaddr, size); |
| 999 | if (result) |
| 1000 | goto err; |
| 1001 | |
| 1002 | /* Record statistics */ |
| 1003 | |
| 1004 | KGSL_STATS_ADD(size, kgsl_driver.stats.coherent, |
| 1005 | kgsl_driver.stats.coherent_max); |
| 1006 | |
| 1007 | err: |
| 1008 | if (result) |
| 1009 | kgsl_sharedmem_free(memdesc); |
| 1010 | |
| 1011 | return result; |
| 1012 | } |
| 1013 | EXPORT_SYMBOL(kgsl_cma_alloc_coherent); |