blob: f525197d3cae605aa7e0499eb2ca6f1ae134ec93 [file] [log] [blame]
Thomas Gleixner45051532019-05-29 16:57:47 -07001/* SPDX-License-Identifier: GPL-2.0-only */
Joerg Roedelf2f45e52009-01-09 12:19:52 +01002/*
3 * Copyright (C) 2008 Advanced Micro Devices, Inc.
4 *
5 * Author: Joerg Roedel <joerg.roedel@amd.com>
Joerg Roedelf2f45e52009-01-09 12:19:52 +01006 */
7
Christoph Hellwiga1fd09e2020-09-11 10:12:44 +02008#ifndef _KERNEL_DMA_DEBUG_H
9#define _KERNEL_DMA_DEBUG_H
Joerg Roedelf2f45e52009-01-09 12:19:52 +010010
Joerg Roedel6bf07872009-01-09 12:54:42 +010011#ifdef CONFIG_DMA_API_DEBUG
Joerg Roedelf62bc982009-01-09 14:14:49 +010012extern void debug_dma_map_page(struct device *dev, struct page *page,
13 size_t offset, size_t size,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040014 int direction, dma_addr_t dma_addr,
15 unsigned long attrs);
Joerg Roedelf62bc982009-01-09 14:14:49 +010016
17extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
Christoph Hellwig2e05ea52018-12-25 08:50:35 +010018 size_t size, int direction);
Joerg Roedelf62bc982009-01-09 14:14:49 +010019
Joerg Roedel972aa452009-01-09 14:19:54 +010020extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040021 int nents, int mapped_ents, int direction,
22 unsigned long attrs);
Joerg Roedel972aa452009-01-09 14:19:54 +010023
24extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
25 int nelems, int dir);
Joerg Roedelf62bc982009-01-09 14:14:49 +010026
Joerg Roedel6bfd4492009-01-09 14:38:50 +010027extern void debug_dma_alloc_coherent(struct device *dev, size_t size,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040028 dma_addr_t dma_addr, void *virt,
29 unsigned long attrs);
Joerg Roedel6bfd4492009-01-09 14:38:50 +010030
31extern void debug_dma_free_coherent(struct device *dev, size_t size,
32 void *virt, dma_addr_t addr);
33
Niklas Söderlund0e74b342016-08-10 13:22:15 +020034extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
35 size_t size, int direction,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040036 dma_addr_t dma_addr,
37 unsigned long attrs);
Niklas Söderlund0e74b342016-08-10 13:22:15 +020038
39extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr,
40 size_t size, int direction);
41
Joerg Roedelb9d23172009-01-09 14:43:04 +010042extern void debug_dma_sync_single_for_cpu(struct device *dev,
43 dma_addr_t dma_handle, size_t size,
44 int direction);
45
46extern void debug_dma_sync_single_for_device(struct device *dev,
47 dma_addr_t dma_handle,
48 size_t size, int direction);
49
Joerg Roedela31fba52009-01-09 15:01:12 +010050extern void debug_dma_sync_sg_for_cpu(struct device *dev,
51 struct scatterlist *sg,
52 int nelems, int direction);
53
54extern void debug_dma_sync_sg_for_device(struct device *dev,
55 struct scatterlist *sg,
56 int nelems, int direction);
Joerg Roedel6bf07872009-01-09 12:54:42 +010057#else /* CONFIG_DMA_API_DEBUG */
Joerg Roedelf62bc982009-01-09 14:14:49 +010058static inline void debug_dma_map_page(struct device *dev, struct page *page,
59 size_t offset, size_t size,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040060 int direction, dma_addr_t dma_addr,
61 unsigned long attrs)
Joerg Roedelf62bc982009-01-09 14:14:49 +010062{
63}
64
65static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr,
Christoph Hellwig2e05ea52018-12-25 08:50:35 +010066 size_t size, int direction)
Joerg Roedelf62bc982009-01-09 14:14:49 +010067{
68}
69
Joerg Roedel972aa452009-01-09 14:19:54 +010070static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040071 int nents, int mapped_ents, int direction,
72 unsigned long attrs)
Joerg Roedel972aa452009-01-09 14:19:54 +010073{
74}
75
76static inline void debug_dma_unmap_sg(struct device *dev,
77 struct scatterlist *sglist,
78 int nelems, int dir)
79{
80}
Joerg Roedelf62bc982009-01-09 14:14:49 +010081
Joerg Roedel6bfd4492009-01-09 14:38:50 +010082static inline void debug_dma_alloc_coherent(struct device *dev, size_t size,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040083 dma_addr_t dma_addr, void *virt,
84 unsigned long attrs)
Joerg Roedel6bfd4492009-01-09 14:38:50 +010085{
86}
87
88static inline void debug_dma_free_coherent(struct device *dev, size_t size,
89 void *virt, dma_addr_t addr)
90{
91}
92
Niklas Söderlund0e74b342016-08-10 13:22:15 +020093static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr,
94 size_t size, int direction,
Hamza Mahfoozc2bbf9d2021-10-12 01:54:03 -040095 dma_addr_t dma_addr,
96 unsigned long attrs)
Niklas Söderlund0e74b342016-08-10 13:22:15 +020097{
98}
99
100static inline void debug_dma_unmap_resource(struct device *dev,
101 dma_addr_t dma_addr, size_t size,
102 int direction)
103{
104}
105
Joerg Roedelb9d23172009-01-09 14:43:04 +0100106static inline void debug_dma_sync_single_for_cpu(struct device *dev,
107 dma_addr_t dma_handle,
108 size_t size, int direction)
109{
110}
111
112static inline void debug_dma_sync_single_for_device(struct device *dev,
113 dma_addr_t dma_handle,
114 size_t size, int direction)
115{
116}
117
Joerg Roedela31fba52009-01-09 15:01:12 +0100118static inline void debug_dma_sync_sg_for_cpu(struct device *dev,
119 struct scatterlist *sg,
120 int nelems, int direction)
121{
122}
123
124static inline void debug_dma_sync_sg_for_device(struct device *dev,
125 struct scatterlist *sg,
126 int nelems, int direction)
127{
128}
Joerg Roedel6bf07872009-01-09 12:54:42 +0100129#endif /* CONFIG_DMA_API_DEBUG */
Christoph Hellwiga1fd09e2020-09-11 10:12:44 +0200130#endif /* _KERNEL_DMA_DEBUG_H */