1
0
Fork 0
Commit Graph

22 Commits (6446b3a52390c090e17578b19bd71e14dd4c372b)

Author SHA1 Message Date
Robin Gong 6446b3a523 MLK-23652-2: dmagengine: fsl-edma-v3: fix race condition
Add spinlock for 'tcd_pool', otherwise, in some race condition,
'tcd_pool = NULL' cause ISR never clear edma channel INT anymore which
cause interrupt storm. Besides, clear interrupt directly before poweroff
for safe.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 37149f29a631f074ac65889375cd1b077284edf8)
2020-04-28 22:23:41 +08:00
Robin Gong 2191fda25c MLK-23652-1: dmaengine: fsl-edma-v3: only clear own INT
For rx/tx channel for audio share the same interrupt, should check INT
before clearing it directly, otherwise, audio rx may clear wrongly audio tx
channe meaningful interrupt instead of meaningless on audio rx before power
up rx edma channel.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 1afea8def323ae2fadafb50264e52483b855f4bd)
2020-04-28 22:23:41 +08:00
Robin Gong 5882a6f8ef MLK-22909 dmaengine: fsl-edma-v3: clear interrupt coming after channel terminated
Clear EDMA_CH_INT in case dma done interrupt comes after channel terminated
instead of channel free-ed, otherwise, RCU maybe caught because it's
ignored without interrupt status cleared as Android team report in Monkey
test.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit ef91ff6ed465cebe2fe6483a480351abba36e237)
(cherry picked from commit 56ee55c71c5f3ef254acb4dee581e68f79ef13a5)
2019-11-25 16:03:23 +08:00
Robin Gong 3f8b89fadd MLK-22302-2: dmaengine: fsl-edma-v3: fix build warning with CONFIG_PM_SLEEP=n
Fix build waring with CONFIG_PM_SLEEP=n.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Andy Duan <fugang.duan@nxp.com>
(cherry picked from commit dfe2a755209615f9592ed937957b2efdc3b6d6c0)
2019-11-25 16:03:23 +08:00
Robin Gong 7d7fb3da1c MLK-22284-2 dmaengine: fsl-edma-v3: check dma description before register touch
Check dma desscription firstly to ignore any unexpected interrupt
after channel terminate, otherwise, still have chance to touch channel
register whose power has been already off.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: S.j. Wang <shengjiu.wang@nxp.com>
(cherry picked from commit fd073e017e317006a4c254ca5ae3ea17b6f32502)
2019-11-25 16:03:23 +08:00
Robin Gong cfe6412faa MLK-22284-1 dmaengine: fsl-edma-v3: add power domains for each channel
Add power domains for each dma channel so that edma channel could
know the power state of every dma channel anytime and clear easily
unexpected interrupt which triggered before the last partition reset.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: S.j. Wang <shengjiu.wang@nxp.com>
(cherry picked from commit 0b6da46b7bdb2284e24757d48466268b9feb5b7c)
2019-11-25 16:03:22 +08:00
Robin Gong e8e9c9bc99 MLK-21443: dmaengine: fsl-edma-v3: clear pending irq before request irq
edma interrupt maybe happened during reboot or watchdog reset, meanwhile
gic never power down on i.mx8QM/QXP, thus the unexpect irq will come in
once edma driver request irq at probe phase. Unfortunately, at that time
that edma channel's power domain which power-up by customer driver such
as audio/uart driver may not be ready, so kernel panic triggered once
touch such edma registers which still not power up in interrupt handler.
Move request irq from probe to alloc dma channel so that edma channel's
power domain has already been powered, besides, clear meaningless
interrupt before request irq.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 0a0d8f8b944094342fda18f23f3ac13b8a73871d)
2019-11-25 16:03:21 +08:00
Robin Gong f55fd6f075 MLK-22798-1: dmaengine: fsl-edma-v3: do not enable interrupt in dev_2_dev
Do not enable interrupt in dev_2_dev with cyclic case, since in such
case no any interrupt needed. Otherwise many interrupt will come in
every 64 words transfered in ASRC case, which cause heavy system
loading.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit f0a3172e1ceb04c46377160486ad7dc6ee022850)
2019-11-25 16:03:20 +08:00
Robin Gong 1432768dff MLK-20205-1: dmaengine: fsl-edma-v3: fix NULL pointer dereference
Fix 'null pointer dereferences issue' reported by coverity(CID-1477441).

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Anson Huang <Anson.Huang@nxp.com>
(cherry picked from commit 5343c0018af0af2eb3bb90c5a75e765b851a2c12)
2019-11-25 16:03:19 +08:00
Robin Gong 9ff1f271a0 MLK-19931-1: dmaengine: fsl-edma-v3: fix potential kernel crash in cyclic
There is one potential race condition in virt-dma framework as below:
terminate dma channel after the last dma done interrupt, but before
vchan_complete tasklet scheduled, thus the free-ed 'vd' (free in
fsl_edma3_terminate_all) maybe still be touched in vchan_complete()
which cause NULL pointer crash.
  Kernel community noticed this issue and fix it at virt-dma level:
