1. 07 9月, 2020 1 次提交
    • M
      spi: stm32: Rate-limit the 'Communication suspended' message · ea8be08c
      Marek Vasut 提交于
      The 'spi_stm32 44004000.spi: Communication suspended' message means that
      when using PIO, the kernel did not read the FIFO fast enough and so the
      SPI controller paused the transfer. Currently, this is printed on every
      single such event, so if the kernel is busy and the controller is pausing
      the transfers often, the kernel will be all the more busy scrolling this
      message into the log buffer every few milliseconds. That is not helpful.
      
      Instead, rate-limit the message and print it every once in a while. It is
      not possible to use the default dev_warn_ratelimited(), because that is
      still too verbose, as it prints 10 lines (DEFAULT_RATELIMIT_BURST) every
      5 seconds (DEFAULT_RATELIMIT_INTERVAL). The policy here is to print 1 line
      every 50 seconds (DEFAULT_RATELIMIT_INTERVAL * 10), because 1 line is more
      than enough and the cycles saved on printing are better left to the CPU to
      handle the SPI. However, dev_warn_once() is also not useful, as the user
      should be aware that this condition is possibly recurring or ongoing. Thus
      the custom rate-limit policy.
      
      Finally, turn the message from dev_warn() to dev_dbg(), since the system
      does not suffer any sort of malfunction if this message appears, it is
      just slowing down. This further reduces the printing into the log buffer
      and frees the CPU to do useful work.
      
      Fixes: dcbe0d84 ("spi: add driver for STM32 SPI controller")
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Alexandre Torgue <alexandre.torgue@st.com>
      Cc: Amelie Delaunay <amelie.delaunay@st.com>
      Cc: Antonio Borneo <borneo.antonio@gmail.com>
      Cc: Mark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20200905151913.117775-1-marex@denx.deSigned-off-by: NMark Brown <broonie@kernel.org>
      ea8be08c
  2. 03 9月, 2020 1 次提交
    • V
      spi: spi-loopback-test: Fix out-of-bounds read · 837ba18d
      Vincent Whitchurch 提交于
      The "tx/rx-transfer - crossing PAGE_SIZE" test always fails when
      len=131071 and rx_offset >= 5:
      
       spi-loopback-test spi0.0: Running test tx/rx-transfer - crossing PAGE_SIZE
       ...
         with iteration values: len = 131071, tx_off = 0, rx_off = 3
         with iteration values: len = 131071, tx_off = 0, rx_off = 4
         with iteration values: len = 131071, tx_off = 0, rx_off = 5
       loopback strangeness - rx changed outside of allowed range at: ...a4321000
         spi_msg@ffffffd5a4157690
           frame_length:  131071
           actual_length: 131071
           spi_transfer@ffffffd5a41576f8
             len:    131071
             tx_buf: ffffffd5a4340ffc
      
      Note that rx_offset > 3 can only occur if the SPI controller driver sets
      ->dma_alignment to a higher value than 4, so most SPI controller drivers
      are not affect.
      
      The allocated Rx buffer is of size SPI_TEST_MAX_SIZE_PLUS, which is 132
      KiB (assuming 4 KiB pages).  This test uses an initial offset into the
      rx_buf of PAGE_SIZE - 4, and a len of 131071, so the range expected to
      be written in this transfer ends at (4096 - 4) + 5 + 131071 == 132 KiB,
      which is also the end of the allocated buffer.  But the code which
      verifies the content of the buffer reads a byte beyond the allocated
      buffer and spuriously fails because this out-of-bounds read doesn't
      return the expected value.
      
      Fix this by using ITERATE_LEN instead of ITERATE_MAX_LEN to avoid
      testing sizes which cause out-of-bounds reads.
      Signed-off-by: NVincent Whitchurch <vincent.whitchurch@axis.com>
      Link: https://lore.kernel.org/r/20200902132341.7079-1-vincent.whitchurch@axis.comSigned-off-by: NMark Brown <broonie@kernel.org>
      837ba18d
  3. 26 8月, 2020 1 次提交
  4. 24 8月, 2020 1 次提交
  5. 11 8月, 2020 7 次提交
  6. 05 8月, 2020 1 次提交
  7. 03 8月, 2020 1 次提交
    • L
      spi: Prevent adding devices below an unregistering controller · ddf75be4
      Lukas Wunner 提交于
      CONFIG_OF_DYNAMIC and CONFIG_ACPI allow adding SPI devices at runtime
      using a DeviceTree overlay or DSDT patch.  CONFIG_SPI_SLAVE allows the
      same via sysfs.
      
      But there are no precautions to prevent adding a device below a
      controller that's being removed.  Such a device is unusable and may not
      even be able to unbind cleanly as it becomes inaccessible once the
      controller has been torn down.  E.g. it is then impossible to quiesce
      the device's interrupt.
      
      of_spi_notify() and acpi_spi_notify() do hold a ref on the controller,
      but otherwise run lockless against spi_unregister_controller().
      
      Fix by holding the spi_add_lock in spi_unregister_controller() and
      bailing out of spi_add_device() if the controller has been unregistered
      concurrently.
      
      Fixes: ce79d54a ("spi/of: Add OF notifier handler")
      Signed-off-by: NLukas Wunner <lukas@wunner.de>
      Cc: stable@vger.kernel.org # v3.19+
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: Octavian Purdila <octavian.purdila@intel.com>
      Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
      Link: https://lore.kernel.org/r/a8c3205088a969dc8410eec1eba9aface60f36af.1596451035.git.lukas@wunner.deSigned-off-by: NMark Brown <broonie@kernel.org>
      ddf75be4
  8. 29 7月, 2020 10 次提交
  9. 27 7月, 2020 3 次提交
  10. 22 7月, 2020 14 次提交