1. 18 3月, 2016 1 次提交
  2. 11 3月, 2016 1 次提交
  3. 09 3月, 2016 2 次提交
    • A
      spi: respect the maximum segment size of DMA device · df88e91b
      Andy Shevchenko 提交于
      The device which is actually does DMA may have a limitation of the maximum
      segment size. Respect this setting when preparing scatter-gather list.
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      df88e91b
    • J
      spi: core: Fix deadlock when sending messages · 49023d2e
      Jon Hunter 提交于
      The function __spi_pump_messages() is called by spi_pump_messages() and
      __spi_sync(). The function __spi_sync() has an argument 'bus_locked'
      that indicates if it is called with the SPI bus mutex held or not. If
      'bus_locked' is false then __spi_sync() will acquire the mutex itself.
      
      Commit 556351f1 ("spi: introduce accelerated read support for spi
      flash devices") made a change to acquire the SPI bus mutex within
      __spi_pump_messages(). However, this change did not check to see if the
      mutex is already held. If __spi_sync() is called with the mutex held
      (ie. 'bus_locked' is true), then a deadlock occurs when
      __spi_pump_messages() is called.
      
      Fix this deadlock by passing the 'bus_locked' state from __spi_sync() to
      __spi_pump_messages() and only acquire the mutex if not already held. In
      the case where __spi_pump_messages() is called from spi_pump_messages()
      it is assumed that the mutex is not held and so call
      __spi_pump_messages() with 'bus_locked' set to false. Finally, move the
      unlocking of the mutex to the end of the __spi_pump_messages() function
      to simplify the code and only call cond_resched() if there are no
      errors.
      
      Fixes: 556351f1 ("spi: introduce accelerated read support for spi flash devices")
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      49023d2e
  4. 22 2月, 2016 1 次提交
  5. 19 2月, 2016 2 次提交
  6. 18 2月, 2016 2 次提交
  7. 16 2月, 2016 1 次提交
  8. 13 2月, 2016 1 次提交
  9. 10 2月, 2016 5 次提交
    • V
      spi: introduce accelerated read support for spi flash devices · 556351f1
      Vignesh R 提交于
      In addition to providing direct access to SPI bus, some spi controller
      hardwares (like ti-qspi) provide special port (like memory mapped port)
      that are optimized to improve SPI flash read performance.
      This means the controller can automatically send the SPI signals
      required to read data from the SPI flash device.
      For this, SPI controller needs to know flash specific information like
      read command to use, dummy bytes and address width.
      
      Introduce spi_flash_read() interface to support accelerated read
      over SPI flash devices. SPI master drivers can implement this callback to
      support interfaces such as memory mapped read etc. m25p80 flash driver
      and other flash drivers can call this make use of such interfaces. The
      interface should only be used with SPI flashes and cannot be used with
      other SPI devices.
      Signed-off-by: NVignesh R <vigneshr@ti.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      556351f1
    • M
      spi: core: add spi_split_transfers_maxsize · d9f12122
      Martin Sperl 提交于
      Add spi_split_transfers_maxsize method that splits
      spi_transfers transparently into multiple transfers
      that are below the given max-size.
      
      This makes use of the spi_res framework via
      spi_replace_transfers to allocate/free the extra
      transfers as well as reverting back the changes applied
      while processing the spi_message.
      Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      d9f12122
    • M
      spi: core: add spi_replace_transfers method · 523baf5a
      Martin Sperl 提交于
      Add the spi_replace_transfers method that can get used
      to replace some spi_transfers from a spi_message with other
      transfers.
      Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      523baf5a
    • M
      spi: core: added spi_resource management · d780c371
      Martin Sperl 提交于
      SPI resource management framework used while processing a spi_message
      via the spi-core.
      
      The basic idea is taken from devres, but as the allocation may happen
      fairly frequently, some provisioning (in the form of an unused spi_device
      pointer argument to spi_res_alloc) has been made so that at a later stage
      we may implement reuse objects allocated earlier avoiding the repeated
      allocation by keeping a cache of objects that we can reuse.
      
      This framework can get used for:
      * rewriting spi_messages
        * to fullfill alignment requirements of the spi_master HW
        * to fullfill transfer length requirements
          (e.g: transfers need to be less than 64k)
        * consolidate spi_messages with multiple transfers into a single transfer
        when the total transfer length is below a threshold.
      * reimplement spi_unmap_buf without explicitly needing to check if it has
        been mapped
      Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      d780c371
    • M
      spi: Let drivers translate ACPI DeviceSelection to suitable Linux chip select · a0a90718
      Mika Westerberg 提交于
      In Windows it is up to the SPI host controller driver to handle the ACPI
      DeviceSelection as it likes. The SPI core does not take any part in it.
      This is different in Linux because we always expect to have chip select in
      range of 0 .. master->num_chipselect - 1.
      
      In order to support this in Linux we need a way to allow the driver to
      translate between ACPI DeviceSelection field and Linux chip select number
      so provide a new optional hook ->fw_translate_cs() that can be used by a
      driver to handle translation and call this hook if set during SPI slave
      ACPI enumeration.
      Signed-off-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Reviewed-by: NJarkko Nikula <jarkko.nikula@linux.intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      a0a90718
  10. 01 1月, 2016 1 次提交
  11. 23 12月, 2015 1 次提交
  12. 16 12月, 2015 1 次提交
  13. 02 12月, 2015 2 次提交
  14. 27 11月, 2015 1 次提交
  15. 11 11月, 2015 1 次提交
  16. 28 10月, 2015 2 次提交
  17. 24 10月, 2015 1 次提交
  18. 21 10月, 2015 1 次提交
  19. 16 10月, 2015 1 次提交
  20. 13 10月, 2015 1 次提交
    • J
      spi: Map SPI OF client IRQ at probe time · 44af7927
      Jon Hunter 提交于
      Currently the IRQs for SPI client devices, registered via device-tree,
      are mapped when the client devices are registered. If the corresponding
      irq-chip has not been probed yet, then the probing of the client device
      will fail and will not be retried. Resolve this by mapping the IRQ at
      probe time and allow the probe to be deferred if the IRQ is not yet
      available.
      
      If of_irq_get() returns an error that is not -EPROBE_DEFER, then assume
      that the SPI client does not have an IRQ and set the IRQ number to zero
      (which is equivalent to irq_of_parse_and_map()).
      
      This is based on some inputs from Thierry Reding <treding@nvidia.com>.
      
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
      Signed-off-by: NJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      44af7927
  21. 20 9月, 2015 1 次提交
  22. 06 9月, 2015 1 次提交
  23. 27 8月, 2015 1 次提交
  24. 22 8月, 2015 1 次提交
  25. 25 7月, 2015 1 次提交
  26. 07 7月, 2015 2 次提交
    • M
      spi: expose spi_master and spi_device statistics via sysfs · eca2ebc7
      Martin Sperl 提交于
      per spi-master statistics accessible as:
        /sys/class/spi_master/spi*/statistics/*
      
      per spi-device statistics accessible via:
        /sys/class/spi_master/spi*/spi*.*/statistics/*
      
      The following statistics are exposed as separate "files" inside
      these directories:
      * messages              number of spi_messages
      * transfers             number of spi_transfers
      * bytes                 number of bytes transferred
      * bytes_rx              number of bytes transmitted
      * bytes_tx              number of bytes received
      * errors                number of errors encounterd
      * timedout              number of messages that have timed out
      * spi_async             number of spi_messages submitted using spi_async
      * spi_sync              number of spi_messages submitted using spi_sync
      * spi_sync_immediate    number of spi_messages submitted using spi_sync,
                              that are handled immediately without a context switch
                              to the spi_pump worker-thread
      Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      eca2ebc7
    • A
      spi: Fix per-page mapping of unaligned vmalloc-ed buffer · 65598c13
      Andrew Gabbasov 提交于
      spi_map_buf() processes mapping of vmalloc-ed buffers in a special way,
      making mapping of every page separately. However, if the buffer is not
      aligned to page boundary (e.g. sub-array in a vmalloc-ed array), it
      fills the scatter table with page-size unaligned pieces, that cross
      page boundaries. This is incorrect and can, for example, cause memory
      corruption and various crashes when working with ubifs on spi-nor chips
      (though those drivers are themselves buggy in that they should be
      providing DMAable memory to the SPI framework).
      
      Fix this by using proper scatter table size and intra-page buffer lengths,
      so that the whole buffer splits into separate scatter table entries on
      page boundaries.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      65598c13
  27. 03 6月, 2015 1 次提交
    • M
      spi: restore rx/tx_buf in case of unset CONFIG_HAS_DMA · 4b786458
      Martin Sperl 提交于
      The case where spi_master sets the flags SPI_MASTER_MUST_RX/TX while
      CONFIG_HAS_DMA is unset (which is unlikley) together with a driver
      that reuses spi_messages with rx/tx_buff set to NULL, can result in:
      * data disclosure over the SPI (for tx_buf == NULL)
      * memory corruption (for rx_buf == NULL)
      
      This happenes when dummy_rx/dummy_tx are changing address due to krealloc
      or free and an allocation of the memory by a different part of the kernel.
      Signed-off-by: NMartin Sperl <kernel@martin.sperl.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      4b786458
  28. 12 5月, 2015 1 次提交
  29. 17 4月, 2015 1 次提交
    • R
      spi: check tx_buf and rx_buf in spi_unmap_msg · f8bb820d
      Robin Gong 提交于
      Some spi device drivers use the same tx_buf and rx_buf repeatly for better
      performance such as driver/input/touchsreen/ads7846.c, but spi core grab tx_buf
      /rx_buf of transfer and set them as dummy_tx/dummy_rx once they are NULL. Thus,
      in the second time the tx_buf/rx_buf will be replaced by dummy_tx/dummy_rx and
      the data which produced by the last tx or rx may be wrongly sent to the device
      or handled by the upper level protocol. This patch just keep the orignal value
      of tx_buf/rx_buf if they are NULL after this transfer processed.
      Signed-off-by: NRobin Gong <b38343@freescale.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      f8bb820d
  30. 08 4月, 2015 1 次提交
    • G
      spi: Make master->handle_err() callback optional to avoid crashes · ff61eb42
      Geert Uytterhoeven 提交于
      If a driver doesn't implement the master->handle_err() callback and an
      SPI transfer fails, the kernel will crash with a NULL pointer
      dereference:
      
          Unable to handle kernel NULL pointer dereference at virtual address 00000000
          pgd = c0003000
          [00000000] *pgd=80000040004003, *pmd=00000000
          Internal error: Oops: 80000206 [#1] SMP ARM
          Modules linked in:
          CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.0.0-rc7-koelsch-05861-g1fc9fdd4add4f783 #1046
          Hardware name: Generic R8A7791 (Flattened Device Tree)
          task: eec359c0 ti: eec54000 task.ti: eec54000
          PC is at 0x0
          LR is at spi_transfer_one_message+0x1cc/0x1f0
      
      Make the master->handle_err() callback optional to avoid the crash.
      
      Also fix a spelling mistake in the callback documentation while we're at
      it.
      
      Fixes: b716c4ff ("spi: introduce master->handle_err() callback")
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      ff61eb42