Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 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 | |
| 20 | #ifndef __DMA_DEBUG_H |
| 21 | #define __DMA_DEBUG_H |
| 22 | |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 23 | #include <linux/types.h> |
| 24 | |
Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 25 | struct device; |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 26 | struct scatterlist; |
Joerg Roedel | 41531c8 | 2009-03-16 17:32:14 +0100 | [diff] [blame] | 27 | struct bus_type; |
Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 28 | |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 29 | #ifdef CONFIG_DMA_API_DEBUG |
| 30 | |
Joerg Roedel | 41531c8 | 2009-03-16 17:32:14 +0100 | [diff] [blame] | 31 | extern void dma_debug_add_bus(struct bus_type *bus); |
| 32 | |
Stephen Boyd | 99c65fa | 2018-10-08 00:20:07 -0700 | [diff] [blame] | 33 | extern void debug_dma_map_single(struct device *dev, const void *addr, |
| 34 | unsigned long len); |
| 35 | |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 36 | extern void debug_dma_map_page(struct device *dev, struct page *page, |
| 37 | size_t offset, size_t size, |
Christoph Hellwig | 2e05ea5 | 2018-12-25 08:50:35 +0100 | [diff] [blame] | 38 | int direction, dma_addr_t dma_addr); |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 39 | |
Shuah Khan | 6c9c6d6 | 2012-10-08 11:08:06 -0600 | [diff] [blame] | 40 | extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr); |
| 41 | |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 42 | extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, |
Christoph Hellwig | 2e05ea5 | 2018-12-25 08:50:35 +0100 | [diff] [blame] | 43 | size_t size, int direction); |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 44 | |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 45 | extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, |
| 46 | int nents, int mapped_ents, int direction); |
| 47 | |
| 48 | extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, |
| 49 | int nelems, int dir); |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 50 | |
Joerg Roedel | 6bfd449 | 2009-01-09 14:38:50 +0100 | [diff] [blame] | 51 | extern void debug_dma_alloc_coherent(struct device *dev, size_t size, |
| 52 | dma_addr_t dma_addr, void *virt); |
| 53 | |
| 54 | extern void debug_dma_free_coherent(struct device *dev, size_t size, |
| 55 | void *virt, dma_addr_t addr); |
| 56 | |
Niklas Söderlund | 0e74b34 | 2016-08-10 13:22:15 +0200 | [diff] [blame] | 57 | extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr, |
| 58 | size_t size, int direction, |
| 59 | dma_addr_t dma_addr); |
| 60 | |
| 61 | extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr, |
| 62 | size_t size, int direction); |
| 63 | |
Joerg Roedel | b9d2317 | 2009-01-09 14:43:04 +0100 | [diff] [blame] | 64 | extern void debug_dma_sync_single_for_cpu(struct device *dev, |
| 65 | dma_addr_t dma_handle, size_t size, |
| 66 | int direction); |
| 67 | |
| 68 | extern void debug_dma_sync_single_for_device(struct device *dev, |
| 69 | dma_addr_t dma_handle, |
| 70 | size_t size, int direction); |
| 71 | |
Joerg Roedel | a31fba5 | 2009-01-09 15:01:12 +0100 | [diff] [blame] | 72 | extern void debug_dma_sync_sg_for_cpu(struct device *dev, |
| 73 | struct scatterlist *sg, |
| 74 | int nelems, int direction); |
| 75 | |
| 76 | extern void debug_dma_sync_sg_for_device(struct device *dev, |
| 77 | struct scatterlist *sg, |
| 78 | int nelems, int direction); |
| 79 | |
David Woodhouse | ac26c18 | 2009-02-12 16:19:13 +0100 | [diff] [blame] | 80 | extern void debug_dma_dump_mappings(struct device *dev); |
| 81 | |
Dan Williams | 0abdd7a | 2014-01-21 15:48:12 -0800 | [diff] [blame] | 82 | extern void debug_dma_assert_idle(struct page *page); |
| 83 | |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 84 | #else /* CONFIG_DMA_API_DEBUG */ |
| 85 | |
Ingo Molnar | 84be58d | 2009-03-18 11:50:29 +0100 | [diff] [blame] | 86 | static inline void dma_debug_add_bus(struct bus_type *bus) |
Joerg Roedel | 41531c8 | 2009-03-16 17:32:14 +0100 | [diff] [blame] | 87 | { |
| 88 | } |
| 89 | |
Stephen Boyd | 99c65fa | 2018-10-08 00:20:07 -0700 | [diff] [blame] | 90 | static inline void debug_dma_map_single(struct device *dev, const void *addr, |
| 91 | unsigned long len) |
| 92 | { |
| 93 | } |
| 94 | |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 95 | static inline void debug_dma_map_page(struct device *dev, struct page *page, |
| 96 | size_t offset, size_t size, |
Christoph Hellwig | 2e05ea5 | 2018-12-25 08:50:35 +0100 | [diff] [blame] | 97 | int direction, dma_addr_t dma_addr) |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 98 | { |
| 99 | } |
| 100 | |
Shuah Khan | 6c9c6d6 | 2012-10-08 11:08:06 -0600 | [diff] [blame] | 101 | static inline void debug_dma_mapping_error(struct device *dev, |
| 102 | dma_addr_t dma_addr) |
| 103 | { |
| 104 | } |
| 105 | |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 106 | static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, |
Christoph Hellwig | 2e05ea5 | 2018-12-25 08:50:35 +0100 | [diff] [blame] | 107 | size_t size, int direction) |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 108 | { |
| 109 | } |
| 110 | |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 111 | static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, |
| 112 | int nents, int mapped_ents, int direction) |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | static inline void debug_dma_unmap_sg(struct device *dev, |
| 117 | struct scatterlist *sglist, |
| 118 | int nelems, int dir) |
| 119 | { |
| 120 | } |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 121 | |
Joerg Roedel | 6bfd449 | 2009-01-09 14:38:50 +0100 | [diff] [blame] | 122 | static inline void debug_dma_alloc_coherent(struct device *dev, size_t size, |
| 123 | dma_addr_t dma_addr, void *virt) |
| 124 | { |
| 125 | } |
| 126 | |
| 127 | static inline void debug_dma_free_coherent(struct device *dev, size_t size, |
| 128 | void *virt, dma_addr_t addr) |
| 129 | { |
| 130 | } |
| 131 | |
Niklas Söderlund | 0e74b34 | 2016-08-10 13:22:15 +0200 | [diff] [blame] | 132 | static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr, |
| 133 | size_t size, int direction, |
| 134 | dma_addr_t dma_addr) |
| 135 | { |
| 136 | } |
| 137 | |
| 138 | static inline void debug_dma_unmap_resource(struct device *dev, |
| 139 | dma_addr_t dma_addr, size_t size, |
| 140 | int direction) |
| 141 | { |
| 142 | } |
| 143 | |
Joerg Roedel | b9d2317 | 2009-01-09 14:43:04 +0100 | [diff] [blame] | 144 | static inline void debug_dma_sync_single_for_cpu(struct device *dev, |
| 145 | dma_addr_t dma_handle, |
| 146 | size_t size, int direction) |
| 147 | { |
| 148 | } |
| 149 | |
| 150 | static inline void debug_dma_sync_single_for_device(struct device *dev, |
| 151 | dma_addr_t dma_handle, |
| 152 | size_t size, int direction) |
| 153 | { |
| 154 | } |
| 155 | |
Joerg Roedel | a31fba5 | 2009-01-09 15:01:12 +0100 | [diff] [blame] | 156 | static inline void debug_dma_sync_sg_for_cpu(struct device *dev, |
| 157 | struct scatterlist *sg, |
| 158 | int nelems, int direction) |
| 159 | { |
| 160 | } |
| 161 | |
| 162 | static inline void debug_dma_sync_sg_for_device(struct device *dev, |
| 163 | struct scatterlist *sg, |
| 164 | int nelems, int direction) |
| 165 | { |
| 166 | } |
| 167 | |
David Woodhouse | ac26c18 | 2009-02-12 16:19:13 +0100 | [diff] [blame] | 168 | static inline void debug_dma_dump_mappings(struct device *dev) |
| 169 | { |
| 170 | } |
| 171 | |
Dan Williams | 0abdd7a | 2014-01-21 15:48:12 -0800 | [diff] [blame] | 172 | static inline void debug_dma_assert_idle(struct page *page) |
| 173 | { |
| 174 | } |
| 175 | |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 176 | #endif /* CONFIG_DMA_API_DEBUG */ |
| 177 | |
Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 178 | #endif /* __DMA_DEBUG_H */ |