Re: device driver race conditions problems (kernel 2.4)

From: Pete Zaitcev (OTID1) (ot16a6ca05878e44c0_at_comcast.net)
Date: 08/28/04


Date: Fri, 27 Aug 2004 19:35:32 -0700

On Fri, 27 Aug 2004 13:14:52 -0700, Paulo Garcia wrote:

> My driver must be able to manage more than one card using the same ISR
> and putting all signals into the same sbuffer. My approach is to use
> just one inode file (/dev/vbe1_s) to send data of all cards.

Why have you decided to do it this way?

> My ISR calls *spin_lock_irqsave* to avoid one interrupt interrupts
> another one of another card.
>
> The problem is when I put more than one card into PC, I have
> experienced some hangs. [...]

The code snippet below cannot work right, because the user context
part is not interlocked with the interrupt processing. It has no
calls to spin_lock_irqsave at all.

However, if it did, it would be tricky. You cannot call copy_to_user
while under lock, or you lock up. So, you would need to flip pointers
under lock to extract a buffer, then copy it out.

As for the lockup itself, the fragment does not tell us enough
to guess what may be wrong. My money is on improper interrupt
deactivation, causing a storm on level-triggered interrupt.
The deactivation sequence was omitted from the fragment.
If you need real help, you will have to do better than this
and perhaps post real code.

-- Pete



Relevant Pages

  • Re: Hello All
    ... section to be used as INTERRUPT PROCEDURE. ... You would normally use more than one INTERRUPT PROCEDURE when you have more than one event that you want to trigger a software interrupt. ... The requirement to lock master records before detail records is controlled by the LOCK TO MODIFY DETAILS option in DASDL. ... It is specified on the master data set. ...
    (comp.sys.unisys)
  • Re: race on multi-processor solaris
    ... > want to block if the lock holder is not running. ... and there is a CPU structure for each CPU. ... interrupts") are handled by "interrupt threads", ... Before we set the waiters bit, we grab the lock protecting the lock's ...
    (comp.unix.solaris)
  • Re: [RFC PATCH] Fair low-latency rwlock v5
    ... If the lock is uncontended, but is not in the current CPU's caches, ... Fair low-latency rwlock provides fairness for writers against reader threads, ... but lets softirq and irq readers in even when there are subscribed writers ... Added contention delays performance tests for thread and interrupt contexts to ...
    (Linux-Kernel)
  • Re: RT patch acceptance
    ... > I really dislike the idea of interrupt threads. ... it isn't possible to do all of this per path and lock in any sane manner. ... This extends to all of the drivers in Linux as well. ... > Of course you would not do it as a big patch. ...
    (Linux-Kernel)
  • Re: Locking netatm
    ... Interrupting the code while getting a lock could result in a race condition. ... If you have to protect datas through a TSL ... by interrupt timer and threadB is scheduled to run. ... want to receive interrupts until the netatm memory for the ...
    (freebsd-arch)