dma-debug.h 5.5 KB

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