All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Octavian Purdila <octavian.purdila@intel.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>
Subject: Re: [PATCH v2 11/11] iio: bmc150: add support for hardware fifo
Date: Thu, 05 Feb 2015 11:20:42 +0000	[thread overview]
Message-ID: <54D3520A.6020705@kernel.org> (raw)
In-Reply-To: <CAE1zot+H7y0Nu_kYzHAeNd7d4org4dW8RyCCx8egQTEv0q0LMA@mail.gmail.com>

On 04/02/15 20:18, Octavian Purdila wrote:
> On Wed, Feb 4, 2015 at 7:16 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> <snip>
>>>> As this is on the flush rather than an interrupt these are going
>>>> to be of dubious benefit... There isn't an obvious way of doing better though
>>>> unless we do have an interrupt.  In that case you want to grab them as
>>>> early as possible (typically even in the interrupt top half) and pass it
>>>> down to where you want to use it.
>>>
>>> Actually flush gets called from two places: from the watermark trigger
>>> and in this case we take the timestamp in the IRQ handler, and when we
>>> do a read or poll and there is not enough data available in the
>>> buffer.
>>>
>>> For this later case we will have an error of up to a maximum of a one
>>> sample period since flush was called in between one of the sampling
>>> periods - the watermark interrupt makes sure we don't stall forever.
>>> That is not that bad.
>> Not terrible.  I wonder if we want to indicated a dubious timestamp
>> in some way?  Or maybe event specify a jitter on the channel?
>> (been wondering if we want this sort of description for channels in
>> general - how noisy are they?)  Can be very useful to userspace and
>> is often tied up with the particular settings of the device.
> 
> Do you mean adding something like IIO_CHAN_INFO_JITTER? That would be
> nice, but in this case the value is variable and depends on the
> sampling frequency. What could work would be to also add a new event
> IIO_EV_TYPE_JITTER_CHANGED and issue it when the sampling frequency is
> changed.
General principle has always been that any sysfs type writes can effect
any of other attributes, so if userspace cares it should verify that
everything is as it expects.
> 
> But at this point is getting too complex and I don't know how much it
> helps userspace.
Definitely a job for another day!

Also in this category is having _available type information for all 
attributes, rather just some. Makes for nicer handling in userspace
but adds a lot of additional sysfs files!
> 
> 
>>> Also, the later case should be an exception if the application sets
>>> the right watermark level and uses the right timeout. Otherwise it
>>> will not use power optimally which is the whole point of the hw fifo.
>>>
>>>>> +
>>>>> +     tstamp = data->timestamp - count * sample_freq;
>>>>> +
>>>>> +     for (i = 0; i < count; i++) {
>>>>> +             u16 sample[8];
>>>>> +             int j, bit;
>>>>> +
>>>>> +             j = 0;
>>>>> +             for_each_set_bit(bit, indio_dev->buffer->scan_mask,
>>>>> +                              indio_dev->masklength) {
>>>>> +                     memcpy(&sample[j++], &buffer[i * 3 + bit], 2);
>>>>> +             }
>>>>
>>>> A local demux rather than using the main iio one. Given you clearly read the
>>>> lot anyway is there any reason not to just pass it all on and let the IIO
>>>> demux handling the demux on the way to the kfifo?
>>>>
>>>
>>> Hmm, isn't the demux part only used when we have client buffers?  The
>>> demux part is not used at all in my tests, due to
>>> indio_dev->active_scan_mask being equal to buffer->scan_mask.
>> I'm guessing you figured this out. Yes, only used with client buffers,
>> but the normal buffered access is a client buffer :)
>>>
> 
> Correct me if I am wrong: when we only use normal buffer access (no
> kernel clients) the active_scan_mask is always equal to
> buffer->scan_mask thus no demux will happen in core. So we still need
> to do the demux in the driver.
> 
> In fact the above is true when we have only one client, be it user or kernel.
Not quite.  If the device driver provides available_scan_masks (e.g. indicates
that general random access is not possible) then the demux is used to pull
out what the buffer wants from the in coming stream.

