All of lore.kernel.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Nuno Sa <Nuno.Sa@analog.com>
Subject: Re: [PATCH v4 14/16] iio: adc: max1027: Use the EOC IRQ when populated for single reads
Date: Mon, 27 Sep 2021 16:30:04 +0200	[thread overview]
Message-ID: <20210927163004.54f1a824@xps13> (raw)
In-Reply-To: <20210926153659.70162a99@jic23-huawei>

Hi Jonathan,

jic23@kernel.org wrote on Sun, 26 Sep 2021 15:36:59 +0100:

> On Tue, 21 Sep 2021 13:54:06 +0200
> Miquel Raynal <miquel.raynal@bootlin.com> wrote:
> 
> > So far the End-Of-Conversion interrupt was only used in conjunction with
> > the internal trigger to process the data. Let's extend the use of this
> > interrupt handler to support regular single-shot conversions as well.
> > 
> > Doing so requires writing our own hard IRQ handler. This handler has to
> > check if buffers are enabled or not:
> > 
> > *** Buffers disabled condition ***
> > 
> >   This means the user requested a single conversion and the sample is
> >   ready to be retrieved.
> >   
> >     -> This implies adding the relevant completion boilerplate.    
> > 
> > *** Buffers enabled condition ***
> > 
> >   Triggers are used. So far there is only support for the internal
> >   trigger but this trigger might soon be attached to another device as
> >   well so it is the core duty to decide which handler to call in order
> >   to process the data. The core will decide to either:
> > 
> >   * Call the internal trigger handler which will extract the data that
> >     is already present in the ADC FIFOs
> > 
> >   or
> > 
> >   * Call the trigger handler of another driver when using this trigger
> >     with another device, even though this call will be slightly delayed
> >     by the fact that the max1027 IRQ is a data-ready interrupt rather
> >     than a real trigger:
> >   
> >   -> The new handler will manually inform the core about the trigger    
> >      having transitioned by directly calling iio_trigger_poll() (which
> >      iio_trigger_generic_data_rdy_poll() initially did).
> > 
> > In order for the handler to be "source" agnostic, we also need to change
> > the private pointer and provide the IIO device instead of the trigger
> > object.
> > 
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > 
> > Jonathan,
> > 
> > I hope this fits the IIO model now. In order to be sure I got the big
> > picture I first refused to look at your code snippets. Just with your
> > "plain english" explanations I wrote most of these three patches, before
> > checking back that they were indeed fully aligned with your examples. I
> > truly hope they do now, but do not hesitate if I missed something.  
> 
> Looks great to me (in fact I just applied it but I'll reply to the cover letter
> shortly for that).

Great, thanks!

> Thanks for persisting with this and I'm looking forward to that blog you
> mentioned.

Thank you for all the time you put in these reviews.

I wrote most of it, it's not very long but I tried to cover most of the
common interactions with the core. It is under internal review, I'll
certainly show you its content before publishing in case you have
comments or spot any mistake.

>  If you have time / inclination to help improve the documentation
> in the kernel tree that would also be great.  This discussion has made it
> clear to me that it would be great to have a set of 'patterns' for common
> types of device + how we map them onto the model of IIO (particularly
> when they don't quite fit that idealised model).  There are similar
> compromises around when to use multiple buffers for instance.
> 
> It is always on the list of things to work on but somehow there is always
> something else more urgent :(

Hehe :) I know, documentation is always a good-to-have item that is not
often reached... I feel I need more occasions to work in the IIO
area (for example with hardware fifos/buffers or events) before being
able to fully appreciate the internal design, but I agree having a set
of 'usual patterns' that drivers should conform with depending on the
devices capabilities/constraints would be a must.

In the mean time, let's start by clarifying this 'iio_dev->modes'
property :)

Thanks,
Miquèl

  reply	other threads:[~2021-09-27 14:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-21 11:53 [PATCH v4 00/16] Bring external triggers support to MAX1027-like ADCs Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 01/16] iio: adc: max1027: Fix style Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 02/16] iio: adc: max1027: Drop extra warning message Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 03/16] iio: adc: max1027: Drop useless debug messages Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 04/16] iio: adc: max1027: Minimize the number of converted channels Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 05/16] iio: adc: max1027: Rename a helper Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 06/16] iio: adc: max1027: Create a helper to enable/disable the cnvst trigger Miquel Raynal
2021-09-21 11:53 ` [PATCH v4 07/16] iio: adc: max1027: Simplify the _set_trigger_state() helper Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 08/16] iio: adc: max1027: Ensure a default cnvst trigger configuration Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 09/16] iio: adc: max1027: Create a helper to configure the channels to scan Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 10/16] iio: adc: max1027: Prevent single channel accesses during buffer reads Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 11/16] iio: adc: max1027: Separate the IRQ handler from the read logic Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 12/16] iio: adc: max1027: Introduce an end of conversion helper Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 13/16] iio: adc: max1027: Stop requesting a threaded IRQ Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 14/16] iio: adc: max1027: Use the EOC IRQ when populated for single reads Miquel Raynal
2021-09-26 14:36   ` Jonathan Cameron
2021-09-27 14:30     ` Miquel Raynal [this message]
2021-09-21 11:54 ` [PATCH v4 15/16] iio: adc: max1027: Allow all kind of triggers to be used Miquel Raynal
2021-09-21 11:54 ` [PATCH v4 16/16] iio: adc: max1027: Don't reject external triggers when there is no IRQ Miquel Raynal
2021-09-26 14:38 ` [PATCH v4 00/16] Bring external triggers support to MAX1027-like ADCs 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=20210927163004.54f1a824@xps13 \
    --to=miquel.raynal@bootlin.com \
    --cc=Nuno.Sa@analog.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.petazzoni@bootlin.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.