All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Doug Anderson <dianders@chromium.org>
Cc: Naveen Krishna Chatradhi <ch.naveen@samsung.com>,
	linux-iio <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-samsung-soc@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Naveen Krishna <naveenkrishna.ch@gmail.com>
Subject: Re: [RFC: PATCH 2/2] iio: adc: exynos_adc: Handle timeout and race conditions
Date: Fri, 05 Apr 2013 10:53:17 +0200	[thread overview]
Message-ID: <515E90FD.10006@metafoo.de> (raw)
In-Reply-To: <CAD=FV=VBYHyD6yXBrM1BV3gazDFT0oHgvJM0+5LU1w4AO16Yzg@mail.gmail.com>

On 04/03/2013 07:06 PM, Doug Anderson wrote:
> Lars,
> 
> On Sat, Mar 16, 2013 at 7:41 AM, Lars-Peter Clausen <lars@metafoo.de> wrote:
>> I think you still need the mutex for serialization, otherwise the requests
>> would just cancel each other out. Btw. what happens if you start a conversion
>> while another is still in progress? Is it possible to abort a conversion?
> 
> I was thinking that the spinlock would just replace the mutex for the
> purposes of serialization.
> 

Since we sleep inside the protected section we need to use a mutex.

> I stepped back a bit, though, and I'm wondering if we're over-thinking
> things.  The timeout case should certainly be handled properly (thanks
> for pointing it out), but getting a timeout is really not expected and
> adding a lot of extra overhead to handle it elegantly seems a bit
> much?
> 
> Specifically, the mutex means that we have one user of the ADC at a
> time, and ADC conversion has nothing variable about it.  The user
> manual that I have access to talks about 12-bit conversion happening
> in 1 microsecond with a 5MHz input clock or 5 microseconds with a 1MHz
> input clock.  Even if someone has clocks configured very differently,
> it would be hard to imagine a conversion actually taking a full
> second.
> 
> ...so that means that if the timeout actually fires then something
> else fairly drastic has gone wrong.  It's _very_ unlikely that the IRQ
> will still go off for this conversion sometime in the future.
> 

It's not the timeout case I'm worried about, but the case where the transfer
is interrupted by the user. Even though it is rather unlikely for the
problem to occur we should still try to avoid it, this is one of these
annoying heisenbugs that happen once in a while and nobody is able to
reproduce them.

> To me, total modifications to what's landed already ought to be:
> 
> * Change timeout to long (from unsigned long)
> 
> * Make sure we return errors (negative results) from
> wait_for_completion_interruptible_timeout() properly.
> 
> * If we get back a value of 0 from
> wait_for_completion_interruptible_timeout() then we should print a
> warning and attempt machinations to reset the ADC.  Without ever
> seeing real-world situtations that would cause a real timeout these
> machinations would be a bit of a guess (is resetting the adc useful
> when it's more likely that someone accidentally messed with the clock
> tree or power gated the ADC?)...  ...or perhaps a warning and a TODO
> in the code would be enough?
> 
> 
> Thoughts?

I think most of this is already implemented and Naveen sent a patch to reset
the controller in case of a timeout, which is a good idea and works fine,
but you still should handle the case where the user aborted the transfer.
Just resetting the core should work as well in that case.

- Lars

  reply	other threads:[~2013-04-05  7:54 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 16:26 [RFC: PATCH 2/2] iio: adc: exynos_adc: Handle timeout and race conditions Naveen Krishna Chatradhi
2013-03-15 21:53 ` Lars-Peter Clausen
2013-03-15 21:53   ` Lars-Peter Clausen
2013-03-16  0:37   ` Doug Anderson
2013-03-16 14:41     ` Lars-Peter Clausen
2013-03-16 14:41       ` Lars-Peter Clausen
2013-04-03 17:06       ` Doug Anderson
2013-04-03 17:06         ` Doug Anderson
2013-04-05  8:53         ` Lars-Peter Clausen [this message]
2013-04-05 14:56           ` Doug Anderson
2013-04-05 14:56             ` Doug Anderson
2013-04-05 16:38             ` Lars-Peter Clausen
2013-04-04  3:59 ` [PATCH 14/14] temp: iio: adc: exynos_adc: Handle timeout issues Naveen Krishna Chatradhi
2013-04-04  4:09   ` Naveen Krishna Ch
     [not found] ` <1363364801-23684-1-git-send-email-ch.naveen-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-04-04  4:06   ` [PATCH] " Naveen Krishna Chatradhi
2013-04-04  4:06     ` Naveen Krishna Chatradhi
     [not found]     ` <1365048389-6364-1-git-send-email-naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-04-13  4:36       ` Naveen Krishna Ch
2013-04-13  4:36         ` Naveen Krishna Ch
     [not found]         ` <CAHfPSqAVUVdFwtMxJYCGaPv_+iO_GEc9_UGNXwuSj9uu_fB81g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-04-15 16:01           ` Doug Anderson
2013-04-15 16:01             ` Doug Anderson
2013-05-02 18:01     ` [PATCH v2] " Naveen Krishna Chatradhi
     [not found]       ` <1367517663-12225-1-git-send-email-naveenkrishna.ch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-05-02 18:10         ` Tomasz Figa
2013-05-02 18:10           ` Tomasz Figa
2013-05-02 18:22           ` Naveen Krishna Ch
2013-05-02 18:22             ` Naveen Krishna Ch
     [not found]             ` <CAHfPSqCc81765zQVur=AtW2Cf+taYef=LYJK008i03cmYPu0WQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-05-02 18:36               ` Tomasz Figa
2013-05-02 18:36                 ` Tomasz Figa
2013-10-11  8:23     ` [PATCH v3] iio: exynos_adc: use wait_for_completion_timeout instead of interruptible Naveen Krishna Chatradhi
2013-10-11 14:30       ` Lars-Peter Clausen
2013-10-11 14:30         ` Lars-Peter Clausen
2013-10-12  6:40         ` Naveen Krishna Ch
2013-10-12  6:40           ` Naveen Krishna Ch
2013-10-12  6:40           ` Naveen Krishna Ch
2013-10-15  5:15       ` [PATCH v4] " Naveen Krishna Chatradhi
2013-10-25 15:42         ` Doug Anderson
2013-10-28  5:41       ` [PATCH v5] " Naveen Krishna Chatradhi
2013-11-05  9:45       ` [PATCH v6] " Naveen Krishna Chatradhi
2013-11-10 12:48         ` Tomasz Figa
2013-11-10 12:48           ` Tomasz Figa

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=515E90FD.10006@metafoo.de \
    --to=lars@metafoo.de \
    --cc=ch.naveen@samsung.com \
    --cc=dianders@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=naveenkrishna.ch@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.