Basically, there is no point in doing local demux of incoming data as this
is better left to the core (which knows about everything that wants the data
and can chose appropriately).

Now, if you have a true random access part (any channel, any order any time -
so basically convert on demand devices) then don't provide available_scan_masks
and everything works as you say.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


  reply	other threads:[~2015-02-05 18:15 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-21  0:42 [PATCH v2 00/11] iio: add support for hardware buffers Octavian Purdila
2014-12-21  0:42 ` [PATCH v2 01/11] iio: buffer: fix custom buffer attributes copy Octavian Purdila
2015-01-04 11:25   ` Jonathan Cameron
2015-01-04 11:34     ` Lars-Peter Clausen
2015-01-04 16:11       ` Jonathan Cameron
2014-12-21  0:42 ` [PATCH v2 02/11] iio: buffer: refactor buffer attributes setup Octavian Purdila
2015-01-04 11:31   ` Jonathan Cameron
2015-01-05 10:48     ` Octavian Purdila
2014-12-21  0:42 ` [PATCH v2 03/11] iio: add watermark logic to iio read and poll Octavian Purdila
2015-01-04 15:44   ` Jonathan Cameron
2015-01-25 21:22   ` Hartmut Knaack
2015-01-26  9:40     ` Octavian Purdila
2014-12-21  0:42 ` [PATCH v2 04/11] iio: add support for hardware fifo Octavian Purdila
2015-01-04 16:07   ` Jonathan Cameron
2015-01-05 11:29     ` Octavian Purdila
2015-02-04 17:08       ` Jonathan Cameron
2015-02-05 21:36         ` Octavian Purdila
2015-02-08 10:53           ` Jonathan Cameron
2015-02-09 13:44             ` Octavian Purdila
2015-01-28 23:46   ` Hartmut Knaack
2015-01-29 11:38     ` Octavian Purdila
2015-01-29 22:49       ` Hartmut Knaack
2015-02-04 17:18         ` Jonathan Cameron
2015-02-04 17:11       ` Jonathan Cameron
2014-12-21  0:42 ` [PATCH v2 05/11] iio: bmc150: refactor slope duration and threshold update Octavian Purdila
2015-01-04 16:21   ` Jonathan Cameron
2015-01-06 18:53     ` Srinivas Pandruvada
2015-01-28  9:22       ` Octavian Purdila
2015-01-28 17:15         ` Srinivas Pandruvada
2014-12-21  0:42 ` [PATCH v2 06/11] iio: bmc150: refactor interrupt enabling Octavian Purdila
2015-01-04 16:27   ` Jonathan Cameron
2015-01-28 10:33     ` Octavian Purdila
2014-12-21  0:42 ` [PATCH v2 07/11] iio: bmc150: exit early if event / trigger state is not changed Octavian Purdila
2015-01-04 16:29   ` Jonathan Cameron
2014-12-21  0:42 ` [PATCH v2 08/11] iio: bmc150: introduce bmc150_accel_interrupt Octavian Purdila
2015-01-04 16:36   ` Jonathan Cameron
2015-01-28 11:09     ` Octavian Purdila
2015-01-28 13:20       ` Jonathan Cameron
2014-12-21  0:42 ` [PATCH v2 09/11] iio: bmc150: introduce bmc150_accel_trigger Octavian Purdila
2015-01-04 16:39   ` Jonathan Cameron
2014-12-21  0:42 ` [PATCH v2 10/11] iio: bmc150: introduce bmc150_accel_event Octavian Purdila
2015-01-04 16:49   ` Jonathan Cameron
2014-12-21  0:42 ` [PATCH v2 11/11] iio: bmc150: add support for hardware fifo Octavian Purdila
2015-01-04 17:08   ` Jonathan Cameron
2015-01-28 19:26     ` Octavian Purdila
2015-02-04 17:16       ` Jonathan Cameron
2015-02-04 20:18         ` Octavian Purdila
2015-02-05 11:20           ` Jonathan Cameron [this message]
2015-02-05 20:04             ` Octavian Purdila
2015-02-06 12:19               ` 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=54D3520A.6020705@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=octavian.purdila@intel.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.