* [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation
[not found] <Pine.LNX.4.64.1401311237080.3234@axis700.grange>
@ 2014-01-31 11:54 ` Guennadi Liakhovetski
2014-02-04 0:57 ` Simon Horman
2014-02-06 12:01 ` Ben Dooks
2014-01-31 11:54 ` [PATCH 2/3] mmc: sh-mmcif: " Guennadi Liakhovetski
1 sibling, 2 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2014-01-31 11:54 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, linux-sh, linux-arm-kernel
According to the DMA API data has to be synchronised before starting
a DMA transfer to device and after completing a DMA transfer from device.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/mmc/host/tmio_mmc_dma.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
index 65edb4a..a997b94 100644
--- a/drivers/mmc/host/tmio_mmc_dma.c
+++ b/drivers/mmc/host/tmio_mmc_dma.c
@@ -168,9 +168,12 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host)
}
ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE);
- if (ret > 0)
+ if (ret > 0) {
+ dma_sync_sg_for_device(chan->device->dev, sg, host->sg_len,
+ DMA_TO_DEVICE);
desc = dmaengine_prep_slave_sg(chan, sg, ret,
DMA_MEM_TO_DEV, DMA_CTRL_ACK);
+ }
if (desc) {
cookie = dmaengine_submit(desc);
@@ -247,14 +250,14 @@ static void tmio_mmc_tasklet_fn(unsigned long arg)
if (!host->data)
goto out;
- if (host->data->flags & MMC_DATA_READ)
- dma_unmap_sg(host->chan_rx->device->dev,
- host->sg_ptr, host->sg_len,
- DMA_FROM_DEVICE);
- else
- dma_unmap_sg(host->chan_tx->device->dev,
- host->sg_ptr, host->sg_len,
- DMA_TO_DEVICE);
+ if (host->data->flags & MMC_DATA_READ) {
+ struct device *dev = host->chan_rx->device->dev;
+ dma_unmap_sg(dev, host->sg_ptr, host->sg_len, DMA_FROM_DEVICE);
+ dma_sync_sg_for_cpu(dev, host->sg_ptr, host->sg_len, DMA_FROM_DEVICE);
+ } else {
+ struct device *dev = host->chan_tx->device->dev;
+ dma_unmap_sg(dev, host->sg_ptr, host->sg_len, DMA_TO_DEVICE);
+ }
tmio_mmc_do_data_irq(host);
out:
--
1.7.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] mmc: sh-mmcif: add DMA SG synchronisation
[not found] <Pine.LNX.4.64.1401311237080.3234@axis700.grange>
2014-01-31 11:54 ` [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation Guennadi Liakhovetski
@ 2014-01-31 11:54 ` Guennadi Liakhovetski
2014-02-04 0:57 ` Simon Horman
1 sibling, 1 reply; 6+ messages in thread
From: Guennadi Liakhovetski @ 2014-01-31 11:54 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, linux-sh, linux-arm-kernel
According to the DMA API data has to be synchronised before starting
a DMA transfer to device and after completing a DMA transfer from device.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
---
drivers/mmc/host/sh_mmcif.c | 18 ++++++++++--------
1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index d032b08..902780c 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -345,6 +345,8 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host)
DMA_TO_DEVICE);
if (ret > 0) {
host->dma_active = true;
+ dma_sync_sg_for_device(chan->device->dev, sg, data->sg_len,
+ DMA_TO_DEVICE);
desc = dmaengine_prep_slave_sg(chan, sg, ret,
DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
}
@@ -1118,14 +1120,14 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host)
time = wait_for_completion_interruptible_timeout(&host->dma_complete,
host->timeout);
- if (data->flags & MMC_DATA_READ)
- dma_unmap_sg(host->chan_rx->device->dev,
- data->sg, data->sg_len,
- DMA_FROM_DEVICE);
- else
- dma_unmap_sg(host->chan_tx->device->dev,
- data->sg, data->sg_len,
- DMA_TO_DEVICE);
+ if (data->flags & MMC_DATA_READ) {
+ struct device *dev = host->chan_rx->device->dev;
+ dma_unmap_sg(dev, data->sg, data->sg_len, DMA_FROM_DEVICE);
+ dma_sync_sg_for_cpu(dev, data->sg, data->sg_len, DMA_FROM_DEVICE);
+ } else {
+ struct device *dev = host->chan_tx->device->dev;
+ dma_unmap_sg(dev, data->sg, data->sg_len, DMA_TO_DEVICE);
+ }
if (host->sd_error) {
dev_err(host->mmc->parent,
--
1.7.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation
2014-01-31 11:54 ` [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation Guennadi Liakhovetski
@ 2014-02-04 0:57 ` Simon Horman
2014-02-06 12:01 ` Ben Dooks
1 sibling, 0 replies; 6+ messages in thread
From: Simon Horman @ 2014-02-04 0:57 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jan 31, 2014 at 12:54:19PM +0100, Guennadi Liakhovetski wrote:
> According to the DMA API data has to be synchronised before starting
> a DMA transfer to device and after completing a DMA transfer from device.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/mmc/host/tmio_mmc_dma.c | 21 ++++++++++++---------
> 1 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c
> index 65edb4a..a997b94 100644
> --- a/drivers/mmc/host/tmio_mmc_dma.c
> +++ b/drivers/mmc/host/tmio_mmc_dma.c
> @@ -168,9 +168,12 @@ static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host)
> }
>
> ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE);
> - if (ret > 0)
> + if (ret > 0) {
> + dma_sync_sg_for_device(chan->device->dev, sg, host->sg_len,
> + DMA_TO_DEVICE);
> desc = dmaengine_prep_slave_sg(chan, sg, ret,
> DMA_MEM_TO_DEV, DMA_CTRL_ACK);
> + }
>
> if (desc) {
> cookie = dmaengine_submit(desc);
> @@ -247,14 +250,14 @@ static void tmio_mmc_tasklet_fn(unsigned long arg)
> if (!host->data)
> goto out;
>
> - if (host->data->flags & MMC_DATA_READ)
> - dma_unmap_sg(host->chan_rx->device->dev,
> - host->sg_ptr, host->sg_len,
> - DMA_FROM_DEVICE);
> - else
> - dma_unmap_sg(host->chan_tx->device->dev,
> - host->sg_ptr, host->sg_len,
> - DMA_TO_DEVICE);
> + if (host->data->flags & MMC_DATA_READ) {
> + struct device *dev = host->chan_rx->device->dev;
> + dma_unmap_sg(dev, host->sg_ptr, host->sg_len, DMA_FROM_DEVICE);
> + dma_sync_sg_for_cpu(dev, host->sg_ptr, host->sg_len, DMA_FROM_DEVICE);
> + } else {
> + struct device *dev = host->chan_tx->device->dev;
> + dma_unmap_sg(dev, host->sg_ptr, host->sg_len, DMA_TO_DEVICE);
> + }
>
> tmio_mmc_do_data_irq(host);
> out:
> --
> 1.7.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/3] mmc: sh-mmcif: add DMA SG synchronisation
2014-01-31 11:54 ` [PATCH 2/3] mmc: sh-mmcif: " Guennadi Liakhovetski
@ 2014-02-04 0:57 ` Simon Horman
0 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2014-02-04 0:57 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Jan 31, 2014 at 12:54:29PM +0100, Guennadi Liakhovetski wrote:
> According to the DMA API data has to be synchronised before starting
> a DMA transfer to device and after completing a DMA transfer from device.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> ---
> drivers/mmc/host/sh_mmcif.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
> index d032b08..902780c 100644
> --- a/drivers/mmc/host/sh_mmcif.c
> +++ b/drivers/mmc/host/sh_mmcif.c
> @@ -345,6 +345,8 @@ static void sh_mmcif_start_dma_tx(struct sh_mmcif_host *host)
> DMA_TO_DEVICE);
> if (ret > 0) {
> host->dma_active = true;
> + dma_sync_sg_for_device(chan->device->dev, sg, data->sg_len,
> + DMA_TO_DEVICE);
> desc = dmaengine_prep_slave_sg(chan, sg, ret,
> DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> }
> @@ -1118,14 +1120,14 @@ static bool sh_mmcif_end_cmd(struct sh_mmcif_host *host)
> time = wait_for_completion_interruptible_timeout(&host->dma_complete,
> host->timeout);
>
> - if (data->flags & MMC_DATA_READ)
> - dma_unmap_sg(host->chan_rx->device->dev,
> - data->sg, data->sg_len,
> - DMA_FROM_DEVICE);
> - else
> - dma_unmap_sg(host->chan_tx->device->dev,
> - data->sg, data->sg_len,
> - DMA_TO_DEVICE);
> + if (data->flags & MMC_DATA_READ) {
> + struct device *dev = host->chan_rx->device->dev;
> + dma_unmap_sg(dev, data->sg, data->sg_len, DMA_FROM_DEVICE);
> + dma_sync_sg_for_cpu(dev, data->sg, data->sg_len, DMA_FROM_DEVICE);
> + } else {
> + struct device *dev = host->chan_tx->device->dev;
> + dma_unmap_sg(dev, data->sg, data->sg_len, DMA_TO_DEVICE);
> + }
>
> if (host->sd_error) {
> dev_err(host->mmc->parent,
> --
> 1.7.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation
2014-01-31 11:54 ` [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation Guennadi Liakhovetski
2014-02-04 0:57 ` Simon Horman
@ 2014-02-06 12:01 ` Ben Dooks
2014-02-06 12:06 ` Guennadi Liakhovetski
1 sibling, 1 reply; 6+ messages in thread
From: Ben Dooks @ 2014-02-06 12:01 UTC (permalink / raw)
To: linux-arm-kernel
On 31/01/14 11:54, Guennadi Liakhovetski wrote:
> According to the DMA API data has to be synchronised before starting
> a DMA transfer to device and after completing a DMA transfer from device.
>
> Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
I've got 1/3 and 2/3, but not 3/3 ?
--
Ben Dooks http://www.codethink.co.uk/
Senior Engineer Codethink - Providing Genius
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation
2014-02-06 12:01 ` Ben Dooks
@ 2014-02-06 12:06 ` Guennadi Liakhovetski
0 siblings, 0 replies; 6+ messages in thread
From: Guennadi Liakhovetski @ 2014-02-06 12:06 UTC (permalink / raw)
To: Ben Dooks; +Cc: linux-mmc, Chris Ball, linux-sh, linux-arm-kernel
Hi Ben
On Thu, 6 Feb 2014, Ben Dooks wrote:
> On 31/01/14 11:54, Guennadi Liakhovetski wrote:
> > According to the DMA API data has to be synchronised before starting
> > a DMA transfer to device and after completing a DMA transfer from device.
> >
> > Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
>
> I've got 1/3 and 2/3, but not 3/3 ?
Unfortunately that thread didn't make it to the ALKML - all patches
bounced, so, they only arrived to sh and mmc. (A day before and a couple
of hours later posting to ALKML worked just fine, just that one time...).
You can view the whole thread here
http://thread.gmane.org/gmane.linux.kernel.mmc/24969/focus$972
Thanks
Guennadi
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-06 12:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <Pine.LNX.4.64.1401311237080.3234@axis700.grange>
2014-01-31 11:54 ` [PATCH 1/3] mmc: tmio-mmc: add DMA SG synchronisation Guennadi Liakhovetski
2014-02-04 0:57 ` Simon Horman
2014-02-06 12:01 ` Ben Dooks
2014-02-06 12:06 ` Guennadi Liakhovetski
2014-01-31 11:54 ` [PATCH 2/3] mmc: sh-mmcif: " Guennadi Liakhovetski
2014-02-04 0:57 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).