device probe re-tried for failed isa device
Warner Losh
imp at bsdimp.com
Fri Jan 13 16:41:38 PST 2006
> 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
More information about the freebsd-hackers
mailing list