Subject: Re: CVS commit: syssrc
To: Chris G. Demetriou <cgd@sibyte.com>
From: Lennart Augustsson <lennart@augustsson.net>
List: port-i386
Date: 12/21/2000 13:26:02
"Chris G. Demetriou" wrote:

> lennart@mail.augustsson.net (Lennart Augustsson) writes:
> > Yes, we should change the attach routines to return a value to indicate
> > failure.  Many drivers need it.
>
> I'm not sure that I agree.  In what situation do you _need_ to return
> an attach failure?
>
> The only things i can think of are resource allocation problems.  For
> some reasources, the code should probably be checking up front in the
> match routines.  (e.g. can I use this bloody IRQ after all?  just like
> it checks use of I/O space, etc.)  For others that I can think of, the
> use of waiting calls should make the right thing happen.
>
> So, really, If you can't attach, you shouldn't have matched
> successfully.

Well, take USB devices as an example.  The match is easy, but while
attaching you often need to frob the device a little (frobbing during match
would be a BAD idea).  Well, doing I/O to a USB device can fail at
any time.  If it fails, I'd like to indicate this.

Another example, you might need to allocate memory in the attach.
Checking that there is memory while doing the match doesn't guarantee
anything since another thread might have taken it.  (I guess this is a
point where a waiting call might be acceptable, but you don't want to
hang the attach thread really.)

There are some situations where the match simply cannot know that
the attach will work for sure.


> One conceptual problem with allowing code to back out of matches is
> something like: OK, say i've got a specific driver which doesn't
> succeed in attaching, but also had a lower-priority match generic
> driver.  It may make sense for that lower-priority driver to be
> attached in place of the specific driver, and that's prevented if the
> specific driver actually matches with a high priority.  I suppose you
> could solve that by keeping a stack of matches, but ... it seems
> better to just match more carefully.

I wouldn't suggest backing out and try a lower match.  If the attach fails
it means that something is seriously wrong and we should just tell the
user and mark the device and unusable.


--

        -- Lennart