From: Michael Welling <mwelling@ieee.org>
To: folkert <folkert@vanheusden.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: Fw: [3.18.3] poll() on gpio pins broken
Date: Fri, 30 Jan 2015 17:45:52 -0600 [thread overview]
Message-ID: <20150130234552.GA20407@sysresccd> (raw)
In-Reply-To: <20150129152902.GX21469@belle.intranet.vanheusden.com>
On Thu, Jan 29, 2015 at 04:29:02PM +0100, folkert wrote:
> Hi,
>
> For timekeeping I wrote a program which waits for interrupts on
> gpio-pins and then tells the local ntp daemon the clock offset.
> I'm aware of the pps support in recent kernel but that does not work
> (yet) on all platforms (eg cubieboard 1).
>
> This has worked for quite some time but no longer.
>
> Until at least kernel 3.12 I could do:
>
> // export gpio pin
> // set direction to in
> // set direction to rising
> int fd = open("/sys.../value", O_RDONLY);
> fdset[0].fd = fd;
> fdset[0].events = POLLPRI;
> fdset[0].revents = 0;
> poll(fdset, 1, -1);
> // at this point pin went high
Try using lseek before reading the data after the poll.
EX.
if (fdset[0].revents & POLLPRI) {
lseek(fdset[0].fd, 0, SEEK_SET);
len = read(fdset[0].fd, buf, MAX_BUF);
.
.
}
See if this helps.
>
> So: I would setup a gpio-pin using /sys-files, and then use poll() to
> wait for the interrupt triggered by the level of the gpio pin going
> high.
> This worked fine on all raspberry pi's I tried, a nanos g20, a beagle
> bone black and a cubieboard 1.
>
> Since kernel 3.18.3 (.4 as well) this no longer works:
>
> 1422542104.894908947] interrupt #2459, offset -0.105091s
> 1422542104.895162937] interrupt #2460, offset -0.104837s
> 1422542104.895408928] interrupt #2461, offset -0.104591s
> 1422542104.895650919] interrupt #2462, offset -0.104349s
> 1422542104.896293896] interrupt #2463, offset -0.103706s
> ...
>
> As you can see suddenly the poll returns immediately.
>
> strace learns me:
> poll([{fd=3, events=POLLPRI}], 1, -1) = 1 ([{fd=3, revents=POLLPRI|POLLERR}])
>
> So apparently somewhere between 3.12 and 3.18 it is no longer
> allowed/possible to do poll() on a gpio-pin value device.
>
> Am I right that something broke the abi? Or have I been doing it wrong
> and did that became visible?
> Please advise.
>
> thanks
>
> Folkert van Heusden
>
> --
> --
> To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-01-30 23:45 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 [this message]
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
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=20150130234552.GA20407@sysresccd \
--to=mwelling@ieee.org \
--cc=folkert@vanheusden.com \
--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).