Messages in this thread | | | Date | Sun, 06 Jun 2004 14:13:43 -0400 | From | Jeff Garzik <> | Subject | Re: 2.6.7-rc1 breaks forcedeth |
| |
Linus Torvalds wrote: > But it's usually a good thing to try to reset a device as much as possible > when you probe for it. If for no other reason than the fact that then > you'll have it in a "known state", and hopefully there won't be as many > surprises..
Strongly agreed. I stress this, in Linux driver writing talks and rants, to whomever will listen as "the proper way to do things in Linux".
Presuming things about a device's state upon entry to the driver has led to bugs in the past. Popular bugs include assuming (a) MAC address registers hold a valid/useful value or (b) ethernet NIC's DMA engine is not active. Both of these are quite often not true when you take into account driver re-loads, warm reboots, and firmware features such as USB kbd/mouse/storage or PXE booting from a network.
A good driver unconditionally makes sure the device is inactive in its probe function (struct pci_driver::probe), before registering itself with any kernel subsystems. This must also be done before request_irq and before enabling the bus-mastering bit in PCI_COMMAND register.
Jeff
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |