1. 28 Nov, 2018 3 commits
    • Lukas Wunner's avatar
      spi: bcm2835: Fix race on DMA termination · e82b0b38
      Lukas Wunner authored
      If a DMA transfer finishes orderly right when spi_transfer_one_message()
      determines that it has timed out, the callbacks bcm2835_spi_dma_done()
      and bcm2835_spi_handle_err() race to call dmaengine_terminate_all(),
      potentially leading to double termination.
      
      Prevent by atomically changing the dma_pending flag before calling
      dmaengine_terminate_all().
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Fixes: 3ecd37ed ("spi: bcm2835: enable dma modes for transfers meeting certain conditions")
      Cc: stable@vger.kernel.org # v4.2+
      Cc: Mathias Duckeck <m.duckeck@kunbus.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Noralf Trønnes <noralf@tronnes.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      e82b0b38
    • Lukas Wunner's avatar
      spi: bcm2835: Fix book-keeping of DMA termination · dbc94411
      Lukas Wunner authored
      If submission of a DMA TX transfer succeeds but submission of the
      corresponding RX transfer does not, the BCM2835 SPI driver terminates
      the TX transfer but neglects to reset the dma_pending flag to false.
      
      Thus, if the next transfer uses interrupt mode (because it is shorter
      than BCM2835_SPI_DMA_MIN_LENGTH) and runs into a timeout,
      dmaengine_terminate_all() will be called both for TX (once more) and
      for RX (which was never started in the first place).  Fix it.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Fixes: 3ecd37ed ("spi: bcm2835: enable dma modes for transfers meeting certain conditions")
      Cc: stable@vger.kernel.org # v4.2+
      Cc: Mathias Duckeck <m.duckeck@kunbus.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Noralf Trønnes <noralf@tronnes.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      dbc94411
    • Lukas Wunner's avatar
      spi: bcm2835: Avoid finishing transfer prematurely in IRQ mode · 56c17234
      Lukas Wunner authored
      The IRQ handler bcm2835_spi_interrupt() first reads as much as possible
      from the RX FIFO, then writes as much as possible to the TX FIFO.
      Afterwards it decides whether the transfer is finished by checking if
      the TX FIFO is empty.
      
      If very few bytes were written to the TX FIFO, they may already have
      been transmitted by the time the FIFO's emptiness is checked.  As a
      result, the transfer will be declared finished and the chip will be
      reset without reading the corresponding received bytes from the RX FIFO.
      
      The odds of this happening increase with a high clock frequency (such
      that the TX FIFO drains quickly) and either passing "threadirqs" on the
      command line or enabling CONFIG_PREEMPT_RT_BASE (such that the IRQ
      handler may be preempted between filling the TX FIFO and checking its
      emptiness).
      
      Fix by instead checking whether rx_len has reached zero, which means
      that the transfer has been received in full.  This is also more
      efficient as it avoids one bus read access per interrupt.  Note that
      bcm2835_spi_transfer_one_poll() likewise uses rx_len to determine
      whether the transfer has finished.
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Fixes: e34ff011 ("spi: bcm2835: move to the transfer_one driver model")
      Cc: stable@vger.kernel.org # v4.1+
      Cc: Mathias Duckeck <m.duckeck@kunbus.de>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Noralf Trønnes <noralf@tronnes.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      56c17234
  2. 16 Nov, 2018 1 commit
    • Tony Lindgren's avatar
      spi: omap2-mcspi: Add missing suspend and resume calls · 91b9deef
      Tony Lindgren authored
      I've been wondering still about omap2-mcspi related suspend and resume
      flakeyness and looks like we're missing calls to spi_master_suspend()
      and spi_master_resume(). Adding those and using pm_runtime_force_suspend()
      and pm_runtime_force_resume() makes things work for suspend and resume
      and allows us to stop using noirq suspend and resume.
      
      And while at it, let's use SET_SYSTEM_SLEEP_PM_OPS to simplify things
      further.
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      91b9deef
  3. 31 Oct, 2018 1 commit
  4. 24 Oct, 2018 1 commit
  5. 21 Oct, 2018 2 commits
  6. 19 Oct, 2018 5 commits
    • Vignesh R's avatar
      spi: omap2-mcspi: Add slave mode support · 89e8b9cb
      Vignesh R authored
      Add support to use McSPI controller as SPI slave. In slave mode, DMA TX
      completion does not mean entire data has been shifted out as data might
      still be stuck in FIFO waiting for master to clock the bus. Therefore,
      add an IRQ handler for slave mode to know when entire data in FIFO has
      been shifted out.
      Signed-off-by: default avatarVignesh R <vigneshr@ti.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      89e8b9cb
    • Vignesh R's avatar
      spi: omap2-mcspi: Set FIFO DMA trigger level to word length · b682cffa
      Vignesh R authored
      McSPI has 32 byte FIFO in Transmit-Receive mode. Current code tries to
      configuration FIFO watermark level for DMA trigger to be GCD of transfer
      length and max FIFO size which would mean trigger level may be set to 32
      for transmit-receive mode if length is aligned. This does not work in
      case of SPI slave mode where FIFO always needs to have data ready
      whenever master starts the clock. With DMA trigger size of 32 there will
      be a small window during slave TX where DMA is still putting data into
      FIFO but master would have started clock for next byte, resulting in
      shifting out of stale data. Similarly, on Slave RX side there may be RX
      FIFO overflow
      Fix this by setting FIFO watermark for DMA trigger to word
      length. This means DMA is triggered as soon as FIFO has space for word
      length bytes and DMA would make sure FIFO is almost always full
      therefore improving FIFO occupancy in both master and slave mode.
      Signed-off-by: default avatarVignesh R <vigneshr@ti.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      b682cffa
    • Vignesh R's avatar
      spi: omap2-mcspi: Switch to readl_poll_timeout() · 13d515c7
      Vignesh R authored
      Use standard readl_poll_timeout() macro for polling on status bits.
      Signed-off-by: default avatarVignesh R <vigneshr@ti.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      13d515c7
    • Ludovic Barre's avatar
      spi: spi-mem: add stm32 qspi controller · c530cd1d
      Ludovic Barre authored
      The qspi controller is a specialized communication interface
      targeting single, dual or quad SPI Flash memories (NOR/NAND).
      
      It can operate in any of the following modes:
      -indirect mode: all the operations are performed using the quadspi
       registers
      -read memory-mapped mode: the external Flash memory is mapped to the
       microcontroller address space and is seen by the system as if it was
       an internal memory
      
      tested on:
      -NOR: mx66l51235l
      -NAND: MT29F2G01ABAGD
      Signed-off-by: default avatarLudovic Barre <ludovic.barre@st.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      c530cd1d
    • Ludovic Barre's avatar
      dt-bindings: spi: add stm32 qspi controller · c3e6845e
      Ludovic Barre authored
      This patch adds the documentation of device tree bindings
      for the STM32 QSPI controller. It is a specialized communication
      interface targeting single, dual or quad SPI Flash memories (NOR/NAND).
      Signed-off-by: default avatarLudovic Barre <ludovic.barre@st.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      c3e6845e
  7. 17 Oct, 2018 2 commits
  8. 12 Oct, 2018 5 commits
  9. 11 Oct, 2018 16 commits
  10. 10 Oct, 2018 4 commits