Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Mar 2003 10:51:01 +0100 (CET)
From:      Harti Brandt <brandt@fokus.fraunhofer.de>
To:        net@freebsd.org
Subject:   locking in network if attach again
Message-ID:  <20030314104019.T65266@beagle.fokus.fraunhofer.de>

next in thread | raw e-mail | index | archive | help

Hi all,

the following problem occured just to me. Suppose the last lines in
my attach() function look something like:

	if_attach(...)

	bus_setup_intr(...)

Last time we had the locking discussion it was more or less the concensus,
that no locking is needed in attach() and that the last thing I do is
setting up the interrupt. It seems to me, however, that the following may
happen here:

1. After if_attach but before setup_intr() a process on another processor
calls if_ioctl to make the interface UP and if_start() to start output.

2. while the attach routine is blocked (perhaps while an interrupt is
serverd) if_start initiates output.

3. The device tries to interrupt but cannot do that (setup_intr() has not
been called yet).

4. The device gets stuck, because the interrupt is lost.

5. setup_intr() is called but that does not help.

Is this a possible scenario?

I must admit, that such a scenarion has a rather low probability, but
according to Murphy's Law, it will happen.

Maybe if_attach and bus_setup_intr can be reversed. In this case the
interrupt routine must be careful to not call into the network system,
because the network system doesn't know anything about the interface
until if_attach().

Another solution would be to lock softc before if_attach, but this would
probably provoke an LOR (as I remember).

Regards,
harti
-- 
harti brandt,
http://www.fokus.fraunhofer.de/research/cc/cats/employees/hartmut.brandt/private
brandt@fokus.fraunhofer.de, harti@freebsd.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030314104019.T65266>