[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a2b89956-5a1a-d311-8f5c-84ce2378c2e9@ti.com>
Date: Tue, 9 Aug 2016 15:27:49 +0530
From: Vignesh R <vigneshr@...com>
To: Matt Ranostay <mranostay@...il.com>
CC: Jonathan Cameron <jic23@...nel.org>,
Hartmut Knaack <knaack.h@....de>,
Lars-Peter Clausen <lars@...afoo.de>,
Peter Meerwald-Stadler <pmeerw@...erw.net>,
Lee Jones <lee.jones@...aro.org>,
"Andrew F . Davis" <afd@...com>,
"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Linux OMAP List <linux-omap@...r.kernel.org>
Subject: Re: [PATCH 1/2] iio: adc: ti_am335x_adc: Protect FIFO1 from
concurrent access
On Tuesday 09 August 2016 03:21 PM, Matt Ranostay wrote:
> On Mon, Aug 8, 2016 at 4:05 AM, Vignesh R <vigneshr@...com> wrote:
>> 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.
>>
>> Signed-off-by: Vignesh R <vigneshr@...com>
>> ---
>> drivers/iio/adc/ti_am335x_adc.c | 14 +++++++++++---
>> 1 file changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
>> index 8a368756881b..bed9977a1863 100644
>> --- a/drivers/iio/adc/ti_am335x_adc.c
>> +++ b/drivers/iio/adc/ti_am335x_adc.c
>> @@ -32,6 +32,7 @@
>>
>> struct tiadc_device {
>> struct ti_tscadc_dev *mfd_tscadc;
>> + struct mutex fifo1_lock; /* to protect fifo access */
>
> Are there more than one FIFOs, or even possible? Just wondering the
> number indexing here..
ADC IP as such as two FIFOs: FIFO0 and FIFO1. FIFO0 is dedicated for
touchscreen channels and FIFO1 is used for ADC channels. Its not
possible to use FIFO0 for ADC, but to match h/w register naming, I used
above name for mutex.
--
Regards
Vignesh
Powered by blists - more mailing lists