Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 May 2000 19:16:21 -0600
From:      Warner Losh <imp@village.org>
To:        Sergey Babkin <babkin@bellatlantic.net>
Cc:        Alexander Langer <alex@big.endian.de>, doc@FreeBSD.ORG, hackers@FreeBSD.ORG
Subject:   Re: request for review: bus_alloc_resource(9) 
Message-ID:  <200005190116.TAA98120@harmony.village.org>
In-Reply-To: Your message of "Thu, 18 May 2000 21:04:30 EDT." <3924931E.A8471B0@bellatlantic.net> 
References:  <3924931E.A8471B0@bellatlantic.net>  <20000518223846.A16098@cichlids.cichlids.com> <200005182332.RAA97696@harmony.village.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <3924931E.A8471B0@bellatlantic.net> Sergey Babkin writes:
: The code seems to guarantee that if the probe routine returns 0
: then the attach routine will be called right away. So if the probe
: routine returns 0 they don't have to be freed. Actually, the
: comments seem to say explicitly that the resources should be
: freed only if the probe routine returns a negative value but not 0.
: Or am I missing something ?

The code doesn't write the guarantee.  In general probe routines are
supposed to be idempotent.  You are supposed to be able to have them
be called multiple times, at least in theory.  The probe routine
should not hold resources past the end of its execution, positive or
negative.

I'm not sure where you found the comments that say that the probe
routine can hold resources after it is called.  I couldn't find any.

It is also legal for buses to probe all their devices before attaching
any of them (the pci bus does this, iirc, so that generic drivers can
handle some hardware and more specific drivers can handle other).
There's nothing that states probe_and_attach is the only way to get
things done.

Finally, there's a comment in subr_bus:
	device_set_driver(child, best->driver);
	if (pri < 0) {
	    /*
	     * A bit bogus. Call the probe method again to make sure
	     * that we have the right description.
	     */
	    DEVICE_PROBE(child);
	}

which indicates to me that the probe routines will be called multiple
times if they return < 0 (pri is the priority they returned, 0 meaning
it is mine and nobody else's).

Warner


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




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