Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-18 Thread Russell King - ARM Linux
On Mon, Sep 17, 2012 at 08:43:57AM +0530, Vinod Koul wrote:
> On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
> > -   /* FIXME: not supported by platform private API */
> > -   return -EINVAL;
> > +   /* Pause/Resume only allowed with cyclic mode */
> > +   if (!c->cyclic)
> > +   return -EINVAL; 
> This is not a dma restriction right?

This is needed because this is not a real "pause" - it is a stop, which
causes the contents of the DMA engine's FIFOs to be discarded - which
means a subsequent resume will loose data.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-18 Thread Russell King - ARM Linux
On Mon, Sep 17, 2012 at 08:43:57AM +0530, Vinod Koul wrote:
 On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
  -   /* FIXME: not supported by platform private API */
  -   return -EINVAL;
  +   /* Pause/Resume only allowed with cyclic mode */
  +   if (!c-cyclic)
  +   return -EINVAL; 
 This is not a dma restriction right?

This is needed because this is not a real pause - it is a stop, which
causes the contents of the DMA engine's FIFOs to be discarded - which
means a subsequent resume will loose data.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-17 Thread Vinod Koul
On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
> The audio stack used omap_stop_dma/omap_start_dma to pause/resume the
> DMA.
> This method has been used for years on OMAP based products.
> We only allow pause/resume when the DMA has been configured in cyclic
> mode
> which is used by the audio stack.
> 
> Signed-off-by: Peter Ujfalusi 
> CC: Russell King 
> --- 
Acked-by: Vinod Koul 

-- 
~Vinod

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-17 Thread Peter Ujfalusi
Hi Vinod,

On 09/17/2012 06:13 AM, Vinod Koul wrote:
> On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
>> -   /* FIXME: not supported by platform private API */
>> -   return -EINVAL;
>> +   /* Pause/Resume only allowed with cyclic mode */
>> +   if (!c->cyclic)
>> +   return -EINVAL; 
> This is not a dma restriction right?

The pause/resume operation has been only used by audio. This might work with
non cyclic modes as well but it has never been used/tested so to be safe I
have added this restriction.

-- 
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-17 Thread Peter Ujfalusi
Hi Vinod,

On 09/17/2012 06:13 AM, Vinod Koul wrote:
 On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
 -   /* FIXME: not supported by platform private API */
 -   return -EINVAL;
 +   /* Pause/Resume only allowed with cyclic mode */
 +   if (!c-cyclic)
 +   return -EINVAL; 
 This is not a dma restriction right?

The pause/resume operation has been only used by audio. This might work with
non cyclic modes as well but it has never been used/tested so to be safe I
have added this restriction.

-- 
Péter
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-17 Thread Vinod Koul
On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
 The audio stack used omap_stop_dma/omap_start_dma to pause/resume the
 DMA.
 This method has been used for years on OMAP based products.
 We only allow pause/resume when the DMA has been configured in cyclic
 mode
 which is used by the audio stack.
 
 Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
 CC: Russell King rmk+ker...@arm.linux.org.uk
 --- 
Acked-by: Vinod Koul vinod.k...@linux.intel.com

-- 
~Vinod

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-16 Thread Vinod Koul
On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
> -   /* FIXME: not supported by platform private API */
> -   return -EINVAL;
> +   /* Pause/Resume only allowed with cyclic mode */
> +   if (!c->cyclic)
> +   return -EINVAL; 
This is not a dma restriction right?

-- 
~Vinod

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-16 Thread Vinod Koul
On Fri, 2012-09-14 at 15:05 +0300, Peter Ujfalusi wrote:
 -   /* FIXME: not supported by platform private API */
 -   return -EINVAL;
 +   /* Pause/Resume only allowed with cyclic mode */
 +   if (!c-cyclic)
 +   return -EINVAL; 
This is not a dma restriction right?

-- 
~Vinod

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-14 Thread Peter Ujfalusi
The audio stack used omap_stop_dma/omap_start_dma to pause/resume the DMA.
This method has been used for years on OMAP based products.
We only allow pause/resume when the DMA has been configured in cyclic mode
which is used by the audio stack.

