remarkable-linux/drivers/iio
Lars-Peter Clausen b91accafbb iio:event: Fix and cleanup locking
The event code currently holds a spinlock with IRQs disabled while calling
kfifo_to_user(). kfifo_to_user() can generate a page fault though, which means
we have to be able to sleep, which is not possible if the interrupts are
disabled. The good thing is that kfifo handles concurrent read and write access
just fine as long as there is only one reader and one writer, so we do not any
locking to protect against concurrent access from the read and writer thread. It
is possible though that userspace is trying to read from the event FIFO from
multiple concurrent threads, so we need to add locking to protect against this.
This is done using a mutex. The mutex will only protect the kfifo_to_user()
call, it will not protect the waitqueue. This means that multiple threads can be
waiting for new data and once a new event is added to the FIFO all waiting
threads will be woken up. If one of those threads is unable to read any data
(because another thread already read all the data) it will go back to sleep. The
only remaining issue is that now that the clearing of the BUSY flag and the
emptying of the FIFO does no longer happen in one atomic step it is possible
that a event is added to the FIFO after it has been emptied and this sample will
be visible the next time a new event file descriptor is created. To avoid this
rather move the emptying of the FIFO from iio_event_chrdev_release to
iio_event_getfd().

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2014-02-23 15:53:25 +00:00
..
accel iio:accel:bma180: Make LOW_PASS_FILTER_3DB_FREQUENCY shared_by_type 2014-02-15 11:05:02 +00:00
adc iio:max1363 fix typos of int_vref_mv 2014-02-18 08:44:11 +00:00
amplifiers iio: amplifiers: ad8366: Remove regulator_put 2013-09-28 11:49:45 +01:00
common iio: hid-sensors: Fix power and report state 2013-12-02 21:05:32 +00:00
dac iio: dac: ad7303: remove an unneeded check 2014-02-03 21:44:42 +00:00
frequency Merge 3.12-rc6 into staging-next. 2013-10-19 13:14:34 -07:00
gyro Merge v3.13-rc2 into staging-next 2013-12-02 16:39:07 -08:00
humidity iio: Add si7005 relative humidity and temperature sensor driver 2014-01-11 11:12:44 +00:00
imu First set of new drivers and cleanups for IIO in the 3.15 cycle. 2014-02-11 14:12:12 -08:00
light iio: hid-sensors: Added Proximity Sensor Driver 2014-02-22 13:07:01 +00:00
magnetometer iio:magnetometer:mag3110: Scale factor missing for temperature 2014-02-15 09:54:46 +00:00
orientation iio: hid-sensors: Added Inclinometer 3D 2013-12-03 20:31:59 +00:00
pressure iio:pressure: Add support for LPS25H pressure sensor 2014-02-22 13:09:53 +00:00
temperature Merge 3.12-rc2 into staging-next. 2013-09-25 08:59:04 -07:00
trigger iio:trigger: fix sysfs name on list mutex 2013-09-28 11:51:16 +01:00
buffer_cb.c iio get rid of unneccessary error_ret 2014-02-18 08:46:36 +00:00
iio_core.h iio: Factor IIO value formating into its own function 2013-10-12 12:23:33 +01:00
iio_core_trigger.h
industrialio-buffer.c iio get rid of unneccessary error_ret 2014-02-18 08:46:36 +00:00
industrialio-core.c iio: Avoid unnecessary kasprintf 2014-02-18 10:31:11 +00:00
industrialio-event.c iio:event: Fix and cleanup locking 2014-02-23 15:53:25 +00:00
industrialio-trigger.c iio get rid of unneccessary error_ret 2014-02-18 08:46:36 +00:00
industrialio-triggered-buffer.c iio:triggered-buffer: Remove redundant call to iio_sw_buffer_preenable(). 2013-10-16 19:12:47 +01:00
inkern.c
Kconfig iio: hid-sensors: Added Inclinometer 3D 2013-12-03 20:31:59 +00:00
kfifo_buf.c iio: kfifo_buf: Implement data_available() callback 2013-12-03 20:22:28 +00:00
Makefile iio: hid-sensors: Added Inclinometer 3D 2013-12-03 20:31:59 +00:00