dma-debug.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*
  2. * Copyright (C) 2008 Advanced Micro Devices, Inc.
  3. *
  4. * Author: Joerg Roedel <joerg.roedel@amd.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License version 2 as published
  8. * by the Free Software Foundation.
  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. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __DMA_DEBUG_H
  20. #define __DMA_DEBUG_H
  21. #include <linux/types.h>
  22. struct device;
  23. struct scatterlist;
  24. struct bus_type;
  25. #ifdef CONFIG_DMA_API_DEBUG
  26. extern void dma_debug_add_bus(struct bus_type *bus);
  27. extern int dma_debug_resize_entries(u32 num_entries);
  28. extern void debug_dma_map_single(struct device *dev, const void *addr,
  29. unsigned long len);
  30. extern void debug_dma_map_page(struct device *dev, struct page *page,
  31. size_t offset, size_t size,
  32. int direction, dma_addr_t dma_addr,
  33. bool map_single);
  34. extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
  35. extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
  36. size_t size, int direction, bool map_single);
  37. extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
  38. int nents, int mapped_ents, int direction);
  39. extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
  40. int nelems, int dir);
  41. extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
  42. dma_addr_t dma_addr, void *virt);
  43. extern void debug_dma_free_coherent(struct device *dev, size_t size,
  44. void *virt, dma_addr_t addr);
  45. extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
  46. size_t size, int direction,
  47. dma_addr_t dma_addr);
  48. extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
  49. size_t size, int direction);
  50. extern void debug_dma_sync_single_for_cpu(struct device *dev,
  51. dma_addr_t dma_handle, size_t size,
  52. int direction);
  53. extern void debug_dma_sync_single_for_device(struct device *dev,
  54. dma_addr_t dma_handle,
  55. size_t size, int direction);
  56. extern void debug_dma_sync_single_range_for_cpu(struct device *dev,
  57. dma_addr_t dma_handle,
  58. unsigned long offset,
  59. size_t size,
  60. int direction);
  61. extern void debug_dma_sync_single_range_for_device(struct device *dev,
  62. dma_addr_t dma_handle,
  63. unsigned long offset,
  64. size_t size, int direction);
  65. extern void debug_dma_sync_sg_for_cpu(struct device *dev,
  66. struct scatterlist *sg,
  67. int nelems, int direction);
  68. extern void debug_dma_sync_sg_for_device(struct device *dev,
  69. struct scatterlist *sg,
  70. int nelems, int direction);
  71. extern void debug_dma_dump_mappings(struct device *dev);
  72. extern void debug_dma_assert_idle(struct page *page);
  73. #else /* CONFIG_DMA_API_DEBUG */
  74. static inline void dma_debug_add_bus(struct bus_type *bus)
  75. {
  76. }
  77. static inline int dma_debug_resize_entries(u32 num_entries)
  78. {
  79. return 0;
  80. }
  81. static inline void debug_dma_map_single(struct device *dev, const void *addr,
  82. unsigned long len)
  83. {
  84. }
  85. static inline void debug_dma_map_page(struct device *dev, struct page *page,
  86. size_t offset, size_t size,
  87. int direction, dma_addr_t dma_addr,
  88. bool map_single)
  89. {
  90. }
  91. static inline void debug_dma_mapping_error(struct device *dev,
  92. dma_addr_t dma_addr)
  93. {
  94. }
  95. static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
  96. size_t size, int direction,
  97. bool map_single)
  98. {
  99. }
  100. static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
  101. int nents, int mapped_ents, int direction)
  102. {
  103. }
  104. static inline void debug_dma_unmap_sg(struct device *dev,
  105. struct scatterlist *sglist,
  106. int nelems, int dir)
  107. {
  108. }
  109. static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
  110. dma_addr_t dma_addr, void *virt)
  111. {
  112. }
  113. static inline void debug_dma_free_coherent(struct device *dev, size_t size,
  114. void *virt, dma_addr_t addr)
  115. {
  116. }
  117. static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
  118. size_t size, int direction,
  119. dma_addr_t dma_addr)
  120. {
  121. }
  122. static inline void debug_dma_unmap_resource(struct device *dev,
  123. dma_addr_t dma_addr, size_t size,
  124. int direction)
  125. {
  126. }
  127. static inline void debug_dma_sync_single_for_cpu(struct device *dev,
  128. dma_addr_t dma_handle,
  129. size_t size, int direction)
  130. {
  131. }
  132. static inline void debug_dma_sync_single_for_device(struct device *dev,
  133. dma_addr_t dma_handle,
  134. size_t size, int direction)
  135. {
  136. }
  137. static inline void debug_dma_sync_single_range_for_cpu(struct device *dev,
  138. dma_addr_t dma_handle,
  139. unsigned long offset,
  140. size_t size,
  141. int direction)
  142. {
  143. }
  144. static inline void debug_dma_sync_single_range_for_device(struct device *dev,
  145. dma_addr_t dma_handle,
  146. unsigned long offset,
  147. size_t size,
  148. int direction)
  149. {
  150. }
  151. static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
  152. struct scatterlist *sg,
  153. int nelems, int direction)
  154. {
  155. }
  156. static inline void debug_dma_sync_sg_for_device(struct device *dev,
  157. struct scatterlist *sg,
  158. int nelems, int direction)
  159. {
  160. }
  161. static inline void debug_dma_dump_mappings(struct device *dev)
  162. {
  163. }
  164. static inline void debug_dma_assert_idle(struct page *page)
  165. {
  166. }
  167. #endif /* CONFIG_DMA_API_DEBUG */
  168. #endif /* __DMA_DEBUG_H */