All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	freeman.liu@unisoc.com,
	Vincent Guittot <vincent.guittot@linaro.org>,
	linux-iio@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] iio: adc: sc27xx: Change to polling mode to read data
Date: Sun, 11 Aug 2019 09:03:15 +0100	[thread overview]
Message-ID: <20190811090251.5fbd7d75@archlinux> (raw)
In-Reply-To: <CAMz4kuK4GFfOi3vGvFOLdRfmqrwVLDs5CN+Xp_it3jG4=iKi=w@mail.gmail.com>

On Tue, 6 Aug 2019 15:39:45 +0800
Baolin Wang <baolin.wang@linaro.org> wrote:

> Hi Jonathan,
> 
> On Mon, 5 Aug 2019 at 21:50, Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Mon, 29 Jul 2019 10:19:48 +0800
> > Baolin Wang <baolin.wang@linaro.org> wrote:
> >  
> > > Hi Jonathan,
> > >
> > > On Sun, 28 Jul 2019 at 01:27, Jonathan Cameron <jic23@kernel.org> wrote:  
> > > >
> > > > On Thu, 25 Jul 2019 14:33:50 +0800
> > > > Baolin Wang <baolin.wang@linaro.org> wrote:
> > > >  
> > > > > From: Freeman Liu <freeman.liu@unisoc.com>
> > > > >
> > > > > On Spreadtrum platform, the headphone will read one ADC channel multiple
> > > > > times to identify the headphone type, and the headphone identification is
> > > > > sensitive of the ADC reading time. And we found it will take longer time
> > > > > to reading ADC data by using interrupt mode comparing with the polling
> > > > > mode, thus we should change to polling mode to improve the efficiency
> > > > > of reading data, which can identify the headphone type successfully.
> > > > >
> > > > > Signed-off-by: Freeman Liu <freeman.liu@unisoc.com>
> > > > > Signed-off-by: Baolin Wang <baolin.wang@linaro.org>  
> > > >
> > > > Hi,
> > > >
> > > > My concerns with this sort of approach is that we may be sacrificing power
> > > > efficiency for some usecases to support one demanding one.
> > > >
> > > > The maximum sleep time is 1 second (I think) which is probably too long
> > > > to poll a register for in general.  
> > >
> > > 1 second is the timeout time, that means something wrong when reading
> > > the data taking 1 second, and we will poll the register status every
> > > 500 us.
> > > From the testing, polling mode takes less time than interrupt mode
> > > when reading ADC data multiple times, so polling mode did not
> > > sacrifice power
> > > efficiency.  
> >
> > Hmm.  I'll go with a probably on that, depends on interrupt response
> > latency etc so isn't entirely obvious.  Faster response doesn't necessarily
> > mean lower power.
> >  
> > >  
> > > > Is there some way we can bound that time and perhaps switch between
> > > > interrupt and polling modes depending on how long we expect to wait?  
> > >
> > > I do not think the interrupt mode is needed any more, since the ADC
> > > reading is so fast enough usually. Thanks.  
> > The reason for interrupts in such devices is usually precisely the opposite.
> >
> > You do it because things are slow enough that you can go to sleep
> > for a long time before the interrupt occurs.
> >
> > So question becomes whether there are circumstances in which we are
> > running with long timescales and would benefit from using interrupts.  
> 
> From our testing, the ADC version time is usually about 100us, it will
> be faster to get data if we poll every 50us in this case. But if we
> change to use interrupt mode, it will take millisecond level time to
> get data. That will cause problems for those time sensitive scenarios,
> like headphone detection, that's the main reason we can not use
> interrupt mode.
> 
> For those non-time-sensitive scenarios, yes, I agree with you, the
> interrupt mode will get a better power efficiency. But ADC driver can
> not know what scenarios asked by consumers, so changing to polling
> mode seems the easiest way to solve the problem, and we've applied
> this patch in our downstream kernel for a while, we did not see any
> other problem.
> 
> Thanks for your comments.

OK. It's not ideal but sometimes such is life ;)

So last question - fix or not?  If a fix, can I have a fixes tag
please.

Thanks,

Jonathan

> 


  reply	other threads:[~2019-08-11  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-25  6:33 [PATCH] iio: adc: sc27xx: Change to polling mode to read data Baolin Wang
2019-07-27 17:27 ` Jonathan Cameron
2019-07-29  2:19   ` Baolin Wang
2019-08-05 13:50     ` Jonathan Cameron
2019-08-06  7:39       ` Baolin Wang
2019-08-11  8:03         ` Jonathan Cameron [this message]
2019-08-12  2:37           ` Baolin Wang
2019-08-18 19:27             ` Jonathan Cameron
2019-08-19  1:12               ` Baolin Wang

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=20190811090251.5fbd7d75@archlinux \
    --to=jic23@kernel.org \
    --cc=baolin.wang@linaro.org \
    --cc=freeman.liu@unisoc.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    --cc=vincent.guittot@linaro.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 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.