1. 12 Mar, 2019 10 commits
  2. 25 Feb, 2019 12 commits
  3. 19 Feb, 2019 1 commit
  4. 11 Feb, 2019 2 commits
  5. 04 Feb, 2019 13 commits
    • Li Yu's avatar
      dmaengine: k3dma: Add support for dma-channel-mask · c4994a98
      Li Yu authored
      Add dma-channel-mask as a property for k3dma, it defines
      available dma channels which a non-secure mode driver can use.
      
      One sample usage of this is in Hi3660 SoC. DMA channel 0 is
      reserved to lpm3, which is a coprocessor for power management. So
      as a result, any request in kernel (which runs on main processor
      and in non-secure mode) should start from at least channel 1.
      
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: Tanglei Han <hantanglei@huawei.com>
      Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
      Cc: Ryan Grachek <ryan@edited.us>
      Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Cc: Guodong Xu <guodong.xu@linaro.org>
      Cc: dmaengine@vger.kernel.org
      Signed-off-by: default avatarLi Yu <liyu65@hisilicon.com>
      [jstultz: Reworked to use a channel mask]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      c4994a98
    • Li Yu's avatar
      dmaengine: k3dma: Delete axi_config · 1200e070
      Li Yu authored
      Axi_config controls whether DMA resources can be accessed in non-secure
      mode, such as linux kernel. The register should be set by the bootloader
      stage and depends on the device.
      
      Thus, this patch removes axi_config from k3dma driver.
      
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: Tanglei Han <hantanglei@huawei.com>
      Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
      Cc: Ryan Grachek <ryan@edited.us>
      Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Cc: dmaengine@vger.kernel.org
      Acked-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Signed-off-by: default avatarLi Yu <liyu65@hisilicon.com>
      Signed-off-by: default avatarGuodong Xu <guodong.xu@linaro.org>
      [jstultz: Minor tweaks to commit message]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      1200e070
    • Youlin Wang's avatar
      dmaengine: k3dma: Upgrade k3dma driver to support hisi_asp_dma hardware · d4bdc39f
      Youlin Wang authored
      On the hi3660 hardware there are two (at least) DMA controllers,
      the DMA-P (Peripheral DMA) and the DMA-A (Audio DMA). The
      two blocks are similar, but have some slight differences. This
      resulted in the vendor implementing two separate drivers, which
      after review, they have been able to condense and re-use the
      existing k3dma driver.
      
      Thus, this patch adds support for the new "hisi-pcm-asp-dma-1.0"
      compatible string in the binding.
      
      One difference with the DMA-A controller, is that it does not
      need to initialize a clock. So we skip this by adding and using
      soc data flags.
      
      After above this driver will support both k3 and hisi_asp dma
      hardware.
      
      Cc: Dan Williams <dan.j.williams@intel.com>
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
      Cc: Ryan Grachek <ryan@edited.us>
      Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Cc: dmaengine@vger.kernel.org
      Acked-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Signed-off-by: default avatarYoulin Wang <wwx575822@notesmail.huawei.com>
      Signed-off-by: default avatarTanglei Han <hantanglei@huawei.com>
      [jstultz: Reworked to use of_match_data, commit msg improvements]
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      d4bdc39f
    • John Stultz's avatar
      Documentation: bindings: dma: Add binding for dma-channel-mask · e2d896c0
      John Stultz authored
      Some dma channels can be reserved for secure mode or other
      hardware on the SoC, so provide a binding for a bitmask
      listing the available channels for the kernel to use.
      
      This follows the pre-existing bcm,dma-channel-mask binding.
      
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Tanglei Han <hantanglei@huawei.com>
      Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
      Cc: Ryan Grachek <ryan@edited.us>
      Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Cc: dmaengine@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      e2d896c0
    • Youlin Wang's avatar
      Documentation: bindings: k3dma: Extend the k3dma driver binding to support hisi-asp · 50fdb52a
      Youlin Wang authored
      Extend the k3dma driver binding to support hisi-asp hardware
      variants.
      
      Cc: Vinod Koul <vkoul@kernel.org>
      Cc: Rob Herring <robh+dt@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Zhuangluan Su <suzhuangluan@hisilicon.com>
      Cc: Tanglei Han <hantanglei@huawei.com>
      Cc: Ryan Grachek <ryan@edited.us>
      Cc: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Cc: dmaengine@vger.kernel.org
      Cc: devicetree@vger.kernel.org
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarYoulin Wang <wwx575822@notesmail.huawei.com>
      Signed-off-by: default avatarTanglei Han <hantanglei@huawei.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      50fdb52a
    • Scott Wood's avatar
      dmaengine: fsldma: Add 64-bit I/O accessors for powerpc64 · 6175f6a7
      Scott Wood authored
      Otherwise 64-bit PPC builds fail with undefined references
      to these accessors.
      
      Cc: Peng Ma <peng.ma@nxp.com>
      Cc: Wen He <wen.he_1@nxp.com>
      Fixes: 68997fff94afa (" dmaengine: fsldma: Adding macro FSL_DMA_IN/OUT implement for ARM platform")
      Signed-off-by: default avatarScott Wood <oss@buserror.net>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      6175f6a7
    • Lukas Wunner's avatar
      dmaengine: bcm2835: Drop outdated comment on supported transactions · 37c22cab
      Lukas Wunner authored
      Remove an outdated comment claiming the driver only supports cyclic
      transactions.  The driver has been supporting other transaction types
      for more than two years.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Florian Meier <florian.meier@koalo.de>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Acked-by: default avatarFlorian Kauer <florian.kauer@koalo.de>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      37c22cab
    • Lukas Wunner's avatar
      dmaengine: bcm2835: Drop gratuitous list deletion · efdffc1a
      Lukas Wunner authored
      The BCM2835 DMA driver deletes a channel from a list upon termination
      without having added it to a list first.  Moreover that operation is
      protected by a spinlock which isn't taken anywhere else.  These appear
      to be remnants of an older version of the driver which accidentally
      got mainlined.  Remove the dead code.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Florian Meier <florian.meier@koalo.de>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Acked-by: default avatarFlorian Kauer <florian.kauer@koalo.de>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      efdffc1a
    • Lukas Wunner's avatar
      dmaengine: bcm2835: Enforce control block alignment · 603fe86b
      Lukas Wunner authored
      Per section 4.2.1.1 of the BCM2835 ARM Peripherals spec, control blocks
      "must start at a 256 bit aligned address":
      https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
      
      This rule is currently satisfied only by accident because struct
      bcm2835_dma_cb has a size of 256 bit and the DMA pool API happens to
      allocate blocks consecutively.  It seems safer to be explicit and tell
      the DMA pool allocator about the required alignment.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Florian Meier <florian.meier@koalo.de>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Acked-by: default avatarFlorian Kauer <florian.kauer@koalo.de>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      603fe86b
    • Lukas Wunner's avatar
      dmaengine: bcm2835: Return void from abort of transactions · 3e05ada0
      Lukas Wunner authored
      bcm2835_dma_abort() returns an int but bcm2835_dma_terminate_all() (its
      sole caller) does not evaluate the return value. Change the return type
      to void.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Florian Meier <florian.meier@koalo.de>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Acked-by: default avatarFlorian Kauer <florian.kauer@koalo.de>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      3e05ada0
    • Lukas Wunner's avatar
      dmaengine: bcm2835: Fix abort of transactions · 9e528c79
      Lukas Wunner authored
      There are multiple issues with bcm2835_dma_abort() (which is called on
      termination of a transaction):
      
      * The algorithm to abort the transaction first pauses the channel by
        clearing the ACTIVE flag in the CS register, then waits for the PAUSED
        flag to clear.  Page 49 of the spec documents the latter as follows:
      
        "Indicates if the DMA is currently paused and not transferring data.
         This will occur if the active bit has been cleared [...]"
         https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
      
        So the function is entering an infinite loop because it is waiting for
        PAUSED to clear which is always set due to the function having cleared
        the ACTIVE flag.  The only thing that's saving it from itself is the
        upper bound of 10000 loop iterations.
      
        The code comment says that the intention is to "wait for any current
        AXI transfer to complete", so the author probably wanted to check the
        WAITING_FOR_OUTSTANDING_WRITES flag instead.  Amend the function
        accordingly.
      
      * The CS register is only read at the beginning of the function.  It
        needs to be read again after pausing the channel and before checking
        for outstanding writes, otherwise writes which were issued between
        the register read at the beginning of the function and pausing the
        channel may not be waited for.
      
      * The function seeks to abort the transfer by writing 0 to the NEXTCONBK
        register and setting the ABORT and ACTIVE flags.  Thereby, the 0 in
        NEXTCONBK is sought to be loaded into the CONBLK_AD register.  However
        experimentation has shown this approach to not work:  The CONBLK_AD
        register remains the same as before and the CS register contains
        0x00000030 (PAUSED | DREQ_STOPS_DMA).  In other words, the control
        block is not aborted but merely paused and it will be resumed once the
        next DMA transaction is started.  That is absolutely not the desired
        behavior.
      
        A simpler approach is to set the channel's RESET flag instead.  This
        reliably zeroes the NEXTCONBK as well as the CS register.  It requires
        less code and only a single MMIO write.  This is also what popular
        user space DMA drivers do, e.g.:
        https://github.com/metachris/RPIO/blob/master/source/c_pwm/pwm.c
      
        Note that the spec is contradictory whether the NEXTCONBK register
        is writeable at all.  On the one hand, page 41 claims:
      
        "The value loaded into the NEXTCONBK register can be overwritten so
        that the linked list of Control Block data structures can be
        dynamically altered. However it is only safe to do this when the DMA
        is paused."
      
        On the other hand, page 40 specifies:
      
        "Only three registers in each channel's register set are directly
        writeable (CS, CONBLK_AD and DEBUG). The other registers (TI,
        SOURCE_AD, DEST_AD, TXFR_LEN, STRIDE & NEXTCONBK), are automatically
        loaded from a Control Block data structure held in external memory."
      
      Fixes: 96286b57 ("dmaengine: Add support for BCM2835")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: stable@vger.kernel.org # v3.14+
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Florian Meier <florian.meier@koalo.de>
      Cc: Clive Messer <clive.m.messer@gmail.com>
      Cc: Matthias Reichl <hias@horus.com>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Acked-by: default avatarFlorian Kauer <florian.kauer@koalo.de>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      9e528c79
    • Lukas Wunner's avatar
      dmaengine: bcm2835: Fix interrupt race on RT · f7da7782
      Lukas Wunner authored
      If IRQ handlers are threaded (either because CONFIG_PREEMPT_RT_BASE is
      enabled or "threadirqs" was passed on the command line) and if system
      load is sufficiently high that wakeup latency of IRQ threads degrades,
      SPI DMA transactions on the BCM2835 occasionally break like this:
      
      ks8851 spi0.0: SPI transfer timed out
      bcm2835-dma 3f007000.dma: DMA transfer could not be terminated
      ks8851 spi0.0 eth2: ks8851_rdfifo: spi_sync() failed
      
      The root cause is an assumption made by the DMA driver which is
      documented in a code comment in bcm2835_dma_terminate_all():
      
      /*
       * Stop DMA activity: we assume the callback will not be called
       * after bcm_dma_abort() returns (even if it does, it will see
       * c->desc is NULL and exit.)
       */
      
      That assumption falls apart if the IRQ handler bcm2835_dma_callback() is
      threaded: A client may terminate a descriptor and issue a new one
      before the IRQ handler had a chance to run. In fact the IRQ handler may
      miss an *arbitrary* number of descriptors. The result is the following
      race condition:
      
      1. A descriptor finishes, its interrupt is deferred to the IRQ thread.
      2. A client calls dma_terminate_async() which sets channel->desc = NULL.
      3. The client issues a new descriptor. Because channel->desc is NULL,
         bcm2835_dma_issue_pending() immediately starts the descriptor.
      4. Finally the IRQ thread runs and writes BCM2835_DMA_INT to the CS
         register to acknowledge the interrupt. This clears the ACTIVE flag,
         so the newly issued descriptor is paused in the middle of the
         transaction. Because channel->desc is not NULL, the IRQ thread
         finalizes the descriptor and tries to start the next one.
      
      I see two possible solutions: The first is to call synchronize_irq()
      in bcm2835_dma_issue_pending() to wait until the IRQ thread has
      finished before issuing a new descriptor. The downside of this approach
      is unnecessary latency if clients desire rapidly terminating and
      re-issuing descriptors and don't have any use for an IRQ callback.
      (The SPI TX DMA channel is a case in point.)
      
      A better alternative is to make the IRQ thread recognize that it has
      missed descriptors and avoid finalizing the newly issued descriptor.
      So first of all, set the ACTIVE flag when acknowledging the interrupt.
      This keeps a newly issued descriptor running.
      
      If the descriptor was finished, the channel remains idle despite the
      ACTIVE flag being set. However the ACTIVE flag can then no longer be
      used to check whether the channel is idle, so instead check whether
      the register containing the current control block address is zero
      and finalize the current descriptor only if so.
      
      That way, there is no impact on latency and throughput if the client
      doesn't care for the interrupt: Only minimal additional overhead is
      introduced for non-cyclic descriptors as one further MMIO read is
      necessary per interrupt to check for idleness of the channel. Cyclic
      descriptors are sped up slightly by removing one MMIO write per
      interrupt.
      
      Fixes: 96286b57 ("dmaengine: Add support for BCM2835")
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: stable@vger.kernel.org # v3.14+
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Florian Meier <florian.meier@koalo.de>
      Cc: Clive Messer <clive.m.messer@gmail.com>
      Cc: Matthias Reichl <hias@horus.com>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Acked-by: default avatarFlorian Kauer <florian.kauer@koalo.de>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      f7da7782
    • Laurentiu Tudor's avatar
      dmaengine: fsl-edma: dma map slave device address · 0fa89f97
      Laurentiu Tudor authored
      This mapping needs to be created in order for slave dma transfers
      to work on systems with SMMU. The implementation mostly mimics the
      one in pl330 dma driver, authored by Robin Murphy.
      Signed-off-by: default avatarLaurentiu Tudor <laurentiu.tudor@nxp.com>
      Suggested-by: default avatarRobin Murphy <robin.murphy@arm.com>
      Tested-by: default avatarAngelo Dureghello <angelo@sysam.it>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      0fa89f97
  6. 20 Jan, 2019 2 commits