aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/davinci_cpdma.c
diff options
context:
space:
mode:
authorSriram <srk@ti.com>2011-03-21 22:31:03 -0400
committerDavid S. Miller <davem@davemloft.net>2011-03-22 22:25:05 -0400
commit6a1fef6d000944911df0f160f366111daa10740a (patch)
tree905c6f7f078b0fcb8427d28f7a4bd23082316f1f /drivers/net/davinci_cpdma.c
parent9c7a4f9ce651383c73dfdff3d7e21d5f9572c4ec (diff)
net: davinci_emac:Fix translation logic for buffer descriptor
With recent changes to the driver(switch to new cpdma layer), the support for buffer descriptor address translation logic is broken. This affects platforms where the physical address of the descriptors as seen by the DMA engine is different from the physical address. Original Patch adding translation logic support: Commit: ad021ae8862209864dc8ebd3b7d3a55ce84b9ea2 Signed-off-by: Sriramakrishnan A G <srk@ti.com> Tested-By: Sekhar Nori <nsekhar@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/davinci_cpdma.c')
-rw-r--r--drivers/net/davinci_cpdma.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/net/davinci_cpdma.c b/drivers/net/davinci_cpdma.c
index e92b2b6cd8c..ae47f23ba93 100644
--- a/drivers/net/davinci_cpdma.c
+++ b/drivers/net/davinci_cpdma.c
@@ -76,6 +76,7 @@ struct cpdma_desc {
76 76
77struct cpdma_desc_pool { 77struct cpdma_desc_pool {
78 u32 phys; 78 u32 phys;
79 u32 hw_addr;
79 void __iomem *iomap; /* ioremap map */ 80 void __iomem *iomap; /* ioremap map */
80 void *cpumap; /* dma_alloc map */ 81 void *cpumap; /* dma_alloc map */
81 int desc_size, mem_size; 82 int desc_size, mem_size;
@@ -137,7 +138,8 @@ struct cpdma_chan {
137 * abstract out these details 138 * abstract out these details
138 */ 139 */
139static struct cpdma_desc_pool * 140static struct cpdma_desc_pool *
140cpdma_desc_pool_create(struct device *dev, u32 phys, int size, int align) 141cpdma_desc_pool_create(struct device *dev, u32 phys, u32 hw_addr,
142 int size, int align)
141{ 143{
142 int bitmap_size; 144 int bitmap_size;
143 struct cpdma_desc_pool *pool; 145 struct cpdma_desc_pool *pool;
@@ -161,10 +163,12 @@ cpdma_desc_pool_create(struct device *dev, u32 phys, int size, int align)
161 if (phys) { 163 if (phys) {
162 pool->phys = phys; 164 pool->phys = phys;
163 pool->iomap = ioremap(phys, size); 165 pool->iomap = ioremap(phys, size);
166 pool->hw_addr = hw_addr;
164 } else { 167 } else {
165 pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys, 168 pool->cpumap = dma_alloc_coherent(dev, size, &pool->phys,
166 GFP_KERNEL); 169 GFP_KERNEL);
167 pool->iomap = (void __force __iomem *)pool->cpumap; 170 pool->iomap = (void __force __iomem *)pool->cpumap;
171 pool->hw_addr = pool->phys;
168 } 172 }
169 173
170 if (pool->iomap) 174 if (pool->iomap)
@@ -201,14 +205,14 @@ static inline dma_addr_t desc_phys(struct cpdma_desc_pool *pool,
201{ 205{
202 if (!desc) 206 if (!desc)
203 return 0; 207 return 0;
204 return pool->phys + (__force dma_addr_t)desc - 208 return pool->hw_addr + (__force dma_addr_t)desc -
205 (__force dma_addr_t)pool->iomap; 209 (__force dma_addr_t)pool->iomap;
206} 210}
207 211
208static inline struct cpdma_desc __iomem * 212static inline struct cpdma_desc __iomem *
209desc_from_phys(struct cpdma_desc_pool *pool, dma_addr_t dma) 213desc_from_phys(struct cpdma_desc_pool *pool, dma_addr_t dma)
210{ 214{
211 return dma ? pool->iomap + dma - pool->phys : NULL; 215 return dma ? pool->iomap + dma - pool->hw_addr : NULL;
212} 216}
213 217
214static struct cpdma_desc __iomem * 218static struct cpdma_desc __iomem *
@@ -260,6 +264,7 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
260 264
261 ctlr->pool = cpdma_desc_pool_create(ctlr->dev, 265 ctlr->pool = cpdma_desc_pool_create(ctlr->dev,
262 ctlr->params.desc_mem_phys, 266 ctlr->params.desc_mem_phys,
267 ctlr->params.desc_hw_addr,
263 ctlr->params.desc_mem_size, 268 ctlr->params.desc_mem_size,
264 ctlr->params.desc_align); 269 ctlr->params.desc_align);
265 if (!ctlr->pool) { 270 if (!ctlr->pool) {