Thomas Gleixner | 4505153 | 2019-05-29 16:57:47 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2008 Advanced Micro Devices, Inc. |
| 4 | * |
| 5 | * Author: Joerg Roedel <joerg.roedel@amd.com> |
Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
Christoph Hellwig | a1fd09e | 2020-09-11 10:12:44 +0200 | [diff] [blame] | 8 | #ifndef _KERNEL_DMA_DEBUG_H |
| 9 | #define _KERNEL_DMA_DEBUG_H |
Joerg Roedel | f2f45e5 | 2009-01-09 12:19:52 +0100 | [diff] [blame] | 10 | |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 11 | #ifdef CONFIG_DMA_API_DEBUG |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 12 | extern void debug_dma_map_page(struct device *dev, struct page *page, |
| 13 | size_t offset, size_t size, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 14 | int direction, dma_addr_t dma_addr, |
| 15 | unsigned long attrs); |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 16 | |
| 17 | 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] | 18 | size_t size, int direction); |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 19 | |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 20 | extern void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 21 | int nents, int mapped_ents, int direction, |
| 22 | unsigned long attrs); |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 23 | |
| 24 | extern void debug_dma_unmap_sg(struct device *dev, struct scatterlist *sglist, |
| 25 | int nelems, int dir); |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 26 | |
Joerg Roedel | 6bfd449 | 2009-01-09 14:38:50 +0100 | [diff] [blame] | 27 | extern void debug_dma_alloc_coherent(struct device *dev, size_t size, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 28 | dma_addr_t dma_addr, void *virt, |
| 29 | unsigned long attrs); |
Joerg Roedel | 6bfd449 | 2009-01-09 14:38:50 +0100 | [diff] [blame] | 30 | |
| 31 | extern void debug_dma_free_coherent(struct device *dev, size_t size, |
| 32 | void *virt, dma_addr_t addr); |
| 33 | |
Niklas Söderlund | 0e74b34 | 2016-08-10 13:22:15 +0200 | [diff] [blame] | 34 | extern void debug_dma_map_resource(struct device *dev, phys_addr_t addr, |
| 35 | size_t size, int direction, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 36 | dma_addr_t dma_addr, |
| 37 | unsigned long attrs); |
Niklas Söderlund | 0e74b34 | 2016-08-10 13:22:15 +0200 | [diff] [blame] | 38 | |
| 39 | extern void debug_dma_unmap_resource(struct device *dev, dma_addr_t dma_addr, |
| 40 | size_t size, int direction); |
| 41 | |
Joerg Roedel | b9d2317 | 2009-01-09 14:43:04 +0100 | [diff] [blame] | 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 | |
| 46 | extern void debug_dma_sync_single_for_device(struct device *dev, |
| 47 | dma_addr_t dma_handle, |
| 48 | size_t size, int direction); |
| 49 | |
Joerg Roedel | a31fba5 | 2009-01-09 15:01:12 +0100 | [diff] [blame] | 50 | extern void debug_dma_sync_sg_for_cpu(struct device *dev, |
| 51 | struct scatterlist *sg, |
| 52 | int nelems, int direction); |
| 53 | |
| 54 | extern void debug_dma_sync_sg_for_device(struct device *dev, |
| 55 | struct scatterlist *sg, |
| 56 | int nelems, int direction); |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 57 | #else /* CONFIG_DMA_API_DEBUG */ |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 58 | static inline void debug_dma_map_page(struct device *dev, struct page *page, |
| 59 | size_t offset, size_t size, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 60 | int direction, dma_addr_t dma_addr, |
| 61 | unsigned long attrs) |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 62 | { |
| 63 | } |
| 64 | |
| 65 | 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] | 66 | size_t size, int direction) |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 67 | { |
| 68 | } |
| 69 | |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 70 | static inline void debug_dma_map_sg(struct device *dev, struct scatterlist *sg, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 71 | int nents, int mapped_ents, int direction, |
| 72 | unsigned long attrs) |
Joerg Roedel | 972aa45 | 2009-01-09 14:19:54 +0100 | [diff] [blame] | 73 | { |
| 74 | } |
| 75 | |
| 76 | static inline void debug_dma_unmap_sg(struct device *dev, |
| 77 | struct scatterlist *sglist, |
| 78 | int nelems, int dir) |
| 79 | { |
| 80 | } |
Joerg Roedel | f62bc98 | 2009-01-09 14:14:49 +0100 | [diff] [blame] | 81 | |
Joerg Roedel | 6bfd449 | 2009-01-09 14:38:50 +0100 | [diff] [blame] | 82 | static inline void debug_dma_alloc_coherent(struct device *dev, size_t size, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 83 | dma_addr_t dma_addr, void *virt, |
| 84 | unsigned long attrs) |
Joerg Roedel | 6bfd449 | 2009-01-09 14:38:50 +0100 | [diff] [blame] | 85 | { |
| 86 | } |
| 87 | |
| 88 | static inline void debug_dma_free_coherent(struct device *dev, size_t size, |
| 89 | void *virt, dma_addr_t addr) |
| 90 | { |
| 91 | } |
| 92 | |
Niklas Söderlund | 0e74b34 | 2016-08-10 13:22:15 +0200 | [diff] [blame] | 93 | static inline void debug_dma_map_resource(struct device *dev, phys_addr_t addr, |
| 94 | size_t size, int direction, |
Hamza Mahfooz | c2bbf9d | 2021-10-12 01:54:03 -0400 | [diff] [blame] | 95 | dma_addr_t dma_addr, |
| 96 | unsigned long attrs) |
Niklas Söderlund | 0e74b34 | 2016-08-10 13:22:15 +0200 | [diff] [blame] | 97 | { |
| 98 | } |
| 99 | |
| 100 | static 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 Roedel | b9d2317 | 2009-01-09 14:43:04 +0100 | [diff] [blame] | 106 | static 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 | |
| 112 | static 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 Roedel | a31fba5 | 2009-01-09 15:01:12 +0100 | [diff] [blame] | 118 | static inline void debug_dma_sync_sg_for_cpu(struct device *dev, |
| 119 | struct scatterlist *sg, |
| 120 | int nelems, int direction) |
| 121 | { |
| 122 | } |
| 123 | |
| 124 | static inline void debug_dma_sync_sg_for_device(struct device *dev, |
| 125 | struct scatterlist *sg, |
| 126 | int nelems, int direction) |
| 127 | { |
| 128 | } |
Joerg Roedel | 6bf0787 | 2009-01-09 12:54:42 +0100 | [diff] [blame] | 129 | #endif /* CONFIG_DMA_API_DEBUG */ |
Christoph Hellwig | a1fd09e | 2020-09-11 10:12:44 +0200 | [diff] [blame] | 130 | #endif /* _KERNEL_DMA_DEBUG_H */ |