Re: Initialization order of PCI devices

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Tue May 23 2000 - 10:51:04 EST


Petr Vandrovec wrote:
> drivers/atm/eni.c - driver unregisters if pci_register_driver returns 0.
> Fixed
[...]
> drivers/sound/via82cxxx_audio.c - driver unregisters if
> pci_register_driver returns 0.
> Fixed
[...]

I do not think this is a bug. In via82cxxx_audio at least, I
-purposefully- do not call pci_module_init, because it is not a hotplug
driver. I don't want the PCI driver instance hanging around if there is
no hardware for it -- even when CONFIG_HOTPLUG is true.

Your patch may also have unintended consequences, since you do not
appear to search & replace "__init" with "__devinit" where necessary.
Thus when a driver which DOES hang around (pci_register_driver returns 0
under CONFIG_HOTPLUG), and in the unlikely event such a device is
plugged in, the kernel crashes because the __devinit code it is
searching for has already been dropped (because it is __init instead).

On the whole, though, I like your core change -- I think it is important
to have a generic ability to order devices at startup.

Unfortunately since your change only supports PCI drivers, it does not
allow us to completely ignore/eliminate a user-specified ethX ordering
[for example]. I also think that the call for this patch is less strong
as we move to a more modular world.

        Jeff

> diff -urdN linux/drivers/sound/via82cxxx_audio.c linux/drivers/sound/via82cxxx_audio.c
> --- linux/drivers/sound/via82cxxx_audio.c Tue May 23 09:58:56 2000
> +++ linux/drivers/sound/via82cxxx_audio.c Tue May 23 14:20:23 2000
> @@ -2370,10 +2370,8 @@
> return rc;
> }
>
> - rc = pci_register_driver (&via_driver);
> - if (rc < 1) {
> - if (rc == 0)
> - pci_unregister_driver (&via_driver);
> + rc = pci_module_init (&via_driver);
> + if (rc < 0) {
> via_cleanup_proc ();
> MOD_DEC_USE_COUNT;
> DPRINTK ("EXIT, returning -ENODEV\n");

-- 
Jeff Garzik              | Liberty is always dangerous, but
Building 1024            | it is the safest thing we have.
MandrakeSoft, Inc.       |      -- Harry Emerson Fosdick

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue May 23 2000 - 21:00:23 EST