From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Robert Love <rml@tech9.net>
Cc: jgarzik@pobox.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] 8390.c: preemption and disable_irq
Date: 02 Oct 2002 01:39:01 +0100 [thread overview]
Message-ID: <1033519141.20103.32.camel@irongate.swansea.linux.org.uk> (raw)
In-Reply-To: <1033509479.12851.34.camel@phantasy>
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.
prev parent reply other threads:[~2002-10-02 0:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-01 21:58 Robert Love
2002-10-02 0:39 ` Alan Cox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1033519141.20103.32.camel@irongate.swansea.linux.org.uk \
--to=alan@lxorguk.ukuu.org.uk \
--cc=jgarzik@pobox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rml@tech9.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®