1. 02 3月, 2017 1 次提交
  2. 07 2月, 2017 1 次提交
  3. 01 2月, 2017 2 次提交
    • J
      spi: fix device-node leaks · 8324147f
      Johan Hovold 提交于
      Make sure to release the device-node reference taken in
      of_register_spi_device() on errors and when deregistering the device.
      
      Fixes: 284b0189 ("spi: Add OF binding support for SPI busses")
      Signed-off-by: NJohan Hovold <johan@kernel.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8324147f
    • D
      spi: When no dma_chan map buffers with spi_master's parent · 88b0aa54
      Daniel Kurtz 提交于
      Back before commit 1dccb598 ("arm64: simplify dma_get_ops"), for
      arm64, devices for which dma_ops were not explicitly set were automatically
      configured to use swiotlb_dma_ops, since this was hard-coded as the
      global "dma_ops" in arm64_dma_init().
      
      Now that global "dma_ops" has been removed, all devices much have their
      dma_ops explicitly set by a call to arch_setup_dma_ops(), otherwise the
      device is assigned dummy_dma_ops, and thus calls to map_sg for such a
      device will fail (return 0).
      
      Mediatek SPI uses DMA but does not use a dma channel.  Support for this
      was added by commit c37f45b5 ("spi: support spi without dma channel
      to use can_dma()"), which uses the master_spi dev to DMA map buffers.
      
      The master_spi device is not a platform device, rather it is created
      in spi_alloc_device(), and therefore its dma_ops are never set.
      
      Therefore, when the mediatek SPI driver when it does DMA (for large SPI
      transactions > 32 bytes), SPI will use spi_map_buf()->dma_map_sg() to
      map the buffer for use in DMA.  But dma_map_sg()->dma_map_sg_attrs() returns
      0, because ops->map_sg is dummy_dma_ops->__dummy_map_sg, and hence
      spi_map_buf() returns -ENOMEM (-12).
      
      Fix this by using the real spi_master's parent device which should be a
      real physical device with DMA properties.
      Signed-off-by: NDaniel Kurtz <djkurtz@chromium.org>
      Fixes: c37f45b5 ("spi: support spi without dma channel to use can_dma()")
      Cc: Leilk Liu <leilk.liu@mediatek.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      88b0aa54
  4. 18 1月, 2017 1 次提交
  5. 16 12月, 2016 1 次提交
  6. 23 11月, 2016 1 次提交
    • J
      spi: use sg_next for walking through the allocated scatterlist table · 8dd4a016
      Juan Gutierrez 提交于
      A null dereference or Oops exception might occurs when reading at once the
      whole content of an spi-nor of big enough size that requires an scatterlist
      table that does not fit into one single page.
      
      The spi_map_buf function is ignoring the chained sg case by dereferenceing
      the scatterlist elements in an array fashion. This wrongly assumes that
      the allocation of the scatterlist elements are contiguous. This is true as
      long as the scatterlist table fits within a PAGE_SIZE. However, for
      allocation where the scatter table is bigger than that, the pages allocated
      by sg_alloc might not be contigous.
      
      The sg table can be properly walked by sg_next instead of using an array.
      Signed-off-by: NJuan Gutierrez <juan.gutierrez@nxp.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8dd4a016
  7. 26 10月, 2016 1 次提交
    • D
      spi: change post transfer udelay() to usleep_range() for long delays · 8244bd3a
      Daniel Kurtz 提交于
      The spi_transfer parameter delay_usecs allows specifying a time to wait
      after transferring a spi message.  This wait can be quite long - some
      devices, such as some Chrome OS ECs, require as much as 2000 usecs after
      a SPI transaction, before it can respond.
      
      (cf: arch/arm64/boot/dts/nvidia/tegra132-norrin.dts:
         google,cros-ec-spi-msg-delay = <2000>
      )
      
      Blocking a CPU for 2 msecs in a busy loop like this doesn't seem very
      friendly to other processes, so change the blocking delay to a sleep
      to allow other things to use this CPU (or so it can sleep).
      
      This should be safe to do, because:
       (a) A post-transaction delay like this is always specified as a minimum
           wait time
       (b) A delay here is most likely not very time sensitive, as it occurs
           after all data has been transferred
       (c) This delay occurs in a non-critical section of the spi worker thread
           so where it is safe to sleep.
      
      Two caveats:
       1) To avoid penalizing short delays, still use udelay for delays < 10us.
       2) usleep_range() very often picks the upper bound, an upper bounds 10%
          should be plenty.
      Signed-off-by: NDaniel Kurtz <djkurtz@chromium.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8244bd3a
  8. 25 10月, 2016 1 次提交
  9. 21 10月, 2016 1 次提交
    • T
      spi: Add Flag to Enable Slave Select with GPIO Chip Select. · 8eee6b9d
      Thor Thayer 提交于
      Some SPI masters require slave selection before the transfer
      can begin [1]. The SPI framework currently selects the chip using
      either 1) the internal CS mechanism or 2) the GPIO CS, but not both.
      
      This patch adds a new master->flags define to indicate both the GPIO
      CS and the internal chip select mechanism should be used.
      
      Tested On:
          Altera CycloneV development kit
          Compile tested for build errors on x86_64 (allyesconfigs)
      
      [1] DesignWare dw_apb_ssi Databook, Version 3.20a (page 39)
      Signed-off-by: NThor Thayer <tthayer@opensource.altera.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      8eee6b9d
  10. 12 10月, 2016 1 次提交
    • P
      kthread: kthread worker API cleanup · 3989144f
      Petr Mladek 提交于
      A good practice is to prefix the names of functions by the name
      of the subsystem.
      
      The kthread worker API is a mix of classic kthreads and workqueues.  Each
      worker has a dedicated kthread.  It runs a generic function that process
      queued works.  It is implemented as part of the kthread subsystem.
      
      This patch renames the existing kthread worker API to use
      the corresponding name from the workqueues API prefixed by
      kthread_:
      
      __init_kthread_worker()		-> __kthread_init_worker()
      init_kthread_worker()		-> kthread_init_worker()
      init_kthread_work()		-> kthread_init_work()
      insert_kthread_work()		-> kthread_insert_work()
      queue_kthread_work()		-> kthread_queue_work()
      flush_kthread_work()		-> kthread_flush_work()
      flush_kthread_worker()		-> kthread_flush_worker()
      
      Note that the names of DEFINE_KTHREAD_WORK*() macros stay
      as they are. It is common that the "DEFINE_" prefix has
      precedence over the subsystem names.
      
      Note that INIT() macros and init() functions use different
      naming scheme. There is no good solution. There are several
      reasons for this solution:
      
        + "init" in the function names stands for the verb "initialize"
          aka "initialize worker". While "INIT" in the macro names
          stands for the noun "INITIALIZER" aka "worker initializer".
      
        + INIT() macros are used only in DEFINE() macros
      
        + init() functions are used close to the other kthread()
          functions. It looks much better if all the functions
          use the same scheme.
      
        + There will be also kthread_destroy_worker() that will
          be used close to kthread_cancel_work(). It is related
          to the init() function. Again it looks better if all
          functions use the same naming scheme.
      
        + there are several precedents for such init() function
          names, e.g. amd_iommu_init_device(), free_area_init_node(),
          jump_label_init_type(),  regmap_init_mmio_clk(),
      
        + It is not an argument but it was inconsistent even before.
      
      [arnd@arndb.de: fix linux-next merge conflict]
       Link: http://lkml.kernel.org/r/20160908135724.1311726-1-arnd@arndb.de
      Link: http://lkml.kernel.org/r/1470754545-17632-3-git-send-email-pmladek@suse.comSuggested-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NPetr Mladek <pmladek@suse.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Jiri Kosina <jkosina@suse.cz>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Michal Hocko <mhocko@suse.cz>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3989144f
  11. 11 10月, 2016 1 次提交
    • T
      spi: Add Flag to Enable Slave Select with GPIO Chip Select. · 6b1576aa
      Thor Thayer 提交于
      Some SPI masters require slave selection before the transfer
      can begin [1]. The SPI framework currently selects the chip using
      either 1) the internal CS mechanism or 2) the GPIO CS, but not both.
      
      This patch adds a new master->flags define to indicate both the GPIO
      CS and the internal chip select mechanism should be used.
      
      Tested On:
          Altera CycloneV development kit
          Compile tested for build errors on x86_64 (allyesconfigs)
      
      [1] DesignWare dw_apb_ssi Databook, Version 3.20a (page 39)
      Signed-off-by: NThor Thayer <tthayer@opensource.altera.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      6b1576aa
  12. 03 9月, 2016 1 次提交
  13. 17 8月, 2016 1 次提交
  14. 10 8月, 2016 1 次提交
  15. 25 7月, 2016 1 次提交
    • M
      spi: Split bus and I/O locking · ef4d96ec
      Mark Brown 提交于
      The current SPI code attempts to use bus_lock_mutex for two purposes. One
      is to implement spi_bus_lock() which grants exclusive access to the bus.
      The other is to serialize access to the physical hardware. This duplicate
      purpose causes confusion which leads to cases where access is not locked
      when a caller holds the bus lock mutex. Fix this by splitting out the I/O
      functionality into a new io_mutex.
      
      This means taking both mutexes in the DMA path, replacing the existing
      mutex with the new I/O one in the message pump (the mutex now always
      being taken in the message pump) and taking the bus lock mutex in
      spi_sync(), allowing __spi_sync() to have no mutex handling.
      
      While we're at it hoist the mutex further up the message pump before we
      power up the device so that all power up/down of the block is covered by
      it and there are no races with in-line pumping of messages.
      Reported-by: NRich Felker <dalias@libc.org>
      Tested-by: NRich Felker <dalias@libc.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      ef4d96ec
  16. 09 7月, 2016 1 次提交
    • O
      spi / ACPI: add support for ACPI reconfigure notifications · 7f24467f
      Octavian Purdila 提交于
      This patch adds supports for SPI device enumeration and removal via
      ACPI reconfiguration notifications that are send as a result of an
      ACPI table load or unload operation.
      
      The code is very similar with the device tree reconfiguration code
      with only small differences in the way we test and set the enumerated
      state of the device:
      
       * the equivalent of device tree's OF_POPULATED flag is the
         flags.visited field in the ACPI device and the following wrappers
         are used to manipulate it: acpi_device_enumerated(),
         acpi_device_set_enumerated() and acpi_device_clear_enumerated()
      
       * the device tree code checks of status of the OF_POPULATED flag to
         avoid trying to create duplicate Linux devices in two places: once
         when the controller is probed, and once when the reconfigure event
         is received; in the ACPI code the check is performed only once when
         the ACPI namespace is searched because this code path is invoked in
         both of the two mentioned cases
      
      The rest of the enumeration handling is similar with device tree: when
      the Linux device is unregistered the ACPI device is marked as not
      enumerated; also, when a device remove notification is received we
      check that the device is in the enumerated state before continuing
      with the removal of the Linux device.
      Signed-off-by: NOctavian Purdila <octavian.purdila@intel.com>
      Reviewed-by: NMika Westerberg <mika.westerberg@linux.intel.com>
      Acked-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      7f24467f
  17. 08 6月, 2016 1 次提交
    • V
      spi: Add DMA support for spi_flash_read() · f4502dd1
      Vignesh R 提交于
      Few SPI devices provide accelerated read interfaces to read from
      SPI-NOR flash devices. These hardwares also support DMA to transfer data
      from flash to memory either via mem-to-mem DMA or dedicated slave DMA
      channels. Hence, add support for DMA in order to improve throughput and
      reduce CPU load.
      Use spi_map_buf() to get sg table for the buffer and pass it to SPI
      driver.
      Signed-off-by: NVignesh R <vigneshr@ti.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      f4502dd1
  18. 04 5月, 2016 1 次提交
  19. 26 4月, 2016 1 次提交
  20. 12 4月, 2016 1 次提交
  21. 18 3月, 2016 1 次提交
  22. 11 3月, 2016 1 次提交
  23. 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
  24. 22 2月, 2016 1 次提交
  25. 19 2月, 2016 2 次提交
  26. 18 2月, 2016 2 次提交
  27. 16 2月, 2016 1 次提交
  28. 13 2月, 2016 1 次提交
  29. 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
  30. 01 1月, 2016 1 次提交
  31. 23 12月, 2015 1 次提交
  32. 16 12月, 2015 1 次提交