1
0
Fork 0
Commit Graph

27 Commits (redonkable)

Author SHA1 Message Date
Shengjiu Wang 857284dc23 MLK-24084-1: ASoc: fsl_asrc_m2m: Fix kernel panic in m2m stress test
initilize the m2m->complete in open() to avoid the NULL pointer in suspend
because the suspend can be called before initilizing m2m->complete in convert

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-05-21 18:45:35 +08:00
Shengjiu Wang 6a895a2c4c MLK-23650-2: ASoC: fsl_asrc_m2m: Fix oops error
Don't need to add one more buffer, if the buffer
size is same as ASRC_MAX_BUFFER_SIZE.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
2020-03-23 17:48:15 +08:00
Shengjiu Wang faa039ded9 MLK-22295-1: ASoC: fsl_asrc: fix build warning with CONFIG_PM_SLEEP=n
fix build warning with CONFIG_PM_SLEEP=n, the warning message is

In file included from sound/soc/fsl/fsl_asrc.c:968:0:
sound/soc/fsl/fsl_asrc_m2m.c:1021:13: warning: ‘fsl_asrc_m2m_resume’ defined but not used [-Wunused-function]
 static void fsl_asrc_m2m_resume(struct fsl_asrc *asrc_priv)
             ^~~~~~~~~~~~~~~~~~~
sound/soc/fsl/fsl_asrc_m2m.c:990:13: warning: ‘fsl_asrc_m2m_suspend’ defined but not used [-Wunused-function]
 static void fsl_asrc_m2m_suspend(struct fsl_asrc *asrc_priv)
             ^~~~~~~~~~~~~~~~~~~~

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
(cherry picked from commit a3ec5433cfd6fd2b90113a78d5045e04f6a8328c)
2019-11-25 15:48:47 +08:00
Shengjiu Wang cc5cf63ec9 MLK-22239-3: ASoC: fsl_asrc: Support S24_3LE for m2m
Support S24_3LE for m2m with SDMA, but add constraint
for EDMA case, for EDMA don't support 3bytes copy.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
2019-11-25 15:48:41 +08:00
Shengjiu Wang c1484093fe MLK-21940-1: ASoC: fsl_asrc: Update mxc_asrc uapi
In order to support the new ASRC in i.MX815, we update the
user api file mxc_asrc.h.

The reason is that the new ASRC support more sample width, and
support endianness, sign, float format, iec958 format setting,
All these type can be expressed by snd_pcm_format_t type.

So we use the in(out)put_format to instead the in(out)put_word_width.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Viorel Suman <viorel.suman@nxp.com>
(cherry picked from commit b95c32c4d4b51e3e55e1e28269a0e8bce0a04f98)
2019-11-25 15:48:40 +08:00
Shengjiu Wang cf1ce85c92 MLK-18076-1: ASoC: fsl_asrc_m2m: support input width with 8bit
support input data width with 8bit for m2m

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2019-11-25 15:48:36 +08:00
Shengjiu Wang 2c706419b3 MLK-20096: ASoC: fsl_asrc_m2m: fix noise issue for 8k5c to 176k5c conversion
Compare with imx6, the conversion of 8kHz 5channel to 176kHz is ok.
And compare the output we found that about every 48K bytes, there will be
additional data be added, which cause noise.

In this case, there will be two sg_nodes, for the maxmum output size exceed
the ASRC_MAX_BUFFER_SIZE, each size is ASRC_MAX_BUFFER_SIZE, it is 49152.
the value can't be exact divided by channel * word_with * watermark = 40.
So the EDMA can't finish the copy with correct size.

There is limitation of EMDA described in commit 3519b67ac01c
("MLK-19151: ASoC: fsl_asrc: fix dma timeout issue for imx8qxp")

EDMA just copy 49120 bytes, there will 32 bytes wrong data.

According to this limitation, this commit is to change the maxburst to 1
for EDMA case, then EDMA can do what we expect correctly.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2019-11-25 15:48:35 +08:00
Shengjiu Wang 1562153cc8 MLK-13208: ASoC: fsl_asrc_m2m: change the return value for signal_pending
There is error log after suspend resume with asrc alsa plugin.

"fsl-asrc 2034000.asrc: Pair A: failed to process buffer: -16"

"asrc_pair_convert_s16: Convert ASRC pair 0 failed,
[0x989410][440][0x9895d0][1764]"

Which is caused by the return value is -EBUSY when signal_pending, in this
case we can use the -ERESTARTSYS to instead, that system will recall the
convert function after resume.

