All of lore.kernel.org
 help / color / mirror / Atom feed
* Why is the /dev/gpiochip line event kfifo so small?
@ 2020-10-21  9:09 Helmut Grohne
  2020-10-21 11:27 ` Kent Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Helmut Grohne @ 2020-10-21  9:09 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij

Hi,

I was looking into using the /dev/gpiochip API to detect pulses. In my
application, the crucial bit is to precisely identify the start time of
the pule and the API mostly helps doing that by providing high precision
kernel timestamps. However, it stuffs them into a kfifo with 16 entries.
When your hardware is not properly debounced (which it always should,
but often isn't), that space can fill quickly. Is there a reason to
limit the API to such a small number of events?

A single event is 16 bytes. So for every line, we incur 256 bytes of
kfifo space. This space is only incurred for lines that are actually
being watched. It seems to me that bumping up this size would not hurt
badly. Non-realtime applications could then read events after-the-fact
with a smaller risk of missing ones. I've encountered a full kfifo a
number of times now.

Helmut

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Why is the /dev/gpiochip line event kfifo so small?
  2020-10-21  9:09 Why is the /dev/gpiochip line event kfifo so small? Helmut Grohne
@ 2020-10-21 11:27 ` Kent Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: Kent Gibson @ 2020-10-21 11:27 UTC (permalink / raw)
  To: Helmut Grohne; +Cc: linux-gpio, Linus Walleij

On Wed, Oct 21, 2020 at 11:09:40AM +0200, Helmut Grohne wrote:
> Hi,
> 
> I was looking into using the /dev/gpiochip API to detect pulses. In my
> application, the crucial bit is to precisely identify the start time of
> the pule and the API mostly helps doing that by providing high precision
> kernel timestamps. However, it stuffs them into a kfifo with 16 entries.
> When your hardware is not properly debounced (which it always should,
> but often isn't), that space can fill quickly. Is there a reason to
> limit the API to such a small number of events?
> 
> A single event is 16 bytes. So for every line, we incur 256 bytes of
> kfifo space. This space is only incurred for lines that are actually
> being watched. It seems to me that bumping up this size would not hurt
> badly. Non-realtime applications could then read events after-the-fact
> with a smaller risk of missing ones. I've encountered a full kfifo a
> number of times now.
> 

Debounce support is added in GPIO uAPI v2, as is configurable event buffer
size. And sequence numbers in events to help detect buffer overflows.

Btw, uAPI v2 is currently in train to be included in Linux v5.10.

Cheers,
Kent.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-21 11:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-21  9:09 Why is the /dev/gpiochip line event kfifo so small? Helmut Grohne
2020-10-21 11:27 ` Kent Gibson

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.