1. 17 Oct, 2013 10 commits
  2. 16 Oct, 2013 17 commits
  3. 15 Oct, 2013 4 commits
    • Lars-Peter Clausen's avatar
      iio:kfifo: Set update_needed to false after allocating a new buffer · cb6fbfa1
      Lars-Peter Clausen authored
      
      
      update_needed is used to decide whether the kfifo buffer needs to be
      re-allocated. It is set to true whenever the size of the buffer is changed. It
      is never set to false though, causing the buffer to always be re-allocated.
      Setting update_needed to false after the new buffer has been allocated fixes the
      problem.
      
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      cb6fbfa1
    • Lars-Peter Clausen's avatar
      iio:kfifo: Empty buffer on update · 5b78e513
      Lars-Peter Clausen authored
      
      
      The kfifo's request_update callback will free the current buffer and allocate a
      new one if the size has changed. This will remove any samples that might still
      be left in the buffer. If the size has not changed the buffer content is
      left untouched though. This is a bit inconsistent and might cause an application
      to see data from a previous capture. This patch inserts a call to
      kfifo_reset_out() when the size did not change. This makes sure that any pending
      samples are removed from the buffer.
      
      Note, due to a different bug the buffer is currently always re-allocated, even
      if the size did not change. So this patch will not change the behavior. In the
      next patch the bug will be fixed and this patch makes sure that the current
      behavior is kept.
      
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      5b78e513
    • Lars-Peter Clausen's avatar
      iio:kfifo: Protect against concurrent access from userspace · 0894d80d
      Lars-Peter Clausen authored
      
      
      It is possible for userspace to concurrently access the buffer from multiple
      threads or processes. To avoid corruption of the internal state of the buffer we
      need to add proper locking. It is possible for multiple processes to try to read
      from the buffer concurrently and it is also possible that one process causes a
      buffer re-allocation while a different process still access the buffer. Both can
      be fixed by protecting the calls to kfifo_to_user() and kfifo_alloc() by the
      same mutex. In iio_read_first_n_kfifo() we also use kfifo_recsize() instead of
      the buffers bytes_per_datum to avoid a race that can happen if bytes_per_datum
      has been changed, but the buffer has not been reallocated yet.
      
      Note that all access to the buffer from within the kernel is already properly
      synchronized, so there is no need for extra locking in iio_store_to_kfifo().
      
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      0894d80d
    • Lars-Peter Clausen's avatar
      iio:kfifo: Fix memory leak · f6c23f48
      Lars-Peter Clausen authored
      
      
      We need to free the kfifo when we release the buffer, otherwise the fifos memory
      will be leaked.
      
      Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
      Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
      f6c23f48
  4. 14 Oct, 2013 3 commits
  5. 12 Oct, 2013 6 commits