https://patchwork.kernel.org/patch/10057791/. To avoid backport too
much patches, set 'vc->cyclic = NULL' in terminate dma channel
interfaces to fix such issue easily.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit 18c9083826400a2ef731496391a0b5e71d461a5f)
2019-11-25 16:03:18 +08:00
Robin Gong 0b02c5f7d5 MLK-19022-2: dmaengine: fsl-edma-v3: add device_synchronize
Add device_synchronize for edma driver, since some driver such as
Audio need it to make sure dma done callback never come out after
resource related with dma channel free-ed by Audio driver. Android
team report such issue on MA-12087.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 483519c063b08fc1ce0dd297b6c186799cf639d6)
(cherry picked from commit 29ab274aca01ef8f5fc70e8c0a6d43a5bdb3c689)
2019-11-25 16:03:17 +08:00
Robin Gong 9dc7c227d4 MLK-18248: dma: fsl-edma-v3: avoid touch unused edma channel
Avoid touch unused edma channel register in susped/resume, otherwise,
kernel crash if XRDC enabled in scfw.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Acked-by: Fugang Duan <fugang.duan@nxp.com>
(cherry picked from commit aa221c4aba34c6ce1ce5f561fa073bb8297cc0ff)
2019-11-25 16:03:17 +08:00
Robin Gong e3890608e2 MLK-17782 dma: fsl-edma-v3: fix issue reported by Coverity
Fix below issue reported by Coverity, actually, don't need this
condition check here, remove it.

CID undefined (#1 of 1): Wrong operator used (CONSTANT_EXPRESSION_RESULT)operator_confusion:
(16UL /* 1UL << 4 */) | (__u16)(__le16)tcd->csr is always 1/true regardless of the values of its operand.
This occurs as the logical first operand of "&&".

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit ab942110975cadcde57ab1110df03f526bd3fec5)
2019-11-25 16:03:16 +08:00
Robin Gong e2c4230707 MLK-17094 dma: fsl-edma-v3: add suspend/resume to restore back channel registers
Add suspend to save channel registers and resume to restore them back since
edmav3 may powered off in suspend.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 7eda1ae538ec7e7c0f993b3ea91805459f3dedd3)
2019-11-25 16:03:15 +08:00
Robin Gong f8e9e04f6d MLK-16482: dma: fsl-edma-v3: Fix RCU issue while playing Audio
That's caused by commit 593034f1b908 ("MLK-16437: dma: fsl-edma-v3:
fix kernel crash while edma interrupt trigger after channel disabled").
Because fsl_chan->vchan.lock will be hold always and trigger RCU report
as below:

1571.3  Playing WAVE '/mnt/nfs/vte_mx82/../test_stream/esai_stream/48k16bit-six.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Channels 6
1571.5  [ 4642.698771] INFO: rcu_preempt detected stalls on CPUs/tasks:
1571.6  [ 4642.704443] 0-...: (1 GPs behind) idle=2c5/140000000000000/0 softirq=155373/155374 fqs=2541
1571.7  [ 4642.712967] (detected by 2, t=5252 jiffies, g=104259, c=104258, q=22)
1571.8  [ 4642.719501] Task dump for CPU 0:
1571.9  [ 4642.722724] aplay R running task 0 15723 15721 0x00000202
1571.10  [ 4642.729786] Call trace:
1571.11  [ 4642.732239] [<ffff0000080855e4>] __switch_to+0x8c/0xa0
1571.12  [ 4642.737379] [<ffff0000084e3a48>] dma_chan_put+0x70/0xa0
1571.13  [ 4642.742603] [<ffff0000084e3aac>] dma_release_channel+0x34/0xa0
1571.14  [ 4642.748435] [<ffff000008972240>] fsl_asrc_dma_hw_free+0x38/0x50
1571.15  [ 4642.754358] [<ffff000008960568>] soc_pcm_hw_free+0x110/0x1a8
1571.16  [ 4642.760013] [<ffff000008963bcc>] dpcm_fe_dai_hw_free+0x6c/0xe0
1571.17  [ 4642.765844] [<ffff000008948ae8>] snd_pcm_common_ioctl1+0xb40/0xce0
1571.18  [ 4642.772028] [<ffff000008948e64>] snd_pcm_playback_ioctl1+0x1dc/0x310
1571.19  [ 4642.778378] [<ffff000008948fc0>] snd_pcm_playback_ioctl+0x28/0x40
1571.20  [ 4642.784470] [<ffff0000081ee0a4>] do_vfs_ioctl+0xa4/0x748
1571.21  [ 4642.789784] [<ffff0000081ee7d4>] SyS_ioctl+0x8c/0xa0
1571.22  [ 4642.794745] [<ffff000008082f4c>] __sys_trace_return+0x0/0x4
1571.23  [ 4705.718740] INFO: rcu_preempt detected stalls on CPUs/tasks:
1571.24  [ 4705.724420] 0-...: (1 GPs behind) idle=2c5/140000000000000/0 softirq=155373/155374 fqs=10407
1571.25  [ 4705.733030] (detected by 1, t=21010 jiffies, g=104259, c=104258, q=119)

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reported-by: Jason Liu <jason.hui.liu@nxp.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Fixes: 593034f1b908 ("MLK-16437: dma: fsl-edma-v3: fix kernel crash
while edma interrupt trigger after channel disabled").

(cherry picked from commit e62e8707154f47e168fcfd148e97be4e2f991898)
2019-11-25 16:03:14 +08:00
Robin Gong fe8cf28f2b MLK-16437: dma: fsl-edma-v3: fix kernel crash while edma interrupt trigger after channel disabled
edma interrupt may come after channel terminated, so should ignore
interrupts, else kernel crash as below since fsl_chan->edesc set
to NULL when terminate.

 606.837306] Unable to handle kernel NULL pointer dereference at virtual address 00000060
[  606.845411] pgd = ffff000009295000
[  606.848814] [00000060] *pgd=00000008bfffe003[  606.852906] , *pud=00000008bfffd003
 , *pmd=0000000000000000[  606.858395]
[  606.859885] Internal error: Oops: 96000006 1 PREEMPT SMP
[  606.865460] Modules linked in:
[  606.868522] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.9.11-03371-g9904ea0 #42
[  606.875832] Hardware name: Freescale i.MX8QXP LPDDR4 ARM2 (DT)
[  606.881662] task: ffff000009120680 task.stack: ffff000009110000
[  606.887588] PC is at fsl_edma3_tx_handler+0x50/0x150

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Tested-by: Daniel Baluta <daniel.baluta@nxp.com>
(cherry picked from commit 625afad5a0900bc3e3288510f61647b1d891a5a4)
2019-11-25 16:03:14 +08:00
Robin Gong 9d36acb860 MLK-16327-1: dma: fsl-edma-v3: make exclusive channel name for all edma channels
Since there are multi edmav3 instances on i.mx8, every edma channel name
is better unique.But so far, all edma channel name is 'edma-channel(id)-
tx',thus some edma channels which share the same channel id but different
edma instance will show the same channel name in kernel and this is not
friendly to debug in kernel.
  Now the edma channel name(interrupt-names property) is define in dts
