diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-07-16 16:28:00 +0200 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2013-07-20 11:18:53 +0200 |
commit | a1a8e1dc111d6f05e7164e851e58219d428359e1 (patch) | |
tree | cc55f2ba12e095a29599bb7f0084dc905c82d8b1 /include | |
parent | Merge tag 'iio-fixes-for-3.11a' of git://git.kernel.org/pub/scm/linux/kernel/... (diff) | |
download | linux-a1a8e1dc111d6f05e7164e851e58219d428359e1.tar.xz linux-a1a8e1dc111d6f05e7164e851e58219d428359e1.zip |
iio:trigger: Fix use_count race condition
When using more than one trigger consumer it can happen that multiple threads
perform a read-modify-update cycle on 'use_count' concurrently. This can cause
updates to be lost and use_count can get stuck at non-zero value, in which case
the IIO core assumes that at least one thread is still running and will wait for
it to finish before running any trigger handlers again. This effectively renders
the trigger disabled and a reboot is necessary before it can be used again. To
fix this make use_count an atomic variable. Also set it to the number of
consumers before starting the first consumer, otherwise it might happen that
use_count drops to 0 even though not all consumers have been run yet.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Tested-by: Denis Ciocca <denis.ciocca@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/iio/trigger.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index 3869c525b052..369cf2cd5144 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -8,6 +8,7 @@ */ #include <linux/irq.h> #include <linux/module.h> +#include <linux/atomic.h> #ifndef _IIO_TRIGGER_H_ #define _IIO_TRIGGER_H_ @@ -61,7 +62,7 @@ struct iio_trigger { struct list_head list; struct list_head alloc_list; - int use_count; + atomic_t use_count; struct irq_chip subirq_chip; int subirq_base; |