bus notifiers for the generic device model

bus notifiers for the generic device model

Post by Greg K » Thu, 05 Dec 2002 20:00:22




> There are certain bus types (notably MCA and parisc internal ones) that like
> to do generic houskeeping operations (claim slots, claim uniform resources
> etc.) when drivers are attached to devices.

But doesn't the bus specific core know when drivers are attached, as it
was told to register or unregister a specific driver?  So I don't see
why this is really needed.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by James Bottomle » Thu, 05 Dec 2002 20:10:13



Quote:> But doesn't the bus specific core know when drivers are attached, as
> it was told to register or unregister a specific driver?  So I don't
> see why this is really needed.

The problem is that the bus specific core registration no-longer knows if the
probes succeeded or failed (and if they did, what devices were attached),
since probing is controlled by the base core.

What the bus needs to know is when a driver attaches to a specific device (and
what device it has attached to).

Unless you have a better way of getting the attachment information out of the
bus after the base probes have executed, a notifier seemed to be the simplest
thing.

James

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Mike Anderso » Thu, 05 Dec 2002 20:20:07




> > There are certain bus types (notably MCA and parisc internal ones) that like
> > to do generic houskeeping operations (claim slots, claim uniform resources
> > etc.) when drivers are attached to devices.

> But doesn't the bus specific core know when drivers are attached, as it
> was told to register or unregister a specific driver?  So I don't see
> why this is really needed.

The change is when a device is bound to a driver (i.e. when attach /
detach is called bus.c ).

-andmike
--
Michael Anderson

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Greg K » Thu, 05 Dec 2002 20:20:14




> > But doesn't the bus specific core know when drivers are attached, as
> > it was told to register or unregister a specific driver?  So I don't
> > see why this is really needed.

> The problem is that the bus specific core registration no-longer knows if the
> probes succeeded or failed (and if they did, what devices were attached),
> since probing is controlled by the base core.

Not quite.  Well, I guess you can modify all of your drivers to do this,
but see below for an easier way.

Quote:> What the bus needs to know is when a driver attaches to a specific device (and
> what device it has attached to).

Why not have a call in the driver that notifies the bus specific core of
this?  Or just check the status of the return value of your "probe"
function that the bus provides.  See usb_device_probe() and
pci_device_probe() for examples of this.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Patrick Moche » Thu, 05 Dec 2002 20:30:13




> > But doesn't the bus specific core know when drivers are attached, as
> > it was told to register or unregister a specific driver?  So I don't
> > see why this is really needed.

> The problem is that the bus specific core registration no-longer knows if the
> probes succeeded or failed (and if they did, what devices were attached),
> since probing is controlled by the base core.

> What the bus needs to know is when a driver attaches to a specific device (and
> what device it has attached to).

> Unless you have a better way of getting the attachment information out of the
> bus after the base probes have executed, a notifier seemed to be the simplest
> thing.

I believe that the stuff you're allowing the bus to do once the driver has
been attached, is traditionally triggered by the driver in their probe()
method once they've found a valid device. Which, in most cases, is a
perfectly valid place to do it -- drivers have always been considered
masters of their own destiny, and the things that this patch allows the
bus to do seems like they should be triggered by the driver, with the bus
supplying helpers.

The fact that the probe() method is overloaded to setup the device as well
as verify that it should attach to it is a potential opportunity for
improvement. There's been talk in the past about splitting it up into
probe() and start() (or perhaps something better). The first would only
verify that the device was a valid one to attach to, and the latter would
actually do the dirty work of setting it up. It would be called in
drivers/base/bus.c::attach(), like this:

===== drivers/base/bus.c 1.26 vs edited =====
--- 1.26/drivers/base/bus.c     Sun Dec  1 23:22:04 2002

 {
        pr_debug("bound device '%s' to driver '%s'\n",
                 dev->bus_id,dev->driver->name);
+
+       if (dev->driver->start)
+               dev->driver->start(dev);
+
        list_add_tail(&dev->driver_list,&dev->driver->devices);
        sysfs_create_link(&dev->driver->kobj,&dev->kobj,dev->kobj.name);
 }

I don't recall why the change was never done. Perhaps because of other
distractions, or it seemed like it would be too much of a PITA to convert
drivers to a two-step init sequence (though I think it could be done in a
compatible manner).

        -pat

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Jeff Garzi » Thu, 05 Dec 2002 20:50:17



> ===== drivers/base/bus.c 1.26 vs edited =====
> --- 1.26/drivers/base/bus.c        Sun Dec  1 23:22:04 2002
> +++ edited/drivers/base/bus.c      Wed Dec  4 12:02:41 2002

