12 Apr, 2019

1 commit

  • 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
    Acked-by: Fugang Duan
    (cherry picked from commit 0a0d8f8b944094342fda18f23f3ac13b8a73871d)

    Robin Gong
     

14 Feb, 2019

1 commit


12 Feb, 2019

38 commits

  • In multi audio play/stop case,sdma_alloc_chan_resources/
    sdma_free_chan_resources will be called quickly, especially,dma done
    interrupt comes after sdma_free_chan_resources, thus, system will be
    hang in interrupt since it'll check sdma register but clocks have
    already been disabled in sdma_free_chan_resources. To avoid it, enable
    clock in isr.

    Signed-off-by: Robin Gong

    Robin Gong
     
  • Fix 'null pointer dereferences issue' reported by coverity(CID-1477441).

    Signed-off-by: Robin Gong
    Reviewed-by: Anson Huang

    Robin Gong
     
  • Fix potential kernel crash issue on imx-sdma as fsl-edma-v3.

    Signed-off-by: Robin Gong
    Acked-by: Fugang Duan

    Robin Gong
     
  • Fix potential kernel crash issue on fsl-edma as fsl-edma-v3.

    Signed-off-by: Robin Gong
    Acked-by: Fugang Duan

    Robin Gong
     
  • 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
    Acked-by: Fugang Duan

    Robin Gong
     
  • update mxs-dma filter function to firstly filter the dma channels only for mxs-dma, rather than checking unrelated dma chans in following code.

    Signed-off-by: Han Xu

    Han Xu
     
  • Switch from dma_coherent API to dma_pool API for APBH dma driver.

    Got the following warnings with the previous dma_alloc_coherent,

    alloc_contig_range: [xxx, yyy) PFNs busy

    This implementation create one dma_pool dedicate for all following
    dma_alloc and avoid keeping allocate available memories.

    Signed-off-by: Han Xu

    Han Xu
     
  • Multi-fifo scripts will change offset of fifo_num from 8 to 12 for
    enlarging the max watermark from 8 to 128, which could utilize more
    FIFO space as possible as it can. New 'watermarklevel' defined as
    below:

    ;; bit0~11: wartermark level(wml*fifo_number)
    ;; bit15~12: fifo number
    ;; bit16~19: fifo offset
    ;; bit27~24: sw done selector
    ;; bit23: sw done enabled

    Signed-off-by: Robin Gong
    (cherry picked from commit 786c8bd56324463cb94ce2c11a83689de0058ca0)

    Robin Gong
     
  • Add multi-fifo script for i.mx6 instead of dual fifo script, because
    there is one hardware issue inside SSI ip and switch between dual fifo
    and single fifo could workaroud it, so add multi-fifo scripts.

    Signed-off-by: Robin Gong
    (cherry picked from commit 85bb6546ff8cb1fc323e568d689a1e078eaca8fa)

    Robin Gong
     
  • commit 7f3ff14b7eb1 ("dmaengine: imx-sdma: add 1ms delay to ensure
    SDMA channel is stopped") add 1ms delay to ensure no dma done interrupt
    come in after channel disabled. This 1ms may cause SAI underrun issue
    between two times playback, because ALSA framework stop SAI module after
    dma terminate, thus the 1ms timing window trigger continuous 'underrun'
    interrupt. Actually, don't need 1ms delay anymore since virt-dma could
    handle the interrupt after channel terminated.

    Signed-off-by: Robin Gong
    Reviewed-by: Shengjiu Wang

    Robin Gong
     
  • Since sdma_resume will restore all context in case sdma power off after
    suspend, sdma_channel_resume does not need to restore again. Besides,
    'suspend_off' can be removed too.

    Signed-off-by: Robin Gong
    Reviewed-by: Shengjiu Wang

    Robin Gong
     
  • request_firmware_nowait() is async so that can't make sure sdma firmware
    loaded when sdma_resume return back. Add wait code to make sure firmware
    ready.

    Signed-off-by: Robin Gong
    Reviewed-by: Shengjiu Wang

    Robin Gong
     
  • Context switch mode should be set to static before channel0 running
    after sdma bootup. Do that after sdma power up again in case mega/fast
    mix off.

    Signed-off-by: Robin Gong
    Reviewed-by: Shengjiu Wang

    Robin Gong
     
  • The swap is swapped between the i.MX8QM RevA and RevB
    this patch handle this difference to set swap correctly
    otherwise, the eDMA will not work on the i.MX8QM RevB

    Signed-off-by: Jason Liu
    Reviewed-by: Anson Huang
    (cherry picked from commit 5f4d3549e5f61cb8e3c14dbeb406acfcccf32886)

    Jason Liu
     
  • 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
    (cherry picked from commit 483519c063b08fc1ce0dd297b6c186799cf639d6)

    Robin Gong
     
  • 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.

    Signed-off-by: Robin Gong
    (cherry picked from commit cd2d1200280fe573ac4eac5e27675f1b2ea638c4)

    Robin Gong
     
  • When the sdma engine is suspended firmware might get lost and need to be
    reloaded. Right now fw_loaded is set to false in suspend code and SDMA
    is disabled until FW is reloaded on resume.

    However when entering standby mode the firmware is not lost, the resume
    code detects this situation and skips reloading firmware and restoring
    contexts. Unfortunately this incorrectly leaves fw_loaded set to false
    so SDMA is unusable after a standby.

    Fix by setting fw_loaded to false at the start of sdma_resume instead
    of the end of sdma_suspend. This is the point at which we know that
    firmware was lost and needs reloading.

    Fixes: c5e50134e7b1 ("MLK-18315-1 dma: imx-sdma: add fw_loaded check")

    Signed-off-by: Leonard Crestez
    Acked-by: Fugang Duan

    Leonard Crestez
     
  • Add new cell for sw_done/sw_done_selector, because PDM need enable
    software done feature in sdma script.
    The new fourth cell defined as below:
    Bit31: sw_done
    Bit15~bit0: selector
    For example: 0x80000000 means sw_done enabled for done0 sector which
    is for PDM on i.mx8mm.

    Signed-off-by: Robin Gong
    Reviewed-by: Shengjiu Wang

    Robin Gong
     
  • Avoid touch unused edma channel register in susped/resume, otherwise,
    kernel crash if XRDC enabled in scfw.

    Signed-off-by: Robin Gong
    Acked-by: Fugang Duan

    Robin Gong
     
  • Return failure if sdma firmware not loaded from rootfs before
    any dma transfer started indeed. That assume no any dma tranfser
    started in any driver probe function. Otherwise, some driver such
    as spi may probe failed or defered probe until sdma firmware loaded
    from rootfs.

    Signed-off-by: Robin Gong
    Acked-by: Fugang Duan

    Robin Gong
     
  • In SMP, the current running descriptor maybe freeed during done interrupt
    because 'sdmac->vc.lock' will be unlock before driver callback run, thus
    'sdmac->desc' maybe NULL and the memory also freeed if channel terminaed
    in that time(sdma_terminate_all()), unfortunately, the local 'desc' in
    sdma_update_channel_loop() which gets the old value of 'sdmac->desc'
    still used to count 'desc->buftail', that cause memory currupt as below.

    Check 'sdmac->desc' instead of local 'desc' in the while(), so do nothing
    in this corner case. That make sense since this channel was already
    terminated and no one care the callback coming after that.

    [ 1863.117625] Unable to handle kernel paging request at virtual address bfffa1002
    [ 1863.117629] pgd = ffff800008e1e000
    [ 1863.117634] [bfffa1002] *pgd=0000000092ae8003, *pud=0000000000000000
    [ 1863.117638] Internal error: Oops: 96000005 [#1] PREEMPT SMP
    [ 1863.117646] Modules linked in: ath10k_pci ath10k_core ath
    [ 1863.117653] CPU: 0 PID: 23381 Comm: id.printspooler Not tainted 4.9.78 #1
    [ 1863.117654] Hardware name: Freescale i.MX8MQ EVK (DT)
    [ 1863.117657] task: ffff80005249de80 task.stack: ffff8000506e4000
    [ 1863.117670] PC is at sdma_int_handler+0x16c/0x34c
    [ 1863.117674] LR is at sdma_int_handler+0x158/0x34c
    [ 1863.117677] pc : [] lr : [] pstate: 600001c5
    [ 1863.117678] sp : ffff80005ff62eb0
    [ 1863.117683] x29: ffff80005ff62eb0 x28: ffff80004e748300
    [ 1863.117686] x27: 0000000000000003 x26: 0000000000000001
    [ 1863.117690] x25: ffff800056a64018 x24: 0000000000000002
    [ 1863.117694] x23: ffff800056a64258 x22: 0000000000000001
    [ 1863.117698] x21: 0000000000000000 x20: ffff800056a64258
    [ 1863.117701] x19: ffff800056a641b8 x18: 0000000000000008
    [ 1863.117705] x17: 0000e2b0dbd9baa4 x16: 0000e2b0dbdd9dd0
    [ 1863.117709] x15: 000000000000088e x14: 000000007173d1d8
    [ 1863.117713] x13: 0000e2b0b97d1760 x12: 0000e2b0cd0794e0
    [ 1863.117716] x11: 0000000000000008 x10: 0000000000000040
    [ 1863.117720] x9 : 0000000040000000 x8 : 0012355ad191c9ca
    [ 1863.117724] x7 : ffffffffa540c8fe x6 : 0000000000000018
    [ 1863.117727] x5 : 000000003b9ac9ff x4 : 0000000000000000
    [ 1863.117731] x3 : 0000000ffff80000 x2 : 0000000000000000
    [ 1863.117735] x1 : 0000000bfffa0000 x0 : 0000000bfffa1000
    [ 1863.117737]
    [ 1863.117737] SP: 0xffff80005ff62e30:

    Signed-off-by: Robin Gong

    Robin Gong
     
  • When output height is eight, yscale of ps engine will be
    over two, it not support by pxp.

    According to pxp doc, a factor greater than 2 is not
    supported with the bilinear filter. so correct it when
    this case happen in order to ensure that pxp will be
    not hang up.

    Reviewed-by: Robby.cai
    Signed-off-by: Guoniu.Zhou

    Guoniu.Zhou
     
  • When PxP convert yuyv to nv12 format, some color dots will
    introdue to output image. IC recommend that YCBCR_MODE and
    BYPASS bit of CSC1_COEF0 should be 1.

    Reviewed-by: robby.cai
    Signed-off-by: Guoniu.Zhou

    Guoniu.Zhou
     
  • 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
    Reviewed-by: Shengjiu Wang

    Robin Gong
     
  • The type IMX_DMATYPE_MULTI_SAI is used for SAI multi-fifo mode,
    in this mode, the fifo num parameter is configured through
    dma_slave_config

    The watermark definition is:
    bit0~7: wartermark level
    bit8~11: fifo number
    bit16~19: fifo offset
    bit27~24: sw done selector
    bit23: sw done enabled

    Signed-off-by: Shengjiu Wang
    Reviewed-by: Robin Gong

    Shengjiu Wang
     
  • update sdma script for multi fifo SAI on i.mx8MQ.

    Signed-off-by: Robin Gong

    Robin Gong
     
  • Add suspend to save channel registers and resume to restore them back since
    edmav3 may powered off in suspend.

    Signed-off-by: Robin Gong

    Robin Gong
     
  • update buswidth that is supported by sdma.

    Signed-off-by: Shengjiu Wang

    Shengjiu Wang
     
  • The driver already supports DMA_DEV_TO_DEV in sdma_config(),
    DMA_SLAVE_BUSWIDTH_2_BYTES and DMA_SLAVE_BUSWIDTH_1_BYTE in
    sdma_prep_slave_sg(). So this patch adds them to the lists.

    Signed-off-by: Nicolin Chen
    Signed-off-by: Vinod Koul

    Nicolin Chen
     
  • On i.mx8 mscale B0 chip, AHB/SDMA clock ratio 2:1 can't be supportted,
    since SDMA clock ration has to be increased to 250Mhz, AHB can't reach
    to 500Mhz, so use 1:1 instead.

    Signed-off-by: Robin Gong

    Robin Gong
     
  • mxs-dma init function will call runtime pm init, the redundant
    pm_runtime_force_resume will mess up the counter. Also remove some
    unnecessary code.

    Signed-off-by: Han Xu
    Reviewed-by: Frank Li

    During 4.14 rebase squashed the following:

    MLK-16800: dma: mxs-dma: correctly handle mxs-dma clock

    enable mxs-dma clock before HW reset and disable clock after it.

    Signed-off-by: Leonard Crestez

    Han Xu
     
  • enable runtime pm for mxs-dma

    BuildInfo:
    - SCFW 60e110f9, IMX-MKIMAGE e131af10, ATF
    - U-Boot 2017.03-imx_4.9.51_8qm_beta1_8qxp_alpha+gfcc9bdc

    Signed-off-by: Han Xu

    Han Xu
     
  • There is only one clock need to be handled after the clock code change
    for i.MX7D. remove the redundant code.

    Signed-off-by: Han Xu

    Han Xu
     
  • 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] [] __switch_to+0x8c/0xa0
    1571.12 [ 4642.737379] [] dma_chan_put+0x70/0xa0
    1571.13 [ 4642.742603] [] dma_release_channel+0x34/0xa0
    1571.14 [ 4642.748435] [] fsl_asrc_dma_hw_free+0x38/0x50
    1571.15 [ 4642.754358] [] soc_pcm_hw_free+0x110/0x1a8
    1571.16 [ 4642.760013] [] dpcm_fe_dai_hw_free+0x6c/0xe0
    1571.17 [ 4642.765844] [] snd_pcm_common_ioctl1+0xb40/0xce0
    1571.18 [ 4642.772028] [] snd_pcm_playback_ioctl1+0x1dc/0x310
    1571.19 [ 4642.778378] [] snd_pcm_playback_ioctl+0x28/0x40
    1571.20 [ 4642.784470] [] do_vfs_ioctl+0xa4/0x748
    1571.21 [ 4642.789784] [] SyS_ioctl+0x8c/0xa0
    1571.22 [ 4642.794745] [] __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
    Reported-by: Jason Liu
    Reviewed-by: Daniel Baluta
    Fixes: 593034f1b908 ("MLK-16437: dma: fsl-edma-v3: fix kernel crash
    while edma interrupt trigger after channel disabled").

    Robin Gong
     
  • 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
    Tested-by: Daniel Baluta

    Robin Gong
     
  • Enable PS and AS colorkey function if user enable and
    set colorkey parameters of s0 and overlay buffer.

    Signed-off-by: Guoniu.Zhou
    (cherry picked from commit f2ed3bfca174b3e370fc37cd5f75a67334822093)

    Guoniu.Zhou
     
  • In pxp lib, the unit of stride parameter is pixel and stride
    is not equal with width parameter of out buffer in some cases.

    In order to use latest pxp lib in old version rootfs, PXP_DEVICE_LEGACY
    macro is used to distinguish pxp drvier version. Because the
    new pxp driver define a new variable and pxp lib can know this
    through PXP_DEVICE_LEGACY, and determine if use it.

    Signed-off-by: Guoniu.Zhou
    Reviewed-by: Fancy Fang
    (cherry picked from commit 91da74e81cfdd2774b39a7574edf93de3f2a3f25)

    Guoniu.Zhou
     
  • 1) add PXP_PIX_FMT_BGRA32 format support for AS buffer
    2) add PXP_PIX_FMT_BGRA32 format support for OUT buffer

    Signed-off-by: Guoniu.Zhou
    Reviewed-by: Fancy Fang
    (cherry picked from commit 4eeefd54cdbb8d1d3ffd64bd444ea7b759101a35)

    Guoniu.Zhou