All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Webb <w1@codecraftsmen.org>
To: Philippe Gerum <rpm@xenomai.org>
Cc: Greg Gallagher <greg@embeddedgreg.com>,
	"xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: select() unblocks when no data to read()
Date: Wed, 22 May 2019 13:06:50 +0000	[thread overview]
Message-ID: <xIC8TGzlKzGfZWIOYx8ds3uHlTBVT0QrrBv-TpAN-T5tu5Jeu3qsGFUVkWzaoEahY7GDiXfhZRd_Jy2K6NIooGf9HuwfHYBsFwsIkMqxXEM=@codecraftsmen.org> (raw)
In-Reply-To: <5dbf6ceb-950a-ac49-2331-b6fe54fa0808@xenomai.org>

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Friday, May 10, 2019 3:24 AM, Philippe Gerum <rpm@xenomai.org> wrote:

> On 5/10/19 3:26 AM, Jeff Webb via Xenomai wrote:
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > On Thursday, May 9, 2019 9:19 AM, Greg Gallagher greg@embeddedgreg.com wrote:
> >
> > > On Tue, May 7, 2019 at 9:54 PM Jeff Webb via Xenomai
> > > xenomai@xenomai.org wrote:
> > >
> > > > I am having trouble using select() to perform a timed wait on a UDD file descriptor to detect interrupts from a custom PCI card. After some searching, I came across this thread from 2017 that describes my exact issue:
> > > > https://xenomai.org/pipermail/xenomai/2017-July/037494.html
> > > > I am using x86-64 instead of ARM, but I am having the same trouble. The original poster did a great job of describing the problem, so I won't repeat it. If I use only read() without select(), things work as expected, but I need to implement a timeout.
> > > > It sounds like Philippe was going to look into the issue further. Has any progress on this issue been made since the last post in this thread?
> > > > Thanks,
> > > > -Jeff Webb
> > >
> > > There was a fix posted to the list a while ago but it wasn't a patch
> > > it was the whole c file. I don't think a patch was ever made, I'll
> > > see if I can dig it up.
> >
> > Thanks for looking into it, Greg. I must have missed that post. The original poster's solution of adding this line:
> > rtdm_event_clear(&ur->pulse);
> > just before the return statement in udd_read_rt() is working for me. Philippe mentioned that this might be racy, but maybe it's okay (or maybe not?) if there are no shared interrupts and interrupts are unmasked by the userspace application after the read completes.
>
> There is a logic flaw on entry to read_rt, when an interrupt already occurred before we consider waiting for the next one; in that case, the selector block is not reset as it should, which would explain why you get those spurious select() events. Could you try the following change?

Thank you for putting together this patch, Philippe.  Sorry for the delay in testing it, but it seems to work.  I tested it on Xenomai 3.0.5, but it appears there are no other significant changes to UDD since then.  I will keep using your patch and see if any more subtle issues arise.  I will also test with the latest Xenomai when I get a chance.  Thank you again for taking the time to look into this.

-Jeff




      reply	other threads:[~2019-05-22 13:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08  1:53 select() unblocks when no data to read() Jeff Webb
2019-05-09 14:19 ` Greg Gallagher
2019-05-10  1:26   ` Jeff Webb
2019-05-10  1:37     ` Greg Gallagher
2019-05-22 13:02       ` Jeff Webb
2019-05-10  8:24     ` Philippe Gerum
2019-05-22 13:06       ` Jeff Webb [this message]

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='xIC8TGzlKzGfZWIOYx8ds3uHlTBVT0QrrBv-TpAN-T5tu5Jeu3qsGFUVkWzaoEahY7GDiXfhZRd_Jy2K6NIooGf9HuwfHYBsFwsIkMqxXEM=@codecraftsmen.org' \
    --to=w1@codecraftsmen.org \
    --cc=greg@embeddedgreg.com \
    --cc=rpm@xenomai.org \
    --cc=xenomai@xenomai.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 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.