diff options
-rw-r--r-- | arch/x86/kernel/pci-base_32.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/pci-calgary_64.c | 3 | ||||
-rw-r--r-- | arch/x86/kernel/pci-dma_64.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/pci-gart_64.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/pci-nommu_64.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/pci-swiotlb_64.c | 9 | ||||
-rw-r--r-- | include/asm-x86/dma-mapping.h | 10 |
7 files changed, 28 insertions, 19 deletions
diff --git a/arch/x86/kernel/pci-base_32.c b/arch/x86/kernel/pci-base_32.c index 033d94ec5000..cf4bb28dfc6a 100644 --- a/arch/x86/kernel/pci-base_32.c +++ b/arch/x86/kernel/pci-base_32.c | |||
@@ -4,12 +4,12 @@ | |||
4 | #include <linux/dma-mapping.h> | 4 | #include <linux/dma-mapping.h> |
5 | #include <asm/dma-mapping.h> | 5 | #include <asm/dma-mapping.h> |
6 | 6 | ||
7 | static dma_addr_t pci32_map_single(struct device *dev, void *ptr, | 7 | static dma_addr_t pci32_map_single(struct device *dev, phys_addr_t ptr, |
8 | size_t size, int direction) | 8 | size_t size, int direction) |
9 | { | 9 | { |
10 | WARN_ON(size == 0); | 10 | WARN_ON(size == 0); |
11 | flush_write_buffers(); | 11 | flush_write_buffers(); |
12 | return virt_to_phys(ptr); | 12 | return ptr; |
13 | } | 13 | } |
14 | 14 | ||
15 | static int pci32_dma_map_sg(struct device *dev, struct scatterlist *sglist, | 15 | static int pci32_dma_map_sg(struct device *dev, struct scatterlist *sglist, |
diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c index 1b5464c2434f..adb91e4b62da 100644 --- a/arch/x86/kernel/pci-calgary_64.c +++ b/arch/x86/kernel/pci-calgary_64.c | |||
@@ -470,10 +470,11 @@ error: | |||
470 | return 0; | 470 | return 0; |
471 | } | 471 | } |
472 | 472 | ||
473 | static dma_addr_t calgary_map_single(struct device *dev, void *vaddr, | 473 | static dma_addr_t calgary_map_single(struct device *dev, phys_addr_t paddr, |
474 | size_t size, int direction) | 474 | size_t size, int direction) |
475 | { | 475 | { |
476 | dma_addr_t dma_handle = bad_dma_address; | 476 | dma_addr_t dma_handle = bad_dma_address; |
477 | void *vaddr = phys_to_virt(paddr); | ||
477 | unsigned long uaddr; | 478 | unsigned long uaddr; |
478 | unsigned int npages; | 479 | unsigned int npages; |
479 | struct iommu_table *tbl = find_iommu_table(dev); | 480 | struct iommu_table *tbl = find_iommu_table(dev); |
diff --git a/arch/x86/kernel/pci-dma_64.c b/arch/x86/kernel/pci-dma_64.c index e4fffaabe53b..f97a08d0a8f9 100644 --- a/arch/x86/kernel/pci-dma_64.c +++ b/arch/x86/kernel/pci-dma_64.c | |||
@@ -141,7 +141,7 @@ dma_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, | |||
141 | } | 141 | } |
142 | 142 | ||
143 | if (dma_ops->map_simple) { | 143 | if (dma_ops->map_simple) { |
144 | *dma_handle = dma_ops->map_simple(dev, memory, | 144 | *dma_handle = dma_ops->map_simple(dev, virt_to_phys(memory), |
145 | size, | 145 | size, |
146 | PCI_DMA_BIDIRECTIONAL); | 146 | PCI_DMA_BIDIRECTIONAL); |
147 | if (*dma_handle != bad_dma_address) | 147 | if (*dma_handle != bad_dma_address) |
diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c index 700e4647dd30..c07455d1695f 100644 --- a/arch/x86/kernel/pci-gart_64.c +++ b/arch/x86/kernel/pci-gart_64.c | |||
@@ -264,9 +264,9 @@ static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem, | |||
264 | } | 264 | } |
265 | 265 | ||
266 | static dma_addr_t | 266 | static dma_addr_t |
267 | gart_map_simple(struct device *dev, char *buf, size_t size, int dir) | 267 | gart_map_simple(struct device *dev, phys_addr_t paddr, size_t size, int dir) |
268 | { | 268 | { |
269 | dma_addr_t map = dma_map_area(dev, virt_to_bus(buf), size, dir); | 269 | dma_addr_t map = dma_map_area(dev, paddr, size, dir); |
270 | 270 | ||
271 | flush_gart(); | 271 | flush_gart(); |
272 | 272 | ||
@@ -275,18 +275,17 @@ gart_map_simple(struct device *dev, char *buf, size_t size, int dir) | |||
275 | 275 | ||
276 | /* Map a single area into the IOMMU */ | 276 | /* Map a single area into the IOMMU */ |
277 | static dma_addr_t | 277 | static dma_addr_t |
278 | gart_map_single(struct device *dev, void *addr, size_t size, int dir) | 278 | gart_map_single(struct device *dev, phys_addr_t paddr, size_t size, int dir) |
279 | { | 279 | { |
280 | unsigned long phys_mem, bus; | 280 | unsigned long bus; |
281 | 281 | ||
282 | if (!dev) | 282 | if (!dev) |
283 | dev = &fallback_dev; | 283 | dev = &fallback_dev; |
284 | 284 | ||
285 | phys_mem = virt_to_phys(addr); | 285 | if (!need_iommu(dev, paddr, size)) |
286 | if (!need_iommu(dev, phys_mem, size)) | 286 | return paddr; |
287 | return phys_mem; | ||
288 | 287 | ||
289 | bus = gart_map_simple(dev, addr, size, dir); | 288 | bus = gart_map_simple(dev, paddr, size, dir); |
290 | 289 | ||
291 | return bus; | 290 | return bus; |
292 | } | 291 | } |
diff --git a/arch/x86/kernel/pci-nommu_64.c b/arch/x86/kernel/pci-nommu_64.c index ab08e1832228..6e330769d017 100644 --- a/arch/x86/kernel/pci-nommu_64.c +++ b/arch/x86/kernel/pci-nommu_64.c | |||
@@ -26,10 +26,10 @@ check_addr(char *name, struct device *hwdev, dma_addr_t bus, size_t size) | |||
26 | } | 26 | } |
27 | 27 | ||
28 | static dma_addr_t | 28 | static dma_addr_t |
29 | nommu_map_single(struct device *hwdev, void *ptr, size_t size, | 29 | nommu_map_single(struct device *hwdev, phys_addr_t paddr, size_t size, |
30 | int direction) | 30 | int direction) |
31 | { | 31 | { |
32 | dma_addr_t bus = virt_to_bus(ptr); | 32 | dma_addr_t bus = paddr; |
33 | if (!check_addr("map_single", hwdev, bus, size)) | 33 | if (!check_addr("map_single", hwdev, bus, size)) |
34 | return bad_dma_address; | 34 | return bad_dma_address; |
35 | return bus; | 35 | return bus; |
diff --git a/arch/x86/kernel/pci-swiotlb_64.c b/arch/x86/kernel/pci-swiotlb_64.c index 82a0a674a003..490da7f4b8d0 100644 --- a/arch/x86/kernel/pci-swiotlb_64.c +++ b/arch/x86/kernel/pci-swiotlb_64.c | |||
@@ -11,11 +11,18 @@ | |||
11 | 11 | ||
12 | int swiotlb __read_mostly; | 12 | int swiotlb __read_mostly; |
13 | 13 | ||
14 | static dma_addr_t | ||
15 | swiotlb_map_single_phys(struct device *hwdev, phys_addr_t paddr, size_t size, | ||
16 | int direction) | ||
17 | { | ||
18 | return swiotlb_map_single(hwdev, phys_to_virt(paddr), size, direction); | ||
19 | } | ||
20 | |||
14 | const struct dma_mapping_ops swiotlb_dma_ops = { | 21 | const struct dma_mapping_ops swiotlb_dma_ops = { |
15 | .mapping_error = swiotlb_dma_mapping_error, | 22 | .mapping_error = swiotlb_dma_mapping_error, |
16 | .alloc_coherent = swiotlb_alloc_coherent, | 23 | .alloc_coherent = swiotlb_alloc_coherent, |
17 | .free_coherent = swiotlb_free_coherent, | 24 | .free_coherent = swiotlb_free_coherent, |
18 | .map_single = swiotlb_map_single, | 25 | .map_single = swiotlb_map_single_phys, |
19 | .unmap_single = swiotlb_unmap_single, | 26 | .unmap_single = swiotlb_unmap_single, |
20 | .sync_single_for_cpu = swiotlb_sync_single_for_cpu, | 27 | .sync_single_for_cpu = swiotlb_sync_single_for_cpu, |
21 | .sync_single_for_device = swiotlb_sync_single_for_device, | 28 | .sync_single_for_device = swiotlb_sync_single_for_device, |
diff --git a/include/asm-x86/dma-mapping.h b/include/asm-x86/dma-mapping.h index b5a413acac96..b331a8d3a7cf 100644 --- a/include/asm-x86/dma-mapping.h +++ b/include/asm-x86/dma-mapping.h | |||
@@ -16,10 +16,10 @@ struct dma_mapping_ops { | |||
16 | dma_addr_t *dma_handle, gfp_t gfp); | 16 | dma_addr_t *dma_handle, gfp_t gfp); |
17 | void (*free_coherent)(struct device *dev, size_t size, | 17 | void (*free_coherent)(struct device *dev, size_t size, |
18 | void *vaddr, dma_addr_t dma_handle); | 18 | void *vaddr, dma_addr_t dma_handle); |
19 | dma_addr_t (*map_single)(struct device *hwdev, void *ptr, | 19 | dma_addr_t (*map_single)(struct device *hwdev, phys_addr_t ptr, |
20 | size_t size, int direction); | 20 | size_t size, int direction); |
21 | /* like map_single, but doesn't check the device mask */ | 21 | /* like map_single, but doesn't check the device mask */ |
22 | dma_addr_t (*map_simple)(struct device *hwdev, char *ptr, | 22 | dma_addr_t (*map_simple)(struct device *hwdev, phys_addr_t ptr, |
23 | size_t size, int direction); | 23 | size_t size, int direction); |
24 | void (*unmap_single)(struct device *dev, dma_addr_t addr, | 24 | void (*unmap_single)(struct device *dev, dma_addr_t addr, |
25 | size_t size, int direction); | 25 | size_t size, int direction); |
@@ -73,7 +73,7 @@ dma_map_single(struct device *hwdev, void *ptr, size_t size, | |||
73 | int direction) | 73 | int direction) |
74 | { | 74 | { |
75 | BUG_ON(!valid_dma_direction(direction)); | 75 | BUG_ON(!valid_dma_direction(direction)); |
76 | return dma_ops->map_single(hwdev, ptr, size, direction); | 76 | return dma_ops->map_single(hwdev, virt_to_phys(ptr), size, direction); |
77 | } | 77 | } |
78 | 78 | ||
79 | static inline void | 79 | static inline void |
@@ -174,7 +174,9 @@ static inline dma_addr_t dma_map_page(struct device *dev, struct page *page, | |||
174 | size_t offset, size_t size, | 174 | size_t offset, size_t size, |
175 | int direction) | 175 | int direction) |
176 | { | 176 | { |
177 | return dma_map_single(dev, page_address(page)+offset, size, direction); | 177 | BUG_ON(!valid_dma_direction(direction)); |
178 | return dma_ops->map_single(dev, page_to_phys(page)+offset, | ||
179 | size, direction); | ||
178 | } | 180 | } |
179 | 181 | ||
180 | static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, | 182 | static inline void dma_unmap_page(struct device *dev, dma_addr_t addr, |