dma-debug.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  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 void dma_debug_init(u32 num_entries);
  28. extern int dma_debug_resize_entries(u32 num_entries);
  29. extern void debug_dma_map_page(struct device *dev, struct page *page,
  30. size_t offset, size_t size,
  31. int direction, dma_addr_t dma_addr,
  32. bool map_single);
  33. extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr);
  34. extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
  35. size_t size, int direction, bool map_single);
  36. extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
  37. int nents, int mapped_ents, int direction);
  38. extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
  39. int nelems, int dir);
  40. extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
  41. dma_addr_t dma_addr, void *virt);
  42. extern void debug_dma_free_coherent(struct device *dev, size_t size,
  43. void *virt, dma_addr_t addr);
  44. extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
  45. size_t size, int direction,
  46. dma_addr_t dma_addr);
  47. extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
  48. size_t size, int direction);
  49. extern void debug_dma_sync_single_for_cpu(struct device *dev,
  50. dma_addr_t dma_handle, size_t size,
  51. int direction);
  52. extern void debug_dma_sync_single_for_device(struct device *dev,
  53. dma_addr_t dma_handle,
  54. size_t size, int direction);
  55. extern void debug_dma_sync_single_range_for_cpu(struct device *dev,
  56. dma_addr_t dma_handle,
  57. unsigned long offset,
  58. size_t size,
  59. int direction);
  60. extern void debug_dma_sync_single_range_for_device(struct device *dev,
  61. dma_addr_t dma_handle,
  62. unsigned long offset,
  63. size_t size, int direction);
  64. extern void debug_dma_sync_sg_for_cpu(struct device *dev,
  65. struct scatterlist *sg,
  66. int nelems, int direction);
  67. extern void debug_dma_sync_sg_for_device(struct device *dev,
  68. struct scatterlist *sg,
  69. int nelems, int direction);
  70. extern void debug_dma_dump_mappings(struct device *dev);
  71. extern void debug_dma_assert_idle(struct page *page);
  72. #else /* CONFIG_DMA_API_DEBUG */
  73. static inline void dma_debug_add_bus(struct bus_type *bus)
  74. {
  75. }
  76. static inline void dma_debug_init(u32 num_entries)
  77. {
  78. }
  79. static inline int dma_debug_resize_entries(u32 num_entries)
  80. {
  81. return 0;
  82. }
  83. static inline void debug_dma_map_page(struct device *dev, struct page *page,
  84. size_t offset, size_t size,
  85. int direction, dma_addr_t dma_addr,
  86. bool map_single)
  87. {
  88. }
  89. static inline void debug_dma_mapping_error(struct device *dev,
  90. dma_addr_t dma_addr)
  91. {
  92. }
  93. static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
  94. size_t size, int direction,
  95. bool map_single)
  96. {
  97. }
  98. static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
  99. int nents, int mapped_ents, int direction)
  100. {
  101. }
  102. static inline void debug_dma_unmap_sg(struct device *dev,
  103. struct scatterlist *sglist,
  104. int nelems, int dir)
  105. {
  106. }
  107. static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
  108. dma_addr_t dma_addr, void *virt)
  109. {
  110. }
  111. static inline void debug_dma_free_coherent(struct device *dev, size_t size,
  112. void *virt, dma_addr_t addr)
  113. {
  114. }
  115. static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
  116. size_t size, int direction,
  117. dma_addr_t dma_addr)
  118. {
  119. }
  120. static inline void debug_dma_unmap_resource(struct device *dev,
  121. dma_addr_t dma_addr, size_t size,
  122. int direction)
  123. {
  124. }
  125. static inline void debug_dma_sync_single_for_cpu(struct device *dev,
  126. dma_addr_t dma_handle,
  127. size_t size, int direction)
  128. {
  129. }
  130. static inline void debug_dma_sync_single_for_device(struct device *dev,
  131. dma_addr_t dma_handle,
  132. size_t size, int direction)
  133. {
  134. }
  135. static inline void debug_dma_sync_single_range_for_cpu(struct device *dev,
  136. dma_addr_t dma_handle,
  137. unsigned long offset,
  138. size_t size,
  139. int direction)
  140. {
  141. }
  142. static inline void debug_dma_sync_single_range_for_device(struct device *dev,
  143. dma_addr_t dma_handle,
  144. unsigned long offset,
  145. size_t size,
  146. int direction)
  147. {
  148. }
  149. static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
  150. struct scatterlist *sg,
  151. int nelems, int direction)
  152. {
  153. }
  154. static inline void debug_dma_sync_sg_for_device(struct device *dev,
  155. struct scatterlist *sg,
  156. int nelems, int direction)
  157. {
  158. }
  159. static inline void debug_dma_dump_mappings(struct device *dev)
  160. {
  161. }
  162. static inline void debug_dma_assert_idle(struct page *page)
  163. {
  164. }
  165. #endif /* CONFIG_DMA_API_DEBUG */
  166. #endif /* __DMA_DEBUG_H */