Skip to contentSkip to conversation

Hot-plug for pcnet32 ?

DISCUSSION Don Fry 2 participants 2 messages Jan 19, 2004 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Don Fry

author
#1 lore raw
In reply to a message not in the archive
Quoted 4 lines
Quoted 3 lines

Any chance that anyone is thinking of adding hot-plug support to the pcnet32 driver?

Quoted 10 lines

You want to give me a hotplug machine ? :-)

Best regards,
Helge
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Here is a repeat of a patch to enable PCI Hot Plug for pcnet32.

drivers/net/pcnet32.c +22 -2
@@ -806,8 +806,12 @@
     dev->tx_timeout = pcnet32_tx_timeout;
     dev->watchdog_timeo = (5*HZ);
 
-    lp->next = pcnet32_dev;
-    pcnet32_dev = dev;
+    if (pdev)
+	pci_set_drvdata(pdev, dev);
+    else {
+	lp->next = pcnet32_dev;
+	pcnet32_dev = dev;
+    }
 
     /* Fill in the generic fields of the device structure. */
     register_netdev(dev);
@@ -1703,9 +1707,25 @@
     mod_timer (&(lp->watchdog_timer), PCNET32_WATCHDOG_TIMEOUT);
 }
 
+static void __devexit pcnet32_remove_one(struct pci_dev *pdev)
+{
+    struct net_device *dev = pci_get_drvdata(pdev);
+
+    if (dev) {
+	struct pcnet32_private *lp = dev->priv;
+
+	unregister_netdev(dev);
+	release_region(dev->base_addr, PCNET32_TOTAL_SIZE);
+	pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
+	free_netdev(dev);
+	pci_set_drvdata(pdev, NULL);
+    }
+}
+
 static struct pci_driver pcnet32_driver = {
     .name	= DRV_NAME,
     .probe	= pcnet32_probe_pci,
+    .remove	= __devexit_p(pcnet32_remove_one),
     .id_table	= pcnet32_pci_tbl,
 };
 
Signature · 2 lines
Don Fry
[email protected]
#2 lore raw
Quoted 3 lines · Don Fry
Quoted 2 lines
Quoted 2 lines

Any chance that anyone is thinking of adding hot-plug support to the pcnet32 driver?

Here is a repeat of a patch to enable PCI Hot Plug for pcnet32.

Errrmmm, you need to much more than that!

Here are a few rules for writing hotremove-safe drivers:

Don't count on "remove interrupts": hardware may disappear at any time. Always check for 0xffffffff when starting a new hardware operation. This may usually be done very efficiently: in an interrupt handler check for all error status bits with a mask, and in the error handling routine check for missing hardware.

Analyze the transmit routine routine. In many cases the driver can "just assume everything will according to plan and leave the room". But if the driver reads from the hardware, it presumably depends on the value and should check for missing hardware.

Don't forget statistics and ioctl() routines when checking for missing hardware.

Never have unlimited loops. Always use an explicit loop limit (e.g. 'boguscnt=1000' or 'work_limit=20') rather than rely on the value in a hardware register changing.

Signature · 4 lines
Donald Becker				[email protected]
Scyld Computing Corporation		http://www.scyld.com
914 Bay Ridge Road, Suite 220		Scyld Beowulf cluster systems
Annapolis MD 21403			410-990-9993