]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
dmaengine: Use sg_dma_address instead of sg_phys
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 25 Apr 2012 18:50:51 +0000 (20:50 +0200)
committerVinod Koul <vinod.koul@linux.intel.com>
Fri, 11 May 2012 06:34:38 +0000 (12:04 +0530)
dmaengine drivers should always use sg_dma_address instead of sg_phys to get the
addresses for the transfer from a sg element.

To quote Russel King:
sg_phys(sg) of course has nothing to do with DMA addresses. It's the
physical address _to the CPU_ of the memory associated with the scatterlist
entry. That may, or may not have the same value for the DMA engine,
particularly if IOMMUs are involved.

And if these drivers are used on ARM, they must be fixed, sooner rather
than later.  There's patches in the works which will mean we will end up
with IOMMU support in the DMA mapping later, which means everything I've
said above will become reality.

The patch has been generated using the following coccinelle patch:
<smpl>
@@
struct scatterlist *sg;
@@
-sg_phys(sg)
+sg_dma_address(sg)
</smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
drivers/dma/amba-pl08x.c
drivers/dma/coh901318_lli.c
drivers/dma/dw_dmac.c
drivers/dma/intel_mid_dma.c
drivers/dma/pch_dma.c

index e7d5550266e07b5141f7f1afdf6f9fdb83589471..003220a60bcb156b2ee98ecc46a9447493585edf 100644 (file)
@@ -1382,11 +1382,11 @@ static struct dma_async_tx_descriptor *pl08x_prep_slave_sg(
 
                dsg->len = sg_dma_len(sg);
                if (direction == DMA_MEM_TO_DEV) {
-                       dsg->src_addr = sg_phys(sg);
+                       dsg->src_addr = sg_dma_address(sg);
                        dsg->dst_addr = slave_addr;
                } else {
                        dsg->src_addr = slave_addr;
-                       dsg->dst_addr = sg_phys(sg);
+                       dsg->dst_addr = sg_dma_address(sg);
                }
        }
 
index 6c0e2d4c66827c7a179a55c8bc52375b932dfaa1..780e0429b38cd30236001e4a121cefc6fa347aea 100644 (file)
@@ -270,10 +270,10 @@ coh901318_lli_fill_sg(struct coh901318_pool *pool,
 
                if (dir == DMA_MEM_TO_DEV)
                        /* increment source address */
-                       src = sg_phys(sg);
+                       src = sg_dma_address(sg);
                else
                        /* increment destination address */
-                       dst =  sg_phys(sg);
+                       dst = sg_dma_address(sg);
 
                bytes_to_transfer = sg_dma_len(sg);
 
index 13b92983b241e4921af97d2ab3706ac23a473729..e23dc82d43acbb726c0825e3f259c53803cd3c58 100644 (file)
@@ -743,7 +743,7 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
                        struct dw_desc  *desc;
                        u32             len, dlen, mem;
 
-                       mem = sg_phys(sg);
+                       mem = sg_dma_address(sg);
                        len = sg_dma_len(sg);
 
                        if (!((mem | len) & 7))
@@ -810,7 +810,7 @@ slave_sg_todev_fill_desc:
                        struct dw_desc  *desc;
                        u32             len, dlen, mem;
 
-                       mem = sg_phys(sg);
+                       mem = sg_dma_address(sg);
                        len = sg_dma_len(sg);
 
                        if (!((mem | len) & 7))
index c900ca7aaec4b16d2ad5292c9997ff51d9616492..d0ef5937fbf64ceb168e790d0a4780bdf063f96c 100644 (file)
@@ -398,7 +398,7 @@ static int midc_lli_fill_sg(struct intel_mid_dma_chan *midc,
                                                        desc->width,
                                                        midc->dma->block_size);
                /*Populate SAR and DAR values*/
-               sg_phy_addr = sg_phys(sg);
+               sg_phy_addr = sg_dma_address(sg);
                if (desc->dirn ==  DMA_MEM_TO_DEV) {
                        lli_bloc_desc->sar  = sg_phy_addr;
                        lli_bloc_desc->dar  = mids->dma_slave.dst_addr;
index 65c0495a6d40b74a1f0d7dc659f4ff72ec7c4c63..987ab5cd2617a1cc15fa807aba82ae411af5f77b 100644 (file)
@@ -621,7 +621,7 @@ static struct dma_async_tx_descriptor *pd_prep_slave_sg(struct dma_chan *chan,
                        goto err_desc_get;
 
                desc->regs.dev_addr = reg;
-               desc->regs.mem_addr = sg_phys(sg);
+               desc->regs.mem_addr = sg_dma_address(sg);
                desc->regs.size = sg_dma_len(sg);
                desc->regs.next = DMA_DESC_FOLLOW_WITHOUT_IRQ;