diff options
author | Andi Kleen <ak@suse.de> | 2006-01-11 16:44:54 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-11 22:04:56 -0500 |
commit | fd78f11790c37e2165733699f50450500e63a7b3 (patch) | |
tree | b51d2d6d4b1f83c276d81a72d4522ec701aa4354 /include/asm-i386 | |
parent | 3d831d925c6d66569a0c7f6f5f17c0927f7d3d25 (diff) |
[PATCH] i386: make pci_map_single/pci_map_sg warn for zero length.
As suggested by Linus.
This catches driver bugs that could cause corruption on IOMMU architectures.
Also I converted the BUGs to out_of_line_bug()s to save a bit
of text space.
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/asm-i386')
-rw-r--r-- | include/asm-i386/dma-mapping.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/include/asm-i386/dma-mapping.h b/include/asm-i386/dma-mapping.h index 6c37a9ab8d60..9cf20cacf76e 100644 --- a/include/asm-i386/dma-mapping.h +++ b/include/asm-i386/dma-mapping.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <asm/cache.h> | 6 | #include <asm/cache.h> |
7 | #include <asm/io.h> | 7 | #include <asm/io.h> |
8 | #include <asm/scatterlist.h> | 8 | #include <asm/scatterlist.h> |
9 | #include <asm/bug.h> | ||
9 | 10 | ||
10 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) | 11 | #define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) |
11 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) | 12 | #define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) |
@@ -20,7 +21,9 @@ static inline dma_addr_t | |||
20 | dma_map_single(struct device *dev, void *ptr, size_t size, | 21 | dma_map_single(struct device *dev, void *ptr, size_t size, |
21 | enum dma_data_direction direction) | 22 | enum dma_data_direction direction) |
22 | { | 23 | { |
23 | BUG_ON(direction == DMA_NONE); | 24 | if (direction == DMA_NONE) |
25 | BUG(); | ||
26 | WARN_ON(size == 0); | ||
24 | flush_write_buffers(); | 27 | flush_write_buffers(); |
25 | return virt_to_phys(ptr); | 28 | return virt_to_phys(ptr); |
26 | } | 29 | } |
@@ -29,7 +32,8 @@ static inline void | |||
29 | dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | 32 | dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, |
30 | enum dma_data_direction direction) | 33 | enum dma_data_direction direction) |
31 | { | 34 | { |
32 | BUG_ON(direction == DMA_NONE); | 35 | if (direction == DMA_NONE) |
36 | BUG(); | ||
33 | } | 37 | } |
34 | 38 | ||
35 | static inline int | 39 | static inline int |
@@ -38,7 +42,9 @@ dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, | |||
38 | { | 42 | { |
39 | int i; | 43 | int i; |
40 | 44 | ||
41 | BUG_ON(direction == DMA_NONE); | 45 | if (direction == DMA_NONE) |
46 | BUG(); | ||
47 | WARN_ON(nents == 0 || sg[0].length == 0); | ||
42 | 48 | ||
43 | for (i = 0; i < nents; i++ ) { | 49 | for (i = 0; i < nents; i++ ) { |
44 | BUG_ON(!sg[i].page); | 50 | BUG_ON(!sg[i].page); |