Subject: Re: about autoconf
To: ycchang <ycchang@cirx.org>
From: Quentin Garnier <cube@cubidou.net>
List: tech-kern
Date: 09/09/2003 09:10:54
On Tue, Sep 09, 2003 at 01:13:19PM +0800, ycchang wrote:
[...]
> > Le Tue, 09 Sep 2003 09:01:35 +0530
> > anand lalgondar a ecrit :
[...]
> > > >config_found_sm also invokes config_attach, which leads to the call of
> > > >the attach function of the device driver, where config_search only uses
> > > >match.
> > > I assume that attach functions are called only when there is a succesful
> > > match for a particular device even in the case of config_found_sm.
> >
> > Actually, config_attach is called for the best match (the cfattch match
> > function that returned the highest value).
> >
>    what does best match mean? if the we find several children hava the same
> parent
> , why we just call the attach function for the best math, and the
> others?what does the
> routine match for?is it relative tothe bus properties, say, PCI or ISA?

A device can only have one driver attached to it (not entirely true, but
anything otherwise is a hack). A simple reason for it is that two pieces
of code accessing a device in a non co-operative way may lead to a quick
reboot. That's why one driver is elected from all possible ones for a
given device.

autoconf(9) introduces the idea of attributes that refine the search for
a device, and the values related to those attributes are called locators.
Still, a driver has to make sure a device he *could* attach to is one it
handles.

In the kernel config file, you can have 'dummy* at pci? dev ? function ?'
and 'mydev* at pci? dev ? function ?'.

When a PCI bus is initialized (somewhere in the attach function of the
'pci' device driver), it scans itself and calls config_found_sm for the
devices it detects. Then it's up to the driver to accurately match
themselves, usually using the PCI vendor and device IDs.

> > > >isa only calls config_search because it has a very special way of
> > > >initializing the attachment information for the device.
> > > When is the attach function called in the case of config_search and who
> > > is going to make the call.
> >
> > The uses of config_search I can understand (in dev/isa/ and dev/scsi/) are
> > justified if some special action is required before calling the attach
> > function. In any other case, config_found_sm is the way to go.
> >
> any rules of guide?

Basically, you want to use config_found_sm. You have a device, and want a
driver to get attached to it, if one such exists. config_search is only a
part of that and should be restrained to the case that really need special
handling.

Note that I'm nowhere near an official position to dictate any rule about
autoconf(9). It's just my understanding of the system.

Quentin Garnier.