Commit 4b75a442 authored by Scott Feldman's avatar Scott Feldman Committed by Jeff Garzik

enic: bug fix: don't set netdev->name too early

Bug fix: don't set netdev->name early before netdev registration.  Setting
netdev->name early with dev_alloc_name() would occasionally cause netdev
registration to fail returning error that device was already registered.
Since we're using netdev->name to name MSI-X vectors, we now need to
move the request_irq after netdev registartion, so move it to ->open.
Signed-off-by: default avatarScott Feldman <scofeldm@cisco.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent 8f4d248c
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#define DRV_NAME "enic" #define DRV_NAME "enic"
#define DRV_DESCRIPTION "Cisco 10G Ethernet Driver" #define DRV_DESCRIPTION "Cisco 10G Ethernet Driver"
#define DRV_VERSION "0.0.1.18163.472" #define DRV_VERSION "0.0.1-18163.472-k1"
#define DRV_COPYRIGHT "Copyright 2008 Cisco Systems, Inc" #define DRV_COPYRIGHT "Copyright 2008 Cisco Systems, Inc"
#define PFX DRV_NAME ": " #define PFX DRV_NAME ": "
......
...@@ -1250,13 +1250,28 @@ static int enic_open(struct net_device *netdev) ...@@ -1250,13 +1250,28 @@ static int enic_open(struct net_device *netdev)
unsigned int i; unsigned int i;
int err; int err;
err = enic_request_intr(enic);
if (err) {
printk(KERN_ERR PFX "%s: Unable to request irq.\n",
netdev->name);
return err;
}
err = enic_notify_set(enic);
if (err) {
printk(KERN_ERR PFX
"%s: Failed to alloc notify buffer, aborting.\n",
netdev->name);
goto err_out_free_intr;
}
for (i = 0; i < enic->rq_count; i++) { for (i = 0; i < enic->rq_count; i++) {
err = vnic_rq_fill(&enic->rq[i], enic_rq_alloc_buf); err = vnic_rq_fill(&enic->rq[i], enic_rq_alloc_buf);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Unable to alloc receive buffers.\n", "%s: Unable to alloc receive buffers.\n",
netdev->name); netdev->name);
return err; goto err_out_notify_unset;
} }
} }
...@@ -1278,6 +1293,13 @@ static int enic_open(struct net_device *netdev) ...@@ -1278,6 +1293,13 @@ static int enic_open(struct net_device *netdev)
enic_notify_timer_start(enic); enic_notify_timer_start(enic);
return 0; return 0;
err_out_notify_unset:
vnic_dev_notify_unset(enic->vdev);
err_out_free_intr:
enic_free_intr(enic);
return err;
} }
/* rtnl lock is held, process context */ /* rtnl lock is held, process context */
...@@ -1307,6 +1329,9 @@ static int enic_stop(struct net_device *netdev) ...@@ -1307,6 +1329,9 @@ static int enic_stop(struct net_device *netdev)
return err; return err;
} }
vnic_dev_notify_unset(enic->vdev);
enic_free_intr(enic);
(void)vnic_cq_service(&enic->cq[ENIC_CQ_RQ], (void)vnic_cq_service(&enic->cq[ENIC_CQ_RQ],
-1, enic_rq_service_drop, NULL); -1, enic_rq_service_drop, NULL);
(void)vnic_cq_service(&enic->cq[ENIC_CQ_WQ], (void)vnic_cq_service(&enic->cq[ENIC_CQ_WQ],
...@@ -1592,18 +1617,6 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1592,18 +1617,6 @@ static int __devinit enic_probe(struct pci_dev *pdev,
return -ENOMEM; return -ENOMEM;
} }
/* Set the netdev name early so intr vectors are properly
* named and any error msgs can include netdev->name
*/
rtnl_lock();
err = dev_alloc_name(netdev, netdev->name);
rtnl_unlock();
if (err < 0) {
printk(KERN_ERR PFX "Unable to allocate netdev name.\n");
goto err_out_free_netdev;
}
pci_set_drvdata(pdev, netdev); pci_set_drvdata(pdev, netdev);
SET_NETDEV_DEV(netdev, &pdev->dev); SET_NETDEV_DEV(netdev, &pdev->dev);
...@@ -1618,16 +1631,14 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1618,16 +1631,14 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = pci_enable_device(pdev); err = pci_enable_device(pdev);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Cannot enable PCI device, aborting.\n", "Cannot enable PCI device, aborting.\n");
netdev->name);
goto err_out_free_netdev; goto err_out_free_netdev;
} }
err = pci_request_regions(pdev, DRV_NAME); err = pci_request_regions(pdev, DRV_NAME);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Cannot request PCI regions, aborting.\n", "Cannot request PCI regions, aborting.\n");
netdev->name);
goto err_out_disable_device; goto err_out_disable_device;
} }
...@@ -1643,25 +1654,22 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1643,25 +1654,22 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); err = pci_set_dma_mask(pdev, DMA_32BIT_MASK);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: No usable DMA configuration, aborting.\n", "No usable DMA configuration, aborting.\n");
netdev->name);
goto err_out_release_regions; goto err_out_release_regions;
} }
err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Unable to obtain 32-bit DMA " "Unable to obtain 32-bit DMA "
"for consistent allocations, aborting.\n", "for consistent allocations, aborting.\n");
netdev->name);
goto err_out_release_regions; goto err_out_release_regions;
} }
} else { } else {
err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK); err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Unable to obtain 40-bit DMA " "Unable to obtain 40-bit DMA "
"for consistent allocations, aborting.\n", "for consistent allocations, aborting.\n");
netdev->name);
goto err_out_release_regions; goto err_out_release_regions;
} }
using_dac = 1; using_dac = 1;
...@@ -1672,8 +1680,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1672,8 +1680,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: BAR0 not memory-map'able, aborting.\n", "BAR0 not memory-map'able, aborting.\n");
netdev->name);
err = -ENODEV; err = -ENODEV;
goto err_out_release_regions; goto err_out_release_regions;
} }
...@@ -1684,8 +1691,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1684,8 +1691,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
if (!enic->bar0.vaddr) { if (!enic->bar0.vaddr) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Cannot memory-map BAR0 res hdr, aborting.\n", "Cannot memory-map BAR0 res hdr, aborting.\n");
netdev->name);
err = -ENODEV; err = -ENODEV;
goto err_out_release_regions; goto err_out_release_regions;
} }
...@@ -1696,8 +1702,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1696,8 +1702,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
enic->vdev = vnic_dev_register(NULL, enic, pdev, &enic->bar0); enic->vdev = vnic_dev_register(NULL, enic, pdev, &enic->bar0);
if (!enic->vdev) { if (!enic->vdev) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: vNIC registration failed, aborting.\n", "vNIC registration failed, aborting.\n");
netdev->name);
err = -ENODEV; err = -ENODEV;
goto err_out_iounmap; goto err_out_iounmap;
} }
...@@ -1708,8 +1713,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1708,8 +1713,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = enic_dev_open(enic); err = enic_dev_open(enic);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: vNIC dev open failed, aborting.\n", "vNIC dev open failed, aborting.\n");
netdev->name);
goto err_out_vnic_unregister; goto err_out_vnic_unregister;
} }
...@@ -1726,8 +1730,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1726,8 +1730,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = vnic_dev_init(enic->vdev, 0); err = vnic_dev_init(enic->vdev, 0);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: vNIC dev init failed, aborting.\n", "vNIC dev init failed, aborting.\n");
netdev->name);
goto err_out_dev_close; goto err_out_dev_close;
} }
...@@ -1737,8 +1740,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1737,8 +1740,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = enic_get_vnic_config(enic); err = enic_get_vnic_config(enic);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Get vNIC configuration failed, aborting.\n", "Get vNIC configuration failed, aborting.\n");
netdev->name);
goto err_out_dev_close; goto err_out_dev_close;
} }
...@@ -1754,18 +1756,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1754,18 +1756,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = enic_set_intr_mode(enic); err = enic_set_intr_mode(enic);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Failed to set intr mode, aborting.\n", "Failed to set intr mode, aborting.\n");
netdev->name);
goto err_out_dev_close;
}
/* Request interrupt vector(s)
*/
err = enic_request_intr(enic);
if (err) {
printk(KERN_ERR PFX "%s: Unable to request irq.\n",
netdev->name);
goto err_out_dev_close; goto err_out_dev_close;
} }
...@@ -1775,8 +1766,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1775,8 +1766,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = enic_alloc_vnic_resources(enic); err = enic_alloc_vnic_resources(enic);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Failed to alloc vNIC resources, aborting.\n", "Failed to alloc vNIC resources, aborting.\n");
netdev->name);
goto err_out_free_vnic_resources; goto err_out_free_vnic_resources;
} }
...@@ -1792,19 +1782,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1792,19 +1782,7 @@ static int __devinit enic_probe(struct pci_dev *pdev,
ig_vlan_strip_en); ig_vlan_strip_en);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Failed to config nic, aborting.\n", "Failed to config nic, aborting.\n");
netdev->name);
goto err_out_free_vnic_resources;
}
/* Setup notification buffer area
*/
err = enic_notify_set(enic);
if (err) {
printk(KERN_ERR PFX
"%s: Failed to alloc notify buffer, aborting.\n",
netdev->name);
goto err_out_free_vnic_resources; goto err_out_free_vnic_resources;
} }
...@@ -1831,9 +1809,8 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1831,9 +1809,8 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = enic_set_mac_addr(netdev, enic->mac_addr); err = enic_set_mac_addr(netdev, enic->mac_addr);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Invalid MAC address, aborting.\n", "Invalid MAC address, aborting.\n");
netdev->name); goto err_out_free_vnic_resources;
goto err_out_notify_unset;
} }
netdev->open = enic_open; netdev->open = enic_open;
...@@ -1887,18 +1864,14 @@ static int __devinit enic_probe(struct pci_dev *pdev, ...@@ -1887,18 +1864,14 @@ static int __devinit enic_probe(struct pci_dev *pdev,
err = register_netdev(netdev); err = register_netdev(netdev);
if (err) { if (err) {
printk(KERN_ERR PFX printk(KERN_ERR PFX
"%s: Cannot register net device, aborting.\n", "Cannot register net device, aborting.\n");
netdev->name); goto err_out_free_vnic_resources;
goto err_out_notify_unset;
} }
return 0; return 0;
err_out_notify_unset:
vnic_dev_notify_unset(enic->vdev);
err_out_free_vnic_resources: err_out_free_vnic_resources:
enic_free_vnic_resources(enic); enic_free_vnic_resources(enic);
enic_free_intr(enic);
err_out_dev_close: err_out_dev_close:
vnic_dev_close(enic->vdev); vnic_dev_close(enic->vdev);
err_out_vnic_unregister: err_out_vnic_unregister:
...@@ -1926,9 +1899,7 @@ static void __devexit enic_remove(struct pci_dev *pdev) ...@@ -1926,9 +1899,7 @@ static void __devexit enic_remove(struct pci_dev *pdev)
flush_scheduled_work(); flush_scheduled_work();
unregister_netdev(netdev); unregister_netdev(netdev);
vnic_dev_notify_unset(enic->vdev);
enic_free_vnic_resources(enic); enic_free_vnic_resources(enic);
enic_free_intr(enic);
vnic_dev_close(enic->vdev); vnic_dev_close(enic->vdev);
enic_clear_intr_mode(enic); enic_clear_intr_mode(enic);
vnic_dev_unregister(enic->vdev); vnic_dev_unregister(enic->vdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment