Commit e9eeac8f authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Greg Kroah-Hartman

ASoC: fsi: don't reschedule DMA from an atomic context

commit 57451e43 upstream.

shdma doesn't support transfer re-scheduling or triggering from callbacks
or from atomic context. The fsi driver issues DMA transfers from a tasklet
context, which is a bug. To fix it convert tasklet to a work.
Reported-by: default avatarDo Q.Thang <dq-thang@jinso.co.jp>
Tested-by: default avatarDo Q.Thang <dq-thang@jinso.co.jp>
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bb4e9737
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/sh_dma.h> #include <linux/sh_dma.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/workqueue.h>
#include <sound/soc.h> #include <sound/soc.h>
#include <sound/sh_fsi.h> #include <sound/sh_fsi.h>
...@@ -199,7 +200,7 @@ struct fsi_stream { ...@@ -199,7 +200,7 @@ struct fsi_stream {
*/ */
struct dma_chan *chan; struct dma_chan *chan;
struct sh_dmae_slave slave; /* see fsi_handler_init() */ struct sh_dmae_slave slave; /* see fsi_handler_init() */
struct tasklet_struct tasklet; struct work_struct work;
dma_addr_t dma; dma_addr_t dma;
}; };
...@@ -968,9 +969,9 @@ static dma_addr_t fsi_dma_get_area(struct fsi_stream *io) ...@@ -968,9 +969,9 @@ static dma_addr_t fsi_dma_get_area(struct fsi_stream *io)
return io->dma + samples_to_bytes(runtime, io->buff_sample_pos); return io->dma + samples_to_bytes(runtime, io->buff_sample_pos);
} }
static void fsi_dma_do_tasklet(unsigned long data) static void fsi_dma_do_work(struct work_struct *work)
{ {
struct fsi_stream *io = (struct fsi_stream *)data; struct fsi_stream *io = container_of(work, struct fsi_stream, work);
struct fsi_priv *fsi = fsi_stream_to_priv(io); struct fsi_priv *fsi = fsi_stream_to_priv(io);
struct dma_chan *chan; struct dma_chan *chan;
struct snd_soc_dai *dai; struct snd_soc_dai *dai;
...@@ -1023,7 +1024,7 @@ static void fsi_dma_do_tasklet(unsigned long data) ...@@ -1023,7 +1024,7 @@ static void fsi_dma_do_tasklet(unsigned long data)
* FIXME * FIXME
* *
* In DMAEngine case, codec and FSI cannot be started simultaneously * In DMAEngine case, codec and FSI cannot be started simultaneously
* since FSI is using tasklet. * since FSI is using the scheduler work queue.
* Therefore, in capture case, probably FSI FIFO will have got * Therefore, in capture case, probably FSI FIFO will have got
* overflow error in this point. * overflow error in this point.
* in that case, DMA cannot start transfer until error was cleared. * in that case, DMA cannot start transfer until error was cleared.
...@@ -1047,7 +1048,7 @@ static bool fsi_dma_filter(struct dma_chan *chan, void *param) ...@@ -1047,7 +1048,7 @@ static bool fsi_dma_filter(struct dma_chan *chan, void *param)
static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io)
{ {
tasklet_schedule(&io->tasklet); schedule_work(&io->work);
return 0; return 0;
} }
...@@ -1087,14 +1088,14 @@ static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io) ...@@ -1087,14 +1088,14 @@ static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io)
if (!io->chan) if (!io->chan)
return -EIO; return -EIO;
tasklet_init(&io->tasklet, fsi_dma_do_tasklet, (unsigned long)io); INIT_WORK(&io->work, fsi_dma_do_work);
return 0; return 0;
} }
static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io)
{ {
tasklet_kill(&io->tasklet); cancel_work_sync(&io->work);
fsi_stream_stop(fsi, io); fsi_stream_stop(fsi, io);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment