diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2013-01-22 06:23:57 -0500 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2013-02-15 12:46:15 -0500 |
commit | fc7943d29e9f6f5f6d4b111120b66ec86501673e (patch) | |
tree | 04a0c556489438b9c25613345bc1a25cef38819b /arch/arc | |
parent | decae9d3e87b5454b3b190d8e00b063175a3a091 (diff) |
ARC: [Review] Multi-platform image #6: cpu-to-dma-addr optional
All the current platforms can work with 0x8000_0000 based dma_addr_t
since the Bus Bridges typically ignore the top bit (the only excpetion
was Angel4 PCI-AHB bridge which we no longer care for).
That way we don't need plat-specific cpu-addr to bus-addr conversion.
Hooks still provided - just in case a platform has an obscure device
which say needs 0 based bus address.
That way <asm/dma_mapping.h> no longer needs to unconditinally include
<plat/dma_addr.h>
Also verfied that on Angel4 board, other peripherals (IDE-disk / EMAC)
work fine with 0x8000_0000 based dma addresses.
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch/arc')
-rw-r--r-- | arch/arc/Kconfig | 4 | ||||
-rw-r--r-- | arch/arc/include/asm/dma-mapping.h | 16 | ||||
-rw-r--r-- | arch/arc/plat-arcfpga/include/plat/dma_addr.h | 45 |
3 files changed, 20 insertions, 45 deletions
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index ac173687c056..be85ceb8b264 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig | |||
@@ -119,6 +119,10 @@ config CPU_BIG_ENDIAN | |||
119 | help | 119 | help |
120 | Build kernel for Big Endian Mode of ARC CPU | 120 | Build kernel for Big Endian Mode of ARC CPU |
121 | 121 | ||
122 | # If a platform can't work with 0x8000_0000 based dma_addr_t | ||
123 | config ARC_PLAT_NEEDS_CPU_TO_DMA | ||
124 | bool | ||
125 | |||
122 | config SMP | 126 | config SMP |
123 | bool "Symmetric Multi-Processing (Incomplete)" | 127 | bool "Symmetric Multi-Processing (Incomplete)" |
124 | default n | 128 | default n |
diff --git a/arch/arc/include/asm/dma-mapping.h b/arch/arc/include/asm/dma-mapping.h index 7fd150e97eb2..31f77aec0823 100644 --- a/arch/arc/include/asm/dma-mapping.h +++ b/arch/arc/include/asm/dma-mapping.h | |||
@@ -13,7 +13,23 @@ | |||
13 | 13 | ||
14 | #include <asm-generic/dma-coherent.h> | 14 | #include <asm-generic/dma-coherent.h> |
15 | #include <asm/cacheflush.h> | 15 | #include <asm/cacheflush.h> |
16 | |||
17 | #ifndef CONFIG_ARC_PLAT_NEEDS_CPU_TO_DMA | ||
18 | /* | ||
19 | * dma_map_* API take cpu addresses, which is kernel logical address in the | ||
20 | * untranslated address space (0x8000_0000) based. The dma address (bus addr) | ||
21 | * ideally needs to be 0x0000_0000 based hence these glue routines. | ||
22 | * However given that intermediate bus bridges can ignore the high bit, we can | ||
23 | * do with these routines being no-ops. | ||
24 | * If a platform/device comes up which sriclty requires 0 based bus addr | ||
25 | * (e.g. AHB-PCI bridge on Angel4 board), then it can provide it's own versions | ||
26 | */ | ||
27 | #define plat_dma_addr_to_kernel(dev, addr) ((unsigned long)(addr)) | ||
28 | #define plat_kernel_addr_to_dma(dev, ptr) ((dma_addr_t)(ptr)) | ||
29 | |||
30 | #else | ||
16 | #include <plat/dma_addr.h> | 31 | #include <plat/dma_addr.h> |
32 | #endif | ||
17 | 33 | ||
18 | void *dma_alloc_noncoherent(struct device *dev, size_t size, | 34 | void *dma_alloc_noncoherent(struct device *dev, size_t size, |
19 | dma_addr_t *dma_handle, gfp_t gfp); | 35 | dma_addr_t *dma_handle, gfp_t gfp); |
diff --git a/arch/arc/plat-arcfpga/include/plat/dma_addr.h b/arch/arc/plat-arcfpga/include/plat/dma_addr.h deleted file mode 100644 index 0e963431b729..000000000000 --- a/arch/arc/plat-arcfpga/include/plat/dma_addr.h +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | * | ||
8 | * vineetg: Feb 2009 | ||
9 | * -For AA4 board, kernel to DMA address APIs | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * kernel addresses are 0x800_000 based, while Bus addr are 0 based | ||
14 | */ | ||
15 | |||
16 | #ifndef __PLAT_DMA_ADDR_H | ||
17 | #define __PLAT_DMA_ADDR_H | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | |||
21 | static inline unsigned long plat_dma_addr_to_kernel(struct device *dev, | ||
22 | dma_addr_t dma_addr) | ||
23 | { | ||
24 | return dma_addr + PAGE_OFFSET; | ||
25 | } | ||
26 | |||
27 | static inline dma_addr_t plat_kernel_addr_to_dma(struct device *dev, void *ptr) | ||
28 | { | ||
29 | unsigned long addr = (unsigned long)ptr; | ||
30 | /* | ||
31 | * To Catch buggy drivers which can call DMA map API with kernel vaddr | ||
32 | * i.e. for buffers alloc via vmalloc or ioremap which are not | ||
33 | * gaurnateed to be PHY contiguous and hence unfit for DMA anyways. | ||
34 | * On ARC kernel virtual address is 0x7000_0000 to 0x7FFF_FFFF, so | ||
35 | * ideally we want to check this range here, but our implementation is | ||
36 | * better as it checks for even worse user virtual address as well. | ||
37 | */ | ||
38 | if (likely(addr >= PAGE_OFFSET)) | ||
39 | return addr - PAGE_OFFSET; | ||
40 | |||
41 | BUG(); | ||
42 | return addr; | ||
43 | } | ||
44 | |||
45 | #endif | ||