1. 11 6月, 2019 1 次提交
  2. 31 5月, 2019 6 次提交
    • C
      spi: Fix zero length xfer bug · cc211863
      Chris Lesiak 提交于
      [ Upstream commit 5442dcaa0d90fc376bdfc179a018931a8f43dea4 ]
      
      This fixes a bug for messages containing both zero length and
      unidirectional xfers.
      
      The function spi_map_msg will allocate dummy tx and/or rx buffers
      for use with unidirectional transfers when the hardware can only do
      a bidirectional transfer.  That dummy buffer will be used in place
      of a NULL buffer even when the xfer length is 0.
      
      Then in the function __spi_map_msg, if he hardware can dma,
      the zero length xfer will have spi_map_buf called on the dummy
      buffer.
      
      Eventually, __sg_alloc_table is called and returns -EINVAL
      because nents == 0.
      
      This fix prevents the error by not using the dummy buffer when
      the xfer length is zero.
      Signed-off-by: NChris Lesiak <chris.lesiak@licor.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      cc211863
    • T
      spi: imx: stop buffer overflow in RX FIFO flush · 8f7f333a
      Trent Piepho 提交于
      [ Upstream commit c842749ea1d32513f9e603c074d60d7aa07cb2ef ]
      
      Commit 71abd290 ("spi: imx: Add support for SPI Slave mode") added
      an RX FIFO flush before start of a transfer.  In slave mode, the master
      may have sent more data than expected and this data will still be in the
      RX FIFO at the start of the next transfer, and so needs to be flushed.
      
      However, the code to do the flush was accidentally saving this data into
      the previous transfer's RX buffer, clobbering the contents of whatever
      followed that buffer.
      
      Change it to empty the FIFO and throw away the data.  Every one of the
      RX functions for the different eCSPI versions and modes reads the RX
      FIFO data using the same readl() call, so just use that, rather than
      using the spi_imx->rx function pointer and making sure all the different
      rx functions have a working "throw away" mode.
      
      There is another issue, which affects master mode when switching from
      DMA to PIO.  There can be extra data in the RX FIFO which triggers this
      flush code, causing memory corruption in the same manner.  I don't know
      why this data is unexpectedly in the FIFO.  It's likely there is a
      different bug or erratum responsible for that.  But regardless of that,
      I think this is proper fix the for bug at hand here.
      
      Fixes: 71abd290 ("spi: imx: Add support for SPI Slave mode")
      Cc: Jiada Wang <jiada_wang@mentor.com>
      Cc: Fabio Estevam <festevam@gmail.com>
      Cc: Stefan Agner <stefan@agner.ch>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Signed-off-by: NTrent Piepho <tpiepho@impinj.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8f7f333a
    • G
      spi: rspi: Fix sequencer reset during initialization · 3ae1817a
      Geert Uytterhoeven 提交于
      [ Upstream commit 26843bb128590edd7eba1ad7ce22e4b9f1066ce3 ]
      
      While the sequencer is reset after each SPI message since commit
      880c6d11 ("spi: rspi: Add support for Quad and Dual SPI
      Transfers on QSPI"), it was never reset for the first message, thus
      relying on reset state or bootloader settings.
      
      Fix this by initializing it explicitly during configuration.
      
      Fixes: 0b2182dd ("spi: add support for Renesas RSPI")
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3ae1817a
    • A
      spi : spi-topcliff-pch: Fix to handle empty DMA buffers · bdc09563
      Aditya Pakki 提交于
      [ Upstream commit f37d8e67f39e6d3eaf4cc5471e8a3d21209843c6 ]
      
      pch_alloc_dma_buf allocated tx, rx DMA buffers which can fail. Further,
      these buffers are used without a check. The patch checks for these
      failures and sends the error upstream.
      Signed-off-by: NAditya Pakki <pakki001@umn.edu>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      bdc09563
    • S
      spi: tegra114: reset controller on probe · ba906246
      Sowjanya Komatineni 提交于
      [ Upstream commit 019194933339b3e9b486639c8cb3692020844d65 ]
      
      Fixes: SPI driver can be built as module so perform SPI controller reset
      on probe to make sure it is in valid state before initiating transfer.
      Signed-off-by: NSowjanya Komatineni <skomatineni@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ba906246
    • F
      spi: pxa2xx: fix SCR (divisor) calculation · 57667dc8
      Flavio Suligoi 提交于
      [ Upstream commit 29f2133717c527f492933b0622a4aafe0b3cbe9e ]
      
      Calculate the divisor for the SCR (Serial Clock Rate), avoiding
      that the SSP transmission rate can be greater than the device rate.
      
      When the division between the SSP clock and the device rate generates
      a reminder, we have to increment by one the divisor.
      In this way the resulting SSP clock will never be greater than the
      device SPI max frequency.
      
      For example, with:
      
       - ssp_clk  = 50 MHz
       - dev freq = 15 MHz
      
      without this patch the SSP clock will be greater than 15 MHz:
      
       - 25 MHz for PXA25x_SSP and CE4100_SSP
       - 16,56 MHz for the others
      
      Instead, with this patch, we have in both case an SSP clock of 12.5MHz,
      so the max rate of the SPI device clock is respected.
      Signed-off-by: NFlavio Suligoi <f.suligoi@asem.it>
      Reviewed-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Reviewed-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      57667dc8
  3. 24 3月, 2019 2 次提交
  4. 10 1月, 2019 4 次提交
    • L
      spi: bcm2835: Unbreak the build of esoteric configs · feb0be15
      Lukas Wunner 提交于
      commit 29bdedfd9cf40e59456110ca417a8cb672ac9b92 upstream.
      
      Commit e82b0b382845 ("spi: bcm2835: Fix race on DMA termination") broke
      the build with COMPILE_TEST=y on arches whose cmpxchg() requires 32-bit
      operands (xtensa, older arm ISAs).
      
      Fix by changing the dma_pending flag's type from bool to unsigned int.
      
      Fixes: e82b0b382845 ("spi: bcm2835: Fix race on DMA termination")
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Cc: Frank Pavlic <f.pavlic@kunbus.de>
      Cc: Martin Sperl <kernel@martin.sperl.org>
      Cc: Noralf Trønnes <noralf@tronnes.org>
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      feb0be15
    • L
      spi: bcm2835: Avoid finishing transfer prematurely in IRQ mode · 9e9c6698
      Lukas Wunner 提交于
      commit 56c1723426d3cfd4723bfbfce531d7b38bae6266 upstream.
      
      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: NLukas 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: NMark Brown <broonie@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e9c6698
    • L
      spi: bcm2835: Fix book-keeping of DMA termination · cc8b83ff
      Lukas Wunner 提交于
      commit dbc944115eed48af110646992893dc43321368d8 upstream.
      
      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: NLukas 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: NMark Brown <broonie@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cc8b83ff
    • L
      spi: bcm2835: Fix race on DMA termination · 63f97d30
      Lukas Wunner 提交于
      commit e82b0b3828451c1cd331d9f304c6078fcd43b62e upstream.
      
      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: NLukas 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: NMark Brown <broonie@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      63f97d30
  5. 17 12月, 2018 1 次提交
  6. 14 11月, 2018 5 次提交
    • L
      spi: gpio: No MISO does not imply no RX · 74e8d287
      Linus Walleij 提交于
      [ Upstream commit abf5feef3ff0cefade0c76be53b59e55fdd46093 ]
      
      There is a logical problem in spi-gpio with host just
      assigning a MOSI line and no MISO: this is interpreted
      as the host cannot do RX and the host is flagged with
      SPI_MASTER_NO_RX.
      
      This is wrong: since GPIO lines can switch direction,
      in 3WIRE operation the host will simply reverse the
      direction of the GPIO line and start reading from it,
      there is even code for doing this in the driver, but
      it went unnoticed because it was tested by using a
      master with 4 wires but a device using just 3 wires.
      
      Remove the offending flag.
      
      Cc: Andrzej Hajda <a.hajda@samsung.com>
      Cc: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      74e8d287
    • N
      spi: spi-ep93xx: Use dma_data_direction for ep93xx_spi_dma_{finish,prepare} · c2128082
      Nathan Chancellor 提交于
      [ Upstream commit a1108c7b2efb892350ba6a0e932dfd45622f4e2b ]
      
      Clang warns when one enumerated type is implicitly converted to another.
      
      drivers/spi/spi-ep93xx.c:342:62: warning: implicit conversion from
      enumeration type 'enum dma_transfer_direction' to different enumeration
      type 'enum dma_data_direction' [-Wenum-conversion]
              nents = dma_map_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
      ./include/linux/dma-mapping.h:428:58: note: expanded from macro
      'dma_map_sg'
      #define dma_map_sg(d, s, n, r) dma_map_sg_attrs(d, s, n, r, 0)
                                     ~~~~~~~~~~~~~~~~          ^
      drivers/spi/spi-ep93xx.c:348:57: warning: implicit conversion from
      enumeration type 'enum dma_transfer_direction' to different enumeration
      type 'enum dma_data_direction' [-Wenum-conversion]
                      dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
      ./include/linux/dma-mapping.h:429:62: note: expanded from macro
      'dma_unmap_sg'
      #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, 0)
                                       ~~~~~~~~~~~~~~~~~~          ^
      drivers/spi/spi-ep93xx.c:377:56: warning: implicit conversion from
      enumeration type 'enum dma_transfer_direction' to different enumeration
      type 'enum dma_data_direction' [-Wenum-conversion]
              dma_unmap_sg(chan->device->dev, sgt->sgl, sgt->nents, dir);
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
      ./include/linux/dma-mapping.h:429:62: note: expanded from macro
      'dma_unmap_sg'
      #define dma_unmap_sg(d, s, n, r) dma_unmap_sg_attrs(d, s, n, r, 0)
                                       ~~~~~~~~~~~~~~~~~~          ^
      3 warnings generated.
      
      dma_{,un}map_sg expect an enum of type dma_data_direction but this
      driver uses dma_transfer_direction for everything. Convert the driver to
      use dma_data_direction for these two functions.
      
      There are two places that strictly require an enum of type
      dma_transfer_direction: the direction member in struct dma_slave_config
      and the direction parameter in dmaengine_prep_slave_sg. To avoid using
      an explicit cast, add a simple function, ep93xx_dma_data_to_trans_dir,
      to safely map between the two types because they are not 1 to 1 in
      meaning.
      Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2128082
    • R
      spi: bcm-qspi: fix calculation of address length · 95e124ad
      Rafał Miłecki 提交于
      commit 0976eda7915507fe94e07870c19d717c9994b57a upstream.
      
      During implementation of the new API bcm_qspi_bspi_set_flex_mode() has
      been modified breaking calculation of address length. An unnecessary
      multiplication was added breaking flash reads.
      
      Fixes: 5f195ee7 ("spi: bcm-qspi: Implement the spi_mem interface")
      Signed-off-by: NRafał Miłecki <rafal@milecki.pl>
      Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95e124ad
    • R
      spi: bcm-qspi: switch back to reading flash using smaller chunks · 97baa6b2
      Rafał Miłecki 提交于
      commit 940ec770c295682993d1cccce3081fd7c74fece8 upstream.
      
      Fixing/optimizing bcm_qspi_bspi_read() performance introduced two
      changes:
      1) It added a loop to read all requested data using multiple BSPI ops.
      2) It bumped max size of a single BSPI block request from 256 to 512 B.
      
      The later change resulted in occasional BSPI timeouts causing a
      regression.
      
      For some unknown reason hardware doesn't always handle reads as expected
      when using 512 B chunks. In such cases it may happen that BSPI returns
      amount of requested bytes without the last 1-3 ones. It provides the
      remaining bytes later but doesn't raise an interrupt until another LR
      start.
      
      Switching back to 256 B reads fixes that problem and regression.
      
      Fixes: 345309fa ("spi: bcm-qspi: Fix bcm_qspi_bspi_read() performance")
      Signed-off-by: NRafał Miłecki <rafal@milecki.pl>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97baa6b2
    • C
      spi: spi-mem: Adjust op len based on message/transfer size limitations · 9251a21b
      Chuanhua Han 提交于
      commit e757996cafbeb6b71234a17130674bcd8f44c59e upstream.
      
      We need that to adjust the len of the 2nd transfer (called data in
      spi-mem) if it's too long to fit in a SPI message or SPI transfer.
      
      Fixes: c36ff266 ("spi: Extend the core to ease integration of SPI memory controllers")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NChuanhua Han <chuanhua.han@nxp.com>
      Reviewed-by: NBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9251a21b
  7. 05 9月, 2018 5 次提交
  8. 03 9月, 2018 1 次提交
  9. 29 8月, 2018 2 次提交
  10. 15 8月, 2018 1 次提交
  11. 10 8月, 2018 1 次提交
  12. 02 8月, 2018 2 次提交
  13. 01 8月, 2018 3 次提交
  14. 30 7月, 2018 4 次提交
  15. 26 7月, 2018 1 次提交
  16. 24 7月, 2018 1 次提交
    • M
      spi: imx: Use the longuest possible burst size when in dynamic_burst · 2ca300ac
      Maxime Chevallier 提交于
      Dynamic burst mode allows to group together multiple words and send them
      in one continuous burst. When the number of bytes to be sent is not a
      strict multiple of the FIFO entry size (32 bits), the controller expects
      the non aligned bits to be sent first.
      
      This commit adds support for this particular constraint, avoiding the
      need to send the non-aligned bytes one by one at the end of the
      transfer, speeding-up transfer speed in that case.
      
      With this method, a transfer is divided into multiple bursts, limited in
      size by the maximum amount of data that the controller can transfer in
      one continuous burst (which is 512 bytes).
      
      The non-512 byte part of the transfer is sent first. The remaining bytes
      to be transferred in the current burst is stored in the 'remainder'
      field.
      
      With this method, the read_u32 field is no longer necessary, and is
      removed.
      
      This was tested on imx6 solo and imx6 quad.
      Signed-off-by: NMaxime Chevallier <maxime.chevallier@bootlin.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      2ca300ac