Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Jan 2006 17:39:54 -0700 (MST)
From:      Warner Losh <imp@bsdimp.com>
To:        NKoch@demig.de
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: device probe re-tried for failed isa device
Message-ID:  <20060113.173954.02259183.imp@bsdimp.com>
In-Reply-To: <000701c6184c$d3f27060$4801a8c0@ws-ew-3.demig.intra>
References:  <000701c6184c$d3f27060$4801a8c0@ws-ew-3.demig.intra>

next in thread | previous in thread | raw e-mail | index | archive | help
> I wrote two isa device drivers A and B for FreeBSD4.11.
> Both are kld-loaded and have identify() entries.
> 
> Here is the pseudo code for the identify() routines:
> 
> A_identify() /* 2 units */
> {
>   for (i = 0; i <=1; ++ i)
>   {
>     dev = BUS_ADD_CHILD(parent, ISA-ORDER_SPECULATIVE, "a", 0);
>     If (bus_set_resource (dev, ...) != 0)
>     {
>       device_delete_child (parent, dev);
>       continue;
>     };
>     init (device_get_softc (dev, i));
>   }
> }

Don't get softc in your identify routine.  It isn't allowed there.

> B_identify() /* 1 unit */
> {
>   dev = BUS_ADD_CHILD(parent, ISA-ORDER_SPECULATIVE, "a", 0);
>   If (bus_set_resource (dev, ...) != 0)
>   {
>     device_delete_child (parent, dev);
>   }
> }
> 
> When I kldload the two drivers I see these function calls:
> 1. A_identify
> 2. A_probe(unit 0)
> 3. A_attach(unit 0)
> 4. A_probe(unit 1)
>   <-- fails with ENXIO because hardware is not present
> 5. B_identify
> 6. A_probe(unit 1)
>   <-- probed again!?

Yes.  It should be.  The child hasn't been deleted.

> 7. B_probe(unit 0)
> 8. B_attach(unit 0)
> 
> Is it correct, that the isa bus re-tries
> to probe failed devices?

Yes.

> The results from calling device_get_softc()
> differ for the two probe() calls 4 and 6.
> Is this correct?

Yes.  softc is only valid if probe() returns 0.  It is deleted
otherwise.

> Is it correct to initialize softc in identify()?

No.  It isn't,

> Should I call device_delete_child() in
> probe() when the hardware fails?

No.  You shouldn't.

Warner



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