at v4.20 5.9 kB view raw
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 23#include <linux/types.h> 24 25struct device; 26struct scatterlist; 27struct bus_type; 28 29#ifdef CONFIG_DMA_API_DEBUG 30 31extern void dma_debug_add_bus(struct bus_type *bus); 32 33extern int dma_debug_resize_entries(u32 num_entries); 34 35extern void debug_dma_map_single(struct device *dev, const void *addr, 36 unsigned long len); 37 38extern void debug_dma_map_page(struct device *dev, struct page *page, 39 size_t offset, size_t size, 40 int direction, dma_addr_t dma_addr, 41 bool map_single); 42 43extern void debug_dma_mapping_error(struct device *dev, dma_addr_t dma_addr); 44 45extern void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, 46 size_t size, int direction, bool map_single); 47 48extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, 49 int nents, int mapped_ents, int direction); 50 51extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, 52 int nelems, int dir); 53 54extern void debug_dma_alloc_coherent(struct device *dev, size_t size, 55 dma_addr_t dma_addr, void *virt); 56 57extern void debug_dma_free_coherent(struct device *dev, size_t size, 58 void *virt, dma_addr_t addr); 59 60extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr, 61 size_t size, int direction, 62 dma_addr_t dma_addr); 63 64extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr, 65 size_t size, int direction); 66 67extern void debug_dma_sync_single_for_cpu(struct device *dev, 68 dma_addr_t dma_handle, size_t size, 69 int direction); 70 71extern void debug_dma_sync_single_for_device(struct device *dev, 72 dma_addr_t dma_handle, 73 size_t size, int direction); 74 75extern void debug_dma_sync_single_range_for_cpu(struct device *dev, 76 dma_addr_t dma_handle, 77 unsigned long offset, 78 size_t size, 79 int direction); 80 81extern void debug_dma_sync_single_range_for_device(struct device *dev, 82 dma_addr_t dma_handle, 83 unsigned long offset, 84 size_t size, int direction); 85 86extern void debug_dma_sync_sg_for_cpu(struct device *dev, 87 struct scatterlist *sg, 88 int nelems, int direction); 89 90extern void debug_dma_sync_sg_for_device(struct device *dev, 91 struct scatterlist *sg, 92 int nelems, int direction); 93 94extern void debug_dma_dump_mappings(struct device *dev); 95 96extern void debug_dma_assert_idle(struct page *page); 97 98#else /* CONFIG_DMA_API_DEBUG */ 99 100static inline void dma_debug_add_bus(struct bus_type *bus) 101{ 102} 103 104static inline int dma_debug_resize_entries(u32 num_entries) 105{ 106 return 0; 107} 108 109static inline void debug_dma_map_single(struct device *dev, const void *addr, 110 unsigned long len) 111{ 112} 113 114static inline void debug_dma_map_page(struct device *dev, struct page *page, 115 size_t offset, size_t size, 116 int direction, dma_addr_t dma_addr, 117 bool map_single) 118{ 119} 120 121static inline void debug_dma_mapping_error(struct device *dev, 122 dma_addr_t dma_addr) 123{ 124} 125 126static inline void debug_dma_unmap_page(struct device *dev, dma_addr_t addr, 127 size_t size, int direction, 128 bool map_single) 129{ 130} 131 132static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, 133 int nents, int mapped_ents, int direction) 134{ 135} 136 137static inline void debug_dma_unmap_sg(struct device *dev, 138 struct scatterlist *sglist, 139 int nelems, int dir) 140{ 141} 142 143static inline void debug_dma_alloc_coherent(struct device *dev, size_t size, 144 dma_addr_t dma_addr, void *virt) 145{ 146} 147 148static inline void debug_dma_free_coherent(struct device *dev, size_t size, 149 void *virt, dma_addr_t addr) 150{ 151} 152 153static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr, 154 size_t size, int direction, 155 dma_addr_t dma_addr) 156{ 157} 158 159static inline void debug_dma_unmap_resource(struct device *dev, 160 dma_addr_t dma_addr, size_t size, 161 int direction) 162{ 163} 164 165static inline void debug_dma_sync_single_for_cpu(struct device *dev, 166 dma_addr_t dma_handle, 167 size_t size, int direction) 168{ 169} 170 171static inline void debug_dma_sync_single_for_device(struct device *dev, 172 dma_addr_t dma_handle, 173 size_t size, int direction) 174{ 175} 176 177static inline void debug_dma_sync_single_range_for_cpu(struct device *dev, 178 dma_addr_t dma_handle, 179 unsigned long offset, 180 size_t size, 181 int direction) 182{ 183} 184 185static inline void debug_dma_sync_single_range_for_device(struct device *dev, 186 dma_addr_t dma_handle, 187 unsigned long offset, 188 size_t size, 189 int direction) 190{ 191} 192 193static inline void debug_dma_sync_sg_for_cpu(struct device *dev, 194 struct scatterlist *sg, 195 int nelems, int direction) 196{ 197} 198 199static inline void debug_dma_sync_sg_for_device(struct device *dev, 200 struct scatterlist *sg, 201 int nelems, int direction) 202{ 203} 204 205static inline void debug_dma_dump_mappings(struct device *dev) 206{ 207} 208 209static inline void debug_dma_assert_idle(struct page *page) 210{ 211} 212 213#endif /* CONFIG_DMA_API_DEBUG */ 214 215#endif /* __DMA_DEBUG_H */