linux-sg2042/include/linux/iio
Linus Walleij 65925b65ed iio: st_sensors: switch to a threaded interrupt
commit 98ad8b41f58dff6b30713d7f09ae3834b8df7ded
("iio: st_sensors: verify interrupt event to status") caused
a regression when reading ST sensors from a HRTimer trigger
rather than the intrinsic interrupts: the HRTimer may
trigger faster than the sensor provides new values, and
as the check against new values available as a cause of
the interrupt trigger was done in the poll function,
this would bail out of the HRTimer interrupt with
IRQ_NONE.

So clearly we need to only check the new values available
from the proper interrupt handler and not from the poll
function, which should rather just read the raw values
from the registers, put them into the buffer and be happy.

To achieve this: switch the ST Sensors over to using a true
threaded interrupt handler.

In the interrupt thread, check if new values are available,
else yield to the (potential) next device on the same
interrupt line to check the registers. If the interrupt
was ours, proceed to poll the values.

Instead of relying on iio_trigger_generic_data_rdy_poll() as
a top half to wake up the thread that polls the sensor for
new data, have the thread call iio_trigger_poll_chained()
after determining that is is the proper source of the
interrupt. This is modelled on drivers/iio/accel/mma8452.c
which is already using a properly threaded interrupt handler.

In order to get the same precision in timestamps as
previously, where samples would be timestamped in the
poll function pf->timestamp when calling
iio_trigger_generic_data_rdy_poll() we introduce a
local timestamp in the sensor data, set it in the top half
(fastpath) of the interrupt handler and provide that to the
core when calling iio_push_to_buffers_with_timestamp().

Additionally: if the active scanmask is not set for the
sensor no IRQs should be enabled and we need to bail out
with IRQ_NONE. This can happen if spurious IRQs fire when
installing the threaded interrupt handler.

Tested with hard interrupt triggers on LIS331DL, then also
tested with hrtimers on the same sensor by creating a 75Hz
HRTimer and using it to poll the sensor.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Giuseppe Barba <giuseppe.barba@st.com>
Cc: Denis Ciocca <denis.ciocca@st.com>
Reported-by: Crestez Dan Leonard <cdleonard@gmail.com>
Tested-by: Crestez Dan Leonard <cdleonard@gmail.com>
Tested-by: Jonathan Cameron <jic23@kernel.org>
Fixes: 97865fe413 ("iio: st_sensors: verify interrupt event to status")
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-29 20:21:41 +01:00
..
accel iio: accel: kxcjk1013 3-axis accelerometer driver 2014-06-14 17:10:21 +01:00
adc iio:adc:ad_sigma_delta move to info_mask_(shared_by_type/separate) 2013-03-17 19:49:24 +00:00
common iio: st_sensors: switch to a threaded interrupt 2016-05-29 20:21:41 +01:00
dac iio: max517: Add support for MAX520 and MAX521 chips. 2015-03-28 10:57:34 +00:00
frequency iio: frequency: adf4350: cast value to unsigned to make code checkers happy 2013-06-04 18:36:52 +01:00
gyro itg3200: fix incorrect ifdef comment 2013-03-18 10:59:42 +01:00
imu iio:adis: Add support for manual self-test flag clear 2016-04-16 13:42:43 +01:00
magnetometer iio:ak8975: add mounting matrix support 2016-04-23 22:14:34 +01:00
buffer-dma.h iio: Add generic DMA buffer infrastructure 2015-10-25 13:54:34 +00:00
buffer-dmaengine.h iio: Add a DMAengine framework based buffer 2015-10-25 13:55:32 +00:00
buffer.h iio: buffer: add missing descriptions in iio_buffer_access_funcs 2016-04-03 10:27:49 +01:00
configfs.h iio:configfs: Introduce iio/configfs.h to provide a location for the configfs_subsystem 2015-12-05 16:25:30 +00:00
consumer.h iio: core: Add devm_ APIs for iio_channel_{get,release}_all 2016-04-19 19:58:15 +01:00
driver.h iio: Simplify iio_map_array_unregister API 2013-02-02 12:02:20 +00:00
events.h iio: Export userspace IIO headers 2015-02-14 17:05:03 +00:00
iio.h iio:core: mounting matrix support 2016-04-23 22:13:05 +01:00
kfifo_buf.h iio: kfifo: Add resource management devm_iio_kfifo_allocate/free 2014-12-26 11:39:57 +00:00
machine.h staging:iio:in kernel users: Add a data field for channel specific info. 2012-11-10 10:17:27 +00:00
sw_trigger.h iio:configfs: Introduce iio/configfs.h to provide a location for the configfs_subsystem 2015-12-05 16:25:30 +00:00
sysfs.h include: linux: iio: Add missing kernel doc field 2015-08-02 18:36:05 +01:00
trigger.h iio: declare struct to fix warning 2015-08-08 12:28:46 +01:00
trigger_consumer.h iio:trigger_consumer.h: Add missing includes and forward declarations 2012-08-27 18:57:59 +01:00
triggered_buffer.h iio: Fix parameters in iio_triggered_buffer_setup 2015-07-05 15:19:50 +01:00
triggered_event.h iio: Support triggered events 2015-08-27 20:47:09 +01:00
types.h iio: core: add high pass filter attributes 2015-05-17 10:32:35 +01:00