17 Nov, 2020

1 commit

  • Actually, burst size is equal to '1 << desc->rqcfg.brst_size'.
    we should use burst size, not desc->rqcfg.brst_size.

    dma memcpy performance on Rockchip RV1126
    @ 1512MHz A7, 1056MHz LPDDR3, 200MHz DMA:

    dmatest:

    /# echo dma0chan0 > /sys/module/dmatest/parameters/channel
    /# echo 4194304 > /sys/module/dmatest/parameters/test_buf_size
    /# echo 8 > /sys/module/dmatest/parameters/iterations
    /# echo y > /sys/module/dmatest/parameters/norandom
    /# echo y > /sys/module/dmatest/parameters/verbose
    /# echo 1 > /sys/module/dmatest/parameters/run

    dmatest: dma0chan0-copy0: result #1: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #2: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #3: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #4: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #5: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #6: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #7: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000
    dmatest: dma0chan0-copy0: result #8: 'test passed' with src_off=0x0 dst_off=0x0 len=0x400000

    Before:

    dmatest: dma0chan0-copy0: summary 8 tests, 0 failures 48 iops 200338 KB/s (0)

    After this patch:

    dmatest: dma0chan0-copy0: summary 8 tests, 0 failures 179 iops 734873 KB/s (0)

    After this patch and increase dma clk to 400MHz:

    dmatest: dma0chan0-copy0: summary 8 tests, 0 failures 259 iops 1062929 KB/s (0)

    Signed-off-by: Sugar Zhang
    Link: https://lore.kernel.org/r/1605326106-55681-1-git-send-email-sugar.zhang@rock-chips.com
    Signed-off-by: Vinod Koul

    Sugar Zhang
     

01 Oct, 2020

