From: Michael Welling <mwelling@ieee.org>
To: Alexandre Courbot <gnurou@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
folkert <folkert@vanheusden.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: Fw: [3.18.3] poll() on gpio pins broken
Date: Mon, 2 Mar 2015 01:27:09 -0600 [thread overview]
Message-ID: <20150302072655.GA17089@deathray> (raw)
In-Reply-To: <CAAVeFuJxki5mqY91ugumpDEuq9BMbBin4ypr1H2qcA_uzWGT9Q@mail.gmail.com>
On Mon, Mar 02, 2015 at 03:16:06PM +0900, Alexandre Courbot wrote:
> On Fri, Feb 27, 2015 at 10:15 PM, Linus Walleij
> <linus.walleij@linaro.org> wrote:
> > On Thu, Feb 26, 2015 at 11:27 AM, Alexandre Courbot <gnurou@gmail.com> wrote:
> >> On Fri, Feb 20, 2015 at 1:52 AM, Linus Walleij <linus.walleij@linaro.org> wrote:
> >>> On Thu, Feb 19, 2015 at 9:53 AM, folkert <folkert@vanheusden.com> wrote:
> >>>
> >>>> I also think that this interface is cumbersome. I did not measure it(!)
> >>>> but I think adding this open/seek + read construction may add all kinds
> >>>> of overhead. Especially since my use-case requires the lowest latency
> >>>> possible. Not to forget that conversion of the measured value to ascii
> >>>> and back.
I may have opened this can of worms so I figured I should chime in.
The context switches probably of more concern than string conversion.
> >>>
> >>> Yes this interface sucks.
> >>>
> >>> The tentative long-term plan is to replace it with something like
> >>> a char device that can handle a quick context switch and also
> >>> issuing calls to set multiple pins at once, as we now have an
> >>> in-kernel interface for that (that I totally refuse to support from
> >>> sysfs).
> >>
> >> Mmm, I was thinking it would be nice to have a (new, redesigned) sysfs
> >> interface for this. :P
> >>
> >> Aren't we going to make things less accessible if we use a char device?
> >
> > Since sysfs has a "one value per file" paradigm, it also has a
> > "one context switch per operation" paradigm, meaning any
> > efficiency-oriented use cases where a lot of stuff needs to be
> > changed in one context switch are by the very construction
> > not suitable for sysfs IMO. That is the use case for ioctl()
> > operations that can pass an entire struct of stuff over.
> >
> > And things like bit-banging a clock+data line which would in
> > a sysfs case involve two context switches (one per value, since
> > that is one file per GPIO line) in an ioctl() case it would be
> > just one, already 50% less context switches for a very basic
> > use case.
>
> These are absolutely legitimate concerns, but couldn't the desired
> result be achieved using an interface like this (warning: raw and
> dirty draft):
>
> cd /sys/class/gpio
> echo "gpiochip0:12 gpiochip0:13 gpiochip1:7 lcd_gpios" >export #
> exports GPIOs 12 and 13 of chip0 and 7 of chip 1 under the node
> "lcd_gpios"
> echo 5 >lcd_gpios/value # sets gpiochip0:12 and gpiochip1:7
>
> ... or we could request the user to export each GPIO individually,
> then have a "group" node allowing to create a group of GPIOs from
> already-exported ones. This idea might actually work better as it
> would allow finer control over the properties of individual GPIO (e.g.
> active-low status).
>
It may be beneficial and easier to perform the grouping in the device tree.
Then the system could come up with the groups pre-exported in /sys/class/gpio.
The GPIOs would be self consumed like with the proposed pin hogging mechanism
but then available as a single group in the sysfs layer.
What do you guys think?
> I understand that even this way sysfs might be slower than a character
> device, but when you need that level of performance don't you just
> need a dedicated driver? The ioctls might also get complex as it also
> needs to be able to set all the GPIO properties.
>
> Independently of this issue, I think it would be worth to create
> alternative "export" nodes at the chip-level, like the pwm subsystem
> has:
>
> pwm/pwmchip0/export
> pwm/pwmchip0/pwm1
> pwm/pwmchip0/pwm1/duty_cycle
>
> This is much saner and would provide a sysfs interface that does not
> rely on the global GPIO numberspace, which cannot be relied upon as
> shown by countless evidence.
>
> IMHO this is needed regardless of whether we decide to provide a
> character device as well, so I thought we might also add the ability
> to set multiple GPIOs in one call to it. Maintaining two user-space
> ABIs (sysfs and char device) sounds a little bit overkill for
> something as simple as GPIOs.
Perhaps an ioctl would be overkill seeing as the right way to emulate a bus
or whatever timing critical would be in a kernel driver.
String conversion sucks but I could deal with it if more IOs were acessible
with a single system call.
As for the lseek thing I am not sure of the solution yet.
next prev parent reply other threads:[~2015-03-02 7:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-29 15:29 Fw: [3.18.3] poll() on gpio pins broken folkert
2015-01-30 23:45 ` Michael Welling
2015-01-31 8:33 ` folkert
2015-01-31 13:39 ` Alexandre Courbot
2015-01-31 13:53 ` folkert
2015-02-03 9:03 ` Michael Welling
2015-02-13 3:43 ` Linus Walleij
2015-02-19 8:53 ` folkert
2015-02-19 16:52 ` Linus Walleij
2015-02-26 10:27 ` Alexandre Courbot
2015-02-27 13:15 ` Linus Walleij
2015-02-27 13:19 ` folkert
2015-03-02 6:20 ` Alexandre Courbot
2015-03-02 6:16 ` Alexandre Courbot
2015-03-02 7:27 ` Michael Welling [this message]
2015-03-03 8:27 ` Alexandre Courbot
2015-03-03 10:31 ` Linus Walleij
2015-03-04 12:43 ` Alexandre Courbot
2015-03-09 15:52 ` Linus Walleij
2015-03-09 19:02 ` folkert
2015-03-09 20:22 ` Michael Welling
2015-03-17 16:39 ` Linus Walleij
2015-03-17 16:47 ` Michael Welling
2015-03-19 8:30 ` Linus Walleij
2015-02-26 10:29 ` Alexandre Courbot
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=20150302072655.GA17089@deathray \
--to=mwelling@ieee.org \
--cc=folkert@vanheusden.com \
--cc=gnurou@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
/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).