Userland ISRs

Patrick Jennings (jennings@red-river.com)
Wed, 16 Oct 2002 11:41:22 -0500


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");
}
else
{
intr_wait.result = RRENG_WAIT_SUCCESS | waiter->status;
printk("Timed ISR OK\n");
}
}
else
{
interruptible_sleep_on(&waiter->wq);
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,
i);
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;

if(wake_up)
wake_up_interruptible(&waiter.wq);
}
}

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
this?

/patrick

+========================================================+
Patrick Jennings | jennings@red-river.com
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 | www.red-river.com
Richardson,TX 75081 |

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/