[lkml]   [2002]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH] 8390.c: preemption and disable_irq
    On Tue, 2002-10-01 at 22:58, Robert Love wrote:
    > P.S. Note there is a much simpler solution of merely flipping the
    > spin_lock() and disable_irq() calls - the spin_lock() will provide the
    > atomicity without the explicit preempt_disable(). I do not think this
    > is safe, however, since the IRQ handler could deadlock if it grabbed
    > this lock (which I assume it does).

    The actual game the driver is playing goes like this

    ne2k-pci hardware is often very slow (some of it is isa chips nailed to
    crappy pci/isa glue). 8390's also have the fun property that the
    registers are windowed and you can't clear a pending IRQ without
    flipping windows.

    When we do a transmit we want to do the packet upload with most
    interrupts enabled (or you drop serial interrupts and life sucks a lot).
    We take the lock with the irq. We switch window (safely under the lock)
    and we turn interrupts off on the card. We then release the lock.

    At this point you might think all is safe. However IRQ delivery on x86
    is asynchronous so an IRQ can be in flight after we turn it off but not
    yet at the CPU. To cover this case we disable that IRQ line, then take
    the lock - possibly waiting briefly for an IRQ handler to clear on
    another CPU, but not where one can begin to occur and deadlock.

    The end result of this little pile of tricks is that you can run ne2k
    cards and a modem on a PC at the same time. I think you want to
    disable pre-empt before we take the lock with irqsave - to cover the
    moment we have the irq disabled against pre-emption and packet loss too
    - ie move the pre-empt disable further backwards.

    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

     \ /
      Last update: 2005-03-22 13:29    [W:0.029 / U:2.968 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site