Fixes commit e1e9de8e9369 ("MLK-10048-2: ASoC: fsl_asrc: change
the return value")

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2019-11-25 15:48:35 +08:00
Shengjiu Wang e0e7942c70 MLK-18979-1: ASoC: fsl_asrc: add resume function for asrc_m2m
There will be "output DMA task timeout" after suspend and resume.
The reason is there is not enough data in the input FIFO.

In the fsl_asrc_start_pair function we initialize the FIFO with
zero data after pair is enabled, it looks like we add more data
to input FIFO. For example if the input buffer length is 100,
but the actual length is 100 + channel*4. so we need to do same
work in resume for the asrc pair is disabled in suspend, the
input FIFO is cleared.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2019-11-25 15:48:34 +08:00
Shengjiu Wang 9d607a7189 MLK-19151: ASoC: fsl_asrc: fix dma timeout issue for imx8qxp
In the imx8qxp, the DMA is EDMA, which require the buffer size
should be divided by burst size with no remainder, otherwise
the remainder is not transferred by EDMA, so the input buffer
is not consumed by ASRC, then there will be dma output timeout
issue. This behavior is different with SDMA.

This patch is to change the input burst size to be 1 to avoid
the issue, and refine the last_period_size for output buffer.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
2019-11-25 15:48:33 +08:00
Shengjiu Wang 6e7c69f03b MLK-18874: ASoC: fsl_asrc: fix noise issue with 5 channel conversion
The dma_len is the size that how many data dma should transmit. As
the asrc use channel as unit, so the dma_len should also in channel unit.
Otherwise the output data is not align in channel, there will be noise.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Cosmin-Gabriel Samoila <cosmin.samoila@nxp.com>
2019-11-25 15:48:33 +08:00
Shengjiu Wang 3b433c19d3 MLK-18875: ASoC: fsl_asrc_m2m: refine the last period size
The output size of asrc for a dedicate input is uncertain.

For example, if the input size is 1k, the output ratio is
2, so the output size should be 2k. but the actual output
size is not 2k,  is less than 2k. if we set the dma size
to be 2k, the dma can't get enough data that can't finish
the transmission, then there will be

"output DMA task timeout"

So we need to set the dma size a proper value but we don't know
how many data less than expected. so we defined the last period
size for assumption of reduced size.

The last period size should not be too large, if it is large
there will be

"input DMA task timeout"

The reason is the output FIFO is full, which will block the
input data comsumption.

In this patch, the last period size is set to the difference
of configured buffer size and the expected output size, plus
a fix size.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Reviewed-by: Cosmin-Gabriel Samoila <cosmin.samoila@nxp.com>
2019-11-25 15:48:32 +08:00
Shengjiu Wang 5cfc86a07a MLK-16154: ASoC: fsl_asrc_m2m: fix crash issue with multi-instance
When open 2 instances of m2m, there is kernel dump. The reason is we
use the dev_set_drvdata to set drvdata for each instance, but each
instance share a same device, the result is drvdata will be changed
by other instances, then cause issue. so the dev_set_drvdata can't be
used, need to combine the pair data with file handler.

Fixes: 58ab1eb5b8c5 ("MLK-13945-3: ASoC: fsl_asrc: support two asrc
devices")

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2019-11-25 15:48:30 +08:00
Shengjiu Wang 9fb7266cc7 MLK-13945-3: ASoC: fsl_asrc: support two asrc devices
In imx8qm, there is two asrc devices, so using global structure
"miscdevice" will cause error. Each instance should have their
own structure.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
2019-11-25 15:48:28 +08:00
Shengjiu Wang e265086e8f MLK-15061-2: ASoC: fsl_asrc_m2m: fix asrc m2m can't work in imx8
Power domain need to be enabled when asrc m2m start to work, and
disabled when it stop.
Switch back to use the pm_runtime_get_sync and pm_runtime_put_sync
for which is removed in commit 1a3d82e08fa2 ("ASoC: fsl: refine
the asrc driver for imx8qm").

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2019-11-25 15:48:27 +08:00
Shengjiu Wang ce70583b4f MLK-15061-1: ASoC: fsl_asrc_m2m: fix dma_map_sg issue for arm64
For arm64, the dma_map_sg and dma_unmap_sg need the device parameter,
otherwise, it will return error.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2019-11-25 15:48:26 +08:00
Viorel Suman eb267cdcaa ASoC: fsl: refine the asrc driver for imx8qm
The clock source of ASRC in imx8qm is changed.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2019-11-25 15:48:26 +08:00
Shengjiu Wang d53e77a086 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 <shengjiu.wang@freescale.com>
2019-11-25 15:48:25 +08:00
Shengjiu Wang 98ba60a173 MLK-12372: ASoC: fsl_asrc: fix dma task timeout after suspend/resume
commit 743cead0f8c4ac6311ffb500efd6146c40124310 is not a complete fix.
There is low possibility that this issue still occur.

Last commit add init_completion() in the suspend function, but if the
dma callback function is called after convert error, the complete is
done, the init_completion will not be called, so the complete state is
not correct in the next conversion.

This patch is to move init_completion to the beginning of conversion
to fix the issue.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2019-11-25 15:48:24 +08:00
Shengjiu Wang 54c70617c7 MLK-12202: ASoC: fsl_asrc_m2m: fix dma timeout after suspend/resume
In suspend function, the complete will be set to done in callback.
After resuming, the convert will not spend time to wait the complete.
which is a wrong complete.
So in suspend function, the complete need to be reinited for next convert.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
2019-11-25 15:48:24 +08:00
Zidan Wang 299f7667db MLK-11942 ASoC: fsl_asrc_m2m: free pair after allocating m2m failed
free pair after allocating m2m failed. Reported by coverity.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
(cherry picked from commit 237a35db5b48b78250a019f891d9d746c3411d49)
2019-11-25 15:48:23 +08:00
Zidan Wang b89be81eda MLK-11915-12 ASoC: fsl_asrc_m2m: fix null check issue for variable m2m and pair
After allocating memory for m2m, we should null check for m2m instead of pair.

In fsl_asrc_close(), null-checking pair suggests that it may be null, but it
has already been dereferenced before the null check. pair will be alloceted
in fsl_asrc_open(), pair is null means that open dev file failed, and
close should not be called in user space. So remove null check for pair.

buf_len should not greater than ASRC_DMA_BUFFER_SIZE, otherwith dma buffer will
be overrun.

Reported by Coverity.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
(cherry picked from commit b0dc15375b12b6c1bf46b9071b92267b827d8ce0)
2019-11-25 15:48:22 +08:00
Shengjiu Wang f54a93b477 MLK-10048-5: ASoC: fsl_asrc: underrun for playback 192k, 6ch p2p case.
For p2p output, the output divider should align with the output sample
rate, if use the Ideal sample rate, there will be a lot of overload, which
will cause underrun.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 5ab043f1a020ae8c3aeb3d91f6894bbd6a6ec147)
2019-11-25 15:48:21 +08:00
Shengjiu Wang 432bae15ee MLK-10048-4: ASoC: fsl_asrc: fix dma task timeout issue when use 3 instance
Merged from 49108fcf7b79ed77d34be33b53a3964b2ac27204
1. Watermark level in sdma use byte as its unit. but asrc driver use
word, there is mismatch between them. Here fix this issue and sdma can
work more efficiency.
2. Enlarge the larst_period_size, when use small size, for some case,
the dma task will timeout, because sdma has no much data for output.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 8a96e09e265294f396bd3af29b429e4b7bdff461)
2019-11-25 15:48:20 +08:00
Shengjiu Wang b063e095e4 MLK-10048-3: ASoC: fsl_asrc: fix asrc crach when suspend/resume
merge 7e1a620a030d17f93fdd97d076f1cdd042e79337

The reason of crach is that some variables are not protected in
function mxc_asrc_suspend(), when suspend, there is possibility to
access one NULL pointer.
Refine the spin lock usage, add protecting for pair_hold.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit e90c73f8170bc929cff54b0478da0573e4e26c23)
2019-11-25 15:48:20 +08:00
Shengjiu Wang 16d07ad5f7 MLK-10048-2: ASoC: fsl_asrc: change the return value
Merge from c086d0151ee3e131b52bef96c5096d1ee603c852

Return value -ERESTARTSYS is not visible for user space according
to include/linux/errno.h. So use -EBUSY replace it.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 69d529646a610d8d1360bd116ceec1341aef4211)
2019-11-25 15:48:20 +08:00
Shengjiu Wang 6c061d1776 MLK-11398: ASoC: fsl_asrc: Add Memory to Memory support
cherry-pick below patch from v3.14.y:
ENGR00330403-4: ASoC: fsl_asrc: Add Memory to Memory support

ASRC M2M function is not able to put upstream due to its self-designed
ioctl protocol. So I just make a single patch for it and make it merge
into P2P driver as simply as possible.

The patch can only be maintained internally unless some one designs a
new protocol or implement the originally protocol by using some common
approach provided by Linux Kernel.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>

Fixed missing includes in 4.14 rebase

Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
2019-11-25 15:48:19 +08:00