diff options
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/common/dmabounce.c | 21 | ||||
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 26 | ||||
-rw-r--r-- | arch/arm/include/asm/memory.h | 14 | ||||
-rw-r--r-- | arch/arm/mach-iop13xx/include/mach/memory.h | 2 | ||||
-rw-r--r-- | arch/arm/mach-ks8695/include/mach/memory.h | 7 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/mach/memory.h | 7 |
6 files changed, 56 insertions, 21 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c index 734ac9135998..5a375e5fef21 100644 --- a/arch/arm/common/dmabounce.c +++ b/arch/arm/common/dmabounce.c | |||
@@ -342,6 +342,22 @@ dma_addr_t dma_map_single(struct device *dev, void *ptr, size_t size, | |||
342 | } | 342 | } |
343 | EXPORT_SYMBOL(dma_map_single); | 343 | EXPORT_SYMBOL(dma_map_single); |
344 | 344 | ||
345 | /* | ||
346 | * see if a mapped address was really a "safe" buffer and if so, copy | ||
347 | * the data from the safe buffer back to the unsafe buffer and free up | ||
348 | * the safe buffer. (basically return things back to the way they | ||
349 | * should be) | ||
350 | */ | ||
351 | void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | ||
352 | enum dma_data_direction dir) | ||
353 | { | ||
354 | dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", | ||
355 | __func__, (void *) dma_addr, size, dir); | ||
356 | |||
357 | unmap_single(dev, dma_addr, size, dir); | ||
358 | } | ||
359 | EXPORT_SYMBOL(dma_unmap_single); | ||
360 | |||
345 | dma_addr_t dma_map_page(struct device *dev, struct page *page, | 361 | dma_addr_t dma_map_page(struct device *dev, struct page *page, |
346 | unsigned long offset, size_t size, enum dma_data_direction dir) | 362 | unsigned long offset, size_t size, enum dma_data_direction dir) |
347 | { | 363 | { |
@@ -366,8 +382,7 @@ EXPORT_SYMBOL(dma_map_page); | |||
366 | * the safe buffer. (basically return things back to the way they | 382 | * the safe buffer. (basically return things back to the way they |
367 | * should be) | 383 | * should be) |
368 | */ | 384 | */ |
369 | 385 | void dma_unmap_page(struct device *dev, dma_addr_t dma_addr, size_t size, | |
370 | void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | ||
371 | enum dma_data_direction dir) | 386 | enum dma_data_direction dir) |
372 | { | 387 | { |
373 | dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", | 388 | dev_dbg(dev, "%s(ptr=%p,size=%d,dir=%x)\n", |
@@ -375,7 +390,7 @@ void dma_unmap_single(struct device *dev, dma_addr_t dma_addr, size_t size, | |||
375 | 390 | ||
376 | unmap_single(dev, dma_addr, size, dir); | 391 | unmap_single(dev, dma_addr, size, dir); |
377 | } | 392 | } |
378 | EXPORT_SYMBOL(dma_unmap_single); | 393 | EXPORT_SYMBOL(dma_unmap_page); |
379 | 394 | ||
380 | int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, | 395 | int dmabounce_sync_for_cpu(struct device *dev, dma_addr_t addr, |
381 | unsigned long off, size_t sz, enum dma_data_direction dir) | 396 | unsigned long off, size_t sz, enum dma_data_direction dir) |
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index ff46dfa68a97..a96300bf83fd 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -15,20 +15,15 @@ | |||
15 | * must not be used by drivers. | 15 | * must not be used by drivers. |
16 | */ | 16 | */ |
17 | #ifndef __arch_page_to_dma | 17 | #ifndef __arch_page_to_dma |
18 | |||
19 | #if !defined(CONFIG_HIGHMEM) | ||
20 | static inline dma_addr_t page_to_dma(struct device *dev, struct page *page) | 18 | static inline dma_addr_t page_to_dma(struct device *dev, struct page *page) |
21 | { | 19 | { |
22 | return (dma_addr_t)__virt_to_bus((unsigned long)page_address(page)); | 20 | return (dma_addr_t)__pfn_to_bus(page_to_pfn(page)); |
23 | } | 21 | } |
24 | #elif defined(__pfn_to_bus) | 22 | |
25 | static inline dma_addr_t page_to_dma(struct device *dev, struct page *page) | 23 | static inline struct page *dma_to_page(struct device *dev, dma_addr_t addr) |
26 | { | 24 | { |
27 | return (dma_addr_t)__pfn_to_bus(page_to_pfn(page)); | 25 | return pfn_to_page(__bus_to_pfn(addr)); |
28 | } | 26 | } |
29 | #else | ||
30 | #error "this machine class needs to define __arch_page_to_dma to use HIGHMEM" | ||
31 | #endif | ||
32 | 27 | ||
33 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) | 28 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) |
34 | { | 29 | { |
@@ -45,6 +40,11 @@ static inline dma_addr_t page_to_dma(struct device *dev, struct page *page) | |||
45 | return __arch_page_to_dma(dev, page); | 40 | return __arch_page_to_dma(dev, page); |
46 | } | 41 | } |
47 | 42 | ||
43 | static inline struct page *dma_to_page(struct device *dev, dma_addr_t addr) | ||
44 | { | ||
45 | return __arch_dma_to_page(dev, addr); | ||
46 | } | ||
47 | |||
48 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) | 48 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) |
49 | { | 49 | { |
50 | return __arch_dma_to_virt(dev, addr); | 50 | return __arch_dma_to_virt(dev, addr); |
@@ -257,9 +257,11 @@ extern int dma_needs_bounce(struct device*, dma_addr_t, size_t); | |||
257 | */ | 257 | */ |
258 | extern dma_addr_t dma_map_single(struct device *, void *, size_t, | 258 | extern dma_addr_t dma_map_single(struct device *, void *, size_t, |
259 | enum dma_data_direction); | 259 | enum dma_data_direction); |
260 | extern void dma_unmap_single(struct device *, dma_addr_t, size_t, | ||
261 | enum dma_data_direction); | ||
260 | extern dma_addr_t dma_map_page(struct device *, struct page *, | 262 | extern dma_addr_t dma_map_page(struct device *, struct page *, |
261 | unsigned long, size_t, enum dma_data_direction); | 263 | unsigned long, size_t, enum dma_data_direction); |
262 | extern void dma_unmap_single(struct device *, dma_addr_t, size_t, | 264 | extern void dma_unmap_page(struct device *, dma_addr_t, size_t, |
263 | enum dma_data_direction); | 265 | enum dma_data_direction); |
264 | 266 | ||
265 | /* | 267 | /* |
@@ -352,7 +354,6 @@ static inline void dma_unmap_single(struct device *dev, dma_addr_t handle, | |||
352 | { | 354 | { |
353 | /* nothing to do */ | 355 | /* nothing to do */ |
354 | } | 356 | } |
355 | #endif /* CONFIG_DMABOUNCE */ | ||
356 | 357 | ||
357 | /** | 358 | /** |
358 | * dma_unmap_page - unmap a buffer previously mapped through dma_map_page() | 359 | * dma_unmap_page - unmap a buffer previously mapped through dma_map_page() |
@@ -371,8 +372,9 @@ static inline void dma_unmap_single(struct device *dev, dma_addr_t handle, | |||
371 | static inline void dma_unmap_page(struct device *dev, dma_addr_t handle, | 372 | static inline void dma_unmap_page(struct device *dev, dma_addr_t handle, |
372 | size_t size, enum dma_data_direction dir) | 373 | size_t size, enum dma_data_direction dir) |
373 | { | 374 | { |
374 | dma_unmap_single(dev, handle, size, dir); | 375 | /* nothing to do */ |
375 | } | 376 | } |
377 | #endif /* CONFIG_DMABOUNCE */ | ||
376 | 378 | ||
377 | /** | 379 | /** |
378 | * dma_sync_single_range_for_cpu | 380 | * dma_sync_single_range_for_cpu |
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index bc2ff8b28133..5421d82a2572 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h | |||
@@ -136,6 +136,12 @@ | |||
136 | #define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) | 136 | #define __phys_to_pfn(paddr) ((paddr) >> PAGE_SHIFT) |
137 | #define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) | 137 | #define __pfn_to_phys(pfn) ((pfn) << PAGE_SHIFT) |
138 | 138 | ||
139 | /* | ||
140 | * Convert a page to/from a physical address | ||
141 | */ | ||
142 | #define page_to_phys(page) (__pfn_to_phys(page_to_pfn(page))) | ||
143 | #define phys_to_page(phys) (pfn_to_page(__phys_to_pfn(phys))) | ||
144 | |||
139 | #ifndef __ASSEMBLY__ | 145 | #ifndef __ASSEMBLY__ |
140 | 146 | ||
141 | /* | 147 | /* |
@@ -196,7 +202,8 @@ static inline void *phys_to_virt(unsigned long x) | |||
196 | #ifndef __virt_to_bus | 202 | #ifndef __virt_to_bus |
197 | #define __virt_to_bus __virt_to_phys | 203 | #define __virt_to_bus __virt_to_phys |
198 | #define __bus_to_virt __phys_to_virt | 204 | #define __bus_to_virt __phys_to_virt |
199 | #define __pfn_to_bus(x) ((x) << PAGE_SHIFT) | 205 | #define __pfn_to_bus(x) __pfn_to_phys(x) |
206 | #define __bus_to_pfn(x) __phys_to_pfn(x) | ||
200 | #endif | 207 | #endif |
201 | 208 | ||
202 | static inline __deprecated unsigned long virt_to_bus(void *x) | 209 | static inline __deprecated unsigned long virt_to_bus(void *x) |
@@ -295,11 +302,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x) | |||
295 | #endif /* !CONFIG_DISCONTIGMEM */ | 302 | #endif /* !CONFIG_DISCONTIGMEM */ |
296 | 303 | ||
297 | /* | 304 | /* |
298 | * For BIO. "will die". Kill me when bio_to_phys() and bvec_to_phys() die. | ||
299 | */ | ||
300 | #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) | ||
301 | |||
302 | /* | ||
303 | * Optional coherency support. Currently used only by selected | 305 | * Optional coherency support. Currently used only by selected |
304 | * Intel XSC3-based systems. | 306 | * Intel XSC3-based systems. |
305 | */ | 307 | */ |
diff --git a/arch/arm/mach-iop13xx/include/mach/memory.h b/arch/arm/mach-iop13xx/include/mach/memory.h index 42ae29b288a1..25b1da9a5035 100644 --- a/arch/arm/mach-iop13xx/include/mach/memory.h +++ b/arch/arm/mach-iop13xx/include/mach/memory.h | |||
@@ -64,6 +64,8 @@ static inline unsigned long __lbus_to_virt(dma_addr_t x) | |||
64 | (dma_addr_t)page_to_phys(page); \ | 64 | (dma_addr_t)page_to_phys(page); \ |
65 | }) | 65 | }) |
66 | 66 | ||
67 | #define __arch_dma_to_page(dev, addr) phys_to_page(addr) | ||
68 | |||
67 | #endif /* CONFIG_ARCH_IOP13XX */ | 69 | #endif /* CONFIG_ARCH_IOP13XX */ |
68 | #endif /* !ASSEMBLY */ | 70 | #endif /* !ASSEMBLY */ |
69 | 71 | ||
diff --git a/arch/arm/mach-ks8695/include/mach/memory.h b/arch/arm/mach-ks8695/include/mach/memory.h index 76e5308685a4..ffa19aae6e05 100644 --- a/arch/arm/mach-ks8695/include/mach/memory.h +++ b/arch/arm/mach-ks8695/include/mach/memory.h | |||
@@ -41,6 +41,13 @@ extern struct bus_type platform_bus_type; | |||
41 | __dma = __dma - PHYS_OFFSET + KS8695_PCIMEM_PA; \ | 41 | __dma = __dma - PHYS_OFFSET + KS8695_PCIMEM_PA; \ |
42 | __dma; }) | 42 | __dma; }) |
43 | 43 | ||
44 | #define __arch_dma_to_page(dev, x) \ | ||
45 | ({ dma_addr_t __dma = x; \ | ||
46 | if (!is_lbus_device(dev)) \ | ||
47 | __dma += PHYS_OFFSET - KS8695_PCIMEM_PA; \ | ||
48 | phys_to_page(__dma); \ | ||
49 | }) | ||
50 | |||
44 | #endif | 51 | #endif |
45 | 52 | ||
46 | #endif | 53 | #endif |
diff --git a/arch/arm/plat-omap/include/mach/memory.h b/arch/arm/plat-omap/include/mach/memory.h index 9ad41dc484c1..3325f7b49eaa 100644 --- a/arch/arm/plat-omap/include/mach/memory.h +++ b/arch/arm/plat-omap/include/mach/memory.h | |||
@@ -68,6 +68,13 @@ | |||
68 | __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \ | 68 | __dma = __dma - PHYS_OFFSET + OMAP1510_LB_OFFSET; \ |
69 | __dma; }) | 69 | __dma; }) |
70 | 70 | ||
71 | #define __arch_dma_to_page(dev, addr) \ | ||
72 | ({ dma_addr_t __dma = addr; \ | ||
73 | if (is_lbus_device(dev)) \ | ||
74 | __dma += PHYS_OFFSET - OMAP1510_LB_OFFSET; \ | ||
75 | phys_to_page(__dma); \ | ||
76 | }) | ||
77 | |||
71 | #define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \ | 78 | #define __arch_dma_to_virt(dev, addr) ({ (void *) (is_lbus_device(dev) ? \ |
72 | lbus_to_virt(addr) : \ | 79 | lbus_to_virt(addr) : \ |
73 | __phys_to_virt(addr)); }) | 80 | __phys_to_virt(addr)); }) |