>  {
>    pr_debug("bound device '%s' to driver '%s'\n",
>             dev->bus_id,dev->driver->name);
> +
> +  if (dev->driver->start)
> +          dev->driver->start(dev);
> +
>    list_add_tail(&dev->driver_list,&dev->driver->devices);
>    sysfs_create_link(&dev->driver->kobj,&dev->kobj,dev->kobj.name);
>  }

> I don't recall why the change was never done. Perhaps because of other
> distractions, or it seemed like it would be too much of a PITA to convert
> drivers to a two-step init sequence (though I think it could be done in a
> compatible manner).

Possibly because of the "do it in open(2)" rule?

Ignoring the device model entirely, if a driver does a lot of
talking-to-the-hardware in its probe phase, I consider it buggy, in 2.4
or 2.5.

The network driver and chardev ones typically follow this rule quite
well... probe is simple, just registering interfaces with the kernel.
dev->open is where the driver should (and usually does) power-up the
hardware, [re-]initialize it, etc.

So each time you come upon a driver that wants dev->driver->start(),
look closely at the code and wonder why it can't perform the
dev->driver->start() code in its interface's dev->open member.

        Jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Greg K » Thu, 05 Dec 2002 21:00:10





> > > There are certain bus types (notably MCA and parisc internal ones) that like
> > > to do generic houskeeping operations (claim slots, claim uniform resources
> > > etc.) when drivers are attached to devices.

> > But doesn't the bus specific core know when drivers are attached, as it
> > was told to register or unregister a specific driver?  So I don't see
> > why this is really needed.

> The change is when a device is bound to a driver (i.e. when attach /
> detach is called bus.c ).

Whis is called after probe / remove is called for the driver, which can
point to the bus specific functions, like PCI and USB cores do.

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by James Bottomle » Thu, 05 Dec 2002 21:40:11



Quote:> Why not have a call in the driver that notifies the bus specific core
> of this?  Or just check the status of the return value of your "probe"
> function that the bus provides.  See usb_device_probe() and
> pci_device_probe() for examples of this.

Well, I did do it this way for parisc.  However, I assumed from reading the
driver model docs that we were transitioning to using the generic driver probe
rather than doing probe interceptions like this.

Doing it like this just seems rather clumsy.  wouldn't it be better to
deprecate bus specific registrations in favour of the generic one?

There is another advantage to notifiers: they can be chained.  Certain bus
architectures need to do additional setup for things like pci devices.  They
would be able to do this by attaching a notifier.

James

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Greg K » Fri, 06 Dec 2002 00:40:07




> > Why not have a call in the driver that notifies the bus specific core
> > of this?  Or just check the status of the return value of your "probe"
> > function that the bus provides.  See usb_device_probe() and
> > pci_device_probe() for examples of this.

> Well, I did do it this way for parisc.  However, I assumed from reading the
> driver model docs that we were transitioning to using the generic driver probe
> rather than doing probe interceptions like this.

> Doing it like this just seems rather clumsy.  wouldn't it be better to
> deprecate bus specific registrations in favour of the generic one?

I don't know.  Then for every bus specific driver, they would have to do
the "dereference the structure" logic before they can start to determine
if they should bind to this specific device.  That's all the PCI and USB
code really does, strip out the proper structures that are relevant to
the specific bus type, and then call the driver.

So in the end you would probably have a lot of duplicated code that
would be better off being in one place, like it is today :)

Quote:> There is another advantage to notifiers: they can be chained.  Certain bus
> architectures need to do additional setup for things like pci devices.  They
> would be able to do this by attaching a notifier.

That seems a bit overkill.  The bus specific code can add those
architecture setup hooks right now if it's needed, right?

thanks,

greg k-h
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Patrick Moche » Fri, 06 Dec 2002 06:00:07


Quote:> > I don't recall why the change was never done. Perhaps because of other
> > distractions, or it seemed like it would be too much of a PITA to convert
> > drivers to a two-step init sequence (though I think it could be done in a
> > compatible manner).

> Possibly because of the "do it in open(2)" rule?

> Ignoring the device model entirely, if a driver does a lot of
> talking-to-the-hardware in its probe phase, I consider it buggy, in 2.4
> or 2.5.

> The network driver and chardev ones typically follow this rule quite
> well... probe is simple, just registering interfaces with the kernel.
> dev->open is where the driver should (and usually does) power-up the
> hardware, [re-]initialize it, etc.

