msm_ion_priv.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * drivers/gpu/ion/ion_priv.h
  3. *
  4. * Copyright (C) 2011 Google, Inc.
  5. * Copyright (c) 2013, The Linux Foundation. All rights reserved.
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef _MSM_ION_PRIV_H
  18. #define _MSM_ION_PRIV_H
  19. #include <linux/kref.h>
  20. #include <linux/mm_types.h>
  21. #include <linux/mutex.h>
  22. #include <linux/types.h>
  23. #include <linux/ion.h>
  24. #include <linux/iommu.h>
  25. #include <linux/seq_file.h>
  26. /**
  27. * struct mem_map_data - represents information about the memory map for a heap
  28. * @node: list node used to store in the list of mem_map_data
  29. * @addr: start address of memory region.
  30. * @addr: end address of memory region.
  31. * @size: size of memory region
  32. * @client_name: name of the client who owns this buffer.
  33. *
  34. */
  35. struct mem_map_data {
  36. struct list_head node;
  37. ion_phys_addr_t addr;
  38. ion_phys_addr_t addr_end;
  39. unsigned long size;
  40. const char *client_name;
  41. };
  42. struct ion_heap *ion_iommu_heap_create(struct ion_platform_heap *);
  43. void ion_iommu_heap_destroy(struct ion_heap *);
  44. struct ion_heap *ion_cp_heap_create(struct ion_platform_heap *);
  45. void ion_cp_heap_destroy(struct ion_heap *);
  46. #ifdef CONFIG_CMA
  47. struct ion_heap *ion_cma_heap_create(struct ion_platform_heap *);
  48. void ion_cma_heap_destroy(struct ion_heap *);
  49. struct ion_heap *ion_secure_cma_heap_create(struct ion_platform_heap *);
  50. void ion_secure_cma_heap_destroy(struct ion_heap *);
  51. int ion_secure_cma_prefetch(struct ion_heap *heap, void *data);
  52. int ion_secure_cma_drain_pool(struct ion_heap *heap, void *unused);
  53. #else
  54. static inline int ion_secure_cma_prefetch(struct ion_heap *heap, void *data)
  55. {
  56. return -ENODEV;
  57. }
  58. static inline int ion_secure_cma_drain_pool(struct ion_heap *heap, void *unused)
  59. {
  60. return -ENODEV;
  61. }
  62. #endif
  63. struct ion_heap *ion_removed_heap_create(struct ion_platform_heap *);
  64. void ion_removed_heap_destroy(struct ion_heap *);
  65. #define ION_CP_ALLOCATE_FAIL -1
  66. #define ION_RESERVED_ALLOCATE_FAIL -1
  67. /**
  68. * ion_do_cache_op - do cache operations.
  69. *
  70. * @client - pointer to ION client.
  71. * @handle - pointer to buffer handle.
  72. * @uaddr - virtual address to operate on.
  73. * @offset - offset from physical address.
  74. * @len - Length of data to do cache operation on.
  75. * @cmd - Cache operation to perform:
  76. * ION_IOC_CLEAN_CACHES
  77. * ION_IOC_INV_CACHES
  78. * ION_IOC_CLEAN_INV_CACHES
  79. *
  80. * Returns 0 on success
  81. */
  82. int ion_do_cache_op(struct ion_client *client, struct ion_handle *handle,
  83. void *uaddr, unsigned long offset, unsigned long len,
  84. unsigned int cmd);
  85. void ion_cp_heap_get_base(struct ion_heap *heap, unsigned long *base,
  86. unsigned long *size);
  87. void ion_mem_map_show(struct ion_heap *heap);
  88. int ion_secure_handle(struct ion_client *client, struct ion_handle *handle,
  89. int version, void *data, int flags);
  90. int ion_unsecure_handle(struct ion_client *client, struct ion_handle *handle);
  91. int ion_heap_allow_secure_allocation(enum ion_heap_type type);
  92. int ion_heap_allow_heap_secure(enum ion_heap_type type);
  93. int ion_heap_allow_handle_secure(enum ion_heap_type type);
  94. /**
  95. * ion_create_chunked_sg_table - helper function to create sg table
  96. * with specified chunk size
  97. * @buffer_base: The starting address used for the sg dma address
  98. * @chunk_size: The size of each entry in the sg table
  99. * @total_size: The total size of the sg table (i.e. the sum of the
  100. * entries). This will be rounded up to the nearest
  101. * multiple of `chunk_size'
  102. */
  103. struct sg_table *ion_create_chunked_sg_table(phys_addr_t buffer_base,
  104. size_t chunk_size, size_t total_size);
  105. #endif /* _MSM_ION_PRIV_H */