Message ID | 20140428104643.215725974@linutronix.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Monday 28 April 2014 04:19 PM, Thomas Gleixner wrote: > As Joel pointed out, edma_read_position() uses memcpy_fromio() to read > the parameter ram. That's not synchronized with the internal update as > it does a byte by byte copy. We need to do a 32bit read to get a > consistent value. > > Further reading destination and source is pointless. In DEV_TO_MEM > transfers we are only interested in the destination, in MEM_TO_DEV we > care about the source. In MEM_TO_MEM it really does not matter which > one you read. > > Simple solution: Remove the pointers, select dest/source via a bool > and return the read value. > Remove the export of this function while at it. The only potential > user is the dmaengine and that's always builtin. While this is true today, there are other DMA drivers which are modules. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Irrespective of above, Acked-by: Sekhar Nori <nsekhar@ti.com> Thanks, Sekhar
On 04/28/2014 05:49 AM, Thomas Gleixner wrote: > As Joel pointed out, edma_read_position() uses memcpy_fromio() to read > the parameter ram. That's not synchronized with the internal update as > it does a byte by byte copy. We need to do a 32bit read to get a > consistent value. > > Further reading destination and source is pointless. In DEV_TO_MEM > transfers we are only interested in the destination, in MEM_TO_DEV we > care about the source. In MEM_TO_MEM it really does not matter which > one you read. > > Simple solution: Remove the pointers, select dest/source via a bool > and return the read value. > > Remove the export of this function while at it. The only potential > user is the dmaengine and that's always builtin. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Thanks, this looks good. Acked-by: Joel Fernandes <joelf@ti.com> Regards, -Joel
Index: linux-2.6/arch/arm/common/edma.c =================================================================== --- linux-2.6.orig/arch/arm/common/edma.c +++ linux-2.6/arch/arm/common/edma.c @@ -994,29 +994,23 @@ void edma_set_dest(unsigned slot, dma_ad EXPORT_SYMBOL(edma_set_dest); /** - * edma_get_position - returns the current transfer points + * edma_get_position - returns the current transfer point * @slot: parameter RAM slot being examined - * @src: pointer to source port position - * @dst: pointer to destination port position + * @dst: true selects the dest position, false the source * - * Returns current source and destination addresses for a particular - * parameter RAM slot. Its channel should not be active when this is called. + * Returns the position of the current active slot */ -void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst) +dma_addr_t edma_get_position(unsigned slot, bool dst) { - struct edmacc_param temp; - unsigned ctlr; + u32 offs, ctlr = EDMA_CTLR(slot); - ctlr = EDMA_CTLR(slot); slot = EDMA_CHAN_SLOT(slot); - edma_read_slot(EDMA_CTLR_CHAN(ctlr, slot), &temp); - if (src != NULL) - *src = temp.src; - if (dst != NULL) - *dst = temp.dst; + offs = PARM_OFFSET(slot); + offs += dst ? PARM_DST : PARM_SRC; + + return edma_read(ctlr, offs); } -EXPORT_SYMBOL(edma_get_position); /** * edma_set_src_index - configure DMA source address indexing Index: linux-2.6/include/linux/platform_data/edma.h =================================================================== --- linux-2.6.orig/include/linux/platform_data/edma.h +++ linux-2.6/include/linux/platform_data/edma.h @@ -130,7 +130,7 @@ void edma_set_src(unsigned slot, dma_add enum address_mode mode, enum fifo_width); void edma_set_dest(unsigned slot, dma_addr_t dest_port, enum address_mode mode, enum fifo_width); -void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst); +dma_addr_t edma_get_position(unsigned slot, bool dst); void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx); void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx); void edma_set_transfer_params(unsigned slot, u16 acnt, u16 bcnt, u16 ccnt,
As Joel pointed out, edma_read_position() uses memcpy_fromio() to read the parameter ram. That's not synchronized with the internal update as it does a byte by byte copy. We need to do a 32bit read to get a consistent value. Further reading destination and source is pointless. In DEV_TO_MEM transfers we are only interested in the destination, in MEM_TO_DEV we care about the source. In MEM_TO_MEM it really does not matter which one you read. Simple solution: Remove the pointers, select dest/source via a bool and return the read value. Remove the export of this function while at it. The only potential user is the dmaengine and that's always builtin. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> --- arch/arm/common/edma.c | 24 +++++++++--------------- include/linux/platform_data/edma.h | 2 +- 2 files changed, 10 insertions(+), 16 deletions(-)