dma-debug.h 4.7 KB

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