From: Jonathan Cameron <jic23@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Felipe Balbi" <felipe.balbi@linux.intel.com>,
"Bartosz Gołaszewski" <bartekgola@gmail.com>,
linux-iio@vger.kernel.org,
"thierry.reding@gmail.com" <thierry.reding@gmail.com>,
linux-pwm@vger.kernel.org, "Lars-Peter Clausen" <lars@metafoo.de>,
linux-gpio@vger.kernel.org,
"Gregor Boirie" <gregor.boirie@parrot.com>
Subject: Re: [RFC] Periodic Output, Timestamped Input
Date: Sat, 2 Dec 2017 13:34:03 +0000 [thread overview]
Message-ID: <20171202133403.10651f76@archlinux> (raw)
In-Reply-To: <CACRpkdabNMHgs_ywzrgSg-AgQL1wtQN8SaxuZtCruiXnfrXGQw@mail.gmail.com>
On Wed, 29 Nov 2017 23:54:32 +0100
Linus Walleij <linus.walleij@linaro.org> wrote:
> On Wed, Nov 29, 2017 at 2:56 PM, Felipe Balbi
> <felipe.balbi@linux.intel.com> wrote:
> > Me:
> >> For the other thing: timestamping of GPIO events, we already
> >> support timestamps for userspace GPIOs, but all it does is use
> >> the kernel time, see gpiolib.c:
> >>
> >> static irqreturn_t lineevent_irq_thread(int irq, void *p)
> >> {
> >> struct lineevent_state *le = p;
> >> struct gpioevent_data ge;
> >> int ret, level;
> >>
> >> ge.timestamp = ktime_get_real_ns();
> >> level = gpiod_get_value_cansleep(le->desc);
> >
> > this is running as a thread with interrupts enabled, AFAICT. This means
> > this thread can be preempted at least on PREEMPT_RT kernels, so your
> > timestamp can be wrong, right?
>
> Yes, it can be off. What we should do to get i better is
> something like what I did in:
> drivers/iio/gyro/mpu3050-core.c
>
> Here I have both a hard and a soft IRQ handler (fast/slow if
> you like) and take the timestamp in the hard IRQ, then use
> it in the thread.
I did timing tests for both a long time back but I doubt things have
changed much. To do fusion you ideally smooth the result on the basis
you are fairly sure the internal clock is better than even then jitter
we get in an interrupt.
No idea where the absolute numbers went though I'm afraid.
Perhaps Gregor can provide more info?
Not sure who else is doing sensor fusion currently...
>
> This should be done identically in gpiolib to increase precision
> in the general case.
>
> I was thinking about it already when implementing it but it fell
> out of my mind. I'm putting in on my TODO. (CC to bartosz
> who might be interested, he's using these ABIs quite a bit.)
>
> Yours,
> Linus Walleij
next prev parent reply other threads:[~2017-12-02 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-16 9:29 [RFC] Periodic Output, Timestamped Input Felipe Balbi
2017-11-29 13:31 ` Linus Walleij
2017-11-29 13:56 ` Felipe Balbi
2017-11-29 22:54 ` Linus Walleij
2017-12-02 13:34 ` Jonathan Cameron [this message]
2017-12-05 9:20 ` Felipe Balbi
2017-12-05 11:01 ` Linus Walleij
2017-12-05 11:23 ` Felipe Balbi
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=20171202133403.10651f76@archlinux \
--to=jic23@kernel.org \
--cc=bartekgola@gmail.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregor.boirie@parrot.com \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@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 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).