diff options
author | Michael Ellerman <michael@ellerman.id.au> | 2008-01-21 00:42:43 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2008-01-25 06:52:54 -0500 |
commit | 35e4a6e26d0c6bc7f32087db61f0fb3666531183 (patch) | |
tree | 5ff6c3e0067e0cdfbbae9c6d8c18370070ac0639 /arch | |
parent | 450d87eaeb4d43bd9e1f9523a6a3bfeb48209fea (diff) |
[POWERPC] Use archdata.dma_data in dma_direct_ops and add the offset
Now that all platforms using dma_direct_offset setup the
archdata.dma_data correctly, we can change the dma_direct_ops to
retrieve the offset from the dma_data, rather than directly from the
global.
While we're here, change the way the offset is used - instead of
or'ing it into the value, add it. This should have no effect on
current implementations where the offset is far larger than memory,
however in future we may want to use smaller offsets.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/kernel/dma_64.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/arch/powerpc/kernel/dma_64.c b/arch/powerpc/kernel/dma_64.c index 14206e3f0819..a2d076d005c0 100644 --- a/arch/powerpc/kernel/dma_64.c +++ b/arch/powerpc/kernel/dma_64.c | |||
@@ -117,6 +117,11 @@ EXPORT_SYMBOL(dma_iommu_ops); | |||
117 | */ | 117 | */ |
118 | unsigned long dma_direct_offset; | 118 | unsigned long dma_direct_offset; |
119 | 119 | ||
120 | static unsigned long get_dma_direct_offset(struct device *dev) | ||
121 | { | ||
122 | return (unsigned long)dev->archdata.dma_data; | ||
123 | } | ||
124 | |||
120 | static void *dma_direct_alloc_coherent(struct device *dev, size_t size, | 125 | static void *dma_direct_alloc_coherent(struct device *dev, size_t size, |
121 | dma_addr_t *dma_handle, gfp_t flag) | 126 | dma_addr_t *dma_handle, gfp_t flag) |
122 | { | 127 | { |
@@ -130,7 +135,7 @@ static void *dma_direct_alloc_coherent(struct device *dev, size_t size, | |||
130 | return NULL; | 135 | return NULL; |
131 | ret = page_address(page); | 136 | ret = page_address(page); |
132 | memset(ret, 0, size); | 137 | memset(ret, 0, size); |
133 | *dma_handle = virt_to_abs(ret) | dma_direct_offset; | 138 | *dma_handle = virt_to_abs(ret) + get_dma_direct_offset(dev); |
134 | 139 | ||
135 | return ret; | 140 | return ret; |
136 | } | 141 | } |
@@ -145,7 +150,7 @@ static dma_addr_t dma_direct_map_single(struct device *dev, void *ptr, | |||
145 | size_t size, | 150 | size_t size, |
146 | enum dma_data_direction direction) | 151 | enum dma_data_direction direction) |
147 | { | 152 | { |
148 | return virt_to_abs(ptr) | dma_direct_offset; | 153 | return virt_to_abs(ptr) + get_dma_direct_offset(dev); |
149 | } | 154 | } |
150 | 155 | ||
151 | static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr, | 156 | static void dma_direct_unmap_single(struct device *dev, dma_addr_t dma_addr, |
@@ -161,7 +166,7 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, | |||
161 | int i; | 166 | int i; |
162 | 167 | ||
163 | for_each_sg(sgl, sg, nents, i) { | 168 | for_each_sg(sgl, sg, nents, i) { |
164 | sg->dma_address = sg_phys(sg) | dma_direct_offset; | 169 | sg->dma_address = sg_phys(sg) + get_dma_direct_offset(dev); |
165 | sg->dma_length = sg->length; | 170 | sg->dma_length = sg->length; |
166 | } | 171 | } |
167 | 172 | ||