diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-06-05 07:36:22 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-06-05 07:36:22 -0400 |
commit | bd63ce27d9d62bc40a962b991cbbbe4f0dc913d2 (patch) | |
tree | bd998b187b7ea4e9f28c0c61912b701bc6ff6420 /arch | |
parent | 1fb333489fb917c704ad43e51b45c12f52215a9c (diff) | |
parent | 6b74f61a471ad0f3a5e919e314d4f60cd3966f5e (diff) |
Merge branch 'devel-stable' into for-next
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/include/asm/dma-mapping.h | 25 | ||||
-rw-r--r-- | arch/arm/mm/dma-mapping.c | 4 |
2 files changed, 26 insertions, 3 deletions
diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index e701a4d9aa59..c45b61a4b4a5 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h | |||
@@ -58,21 +58,37 @@ static inline int dma_set_mask(struct device *dev, u64 mask) | |||
58 | #ifndef __arch_pfn_to_dma | 58 | #ifndef __arch_pfn_to_dma |
59 | static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) | 59 | static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) |
60 | { | 60 | { |
61 | if (dev) | ||
62 | pfn -= dev->dma_pfn_offset; | ||
61 | return (dma_addr_t)__pfn_to_bus(pfn); | 63 | return (dma_addr_t)__pfn_to_bus(pfn); |
62 | } | 64 | } |
63 | 65 | ||
64 | static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) | 66 | static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) |
65 | { | 67 | { |
66 | return __bus_to_pfn(addr); | 68 | unsigned long pfn = __bus_to_pfn(addr); |
69 | |||
70 | if (dev) | ||
71 | pfn += dev->dma_pfn_offset; | ||
72 | |||
73 | return pfn; | ||
67 | } | 74 | } |
68 | 75 | ||
69 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) | 76 | static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) |
70 | { | 77 | { |
78 | if (dev) { | ||
79 | unsigned long pfn = dma_to_pfn(dev, addr); | ||
80 | |||
81 | return phys_to_virt(__pfn_to_phys(pfn)); | ||
82 | } | ||
83 | |||
71 | return (void *)__bus_to_virt((unsigned long)addr); | 84 | return (void *)__bus_to_virt((unsigned long)addr); |
72 | } | 85 | } |
73 | 86 | ||
74 | static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) | 87 | static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) |
75 | { | 88 | { |
89 | if (dev) | ||
90 | return pfn_to_dma(dev, virt_to_pfn(addr)); | ||
91 | |||
76 | return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); | 92 | return (dma_addr_t)__virt_to_bus((unsigned long)(addr)); |
77 | } | 93 | } |
78 | 94 | ||
@@ -105,6 +121,13 @@ static inline unsigned long dma_max_pfn(struct device *dev) | |||
105 | } | 121 | } |
106 | #define dma_max_pfn(dev) dma_max_pfn(dev) | 122 | #define dma_max_pfn(dev) dma_max_pfn(dev) |
107 | 123 | ||
124 | static inline int set_arch_dma_coherent_ops(struct device *dev) | ||
125 | { | ||
126 | set_dma_ops(dev, &arm_coherent_dma_ops); | ||
127 | return 0; | ||
128 | } | ||
129 | #define set_arch_dma_coherent_ops(dev) set_arch_dma_coherent_ops(dev) | ||
130 | |||
108 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) | 131 | static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) |
109 | { | 132 | { |
110 | unsigned int offset = paddr & ~PAGE_MASK; | 133 | unsigned int offset = paddr & ~PAGE_MASK; |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index b05e08c4734c..85a109bf2e2e 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -885,7 +885,7 @@ static void dma_cache_maint_page(struct page *page, unsigned long offset, | |||
885 | static void __dma_page_cpu_to_dev(struct page *page, unsigned long off, | 885 | static void __dma_page_cpu_to_dev(struct page *page, unsigned long off, |
886 | size_t size, enum dma_data_direction dir) | 886 | size_t size, enum dma_data_direction dir) |
887 | { | 887 | { |
888 | unsigned long paddr; | 888 | phys_addr_t paddr; |
889 | 889 | ||
890 | dma_cache_maint_page(page, off, size, dir, dmac_map_area); | 890 | dma_cache_maint_page(page, off, size, dir, dmac_map_area); |
891 | 891 | ||
@@ -901,7 +901,7 @@ static void __dma_page_cpu_to_dev(struct page *page, unsigned long off, | |||
901 | static void __dma_page_dev_to_cpu(struct page *page, unsigned long off, | 901 | static void __dma_page_dev_to_cpu(struct page *page, unsigned long off, |
902 | size_t size, enum dma_data_direction dir) | 902 | size_t size, enum dma_data_direction dir) |
903 | { | 903 | { |
904 | unsigned long paddr = page_to_phys(page) + off; | 904 | phys_addr_t paddr = page_to_phys(page) + off; |
905 | 905 | ||
906 | /* FIXME: non-speculating: not required */ | 906 | /* FIXME: non-speculating: not required */ |
907 | /* in any case, don't bother invalidating if DMA to device */ | 907 | /* in any case, don't bother invalidating if DMA to device */ |