mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Linux kernel <linux-kernel@vger.kernel.org>
Subject: poll() in 2.6 and beyond
Date: Tue, 2 Mar 2004 13:21:23 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.53.0403021318580.796@chaos> (raw)


Poll in 2.6.0; when a driver routine calls poll_wait()
it returns <<immediately>> to somewhere in the
kernel, then waits for my wake_up_interuptible(), before
returning control to a user sleeping in poll(). This means
that the user gets the wrong poll return value! It
doesn't get the value it was given as a result of the
interrupt, but the value that existed (0) before the
interrupt occurred.

Poll should not return from poll_wait() until it gets
a wake_up_interruptible() call. The wait variable,
info->pwait, below, has been initialized by executing
init_waitqueue_head(&info->pwait) in the initialization
code. This code works in 2.4.24.

What do I do to make it work in 2.6.0 and beyond? There
are no hints in the 2.6 drivers as they all seem to be
written like this and they presumably work.


/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *   The interrupt service routine.
 */
static void pci_isr(int irq, void *p, struct pt_regs *regs)
{
    spin_lock(&info->lock);
    DEB(printk(KERN_INFO"%s : Interrupt!\n", devname));
    info->poll_flag |= POLLIN|DEF_POLL;
    wake_up_interruptible(&info->pwait);
    spin_unlock(&info->lock);
}
/*-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/*
 *  Device poll routine.
 */
static size_t poll(struct file *fp, struct poll_table_struct *wait)
{
    size_t poll_flag;
    size_t flags;
    DEB(printk(KERN_INFO"%s : poll called\n", devname));
    poll_wait(fp, &info->pwait, wait);
    lockit(TRUE, &flags);
    poll_flag = info->poll_flag;
    info->poll_flag = 0;
    lockit(FALSE, &flags);
    DEB(printk(KERN_INFO"%s : poll returns\n", devname));
    return poll_flag;
}

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
            Note 96.31% of all statistics are fiction.



             reply	other threads:[~2004-03-02 18:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-02 18:21 Richard B. Johnson [this message]
2004-03-02 20:04 ` Roland Dreier
2004-03-02 20:24   ` Richard B. Johnson
2004-03-02 21:00     ` Roland Dreier
2004-03-02 21:26       ` Richard B. Johnson
2004-03-02 21:39         ` Roland Dreier
2004-03-02 21:59           ` Richard B. Johnson
2004-03-02 22:41             ` Dave Dillow
2004-03-02 22:56             ` Roland Dreier
2004-03-02 23:16               ` Richard B. Johnson
2004-03-02 23:21                 ` Roland Dreier
     [not found] <1vmPm-4lU-11@gated-at.bofh.it>
     [not found] ` <1vonq-6dr-37@gated-at.bofh.it>
     [not found]   ` <1voGY-6vC-41@gated-at.bofh.it>
     [not found]     ` <1vpjt-7dl-17@gated-at.bofh.it>
     [not found]       ` <1vpCV-7wY-41@gated-at.bofh.it>
     [not found]         ` <1vpWa-7Py-19@gated-at.bofh.it>
2004-03-02 22:53           ` Bill Davidsen
2004-03-02 22:57             ` Roland Dreier
2004-03-02 23:32             ` Richard B. Johnson
2004-03-03  0:07               ` John Muir
2004-03-03  1:18                 ` Richard B. Johnson
2004-03-03  4:04                   ` Roland Dreier
2004-03-03 12:38                     ` Richard B. Johnson
2004-03-03 14:29                       ` Davide Libenzi
2004-03-03  3:57               ` David Dillow
2004-03-03 18:23                 ` Richard B. Johnson
2004-03-03 19:29                   ` Dave Dillow
2004-03-03 20:10                     ` Richard B. Johnson
2004-03-03 22:25                   ` Linus Torvalds
2004-03-03 22:42                     ` Richard B. Johnson
2004-03-03 23:14                       ` Linus Torvalds
2004-03-03 22:52                     ` Linus Torvalds
2004-03-03 23:07                       ` Richard B. Johnson
2004-03-03  3:06 linux

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=Pine.LNX.4.53.0403021318580.796@chaos \
    --to=root@chaos.analogic.com \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®