18 Sep, 2020

1 commit

  • In preparation for unconditionally passing the
    struct tasklet_struct pointer to all tasklet
    callbacks, switch to using the new tasklet_setup()
    and from_tasklet() to pass the tasklet pointer explicitly.

    Signed-off-by: Romain Perier
    Signed-off-by: Allen Pais
    Link: https://lore.kernel.org/r/20200831103542.305571-4-allen.lkml@gmail.com
    Signed-off-by: Vinod Koul

    Allen Pais
     

13 May, 2020

1 commit

  • The current codebase makes use of the zero-length array language
    extension to the C90 standard, but the preferred mechanism to declare
    variable-length types such as these ones is a flexible array member[1][2],
    introduced in C99:

    struct foo {
    int stuff;
    struct boo array[];
    };

    By making use of the mechanism above, we will get a compiler warning
    in case the flexible array does not occur last in the structure, which
    will help us prevent some kind of undefined behavior bugs from being
    inadvertently introduced[3] to the codebase from now on.

    Also, notice that, dynamic memory allocations won't be affected by
    this change:

    "Flexible array members have incomplete type, and so the sizeof operator
    may not be applied. As a quirk of the original implementation of
    zero-length arrays, sizeof evaluates to zero."[1]

    sizeof(flexible-array-member) triggers a warning because flexible array
    members have incomplete type[1]. There are some instances of code in
    which the sizeof operator is being incorrectly/erroneously applied to
    zero-length arrays and the result is zero. Such instances may be hiding
    some bugs. So, this work (flexible-array member conversions) will also
    help to get completely rid of those sorts of issues.

    This issue was found with the help of Coccinelle.

    [1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
    [2] https://github.com/KSPP/linux/issues/21
    [3] commit 76497732932f ("cxgb3/l2t: Fix undefined behaviour")

    Signed-off-by: Gustavo A. R. Silva
    Acked-by: Ludovic Desroches
    Link: https://lore.kernel.org/r/20200507190046.GA15298@embeddedor
    Signed-off-by: Vinod Koul

    Gustavo A. R. Silva
     

25 Feb, 2020

4 commits

  • Tasklets run with all the interrupts enabled. This means that we should
    replace all the (already present) spin_lock_irqsave() uses in the tasklet
    with spin_lock_irq() to protect being interrupted by a IRQ which tries
    to get the same lock (via calls to device_prep_dma_* for example).

    spin_lock and spin_lock_bh in tasklets are not enough to protect from IRQs,
    update these to spin_lock_irq().

    at_xdmac_advance_work() can be called with all the interrupts enabled (when
    called from tasklet), or with interrupts disabled (when called from
    at_xdmac_issue_pending). Move the locking in the callers to be able to use
    spin_lock_irq() and spin_lock_irqsave() for these cases.

    Signed-off-by: Tudor Ambarus
    Acked-by: Ludovic Desroches
    Link: https://lore.kernel.org/r/20200123140237.125799-10-tudor.ambarus@microchip.com
    Signed-off-by: Vinod Koul

    Tudor Ambarus
     
  • device_alloc_chan_resources can sleep, use GFP_KERNEL flag.

    Signed-off-by: Tudor Ambarus
    Acked-by: Ludovic Desroches
    Link: https://lore.kernel.org/r/20200123140237.125799-9-tudor.ambarus@microchip.com
    Signed-off-by: Vinod Koul

    Tudor Ambarus
     
  • There is no need for locking in device_alloc_chan_resources(),
    the DMA core takes care of it by using a dma_list_mutex around
    the DMA devices.

    Signed-off-by: Tudor Ambarus
    Acked-by: Ludovic Desroches
    Link: https://lore.kernel.org/r/20200123140237.125799-8-tudor.ambarus@microchip.com
    Signed-off-by: Vinod Koul

    Tudor Ambarus
     
  • The code in cause is already in the else case of
    'if (at_xdmac_chan_is_cyclic(atchan))', drop the redundant check.

    Signed-off-by: Tudor Ambarus
    Acked-by: Ludovic Desroches
    Link: https://lore.kernel.org/r/20200123140237.125799-7-tudor.ambarus@microchip.com
    Signed-off-by: Vinod Koul

    Tudor Ambarus
     

14 Oct, 2019

1 commit


18 Jul, 2019

1 commit

  • Pull dmaengine updates from Vinod Koul:

    - Add support in dmaengine core to do device node checks for DT devices
    and update bunch of drivers to use that and remove open coding from
    drivers

    - New driver/driver support for new hardware, namely:
    - MediaTek UART APDMA
    - Freescale i.mx7ulp edma2
    - Synopsys eDMA IP core version 0
    - Allwinner H6 DMA

    - Updates to axi-dma and support for interleaved cyclic transfers

    - Greg's debugfs return value check removals on drivers

    - Updates to stm32-dma, hsu, dw, pl330, tegra drivers

    * tag 'dmaengine-5.3-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (68 commits)
    dmaengine: Revert "dmaengine: fsl-edma: add i.mx7ulp edma2 version support"
    dmaengine: at_xdmac: check for non-empty xfers_list before invoking callback
    Documentation: dmaengine: clean up description of dmatest usage
    dmaengine: tegra210-adma: remove PM_CLK dependency
    dmaengine: fsl-edma: add i.mx7ulp edma2 version support
    dt-bindings: dma: fsl-edma: add new i.mx7ulp-edma
    dmaengine: fsl-edma-common: version check for v2 instead
    dmaengine: fsl-edma-common: move dmamux register to another single function
    dmaengine: fsl-edma: add drvdata for fsl-edma
    dmaengine: Revert "dmaengine: fsl-edma: support little endian for edma driver"
    dmaengine: rcar-dmac: Reject zero-length slave DMA requests
    dmaengine: dw: Enable iDMA 32-bit on Intel Elkhart Lake
    dmaengine: dw-edma: fix semicolon.cocci warnings
    dmaengine: sh: usb-dmac: Use [] to denote a flexible array member
    dmaengine: dmatest: timeout value of -1 should specify infinite wait
    dmaengine: dw: Distinguish ->remove() between DW and iDMA 32-bit
    dmaengine: fsl-edma: support little endian for edma driver
    dmaengine: hsu: Revert "set HSU_CH_MTSR to memory width"
    dmagengine: pl330: add code to get reset property
    dt-bindings: pl330: document the optional resets property
    ...

    Linus Torvalds
     

08 Jul, 2019

1 commit


19 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not see http www gnu org
    licenses

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 503 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Alexios Zavras
    Reviewed-by: Allison Randal
    Reviewed-by: Enrico Weigelt
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190602204653.811534538@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

04 May, 2019

1 commit

  • We switched this code from spin_lock_bh() to vanilla spin_lock() but
    there was one stray spin_unlock_bh() that was overlooked. This
    patch converts it to spin_unlock() as well.

    Fixes: d8570d018f69 ("dmaengine: at_xdmac: move spin_lock_bh to spin_lock in tasklet")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Vinod Koul

    Dan Carpenter
     

23 Apr, 2019

3 commits

  • The overflow error flag (ROI: Request Overflow Error) is only relevant
    for the case when the channel handles a peripheral synchronized transfer.
    Not in the case of memory to memory transfer where there is no hardware
    request signal.

    Remove the use of this interrupt source in such a case. It's based on
    the first descriptor which holds the configuration for the whole
    linked list transfer.

    Signed-off-by: Nicolas Ferre
    Acked-by: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Nicolas Ferre
     
  • Complement the identification of errors with stopping the channel and
    dumping the descriptor that led to the error case.

    Signed-off-by: Nicolas Ferre
    Acked-by: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Nicolas Ferre
     
  • Even if this case shouldn't happen when controller is properly programmed,
    it's still better to avoid dumping a kernel Oops for this.
    As the sequence may happen only for debugging purposes, log the error and
    just finish the tasklet call.

    Signed-off-by: Nicolas Ferre
    Acked-by: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Nicolas Ferre
     

02 Feb, 2019

1 commit

  • atchan->status variable is used to store two different information:
    - pass channel interrupts status from interrupt handler to tasklet;
    - channel information like whether it is cyclic or paused;

    This causes a bug when device_terminate_all() is called,
    (AT_XDMAC_CHAN_IS_CYCLIC cleared on atchan->status) and then a late End
    of Block interrupt arrives (AT_XDMAC_CIS_BIS), which sets bit 0 of
    atchan->status. Bit 0 is also used for AT_XDMAC_CHAN_IS_CYCLIC, so when
    a new descriptor for a cyclic transfer is created, the driver reports
    the channel as in use:

    if (test_and_set_bit(AT_XDMAC_CHAN_IS_CYCLIC, &atchan->status)) {
    dev_err(chan2dev(chan), "channel currently used\n");
    return NULL;
    }

    This patch fixes the bug by adding a different struct member to keep
    the interrupts status separated from the channel status bits.

    Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
    Signed-off-by: Codrin Ciubotariu
    Acked-by: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Codrin Ciubotariu
     

03 Sep, 2018

1 commit


23 Apr, 2018

1 commit


27 Mar, 2018

1 commit

  • Despite the efforts made to correctly read the NDA and CUBC registers,
    the order in which the registers are read could sometimes lead to an
    inconsistent state.

    Re-using the timeline from the comments, this following timing of
    registers reads could lead to reading NDA with value "@desc2" and
    CUBC with value "MAX desc1":

    INITD -------- ------------
    |____________________|
    _______________________ _______________
    NDA @desc2 \/ @desc3
    _______________________/\_______________
    __________ ___________ _______________
    CUBC 0 \/ MAX desc1 \/ MAX desc2
    __________/\___________/\_______________
    | | | |
    Events:(1)(2) (3)(4)

    (1) check_nda = @desc2
    (2) initd = 1
    (3) cur_ubc = MAX desc1
    (4) cur_nda = @desc2

    This is allowed by the condition ((check_nda == cur_nda) && initd),
    despite cur_ubc and cur_nda being in the precise state we don't want.

    This error leads to incorrect residue computation.

    Fix it by inversing the order in which CUBC and INITD are read. This
    makes sure that NDA and CUBC are always read together either _before_
    INITD goes to 0 or _after_ it is back at 1.
    The case where NDA is read before INITD is at 0 and CUBC is read after
    INITD is back at 1 will be rejected by check_nda and cur_nda being
    different.

    Fixes: 53398f488821 ("dmaengine: at_xdmac: fix residue corruption")
    Cc: stable@vger.kernel.org
    Signed-off-by: Maxime Jayat
    Acked-by: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Maxime Jayat
     

22 Aug, 2017

2 commits


06 Dec, 2016

1 commit

  • save_gs is supposed to save the channel status in order to be restored at
    resume time but it is never updated and is always 0. Anyway, the channel
    status is updated in the per channel loop later in the resume function.

    Signed-off-by: Alexandre Belloni
    Acked-by: Nicolas Ferre
    Acked-by: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Alexandre Belloni
     

30 Nov, 2016

1 commit


07 Oct, 2016

1 commit

  • Pull dmaengine updates from Vinod Koul:
    "This is bit large pile of code which bring in some nice additions:

    - Error reporting: we have added a new mechanism for users of
    dmaenegine to register a callback_result which tells them the
    result of the dma transaction. Right now only one user (ntb) is
    using it.

    - As we discussed on KS mailing list and pointed out NO_IRQ has no
    place in kernel, this also remove NO_IRQ from dmaengine subsystem
    (both arm and ppc users)

    - Support for IOMMU slave transfers and its implementation for arm.

    - To get better build coverage, enable COMPILE_TEST for bunch of
    driver, and fix the warning and sparse complaints on these.

    - Apart from above, usual updates spread across drivers"

    * tag 'dmaengine-4.9-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (169 commits)
    async_pq_val: fix DMA memory leak
    dmaengine: virt-dma: move function declarations
    dmaengine: omap-dma: Enable burst and data pack for SG
    DT: dmaengine: rcar-dmac: document R8A7743/5 support
    dmaengine: fsldma: Unmap region obtained by of_iomap
    dmaengine: jz4780: fix resource leaks on error exit return
    dma-debug: fix ia64 build, use PHYS_PFN
    dmaengine: coh901318: fix integer overflow when shifting more than 32 places
    dmaengine: edma: avoid uninitialized variable use
    dma-mapping: fix m32r build warning
    dma-mapping: fix ia64 build, use PHYS_PFN
    dmaengine: ti-dma-crossbar: enable COMPILE_TEST
    dmaengine: omap-dma: enable COMPILE_TEST
    dmaengine: edma: enable COMPILE_TEST
    dmaengine: ti-dma-crossbar: Fix of_device_id data parameter usage
    dmaengine: ti-dma-crossbar: Correct type for of_find_property() third parameter
    dmaengine/ARM: omap-dma: Fix the DMAengine compile test on non OMAP configs
    dmaengine: edma: Rename set_bits and remove unused clear_bits helper
    dmaengine: edma: Use correct type for of_find_property() third parameter
    dmaengine: edma: Fix of_device_id data parameter usage (legacy vs TPCC)
    ...

    Linus Torvalds
     

22 Aug, 2016

1 commit


08 Aug, 2016

1 commit

  • This is in preperation of moving to a callback that provides results to the
    callback for the transaction. The conversion will maintain current behavior
    and the driver must convert to new callback mechanism at a later time in
    order to receive results.

    Signed-off-by: Dave Jiang
    Reviewed-by: Lars-Peter Clausen
    Cc: Ludovic Desroches
    Signed-off-by: Vinod Koul

    Dave Jiang
     

29 Jul, 2016

1 commit

  • Pull dmaengine updates from Vinod Koul:
    "This time we have bit of largish changes: two new drivers, bunch of
    updates and cleanups to existing set. Nothing super exciting though.

    New drivers:
    - Xilinx zynqmp dma engine driver
    - Marvell xor2 driver

    Updates:
    - dmatest sg support
    - updates and enhancements to Xilinx drivers, adding of cyclic mode
    - clock handling fixes across drivers
    - removal of OOM messages on kzalloc across subsystem
    - interleaved transfers support in omap driver
    - runtime pm support in qcom bam dma
    - tasklet kill freeup across drivers
    - irq cleanup on remove across drivers"

    * tag 'dmaengine-4.8-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (94 commits)
    dmaengine: k3dma: add missing clk_disable_unprepare() on error in k3_dma_probe()
    dmaengine: zynqmp_dma: add missing MODULE_LICENSE
    dmaengine: qcom_hidma: use for_each_matching_node() macro
    dmaengine: zynqmp_dma: Fix static checker warning
    dmaengine: omap-dma: Support for interleaved transfer
    dmaengine: ioat: statify symbol
    dmaengine: pxa_dma: implement device_synchronize
    dmaengine: imx-sdma: remove assignment never used
    dmaengine: imx-sdma: remove dummy assignment
    dmaengine: cppi: remove unused and bogus check
    dmaengine: qcom_hidma_lli: kill the tasklets upon exit
    dmaengine: pxa_dma: remove owner assignment
    dmaengine: fsl_raid: remove owner assignment
    dmaengine: coh901318: remove owner assignment
    dmaengine: qcom_hidma: kill the tasklets upon exit
    dmaengine: txx9dmac: explicitly freeup irq
    dmaengine: sirf-dma: kill the tasklets upon exit
    dmaengine: s3c24xx: kill the tasklets upon exit
    dmaengine: s3c24xx: explicitly freeup irq
    dmaengine: pl330: explicitly freeup irq
    ...

    Linus Torvalds
     

16 Jul, 2016

1 commit


30 Jun, 2016

1 commit


08 Jun, 2016

1 commit

  • The at_xdmac_init_used_desc() and at_xdmac_prep_dma_memset()
    functions are not exported outside the driver, so make them
    static to avoid the following warnings:

    drivers/dma/at_xdmac.c:459:6: warning: symbol 'at_xdmac_init_used_desc' was not declared. Should it be static?
    drivers/dma/at_xdmac.c:1205:32: warning: symbol 'at_xdmac_prep_dma_memset' was not declared. Should it be static?

    Signed-off-by: Ben Dooks
    Signed-off-by: Vinod Koul

    Ben Dooks
     

30 May, 2016

3 commits

  • Due to the way CUBC register is updated, a double flush is needed to
    compute an accurate residue. First flush aim is to get data from the DMA
    FIFO and second one ensures that we won't report data which are not in
    memory.

    Signed-off-by: Ludovic Desroches
    Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
    eXtended DMA Controller driver")
    Cc: stable@vger.kernel.org #v4.1 and later
    Reviewed-by: Nicolas Ferre
    Signed-off-by: Vinod Koul

    Ludovic Desroches
     
  • An unexpected value of CUBC can lead to a corrupted residue. A more
    complex sequence is needed to detect an inaccurate value for NCA or CUBC.

    Signed-off-by: Ludovic Desroches
    Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
    eXtended DMA Controller driver")
    Cc: stable@vger.kernel.org #v4.1 and later
    Reviewed-by: Nicolas Ferre
    Signed-off-by: Vinod Koul

    Ludovic Desroches
     
  • Having descriptors aligned on 64 bits allows update CNDA and CUBC in an
    atomic way.

    Signed-off-by: Ludovic Desroches
    Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
    eXtended DMA Controller driver")
    Cc: stable@vger.kernel.org #v4.1 and later
    Reviewed-by: Nicolas Ferre
    Signed-off-by: Vinod Koul

    Ludovic Desroches
     

10 Mar, 2016

1 commit

  • When computing the residue we need two pieces of information: the current
    descriptor and the remaining data of the current descriptor. To get
    that information, we need to read consecutively two registers but we
    can't do it in an atomic way. For that reason, we have to check manually
    that current descriptor has not changed.

    Signed-off-by: Ludovic Desroches
    Suggested-by: Cyrille Pitchen
    Reported-by: David Engraf
    Tested-by: David Engraf
    Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
    eXtended DMA Controller driver")
    Cc: stable@vger.kernel.org #4.1 and later
    Signed-off-by: Vinod Koul

    Ludovic Desroches
     

21 Jan, 2016

1 commit

  • Pull dmaengine fixes from Vinod Koul:
    "Here is my second pull request for this window:

    A few driver fixes have piled up and one missed rcar bindings patch
    which got somehow lost in for-linus branch so cherry-picked that one.

    Fixes are for dw, at_hdmac, edma"

    * tag 'dmaengine-fix-4.5-rc1' of git://git.infradead.org/users/vkoul/slave-dma:
    dmaengine: rcar-dmac: Document SoC specific bindings
    dmaengine: at_xdmac: fix resume for cyclic transfers
    dmaengine: dw: fix cyclic transfer callbacks
    dmaengine: dw: fix cyclic transfer setup
    dmaengine: edma: Fix paRAM slot allocation for entry channel 0

    Linus Torvalds
     

18 Jan, 2016

1 commit

  • When having cyclic transfers, the channel was paused when performing
    suspend but was not correctly resumed.

    Signed-off-by: Songjun Wu
    Signed-off-by: Ludovic Desroches
    Fixes: e1f7c9eee707 ("dmaengine: at_xdmac: creation of the atmel
    eXtended DMA Controller driver")
    Cc: # 4.1 and later
    Signed-off-by: Vinod Koul

    Songjun Wu
     

14 Jan, 2016

1 commit

  • Pull dmaengine updates from Vinod Koul:
    "This round we have few new features, new driver and updates to few
    drivers.

    The new features to dmaengine core are:
    - Synchronized transfer termination API to terminate the dmaengine
    transfers in synchronized and async fashion as required by users.
    We have its user now in ALSA dmaengine lib, img, at_xdma, axi_dmac
    drivers.
    - Universal API for channel request and start consolidation of
    request flows. It's user is ompa-dma driver.
    - Introduce reuse of descriptors and use in pxa_dma driver

    Add/Remove:
    - New STM32 DMA driver
    - Removal of unused R-Car HPB-DMAC driver

    Updates:
    - ti-dma-crossbar updates for supporting eDMA
    - tegra-apb pm updates
    - idma64
    - mv_xor updates
    - ste_dma updates"

    * tag 'dmaengine-4.5-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (54 commits)
    dmaengine: mv_xor: add suspend/resume support
    dmaengine: mv_xor: de-duplicate mv_chan_set_mode*()
    dmaengine: mv_xor: remove mv_xor_chan->current_type field
    dmaengine: omap-dma: Add support for DMA filter mapping to slave devices
    dmaengine: edma: Add support for DMA filter mapping to slave devices
    dmaengine: core: Introduce new, universal API to request a channel
    dmaengine: core: Move and merge the code paths using private_candidate
    dmaengine: core: Skip mask matching when it is not provided to private_candidate
    dmaengine: mdc: Correct terminate_all handling
    dmaengine: edma: Add probe callback to edma_tptc_driver
    dmaengine: dw: fix potential memory leak in dw_dma_parse_dt()
    dmaengine: stm32-dma: Fix unchecked deference of chan->desc
    dmaengine: sh: Remove unused R-Car HPB-DMAC driver
    dmaengine: usb-dmac: Document SoC specific compatibility strings
    ste_dma40: Delete an unnecessary variable initialisation in d40_probe()
    ste_dma40: Delete another unnecessary check in d40_probe()
    ste_dma40: Delete an unnecessary check before the function call "kmem_cache_destroy"
    dmaengine: tegra-apb: Free interrupts before killing tasklets
    dmaengine: tegra-apb: Update driver to use GFP_NOWAIT
    dmaengine: tegra-apb: Only save channel state for those in use
    ...

    Linus Torvalds
     

10 Dec, 2015

1 commit

  • This patch fixes at_xdmac_prep_dma_memcpy(). Indeed the data width field
    of the Channel Configuration register was not updated properly in the
    loop: the bits of the dwidth field were not cleared before adding their
    new value.

    Signed-off-by: Cyrille Pitchen
    Acked-by: Ludovic Desroches
    Fixes: e1f7c9eee70 ("dmaengine: at_xdmac: creation of the atmel eXtended DMA Controller driver")
    Cc: stable@vger.kernel.org #4.1 and later
    Signed-off-by: Vinod Koul

    Cyrille Pitchen
     

05 Dec, 2015

3 commits