Signed-off-by: Peter Ujfalusi 
CC: Russell King 
---
 drivers/dma/omap-dma.c | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index b77a40d..71d7869 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -34,6 +34,7 @@ struct omap_chan {
struct dma_slave_config cfg;
unsigned dma_sig;
bool cyclic;
+   bool paused;
 
int dma_ch;
struct omap_desc *desc;
@@ -470,11 +471,14 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 */
if (c->desc) {
c->desc = NULL;
-   omap_stop_dma(c->dma_ch);
+   /* Avoid stopping the dma twice */
+   if (!c->paused)
+   omap_stop_dma(c->dma_ch);
}
 
if (c->cyclic) {
c->cyclic = false;
+   c->paused = false;
omap_dma_unlink_lch(c->dma_ch, c->dma_ch);
}
 
@@ -487,14 +491,30 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 
 static int omap_dma_pause(struct omap_chan *c)
 {
-   /* FIXME: not supported by platform private API */
-   return -EINVAL;
+   /* Pause/Resume only allowed with cyclic mode */
+   if (!c->cyclic)
+   return -EINVAL;
+
+   if (!c->paused) {
+   omap_stop_dma(c->dma_ch);
+   c->paused = true;
+   }
+
+   return 0;
 }
 
 static int omap_dma_resume(struct omap_chan *c)
 {
-   /* FIXME: not supported by platform private API */
-   return -EINVAL;
+   /* Pause/Resume only allowed with cyclic mode */
+   if (!c->cyclic)
+   return -EINVAL;
+
+   if (c->paused) {
+   omap_start_dma(c->dma_ch);
+   c->paused = false;
+   }
+
+   return 0;
 }
 
 static int omap_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
-- 
1.7.12

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3 02/15] dmaengine: omap: Add support for pause/resume in cyclic dma mode

2012-09-14 Thread Peter Ujfalusi
The audio stack used omap_stop_dma/omap_start_dma to pause/resume the DMA.
This method has been used for years on OMAP based products.
We only allow pause/resume when the DMA has been configured in cyclic mode
which is used by the audio stack.

Signed-off-by: Peter Ujfalusi peter.ujfal...@ti.com
CC: Russell King rmk+ker...@arm.linux.org.uk
---
 drivers/dma/omap-dma.c | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/omap-dma.c b/drivers/dma/omap-dma.c
index b77a40d..71d7869 100644
--- a/drivers/dma/omap-dma.c
+++ b/drivers/dma/omap-dma.c
@@ -34,6 +34,7 @@ struct omap_chan {
struct dma_slave_config cfg;
unsigned dma_sig;
bool cyclic;
+   bool paused;
 
int dma_ch;
struct omap_desc *desc;
@@ -470,11 +471,14 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 */
if (c-desc) {
c-desc = NULL;
-   omap_stop_dma(c-dma_ch);
+   /* Avoid stopping the dma twice */
+   if (!c-paused)
+   omap_stop_dma(c-dma_ch);
}
 
if (c-cyclic) {
c-cyclic = false;
+   c-paused = false;
omap_dma_unlink_lch(c-dma_ch, c-dma_ch);
}
 
@@ -487,14 +491,30 @@ static int omap_dma_terminate_all(struct omap_chan *c)
 
 static int omap_dma_pause(struct omap_chan *c)
 {
-   /* FIXME: not supported by platform private API */
-   return -EINVAL;
+   /* Pause/Resume only allowed with cyclic mode */
+   if (!c-cyclic)
+   return -EINVAL;
+
+   if (!c-paused) {
+   omap_stop_dma(c-dma_ch);
+   c-paused = true;
+   }
+
+   return 0;
 }
 
 static int omap_dma_resume(struct omap_chan *c)
 {
-   /* FIXME: not supported by platform private API */
-   return -EINVAL;
+   /* Pause/Resume only allowed with cyclic mode */
+   if (!c-cyclic)
+   return -EINVAL;
+
+   if (c-paused) {
+   omap_start_dma(c-dma_ch);
+   c-paused = false;
+   }
+
+   return 0;
 }
 
 static int omap_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
-- 
1.7.12

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/