SMP safe driver with 2.0.36

Claude Gamache (cgamache@cae.ca)
25 Mar 1999 18:44:25 -0500


Hi,

I wrote a driver for a PCI RS422 card that works well under 2.0.36 UP
(thanks to your help folks, thanks), but has problems with 2.0.36 SMP.

The driver does the following work:

-initialize internal data.
-look for the PCI RS422 card.
-get PCI info (if card found, of course).
-request_irq( irq, SA_SHIRQ, int_handler, dev_id).
-initialize RS422 card.
-schedule a task with a timer.

timer elapses...

-timer_task: start transmitting 1 data sequence.

card generates an interrupt after approx. 0.25 milliseconds.

-int_handler:
o check if card was initialized (since SA_SHIRQ, this can be
someone else interrupt, interrupt received while the
card is not yet initialized).
o check with PCI card if it did send an interrupt:

-Yes
o acknowledge interrupt to the card.
o send a new data sequence to the card.
-No
o nothing to do, return.

and then the card generates an interrupt and so on. With this scheme,
the card generates approx. 4000 interrupts per second. On a UP 2.0.36
this work fine without losing any interrupt on a P100. It does also
work on a PII 450 MHz with 2.0.36 UP. The problem is when I switched
to 2.0.36 SMP on a dual PII 450 MHz. From time to time, I lose an
interrupt. And if I don't acknowledge the interrupt, the card stops
sending them. So the transmission stops.

Also, I have been trying to use a bottom half function, but I have
difficulties (especially in SMP):

-When using bottom half in the immediate queue, does the bh function
executes really quickly after the interrupt handler with SMP kernel ?

-And does the kernel executes 2 instances of the bh function (if it was
marked twice by the interrupt handler) on a SMP kernel ?

-Should the bh function disable interrupts (I don't think so, since
this would be doing the same as the interrupt handler...)

-Would spin_lock help ?

-The card is on PCI bus 2, can this cause a problem ? I don't think so
since there are other cards (NIC) on bus 2 and they are just working
fine.

-With interrupts disabled (save_flags(flags); cli();), are the
interrupts queued by the kernel and distributed once the interrupts
are re-enabled (restore_flags(flags);) or they are dumped into
emptiness ?

Generally speaking, what should be done in SMP besides compiling with
-D__SMP__ ? I'm thinking about spin_lock and save_flags/cli stuff.

thanks in advance,

Claude

-- 
  Claude Gamache, CAE Electronique Ltee, 8585 Cote-de-Liesse  
  Saint-Laurent,  Quebec, Canada H4T 1G6                        
  Email: cgamache@cae.ca  Tel.: (514) 341-2000 x3194, Fax: (514) 734-5612

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