linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: Sean Nyekjaer <sean@geanix.com>,
	linux-iio@vger.kernel.org, martin@geanix.com,
	Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>,
	Denis CIOCCA <denis.ciocca@st.com>
Subject: Re: [PATCH 2/2] iio: imu: st_lsm6dsx: add iio trigger and buffer support
Date: Sat, 18 May 2019 09:38:49 +0100	[thread overview]
Message-ID: <20190518093849.4a8817d9@archlinux> (raw)
In-Reply-To: <20190511170039.GA4547@localhost.localdomain>

On Sat, 11 May 2019 19:00:41 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> > On 11/05/2019 14.30, Lorenzo Bianconi wrote:  
> > > > On Tue,  7 May 2019 10:02:25 +0200
> > > > Sean Nyekjaer <sean@geanix.com> wrote:
> > > >   
> > > > > This adds support for using iio triggers, this is needed because
> > > > > our hardware guys forgot to connect the irq pins from imu device
> > > > > to the SoC.
> > > > > 
> > > > > Signed-off-by: Sean Nyekjaer <sean@geanix.com>  
> > > > Hi Sean
> > > > 
> > > > A small question on the size of the buffer needed inline.  Otherwise looks
> > > > good to me.  
> > > 
> > > Hi Sean,
> > > 
> > > this patch does not make sense to me since running st_lsm6dsx_read_oneshot
> > > you need to wait to power up the device (and you will power it down at the
> > > end). I guess you will not be able to read at a given ODR (e.g. 416Hz).
> > > Moreover you can't read from the hw fifo without the irq line since
> > > you need to read a full pattern from it in order to maintain the alignment.  
> > We are not using the hw fifo if the hw irq isn't present...
> > So if I understand correctly we could speed things up a bit, with leaving
> > the sensor powered by implementing a new reading function and
> > calling st_lsm6dsx_sensor_set_enable when we enable the trigger?  
> 
> I do not think so since in this way you will not know when the hw has updated
> the output registers
> 
> >   
> > >  From my point of view you have 2 possibility:
> > > - poll the output registers from userspace (this is what you are actually
> > >    doing from inside the kernel, what is the advantage of doing so?)  
> > Yes this is exactly what I'm trying to accomplish here.
> > It would be nice for us to have the same hrtimer/trigger to sample this and
> > our adc.  
> 
> Since we need to wait the data to be ready there is no difference between reading
> them polling the output registers in the sysfs and doing so
> 
> >   
> > > - fix the hw bug  
> > Not possible on +20K devices. ;-)
> >   
> > > 
> > > Moreover if I read the patch correctly it has a NULL pointer dereference bug
> > > since hw->iio_devs[i] can be NULL (e.g. if sensor hub is disabled)  
> > Right above, there is:
> > if (!hw->iio_devs[i])
> > 	return -ENOMEM;
> > 
> > Should be enough...  
> 
> Do you mean when we alloc hw->iio_devs[]? If so the for loop stops at
> ST_LSM6DSX_ID_EXT0 while you are going through the complete list here
> (ST_LSM6DSX_ID_MAX)...
> 
> > > 
> > > Regards,
> > > Lorenzo
> > >   
> 
> What I think can be doable is to read data trough the hw fifo but use
> the iio hr timer as trigger. We need to set the hr timer timeout according to
> the pattern len and read the complete pattern. I am not 100% sure it will work
> since read accesses and data generation are asynchronous (so there will be a
> drift).
> @Jonathan, Denis: can it work?
Usual nasty trick to this is you read the fifo faster than you
in theory need to.  I wouldn't use the hr timer trigger for this though as it
adds apparent semantics that aren't true.  So spin a timer up inside the driver.

If you aren't using the fifo you can also do a higher efficiency check by
polling the status registers at twice the rate of of expected data generation.
When they are all set you read.  So basically you poll in the interrupt line
by reading the registers it reflects.  There are device variants out there
where there is an interrupt pin on the die but it doesn't reach the edge
of the package. In those cases we always have to use hacks like this.

Anyhow, seems no actual need for this. I just wanted to put some comments
in here for the future!

Jonathan


> 
> Regards,
> Lorenzo
> 
> 
> > 
> > BR
> > /Sean  
> 


  parent reply	other threads:[~2019-05-18  8:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-07  8:02 [PATCH 1/2] iio: imu: st_lsm6dsx: only set available_scan_masks if using device fifo Sean Nyekjaer
2019-05-07  8:02 ` [PATCH 2/2] iio: imu: st_lsm6dsx: add iio trigger and buffer support Sean Nyekjaer
2019-05-11 11:37   ` Jonathan Cameron
2019-05-11 12:30     ` Lorenzo Bianconi
2019-05-11 12:54       ` Sean Nyekjaer
2019-05-11 17:00         ` Lorenzo Bianconi
2019-05-16 11:46           ` Sean Nyekjaer
2019-05-18  8:38           ` Jonathan Cameron [this message]
2019-05-11 12:38     ` Sean Nyekjaer

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=20190518093849.4a8817d9@archlinux \
    --to=jic23@kernel.org \
    --cc=denis.ciocca@st.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=lorenzo.bianconi83@gmail.com \
    --cc=lorenzo@kernel.org \
    --cc=martin@geanix.com \
    --cc=sean@geanix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).