xref: /linux/kernel/dma/debug.h (revision 762f99f4f3cb41a775b5157dd761217beba65873)
1a1fd09e8SChristoph Hellwig /* SPDX-License-Identifier: GPL-2.0-only */
2a1fd09e8SChristoph Hellwig /*
3a1fd09e8SChristoph Hellwig  * Copyright (C) 2008 Advanced Micro Devices, Inc.
4a1fd09e8SChristoph Hellwig  *
5a1fd09e8SChristoph Hellwig  * Author: Joerg Roedel <joerg.roedel@amd.com>
6a1fd09e8SChristoph Hellwig  */
7a1fd09e8SChristoph Hellwig 
8a1fd09e8SChristoph Hellwig #ifndef _KERNEL_DMA_DEBUG_H
9a1fd09e8SChristoph Hellwig #define _KERNEL_DMA_DEBUG_H
10a1fd09e8SChristoph Hellwig 
11a1fd09e8SChristoph Hellwig #ifdef CONFIG_DMA_API_DEBUG
12a1fd09e8SChristoph Hellwig extern void debug_dma_map_page(struct device *dev, struct page *page,
13a1fd09e8SChristoph Hellwig 			       size_t offset, size_t size,
14*c2bbf9d1SHamza Mahfooz 			       int direction, dma_addr_t dma_addr,
15*c2bbf9d1SHamza Mahfooz 			       unsigned long attrs);
16a1fd09e8SChristoph Hellwig 
17a1fd09e8SChristoph Hellwig extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
18a1fd09e8SChristoph Hellwig 				 size_t size, int direction);
19a1fd09e8SChristoph Hellwig 
20a1fd09e8SChristoph Hellwig extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
21*c2bbf9d1SHamza Mahfooz 			     int nents, int mapped_ents, int direction,
22*c2bbf9d1SHamza Mahfooz 			     unsigned long attrs);
23a1fd09e8SChristoph Hellwig 
24a1fd09e8SChristoph Hellwig extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
25a1fd09e8SChristoph Hellwig 			       int nelems, int dir);
26a1fd09e8SChristoph Hellwig 
27a1fd09e8SChristoph Hellwig extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
28*c2bbf9d1SHamza Mahfooz 				     dma_addr_t dma_addr, void *virt,
29*c2bbf9d1SHamza Mahfooz 				     unsigned long attrs);
30a1fd09e8SChristoph Hellwig 
31a1fd09e8SChristoph Hellwig extern void debug_dma_free_coherent(struct device *dev, size_t size,
32a1fd09e8SChristoph Hellwig 				    void *virt, dma_addr_t addr);
33a1fd09e8SChristoph Hellwig 
34a1fd09e8SChristoph Hellwig extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
35a1fd09e8SChristoph Hellwig 				   size_t size, int direction,
36*c2bbf9d1SHamza Mahfooz 				   dma_addr_t dma_addr,
37*c2bbf9d1SHamza Mahfooz 				   unsigned long attrs);
38a1fd09e8SChristoph Hellwig 
39a1fd09e8SChristoph Hellwig extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
40a1fd09e8SChristoph Hellwig 				     size_t size, int direction);
41a1fd09e8SChristoph Hellwig 
42a1fd09e8SChristoph Hellwig extern void debug_dma_sync_single_for_cpu(struct device *dev,
43a1fd09e8SChristoph Hellwig 					  dma_addr_t dma_handle, size_t size,
44a1fd09e8SChristoph Hellwig 					  int direction);
45a1fd09e8SChristoph Hellwig 
46a1fd09e8SChristoph Hellwig extern void debug_dma_sync_single_for_device(struct device *dev,
47a1fd09e8SChristoph Hellwig 					     dma_addr_t dma_handle,
48a1fd09e8SChristoph Hellwig 					     size_t size, int direction);
49a1fd09e8SChristoph Hellwig 
50a1fd09e8SChristoph Hellwig extern void debug_dma_sync_sg_for_cpu(struct device *dev,
51a1fd09e8SChristoph Hellwig 				      struct scatterlist *sg,
52a1fd09e8SChristoph Hellwig 				      int nelems, int direction);
53a1fd09e8SChristoph Hellwig 
54a1fd09e8SChristoph Hellwig extern void debug_dma_sync_sg_for_device(struct device *dev,
55a1fd09e8SChristoph Hellwig 					 struct scatterlist *sg,
56a1fd09e8SChristoph Hellwig 					 int nelems, int direction);
57a1fd09e8SChristoph Hellwig #else /* CONFIG_DMA_API_DEBUG */
debug_dma_map_page(struct device * dev,struct page * page,size_t offset,size_t size,int direction,dma_addr_t dma_addr,unsigned long attrs)58a1fd09e8SChristoph Hellwig static inline void debug_dma_map_page(struct device *dev, struct page *page,
59a1fd09e8SChristoph Hellwig 				      size_t offset, size_t size,
60*c2bbf9d1SHamza Mahfooz 				      int direction, dma_addr_t dma_addr,
61*c2bbf9d1SHamza Mahfooz 				      unsigned long attrs)
62a1fd09e8SChristoph Hellwig {
63a1fd09e8SChristoph Hellwig }
64a1fd09e8SChristoph Hellwig 
debug_dma_unmap_page(struct device * dev,dma_addr_t addr,size_t size,int direction)65a1fd09e8SChristoph Hellwig static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
66a1fd09e8SChristoph Hellwig 					size_t size, int direction)
67a1fd09e8SChristoph Hellwig {
68a1fd09e8SChristoph Hellwig }
69a1fd09e8SChristoph Hellwig 
debug_dma_map_sg(struct device * dev,struct scatterlist * sg,int nents,int mapped_ents,int direction,unsigned long attrs)70a1fd09e8SChristoph Hellwig static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
71*c2bbf9d1SHamza Mahfooz 				    int nents, int mapped_ents, int direction,
72*c2bbf9d1SHamza Mahfooz 				    unsigned long attrs)
73a1fd09e8SChristoph Hellwig {
74a1fd09e8SChristoph Hellwig }
75a1fd09e8SChristoph Hellwig 
debug_dma_unmap_sg(struct device * dev,struct scatterlist * sglist,int nelems,int dir)76a1fd09e8SChristoph Hellwig static inline void debug_dma_unmap_sg(struct device *dev,
77a1fd09e8SChristoph Hellwig 				      struct scatterlist *sglist,
78a1fd09e8SChristoph Hellwig 				      int nelems, int dir)
79a1fd09e8SChristoph Hellwig {
80a1fd09e8SChristoph Hellwig }
81a1fd09e8SChristoph Hellwig 
debug_dma_alloc_coherent(struct device * dev,size_t size,dma_addr_t dma_addr,void * virt,unsigned long attrs)82a1fd09e8SChristoph Hellwig static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
83*c2bbf9d1SHamza Mahfooz 					    dma_addr_t dma_addr, void *virt,
84*c2bbf9d1SHamza Mahfooz 					    unsigned long attrs)
85a1fd09e8SChristoph Hellwig {
86a1fd09e8SChristoph Hellwig }
87a1fd09e8SChristoph Hellwig 
debug_dma_free_coherent(struct device * dev,size_t size,void * virt,dma_addr_t addr)88a1fd09e8SChristoph Hellwig static inline void debug_dma_free_coherent(struct device *dev, size_t size,
89a1fd09e8SChristoph Hellwig 					   void *virt, dma_addr_t addr)
90a1fd09e8SChristoph Hellwig {
91a1fd09e8SChristoph Hellwig }
92a1fd09e8SChristoph Hellwig 
debug_dma_map_resource(struct device * dev,phys_addr_t addr,size_t size,int direction,dma_addr_t dma_addr,unsigned long attrs)93a1fd09e8SChristoph Hellwig static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
94a1fd09e8SChristoph Hellwig 					  size_t size, int direction,
95*c2bbf9d1SHamza Mahfooz 					  dma_addr_t dma_addr,
96*c2bbf9d1SHamza Mahfooz 					  unsigned long attrs)
97a1fd09e8SChristoph Hellwig {
98a1fd09e8SChristoph Hellwig }
99a1fd09e8SChristoph Hellwig 
debug_dma_unmap_resource(struct device * dev,dma_addr_t dma_addr,size_t size,int direction)100a1fd09e8SChristoph Hellwig static inline void debug_dma_unmap_resource(struct device *dev,
101a1fd09e8SChristoph Hellwig 					    dma_addr_t dma_addr, size_t size,
102a1fd09e8SChristoph Hellwig 					    int direction)
103a1fd09e8SChristoph Hellwig {
104a1fd09e8SChristoph Hellwig }
105a1fd09e8SChristoph Hellwig 
debug_dma_sync_single_for_cpu(struct device * dev,dma_addr_t dma_handle,size_t size,int direction)106a1fd09e8SChristoph Hellwig static inline void debug_dma_sync_single_for_cpu(struct device *dev,
107a1fd09e8SChristoph Hellwig 						 dma_addr_t dma_handle,
108a1fd09e8SChristoph Hellwig 						 size_t size, int direction)
109a1fd09e8SChristoph Hellwig {
110a1fd09e8SChristoph Hellwig }
111a1fd09e8SChristoph Hellwig 
debug_dma_sync_single_for_device(struct device * dev,dma_addr_t dma_handle,size_t size,int direction)112a1fd09e8SChristoph Hellwig static inline void debug_dma_sync_single_for_device(struct device *dev,
113a1fd09e8SChristoph Hellwig 						    dma_addr_t dma_handle,
114a1fd09e8SChristoph Hellwig 						    size_t size, int direction)
115a1fd09e8SChristoph Hellwig {
116a1fd09e8SChristoph Hellwig }
117a1fd09e8SChristoph Hellwig 
debug_dma_sync_sg_for_cpu(struct device * dev,struct scatterlist * sg,int nelems,int direction)118a1fd09e8SChristoph Hellwig static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
119a1fd09e8SChristoph Hellwig 					     struct scatterlist *sg,
120a1fd09e8SChristoph Hellwig 					     int nelems, int direction)
121a1fd09e8SChristoph Hellwig {
122a1fd09e8SChristoph Hellwig }
123a1fd09e8SChristoph Hellwig 
debug_dma_sync_sg_for_device(struct device * dev,struct scatterlist * sg,int nelems,int direction)124a1fd09e8SChristoph Hellwig static inline void debug_dma_sync_sg_for_device(struct device *dev,
125a1fd09e8SChristoph Hellwig 						struct scatterlist *sg,
126a1fd09e8SChristoph Hellwig 						int nelems, int direction)
127a1fd09e8SChristoph Hellwig {
128a1fd09e8SChristoph Hellwig }
129a1fd09e8SChristoph Hellwig #endif /* CONFIG_DMA_API_DEBUG */
130a1fd09e8SChristoph Hellwig #endif /* _KERNEL_DMA_DEBUG_H */
131