mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugen Hristev <eugen.hristev@microchip.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: <ludovic.desroches@microchip.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-iio@vger.kernel.org>,
	<nicolas.ferre@microchip.com>,
	Maxime Ripard <maxime.ripard@bootlin.com>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH 1/2] iio: adc: at91: fix acking DRDY irq on simple conversions
Date: Mon, 24 Sep 2018 09:19:43 +0300	[thread overview]
Message-ID: <9846e106-8baf-b491-29ca-8306be9527ee@microchip.com> (raw)
In-Reply-To: <20180922113123.2c8da044@archlinux>



On 22.09.2018 13:31, Jonathan Cameron wrote:
> On Thu, 20 Sep 2018 15:40:37 +0300
> Eugen Hristev <eugen.hristev@microchip.com> wrote:
> 
>> When doing simple conversions, the driver did not acknowledge the DRDY irq.
>> If this irq is not acked, it will be left pending, and as soon as a trigger
>> is enabled, the irq handler will be called, it doesn't know why this irq
>> has occurred because no channel is pending, and then we will have irq loop
>> and board will hang.
>>
>> Fixes 0e589d5fb ("ARM: AT91: IIO: Add AT91 ADC driver.")
>> Cc: Maxime Ripard <maxime.ripard@bootlin.com>
>> Cc: <stable@vger.kernel.org>
>> Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
>> ---
>>   drivers/iio/adc/at91_adc.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
>> index 44b5168..e85f859 100644
>> --- a/drivers/iio/adc/at91_adc.c
>> +++ b/drivers/iio/adc/at91_adc.c
>> @@ -712,6 +712,11 @@ static int at91_adc_read_raw(struct iio_dev *idev,
>>   		at91_adc_writel(st, AT91_ADC_CHDR,
>>   				AT91_ADC_CH(chan->channel));
>>   		at91_adc_writel(st, AT91_ADC_IDR, BIT(chan->channel));
>> +		/*
>> +		 * we need to ack the DRDY irq, otherwise it will be
>> +		 * left pending and irq handler will be confused
>> +		 */
>> +		at91_adc_readl(st, AT91_ADC_LCDR);
> 
> I'm curious as to how things were working before.  Does this only occur
> if we do a raw_read whilst the buffer is enabled?

No. The situation is that the read raw does not properly cleans itself 
up after it's done.
The DRDY bit is cleared only when LCDR (last converted data ) is being read.
Even if we read the per channel conversion data, the LCDR still needs to 
be read to clear this irq status.
The driver does not use the DRDY irq but this irq status is still being 
set in the status register.

> 
> I would have assumed when it's not enabled, the irq would be masked and
> never generated in the first place...
> 
> It may be that what we actually need to do is to prevent read_raw accesses
> when the buffer is enabled (like lots of other drivers do precisely to
> avoid this sort of condition). The problem there comes if we have
> existing applications doing this combination as we are then breaking
> userspace. If that's the case we'll need to be a bit more clever.
> 
> Hammering down an irq state in a non irq handling path isn't a good
> solution.

Ok, I will move the clearing of the DRDY (LCDR read) in the irq path 
then, and send a v2.


> 
> Jonathan
> 
>>   
>>   		st->last_value = 0;
>>   		st->done = false;
> 

  reply	other threads:[~2018-09-24  6:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 12:40 Eugen Hristev
2018-09-20 12:40 ` [PATCH 2/2] iio: adc: at91: fix wrong channel number in triggered buffer mode Eugen Hristev
2018-09-21  7:26   ` kbuild test robot
2018-09-22 10:36     ` Jonathan Cameron
2018-09-22 11:19       ` Song Qiang
2018-09-22 11:48       ` Himanshu Jha
2018-09-22 12:51         ` Jonathan Cameron
2018-09-22 10:31 ` [PATCH 1/2] iio: adc: at91: fix acking DRDY irq on simple conversions Jonathan Cameron
2018-09-24  6:19   ` Eugen Hristev [this message]
2018-09-24 20:00     ` Jonathan Cameron
2018-09-24 20:27       ` Jonathan Cameron
2018-09-25  6:50         ` Eugen Hristev
2018-09-29 11:20           ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9846e106-8baf-b491-29ca-8306be9527ee@microchip.com \
    --to=eugen.hristev@microchip.com \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ludovic.desroches@microchip.com \
    --cc=maxime.ripard@bootlin.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®