mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Userland ISRs
@ 2002-10-16 16:41 Patrick Jennings
  0 siblings, 0 replies; 2+ messages in thread
From: Patrick Jennings @ 2002-10-16 16:41 UTC (permalink / raw)
  To: LKML

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   |


^ permalink raw reply	[flat|nested] 2+ messages in thread

* RE: Userland ISRs
@ 2002-10-17 14:19 Heater, Daniel (IndSys, GEFanuc, VMIC)
  0 siblings, 0 replies; 2+ messages in thread
From: Heater, Daniel (IndSys, GEFanuc, VMIC) @ 2002-10-17 14:19 UTC (permalink / raw)
  To: 'Patrick Jennings', LKML


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

http://www.xml.com/ldd/chapter/book/ch09.html

Read the section about going to sleep without races.
I think you'll find the solution there.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-17 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-16 16:41 Userland ISRs Patrick Jennings
2002-10-17 14:19 Heater, Daniel (IndSys, GEFanuc, VMIC)

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®