From d53e77a086745032a11284f7e4a5be148d8cce56 Mon Sep 17 00:00:00 2001 From: Shengjiu Wang Date: Thu, 30 Jun 2016 17:45:05 +0800 Subject: MLK-12771: ASoC: fsl_asrc: fix dma task timeout issue The test case is one p2p playback + two m2m converter running simultaneously. There are three root cause for this issue: 1. hw_free() of p2p may be called twice in the end, which cause release twice of one pair, if another pair request is called between this two release, there will be issue. 2. In m2m close(), the asrc_priv->pair[i] will be set NULL twice, which is same issue as 1. 3. when output rate is more than eight multiple of input rate for m2m, the last_period_size should be larger. Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_asrc_m2m.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'sound/soc/fsl/fsl_asrc_m2m.c') diff --git a/sound/soc/fsl/fsl_asrc_m2m.c b/sound/soc/fsl/fsl_asrc_m2m.c index 9ee0f503e8c5..7363dc003aa6 100644 --- a/sound/soc/fsl/fsl_asrc_m2m.c +++ b/sound/soc/fsl/fsl_asrc_m2m.c @@ -274,7 +274,8 @@ static int fsl_asrc_prepare_io_buffer(struct fsl_asrc_pair *pair, word_size = 2; if (buf_len < word_size * pair->channels * wm || - buf_len > ASRC_DMA_BUFFER_SIZE) { + buf_len > ASRC_DMA_BUFFER_SIZE || + (dir == OUT && buf_len < word_size * pair->channels * last_period_size)) { pair_err("%sput buffer size is error: [%d]\n", DIR_STR(dir), buf_len); return -EINVAL; @@ -557,7 +558,9 @@ static long fsl_asrc_ioctl_config_pair(struct fsl_asrc_pair *pair, m2m->rate[IN] = config.input_sample_rate; m2m->rate[OUT] = config.output_sample_rate; - if (m2m->rate[OUT] > m2m->rate[IN]) + if (m2m->rate[OUT] >= m2m->rate[IN] * 8) + m2m->last_period_size = (m2m->rate[OUT] / m2m->rate[IN]) * 5; + else if (m2m->rate[OUT] > m2m->rate[IN]) m2m->last_period_size = ASRC_OUTPUT_LAST_SAMPLE_MAX; else m2m->last_period_size = ASRC_OUTPUT_LAST_SAMPLE; @@ -852,14 +855,6 @@ static int fsl_asrc_close(struct inode *inode, struct file *file) struct fsl_asrc *asrc_priv = pair->asrc_priv; struct device *dev = &asrc_priv->pdev->dev; unsigned long lock_flags; - int i; - - /* Make sure we have clear the pointer */ - spin_lock_irqsave(&asrc_priv->lock, lock_flags); - for (i = 0; i < ASRC_PAIR_MAX_NUM; i++) - if (asrc_priv->pair[i] == pair) - asrc_priv->pair[i] = NULL; - spin_unlock_irqrestore(&asrc_priv->lock, lock_flags); if (m2m->asrc_active) { m2m->asrc_active = 0; -- cgit v1.2.3