Userland ISRs

From: Patrick Jennings (
Date: Wed Oct 16 2002 - 11:41:22 EST

Hello All:

I am writing a device driver for a pci card. We have to have "userland
isrs" in that we need to allow the top level user to run a thread that
responds to differnent isr bits n our card (a digital transever)

The approch i have been using is to create an ioctl that sleeps on interupt,
then waked up and notifies the user land program when and isr is triggired.

So the ioctl part:

        //Enable interupt
                        *(redriver_device_data.bar0ptr+0x584/4) = intr_wait.interrupt;

                        if(intr_wait.timeout != 0)
                                *(redriver_device_data.bar0ptr+0x584/4) = intr_wait.interrupt;
                                timeout = interruptible_sleep_on_timeout(&waiter->wq, intr_wait.timeout
* HZ / 1000);

                                if(timeout == 0)
                                        intr_wait.result = RRENG_WAIT_TIMEOUT;
                                        printk("<1> ISR Timeout\n");
                                        intr_wait.result = RRENG_WAIT_SUCCESS | waiter->status;
                                        printk("Timed ISR OK\n");
                                intr_wait.result = RRENG_WAIT_SUCCESS | waiter->status;
                                printk("<1>Untimed ISR ok\n");

and the isr part

for(i=0; i<RRENG_MAX_INTR_WAITERS; i++)
                        waiter = card->waiters[i];
                        printk("<1>Comparing %x and %x on waiter %d\n", statusisr, waiter.mask,
                        printk("<1>Flagval is %d\n", waiter.flagval);
                        if(waiter.mask & statusisr)
                                *(card->bar0ptr+enableregadr/4) = 0x0; //Diable;
                                printk("<1>Waking up waiter %d with mask 0x%x\n",i , waiter.mask);

                                wake_up = (waiter.status) ? FALSE : TRUE;
                                waiter.status |= status;


This all works well and good, execpt when the isr bit is already true when
isrs are enabled. Then as soon as they are enabled the isr routine gets
called, before the sleep has got a chance to get set up. Any ideas around


Patrick Jennings |
Red River | Direct Phone (972) 671-9636
Radio Products Group | Main Phone (972) 671-9570
797 North Grove Road | Fax (972) 671-9572
Suite 101 |
Richardson,TX 75081 |

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Wed Oct 23 2002 - 22:00:29 EST