> So each time you come upon a driver that wants dev->driver->start(),
> look closely at the code and wonder why it can't perform the
> dev->driver->start() code in its interface's dev->open member.

Oh, right. Sorry, I should have said 'init()' or 'setup()' rather than
'start()'.

In many drivers there are two discrete operations that happen in the
probe() method: verifying the device can be claimed, and registering the
interfaces. By breaking it into two calls, you can conceptually separate
the actions. It would also give the bus a chance to intercept the call and
perform whatever housekeeping it needed to do at that point, giving James
what he wanted.

However, I don't see a great benefit of doing this, besides making it
_blatantly_ obvious what each call is supposed to do. The driver can call
the bus to perform housekeeping duties during the setup (probe()) period,
and everything should be happy.

        -pat

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by James Bottomle » Fri, 06 Dec 2002 18:20:13



Quote:> I don't see how your patch adresses chaining; there is only one
> notifier  per bus type.

Well, you can do it by storing the pointer privately and hijacking it.  
However, I think we'd use the existing kernel notifier chain stuff for that if
it is valuable.

Quote:> Along they way, we've found several things stand in the way of making
> this  a smooth transition, so the plan is to stick with the bus
> intermediaries  until the infrastructure matures enough to tackle
> those problems more  easily.  

I'm happy with keeping probe and remove in the bus specific driver template
and having the <bustype>_add_driver install generic device probe and remove
routines to handle these cases.  My point was that the docs implied I should
use the generic driver probe and remove routines, which I can't without some
type of functionality like this.

If you envisage us never eliminating the driver specific probe and remove
routines, I'm happy.  I'm less happy if there will come a day when I have to
revisit all the converted drivers to do the elimination.

James

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Jeff Garzi » Fri, 06 Dec 2002 19:00:23



> If you envisage us never eliminating the driver specific probe and remove
> routines, I'm happy.  I'm less happy if there will come a day when I have to
> revisit all the converted drivers to do the elimination.

Likewise...  I think with very minor changes, existing PCI-API-compliant
drivers should stay pretty much the same as they are now.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

bus notifiers for the generic device model

Post by Patrick Moche » Sat, 07 Dec 2002 21:40:06


Just to follow up..

Quote:> I'm happy with keeping probe and remove in the bus specific driver template
> and having the <bustype>_add_driver install generic device probe and remove
> routines to handle these cases.  My point was that the docs implied I should
> use the generic driver probe and remove routines, which I can't without some
> type of functionality like this.

> If you envisage us never eliminating the driver specific probe and remove
> routines, I'm happy.  I'm less happy if there will come a day when I have to
> revisit all the converted drivers to do the elimination.

I don't see us eliminating the bus-specific probe() and remove() methods.
At least not for a very long time.

        -pat

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. MCA move to the generic device model ready for inclusion

I've consolidated all of the patches previously posted to linux-kernel in the
BK repository

http://linux-voyager.bkbits.net/mca-sysfs-2.5

This is the diffstat of what I've done:

 arch/i386/Kconfig          |    2
 arch/i386/kernel/mca.c     |  978 ++++++++++----------------------------------
-
 drivers/Makefile           |    1
 drivers/mca/Kconfig        |   17
 drivers/mca/Makefile       |   10
 drivers/mca/mca-bus.c      |  167 +++++++
 drivers/mca/mca-device.c   |  202 +++++++++
 drivers/mca/mca-driver.c   |   47 ++
 drivers/mca/mca-legacy.c   |  408 ++++++++++++++++++
 drivers/mca/mca-proc.c     |  244 +++++++++++
 drivers/net/Space.c        |    4
 drivers/net/smc-mca.c      |  298 ++++++-------
 drivers/scsi/NCR_D700.c    |  267 +++++++-----
 include/asm-i386/mca.h     |   46 ++
 include/linux/mca-legacy.h |   68 +++
 include/linux/mca.h        |  183 +++++---
 16 files changed, 1856 insertions(+), 1086 deletions(-)

inclusion cordially requested.

James

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. echotc -command in tcsh

3. device model: introducing sys bus

4. hosts.allow help

5. Device driver question (generic device driver)

6. Cyrix IRQ routing is wrong?

7. USB device has no driver in /proc/bus/usb/devices

8. Apache Help ... Please. part two

9. Modular IDE Build Failing Without Modular Generic PCI bus-master DMA support

10. Linux on MCA-bus, IBM Server model 80?

11. fast ethernet for model 250 w/MCA bus

12. IDE Generic SCSI devices (emulated)

13. Solaris 8 uscsi does not work with /dev/sg device (SCSI generic)