]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
iio: adc: ti_am335x_adc: Protect FIFO1 from concurrent access
authorVignesh R <vigneshr@ti.com>
Wed, 17 Aug 2016 12:13:00 +0000 (17:43 +0530)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 20 Oct 2016 13:04:56 +0000 (08:04 -0500)
commit3a0881412d15f232eeb81d1ba69b7e6ae3714575
tree700f15de958a06745460d0fad594913ca7dbd3b1
parent68b76d60fea247017e23a21ea4323f0dbd206d44
iio: adc: ti_am335x_adc: Protect FIFO1 from concurrent access

BugLink: http://bugs.launchpad.net/bugs/1627730
commit 90c43ec6997a892448f1f86180a515f59cafd8a3 upstream.

It is possible that two or more ADC channels can be simultaneously
requested for raw samples, in which case there can be race in access to
FIFO data resulting in loss of samples.
If am335x_tsc_se_set_once() is called again from tiadc_read_raw(), when
ADC is still acquired to sample one of the channels, the second process
might be put into uninterruptible sleep state. Fix these issues, by
protecting FIFO access and channel configurations with a mutex. Since
tiadc_read_raw() might take anywhere between few microseconds to few
milliseconds to finish execution (depending on averaging and delay
values supplied via DT), its better to use mutex instead of spinlock.

Fixes: 7ca6740cd1cd4 ("mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronization")
Signed-off-by: Vignesh R <vigneshr@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
drivers/iio/adc/ti_am335x_adc.c