1 commit

  • Commit 59cd818763e8 ("dmaengine: fsl: convert tasklets to use new
    tasklet_setup() API") converted the pl330 driver to use new tasklet
    functions but missed that driver calls the tasklet function directly as
    well, so update it.

    Fixes: 59cd818763e8 ("dmaengine: fsl: convert tasklets to use new tasklet_setup() API")
    Reported-by: kernel test robot
    Link: https://lore.kernel.org/r/20200930121735.49699-1-vkoul@kernel.org
    Signed-off-by: Vinod Koul

    Vinod Koul
     

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-21-allen.lkml@gmail.com
    Signed-off-by: Vinod Koul

    Allen Pais
     

11 Sep, 2020

2 commits


05 Sep, 2020

1 commit

  • Pull dmaengine fixes from Vinod Koul:
    "A couple of core fixes and odd driver fixes for dmaengine subsystem:

    Core:
    - drop ACPI CSRT table reference after using it
    - fix of_dma_router_xlate() error handling

    Drivers fixes in idxd, at_hdmac, pl330, dw-edma and jz478"

    * tag 'dmaengine-fix-5.9-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine:
    dmaengine: ti: k3-udma: Update rchan_oes_offset for am654 SYSFW ABI 3.0
    drivers/dma/dma-jz4780: Fix race condition between probe and irq handler
    dmaengine: dw-edma: Fix scatter-gather address calculation
    dmaengine: ti: k3-udma: Fix the TR initialization for prep_slave_sg
    dmaengine: pl330: Fix burst length if burst size is smaller than bus width
    dmaengine: at_hdmac: add missing kfree() call in at_dma_xlate()
    dmaengine: at_hdmac: add missing put_device() call in at_dma_xlate()
    dmaengine: at_hdmac: check return value of of_find_device_by_node() in at_dma_xlate()
    dmaengine: of-dma: Fix of_dma_router_xlate's of_dma_xlate handling
    dmaengine: idxd: reset states after device disable or reset
    dmaengine: acpi: Put the CSRT table after using it

    Linus Torvalds
     

03 Sep, 2020

1 commit


25 Aug, 2020

2 commits

  • Instruction dump uses two printk() in a row to print one instruction. Use
    KERN_CONT to prevent breaking the output in the middle.

    Signed-off-by: Łukasz Stelmach
    Link: https://lore.kernel.org/r/20200813204123.19044-1-l.stelmach@samsung.com
    Signed-off-by: Vinod Koul

    Łukasz Stelmach
     
  • Move the burst len fixup after setting the generic value for it. This
    finally enables the fixup introduced by commit 137bd11090d8 ("dmaengine:
    pl330: Align DMA memcpy operations to MFIFO width"), which otherwise was
    overwritten by the generic value.

    Reported-by: kernel test robot
    Fixes: 137bd11090d8 ("dmaengine: pl330: Align DMA memcpy operations to MFIFO width")
    Signed-off-by: Marek Szyprowski
    Link: https://lore.kernel.org/r/20200825064617.16193-1-m.szyprowski@samsung.com
    Signed-off-by: Vinod Koul

    Marek Szyprowski
     

24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

15 Jul, 2020

4 commits

  • No 'struct' title is provided. Nor are any attribute descriptions.

    Fixes the following W=1 kernel build warning(s):

    drivers/dma/pl330.c:295: warning: cannot understand function prototype: 'struct pl330_reqcfg '

    Signed-off-by: Lee Jones
    Cc: Philipp Zabel
    Cc: Jaswinder Singh
    Link: https://lore.kernel.org/r/20200714111546.1755231-6-lee.jones@linaro.org
    Signed-off-by: Vinod Koul

    Lee Jones
     
  • This patch adds the qurik to use burst transfers only
    for pl330 controller, even for request with a length of 1.

    Although, the correct way should be: if the peripheral request
    length is 1, the peripheral should use SINGLE request, and then
    notify the dmac using SINGLE mode by src/dst_maxburst with 1.

    For example, on the Rockchip SoCs, all the peripherals can use
    SINGLE or BURST request by setting GRF registers. it is possible
    that if these peripheral drivers are used only for Rockchip SoCs.
    Unfortunately, it's not, such as dw uart, which is used so widely,
    and we can't set src/dst_maxburst according to the SoCs' specific
    to compatible with all the other SoCs.

    So, for convenience, all the peripherals are set as BURST request
    by default on the Rockchip SoCs. even for request with a length of 1.
    the current pl330 driver will perform SINGLE transfer if the client's
    maxburst is 1, which still should be working according to chapter 2.6.6
    of datasheet which describe how DMAC performs SINGLE transfers for
    a BURST request. Unfortunately, it's broken on the Rockchip SoCs,
    which support only matching transfers, such as BURST transfer for
    BURST request, SINGLE transfer for SINGLE request.

    Finally, we add the quirk to specify pl330 to use burst transfers only.

    Signed-off-by: Sugar Zhang
    Link: https://lore.kernel.org/r/1593439555-68130-5-git-send-email-sugar.zhang@rock-chips.com
    Signed-off-by: Vinod Koul

    Sugar Zhang
     
  • Only the unaligned burst transfers have the dregs.
    so, still use BURST transfer with a reduced size
    for better performance.

    Signed-off-by: Sugar Zhang
    Link: https://lore.kernel.org/r/1593439555-68130-3-git-send-email-sugar.zhang@rock-chips.com
    Signed-off-by: Vinod Koul

    Sugar Zhang
     
  • There is no reason to limit the performance on the 'NO-FLUSHP' SoCs,
    because 'FLUSHP' instruction is broken on these platforms, so remove
    the limit to improve the efficiency.

    Signed-off-by: Sugar Zhang
    Link: https://lore.kernel.org/r/1593439555-68130-2-git-send-email-sugar.zhang@rock-chips.com
    Signed-off-by: Vinod Koul

    Sugar Zhang
     

24 Jun, 2020

1 commit

  • According to the datasheet of pl330:

    Example 2-1 Using DMAGO with the debug instruction registers

    1. Create a program for the DMA channel
    2. Store the program in a region of system memory
    3. Poll the DBGSTATUS Register to ensure that the debug is idle
    4. Write to the DBGINST0 Register
    5. Write to the DBGINST1 Register
    6. Write zero to the DBGCMD Register

    so, we should make sure the debug is idle before step 4/5/6, not
    only step 6. if not, there maybe a risk that fail to write DBGINST0/1.

    Signed-off-by: Sugar Zhang
    Link: https://lore.kernel.org/r/1591234598-78919-1-git-send-email-sugar.zhang@rock-chips.com
    Signed-off-by: Vinod Koul

    Sugar Zhang
     

10 Dec, 2019

2 commits

  • It has turned out that it's in general a good idea for dmaengines to allow
    DMA requests during the entire dpm_suspend() phase. Therefore, convert the
    pl330 driver into using SET_LATE_SYSTEM_SLEEP_PM_OPS.

    Signed-off-by: Ulf Hansson
    Tested-by: Marek Szyprowski
    Link: https://lore.kernel.org/r/20191205143746.24873-3-ulf.hansson@linaro.org
    Signed-off-by: Vinod Koul

    Ulf Hansson
     
  • Let's drop the boilerplate code in the system suspend/resume callbacks and
    convert to use pm_runtime_force_suspend|resume(). This change also has a
    nice side effect, as pm_runtime_force_resume() may decide to leave the
    device in low power state, when that is feasible, thus avoiding to waste
    both time and energy during system resume.

    Signed-off-by: Ulf Hansson
    Tested-by: Marek Szyprowski
    Link: https://lore.kernel.org/r/20191205143746.24873-2-ulf.hansson@linaro.org
    Signed-off-by: Vinod Koul

    Ulf Hansson
     

08 Aug, 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
     

14 Jun, 2019

1 commit

  • The DMA controller on some SoCs can be held in reset, and thus requires
    the reset signal(s) to deasserted. Most SoCs will have just one reset
    signal, but there are others, i.e. Arria10/Stratix10 will have an
    additional reset signal, referred to as the OCP.

    Add code to get the reset property from the device tree for deassert and
    assert.

    Signed-off-by: Dinh Nguyen
    Signed-off-by: Vinod Koul

    Dinh Nguyen
     

31 May, 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 as published by
    the free software foundation either version 2 of the license or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

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

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

    Thomas Gleixner
     

26 Apr, 2019

1 commit

  • This patch kill instructs the DMAC to immediately terminate
    execution of a thread. and then clear the interrupt status,
    at last, stop generating interrupts for DMA_SEV. to guarantee
    the next dma start is clean. otherwise, one interrupt maybe leave
    to next start and make some mistake.

    we can reporduce the problem as follows:

    DMASEV: modify the event-interrupt resource, and if the INTEN sets
    function as interrupt, the DMAC will set irq HIGH to
    generate interrupt. write INTCLR to clear interrupt.

    DMA EXECUTING INSTRUCTS DMA TERMINATE
    | |
    | |
    ... _stop
    | |
    | spin_lock_irqsave
    DMASEV |
    | |
    | mask INTEN
    | |
    | DMAKILL
    | |
    | spin_unlock_irqrestore

    in above case, a interrupt was left, and if we unmask INTEN, the DMAC
    will set irq HIGH to generate interrupt.

    to fix this, do as follows:

    DMA EXECUTING INSTRUCTS DMA TERMINATE
    | |
    | |
    ... _stop
    | |
    | spin_lock_irqsave
    DMASEV |
    | |
    | DMAKILL
    | |
    | clear INTCLR
    | mask INTEN
    | |
    | spin_unlock_irqrestore

    Signed-off-by: Sugar Zhang
    Signed-off-by: Vinod Koul

    Sugar Zhang
     

26 Mar, 2019

1 commit

  • This patch adds debugfs interface to show the relationship between
    DMA threads (hardware resource for transferring data) and DMA
    channel ID of DMA slave.

    Typically, PL330 has many slaves than number of DMA threads.
    So sometimes PL330 cannot allocate DMA threads for all slaves even
    if a user specify DMA channel ID in devicetree. This interface will
    be useful for checking that DMA threads are allocated or not.

    Below is an output sample:

    $ sudo cat /sys/kernel/debug/ff1f0000.dmac
    PL330 physical channels:
    THREAD: CHANNEL:
    -------- -----
    0 8
    1 9
    2 11
    3 12
    4 14
    5 15
    6 10
    7 --

    Signed-off-by: Katsuhiro Suzuki
    Signed-off-by: Vinod Koul

    Katsuhiro Suzuki
     

07 Jan, 2019

1 commit

  • Drop LIST_HEAD where the variable it declares is never used.

    The variable has not been used since the function was introduced
    in 740aa95703c5 ("dmaengine: pl330: Split device_control").

    The semantic patch that fixes this problem is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    identifier x;
    @@
    - LIST_HEAD(x);
    ... when != x
    //

    Fixes: 740aa95703c5 ("dmaengine: pl330: Split device_control")
    Signed-off-by: Julia Lawall
    Signed-off-by: Vinod Koul

    Julia Lawall
     

24 Nov, 2018

1 commit


19 Aug, 2018

1 commit

  • Pull DMAengine updates from Vinod Koul:
    "This round brings couple of framework changes, a new driver and usual
    driver updates:

    - new managed helper for dmaengine framework registration

    - split dmaengine pause capability to pause and resume and allow
    drivers to report that individually

    - update dma_request_chan_by_mask() to handle deferred probing

    - move imx-sdma to use virt-dma

    - new driver for Actions Semi Owl family S900 controller

    - minor updates to intel, renesas, mv_xor, pl330 etc"

    * tag 'dmaengine-4.19-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (46 commits)
    dmaengine: Add Actions Semi Owl family S900 DMA driver
    dt-bindings: dmaengine: Add binding for Actions Semi Owl SoCs
    dmaengine: sh: rcar-dmac: Should not stop the DMAC by rcar_dmac_sync_tcr()
    dmaengine: mic_x100_dma: use the new helper to simplify the code
    dmaengine: add a new helper dmaenginem_async_device_register
    dmaengine: imx-sdma: add memcpy interface
    dmaengine: imx-sdma: add SDMA_BD_MAX_CNT to replace '0xffff'
    dmaengine: dma_request_chan_by_mask() to handle deferred probing
    dmaengine: pl330: fix irq race with terminate_all
    dmaengine: Revert "dmaengine: mv_xor_v2: enable COMPILE_TEST"
    dmaengine: mv_xor_v2: use {lower,upper}_32_bits to configure HW descriptor address
    dmaengine: mv_xor_v2: enable COMPILE_TEST
    dmaengine: mv_xor_v2: move unmap to before callback
    dmaengine: mv_xor_v2: convert callback to helper function
    dmaengine: mv_xor_v2: kill the tasklets upon exit
    dmaengine: mv_xor_v2: explicitly freeup irq
    dmaengine: sh: rcar-dmac: Add dma_pause operation
    dmaengine: sh: rcar-dmac: add a new function to clear CHCR.DE with barrier
    dmaengine: idma64: Support dmaengine_terminate_sync()
    dmaengine: hsu: Support dmaengine_terminate_sync()
    ...

    Linus Torvalds
     

25 Jul, 2018

1 commit

  • In pl330_update() when checking if a channel has been aborted, the
    channel's lock is not taken, only the overall pl330_dmac lock. But in
    pl330_terminate_all() the aborted flag (req_running==-1) is set under
    the channel lock and not the pl330_dmac lock.

    With threaded interrupts, this leads to a potential race:

    pl330_terminate_all pl330_update
    ------------------- ------------
    lock channel
    entry
    lock pl330
    _stop channel
    unlock pl330
    lock pl330
    check req_running != -1
    req_running = -1
    _start channel

    Signed-off-by: John Keeping
    Signed-off-by: Vinod Koul

    John Keeping
     

10 Jul, 2018

2 commits


28 Jun, 2018

1 commit


13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

03 May, 2018

1 commit

  • Do DMAFLUSHP _before_ the first DMAWFP to ensure controller
    and peripheral are in agreement about dma request state before first
    transfer. Add support for burst transfers to/from peripherals. In the new
    scheme, the controller does as many burst transfers as it can then
    transfers the remaining dregs with either single transfers for
    peripherals, or with a reduced size burst for memory-to-memory transfers.

    Signed-off-by: Frank Mori Hess
    Tested-by: Frank Mori Hess
    Signed-off-by: Vinod Koul

    Frank Mori Hess
     

06 Mar, 2018

1 commit

  • When booting up with "threadirqs" in command line, all irq handlers of the DMA
    controller pl330 will be threaded forcedly. These threads will race for the same
    list, pl330->req_done.

    Before the callback, the spinlock was released. And after it, the spinlock was
    taken. This opened an race window where another threaded irq handler could steal
    the spinlock and be permitted to delete entries of the list, pl330->req_done.

    If the later deleted an entry that was still referred to by the former, there would
    be a kernel panic when the former was scheduled and tried to get the next sibling
    of the deleted entry.

    The scenario could be depicted as below:

    Thread: T1 pl330->req_done Thread: T2
    | | |
    | -A-B-C-D- |
    Locked | |
    | | Waiting
    Del A | |
    | -B-C-D- |
    Unlocked | |
    | | Locked
    Waiting | |
    | | Del B
    | | |
    | -C-D- Unlocked
    Waiting | |
    |
    Locked
    |
    get C via B
    \
    - Kernel panic

    The kernel panic looked like as below:

    Unable to handle kernel paging request at virtual address dead000000000108
    pgd = ffffff8008c9e000
    [dead000000000108] *pgd=000000027fffe003, *pud=000000027fffe003, *pmd=0000000000000000
    Internal error: Oops: 96000044 [#1] PREEMPT SMP
    Modules linked in:
    CPU: 0 PID: 85 Comm: irq/59-66330000 Not tainted 4.8.24-WR9.0.0.12_standard #2
    Hardware name: Broadcom NS2 SVK (DT)
    task: ffffffc1f5cc3c00 task.stack: ffffffc1f5ce0000
    PC is at pl330_irq_handler+0x27c/0x390
    LR is at pl330_irq_handler+0x2a8/0x390
    pc : [] lr : [] pstate: 800001c5
    sp : ffffffc1f5ce3d00
    x29: ffffffc1f5ce3d00 x28: 0000000000000140
    x27: ffffffc1f5c530b0 x26: dead000000000100
    x25: dead000000000200 x24: 0000000000418958
    x23: 0000000000000001 x22: ffffffc1f5ccd668
    x21: ffffffc1f5ccd590 x20: ffffffc1f5ccd418
    x19: dead000000000060 x18: 0000000000000001
    x17: 0000000000000007 x16: 0000000000000001
    x15: ffffffffffffffff x14: ffffffffffffffff
    x13: ffffffffffffffff x12: 0000000000000000
    x11: 0000000000000001 x10: 0000000000000840
    x9 : ffffffc1f5ce0000 x8 : ffffffc1f5cc3338
    x7 : ffffff8008ce2020 x6 : 0000000000000000
    x5 : 0000000000000000 x4 : 0000000000000001
    x3 : dead000000000200 x2 : dead000000000100
    x1 : 0000000000000140 x0 : ffffffc1f5ccd590

    Process irq/59-66330000 (pid: 85, stack limit = 0xffffffc1f5ce0020)
    Stack: (0xffffffc1f5ce3d00 to 0xffffffc1f5ce4000)
    3d00: ffffffc1f5ce3d80 ffffff80080f09d0 ffffffc1f5ca0c00 ffffffc1f6f7c600
    3d20: ffffffc1f5ce0000 ffffffc1f6f7c600 ffffffc1f5ca0c00 ffffff80080f0998
    3d40: ffffffc1f5ce0000 ffffff80080f0000 0000000000000000 0000000000000000
    3d60: ffffff8008ce202c ffffff8008ce2020 ffffffc1f5ccd668 ffffffc1f5c530b0
    3d80: ffffffc1f5ce3db0 ffffff80080f0d70 ffffffc1f5ca0c40 0000000000000001
    3da0: ffffffc1f5ce0000 ffffff80080f0cfc ffffffc1f5ce3e20 ffffff80080bf4f8
    3dc0: ffffffc1f5ca0c80 ffffff8008bf3798 ffffff8008955528 ffffffc1f5ca0c00
    3de0: ffffff80080f0c30 0000000000000000 0000000000000000 0000000000000000
    3e00: 0000000000000000 0000000000000000 0000000000000000 ffffff80080f0b68
    3e20: 0000000000000000 ffffff8008083690 ffffff80080bf420 ffffffc1f5ca0c80
    3e40: 0000000000000000 0000000000000000 0000000000000000 ffffff80080cb648
    3e60: ffffff8008b1c780 0000000000000000 0000000000000000 ffffffc1f5ca0c00
    3e80: ffffffc100000000 ffffff8000000000 ffffffc1f5ce3e90 ffffffc1f5ce3e90
    3ea0: 0000000000000000 ffffff8000000000 ffffffc1f5ce3eb0 ffffffc1f5ce3eb0
    3ec0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3ee0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3f00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3f20: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3f40: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3f60: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3f80: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3fa0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
    3fc0: 0000000000000000 0000000000000005 0000000000000000 0000000000000000
    3fe0: 0000000000000000 0000000000000000 0000000275ce3ff0 0000000275ce3ff8
    Call trace:
    Exception stack(0xffffffc1f5ce3b30 to 0xffffffc1f5ce3c60)
    3b20: dead000000000060 0000008000000000
    3b40: ffffffc1f5ce3d00 ffffff80084cb694 0000000000000008 0000000000000e88
    3b60: ffffffc1f5ce3bb0 ffffff80080dac68 ffffffc1f5ce3b90 ffffff8008826fe4
    3b80: 00000000000001c0 00000000000001c0 ffffffc1f5ce3bb0 ffffff800848dfcc
    3ba0: 0000000000020000 ffffff8008b15ae4 ffffffc1f5ce3c00 ffffff800808f000
    3bc0: 0000000000000010 ffffff80088377f0 ffffffc1f5ccd590 0000000000000140
    3be0: dead000000000100 dead000000000200 0000000000000001 0000000000000000
    3c00: 0000000000000000 ffffff8008ce2020 ffffffc1f5cc3338 ffffffc1f5ce0000
    3c20: 0000000000000840 0000000000000001 0000000000000000 ffffffffffffffff
    3c40: ffffffffffffffff ffffffffffffffff 0000000000000001 0000000000000007
    [] pl330_irq_handler+0x27c/0x390
    [] irq_forced_thread_fn+0x38/0x88
    [] irq_thread+0x140/0x200
    [] kthread+0xd8/0xf0
    [] ret_from_fork+0x10/0x40
    Code: f2a00838 f9405763 aa1c03e1 aa1503e0 (f9000443)
    ---[ end trace f50005726d31199c ]---
    Kernel panic - not syncing: Fatal exception in interrupt
    SMP: stopping secondary CPUs
    SMP: failed to stop secondary CPUs 0-1
    Kernel Offset: disabled
    Memory Limit: none
    ---[ end Kernel panic - not syncing: Fatal exception in interrupt

    To fix this, re-start with the list-head after dropping the lock then
    re-takeing it.

    Reviewed-by: Frank Mori Hess
    Tested-by: Frank Mori Hess
    Signed-off-by: Qi Hou
    Signed-off-by: Vinod Koul

    Qi Hou
     

20 Oct, 2017

1 commit

  • If two concurrent threads call pl330_get_desc() when DMAC descriptor
    pool is empty it is possible that allocation for one of threads will fail
    with message:

    kernel: dma-pl330 20078000.dma-controller: pl330_get_desc:2469 ALERT!

    Here how that can happen. Thread A calls pl330_get_desc() to get
    descriptor. If DMAC descriptor pool is empty pl330_get_desc() allocates
    new descriptor on shared pool using add_desc() and then get newly
    allocated descriptor using pluck_desc(). At the same time thread B calls
    pluck_desc() and take newly allocated descriptor. In that case descriptor
    allocation for thread A will fail.

    Using on-stack pool for new descriptor allow avoid the issue described.
    The patch modify pl330_get_desc() to use on-stack pool for allocation
    new descriptors.

    Signed-off-by: Alexander Kochetkov
    Tested-by: Marek Szyprowski
    Signed-off-by: Vinod Koul

    Alexander Kochetkov
     

28 Aug, 2017

1 commit


09 Jul, 2017

1 commit

  • Pull dmaengine updates from Vinod Koul:

    - removal of AVR32 support in dw driver as AVR32 is gone

    - new driver for Broadcom stream buffer accelerator (SBA) RAID driver

    - add support for Faraday Technology FTDMAC020 in amba-pl08x driver

    - IOMMU support in pl330 driver

    - updates to bunch of drivers

    * tag 'dmaengine-4.13-rc1' of git://git.infradead.org/users/vkoul/slave-dma: (36 commits)
    dmaengine: qcom_hidma: correct API violation for submit
    dmaengine: zynqmp_dma: Remove max len check in zynqmp_dma_prep_memcpy
    dmaengine: tegra-apb: Really fix runtime-pm usage
    dmaengine: fsl_raid: make of_device_ids const.
    dmaengine: qcom_hidma: allow ACPI/DT parameters to be overridden
    dmaengine: fsldma: set BWC, DAHTS and SAHTS values correctly
    dmaengine: Kconfig: Simplify the help text for MXS_DMA
    dmaengine: pl330: Delete unused functions
    dmaengine: Replace WARN_TAINT_ONCE() with pr_warn_once()
    dmaengine: Kconfig: Extend the dependency for MXS_DMA
    dmaengine: mxs: Use %zu for printing a size_t variable
    dmaengine: ste_dma40: Cleanup scatterlist layering violations
    dmaengine: imx-dma: cleanup scatterlist layering violations
    dmaengine: use proper name for the R-Car SoC
    dmaengine: imx-sdma: Fix compilation warning.
    dmaengine: imx-sdma: Handle return value of clk_prepare_enable
    dmaengine: pl330: Add IOMMU support to slave tranfers
    dmaengine: DW DMAC: Handle return value of clk_prepare_enable
    dmaengine: pl08x: use GENMASK() to create bitmasks
    dmaengine: pl08x: Add support for Faraday Technology FTDMAC020
    ...

    Linus Torvalds
     

17 Jun, 2017

1 commit


02 Jun, 2017

1 commit

  • When removing a device with less than 9 IRQs (AMBA_NR_IRQS), we'll get a
    big WARN_ON from devres.c because pl330_remove calls devm_free_irqs for
    unallocated irqs. Similarly to pl330_probe, check that IRQ number is
    present before calling devm_free_irq.

    Signed-off-by: Jean-Philippe Brucker
    Signed-off-by: Vinod Koul

    Jean-Philippe Brucker
     

30 May, 2017

1 commit


29 Mar, 2017

1 commit