aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2014-05-23 12:48:05 -0400
committerArnd Bergmann <arnd@arndb.de>2014-05-23 15:57:52 -0400
commita36d82e9d3c92f692c7ad68b72b4c1ea87905090 (patch)
tree6e18e218aa21c41fe336c38af0562560a447207c /arch
parent3c2580173e3bc820a8f8c0db968f757b8eca7fe5 (diff)
parent597537730bfc24f61189bac197884d50e1e42248 (diff)
Merge branch 'depends/dma-ranges' into next/soc
This branch has been picked up by rmk to be merged through his tree, and is required as a base for the keystone changes. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/include/asm/dma-mapping.h25
-rw-r--r--arch/arm/mm/dma-mapping.c4
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
59static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) 59static 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
64static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr) 66static 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
69static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) 76static 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
74static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) 87static 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
124static 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
108static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) 131static 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 6b00be1f971e..18e98dfb73fc 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,
885static void __dma_page_cpu_to_dev(struct page *page, unsigned long off, 885static 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,
901static void __dma_page_dev_to_cpu(struct page *page, unsigned long off, 901static 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 /* don't bother invalidating if DMA to device */ 907 /* don't bother invalidating if DMA to device */