Skip to content

Commit 07a7230

Browse files
cladischtorvalds
authored andcommitted
dma-mapping: fix sync_single_range_* DMA debugging
Commit 5fd75a7 (dma-mapping: remove unnecessary sync_single_range_* in dma_map_ops) unified not only the dma_map_ops but also the corresponding debug_dma_sync_* calls. This led to spurious WARN()ings like the following because the DMA debug code was no longer able to detect the DMA buffer base address without the separate offset parameter: WARNING: at lib/dma-debug.c:911 check_sync+0xce/0x446() firewire_ohci 0000:04:00.0: DMA-API: device driver tries to sync DMA memory it has not allocated [device address=0x00000000cedaa400] [size=1024 bytes] Call Trace: ... [<ffffffff811326a5>] check_sync+0xce/0x446 [<ffffffff81132ad9>] debug_dma_sync_single_for_device+0x39/0x3b [<ffffffffa01d6e6a>] ohci_queue_iso+0x4f3/0x77d [firewire_ohci] ... To fix this, unshare the sync_single_* and sync_single_range_* implementations so that we are able to call the correct debug_dma_sync_* functions. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 1a4ceab commit 07a7230

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎include/asm-generic/dma-mapping-common.h‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ static inline void dma_sync_single_range_for_cpu(struct device *dev,
123123
size_t size,
124124
enum dma_data_direction dir)
125125
{
126-
dma_sync_single_for_cpu(dev, addr + offset, size, dir);
126+
const struct dma_map_ops *ops = get_dma_ops(dev);
127+
128+
BUG_ON(!valid_dma_direction(dir));
129+
if (ops->sync_single_for_cpu)
130+
ops->sync_single_for_cpu(dev, addr + offset, size, dir);
131+
debug_dma_sync_single_range_for_cpu(dev, addr, offset, size, dir);
127132
}
128133

129134
static inline void dma_sync_single_range_for_device(struct device *dev,
@@ -132,7 +137,12 @@ static inline void dma_sync_single_range_for_device(struct device *dev,
132137
size_t size,
133138
enum dma_data_direction dir)
134139
{
135-
dma_sync_single_for_device(dev, addr + offset, size, dir);
140+
const struct dma_map_ops *ops = get_dma_ops(dev);
141+
142+
BUG_ON(!valid_dma_direction(dir));
143+
if (ops->sync_single_for_device)
144+
ops->sync_single_for_device(dev, addr + offset, size, dir);
145+
debug_dma_sync_single_range_for_device(dev, addr, offset, size, dir);
136146
}
137147

138148
static inline void

0 commit comments

Comments
 (0)