as below:
        "edmaX-chanX-Xx"
             |     | |---> receive/transmit, r or t
             |     |---> channel id, the max number is 32
             |---> edma controller instance, 0, 1, 2,..etc
and get below correct name with 'cat /proc/interrupts':
 43:          0          0          0          0     GICv3 466 Level     edma0-chan8-rx
 44:          0          0          0          0     GICv3 467 Level     edma0-chan9-tx
 45:         79          0          0          0     GICv3 468 Level     edma0-chan10-rx
 46:        311          0          0          0     GICv3 469 Level     edma0-chan11-tx
 47:          0          0          0          0     GICv3 470 Level     edma0-chan12-rx
 48:          0          0          0          0     GICv3 471 Level     edma0-chan13-tx
 49:          0          0          0          0     GICv3 472 Level     edma0-chan14-rx
 50:          0          0          0          0     GICv3 473 Level     edma0-chan15-tx
 51:          0          0          0          0     GICv3 406 Level     edma2-chan0-tx
 52:          0          0          0          0     GICv3 407 Level     edma2-chan1-tx
 53:          0          0          0          0     GICv3 408 Level     edma2-chan2-tx
 54:          0          0          0          0     GICv3 409 Level     edma2-chan3-tx
 55:          0          0          0          0     GICv3 410 Level     edma2-chan4-tx
 56:          0          0          0          0     GICv3 411 Level     edma2-chan5-tx
 57:          0          0          0          0     GICv3 442 Level     edma2-chan6-rx, edma2-chan7-tx

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
(cherry picked from commit af8e197a92c9c024ec4fbfcf543d744e81748773)
2019-11-25 16:03:13 +08:00
Robin Gong ec32139328 MLK-15330-3 dma: fsl-edma-v3: add dual fifo support
There is Audio dual fifo cause that fill fifo one by one and
loop back after every minor loop:
  -- fill the first 32bit width fifo
  -- fill the next 32bit width fifo
  -- +MLOFF signed offset after the above two FIFOs filled
  -- loop back to the first step to handle the next minor loop.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 5aa5e9663bb3a834444b75ea086bef8c37ecb636)
2019-11-25 16:03:13 +08:00
Robin Gong 4688ef9be7 MLK-15330-1: dma: fsl-edma-v3: combine two cells into one
For dual fifo case, fsl-edma-v3 need add another cell. It's not friendly
for user and it's possible other cells maybe added to other use cases,
so combine two cells into one now, and for some special use cases such as
dual fifo property can directly be passed by one bit of cell3 rather than
another cell.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit 3ecd1b3382e2c746728842fb2c084fbb030eb5de)
2019-11-25 16:03:12 +08:00
Robin Gong b1b8c0ae94 MLK-15014 dma: fsl-edma-v3: clear DONE before E_SG enabled
Below described in RM, otherwise, channel error status(CHa_ES)
may be triggered:
The user must clear the CHa_CSR[DONE] bit before writing the
TCDa_CSR[MAJORELINK] or TCDa_CSR[ESG] bits.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit c4164d0a15306174056c6ff423ba2408dd901fcf)
2019-11-25 16:03:12 +08:00
Shengjiu Wang f61b296ab2 MLK-15003-1: DMA: fsl-edma-v3: add one more parameter for xlate
The parameter is "is_remote", which is to use remote access for
edma, the default access is local access.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit eee976b30b0523680f30e762742984f5b5a01b97)
2019-11-25 16:03:10 +08:00
Robin Gong 2f9e74892d MLK-14610 DMA: fsl-edma-v3: add fsl-edma-v3 support
Add edma-v3 driver on i.mx8qm.

Signed-off-by: Robin Gong <yibin.gong@nxp.com>
(cherry picked from commit d0ac0971c2e637ebddc853f12f71d130f5df4f91)
2019-11-25 16:03:10 +08:00