diff options
author | Scott Feldman <scofeldm@cisco.com> | 2008-09-24 14:23:53 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-09-24 20:48:48 -0400 |
commit | 4b75a442d2affb2ed20422054b1c640bd3b9c36a (patch) | |
tree | 97fb7606f072d4cb44ef14fb971c28d48eeb2871 /drivers/net/enic | |
parent | 8f4d248cb7c1873275608f267e525e08bcbd543b (diff) |
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: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/enic')
-rw-r--r-- | drivers/net/enic/enic.h | 2 | ||||
-rw-r--r-- | drivers/net/enic/enic_main.c | 121 |
2 files changed, 47 insertions, 76 deletions
diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 9e0d484deb20..7f677e89a788 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | #define DRV_NAME "enic" | 34 | #define DRV_NAME "enic" |
35 | #define DRV_DESCRIPTION "Cisco 10G Ethernet Driver" | 35 | #define DRV_DESCRIPTION "Cisco 10G Ethernet Driver" |
36 | #define DRV_VERSION "0.0.1.18163.472" | 36 | #define DRV_VERSION "0.0.1-18163.472-k1" |
37 | #define DRV_COPYRIGHT "Copyright 2008 Cisco Systems, Inc" | 37 | #define DRV_COPYRIGHT "Copyright 2008 Cisco Systems, Inc" |
38 | #define PFX DRV_NAME ": " | 38 | #define PFX DRV_NAME ": " |
39 | 39 | ||
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index d403ce29a141..f3a47a87dbbe 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c | |||
@@ -1250,13 +1250,28 @@ static int enic_open(struct net_device *netdev) | |||
1250 | unsigned int i; | 1250 | unsigned int i; |
1251 | int err; | 1251 | int err; |
1252 | 1252 | ||
1253 | err = enic_request_intr(enic); | ||
1254 | if (err) { | ||
1255 | printk(KERN_ERR PFX "%s: Unable to request irq.\n", | ||
1256 | netdev->name); | ||
1257 | return err; | ||
1258 | } | ||
1259 | |||
1260 | err = enic_notify_set(enic); | ||
1261 | if (err) { | ||
1262 | printk(KERN_ERR PFX | ||
1263 | "%s: Failed to alloc notify buffer, aborting.\n", | ||
1264 | netdev->name); | ||
1265 | goto err_out_free_intr; | ||
1266 | } | ||
1267 | |||
1253 | for (i = 0; i < enic->rq_count; i++) { | 1268 | for (i = 0; i < enic->rq_count; i++) { |
1254 | err = vnic_rq_fill(&enic->rq[i], enic_rq_alloc_buf); | 1269 | err = vnic_rq_fill(&enic->rq[i], enic_rq_alloc_buf); |
1255 | if (err) { | 1270 | if (err) { |
1256 | printk(KERN_ERR PFX | 1271 | printk(KERN_ERR PFX |
1257 | "%s: Unable to alloc receive buffers.\n", | 1272 | "%s: Unable to alloc receive buffers.\n", |
1258 | netdev->name); | 1273 | netdev->name); |
1259 | return err; | 1274 | goto err_out_notify_unset; |
1260 | } | 1275 | } |
1261 | } | 1276 | } |
1262 | 1277 | ||
@@ -1278,6 +1293,13 @@ static int enic_open(struct net_device *netdev) | |||
1278 | enic_notify_timer_start(enic); | 1293 | enic_notify_timer_start(enic); |
1279 | 1294 | ||
1280 | return 0; | 1295 | return 0; |
1296 | |||
1297 | err_out_notify_unset: | ||
1298 | vnic_dev_notify_unset(enic->vdev); | ||
1299 | err_out_free_intr: | ||
1300 | enic_free_intr(enic); | ||
1301 | |||
1302 | return err; | ||
1281 | } | 1303 | } |
1282 | 1304 | ||
1283 | /* rtnl lock is held, process context */ | 1305 | /* rtnl lock is held, process context */ |
@@ -1307,6 +1329,9 @@ static int enic_stop(struct net_device *netdev) | |||
1307 | return err; | 1329 | return err; |
1308 | } | 1330 | } |
1309 | 1331 | ||
1332 | vnic_dev_notify_unset(enic->vdev); | ||
1333 | enic_free_intr(enic); | ||
1334 | |||
1310 | (void)vnic_cq_service(&enic->cq[ENIC_CQ_RQ], | 1335 | (void)vnic_cq_service(&enic->cq[ENIC_CQ_RQ], |
1311 | -1, enic_rq_service_drop, NULL); | 1336 | -1, enic_rq_service_drop, NULL); |
1312 | (void)vnic_cq_service(&enic->cq[ENIC_CQ_WQ], | 1337 | (void)vnic_cq_service(&enic->cq[ENIC_CQ_WQ], |
@@ -1592,18 +1617,6 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1592 | return -ENOMEM; | 1617 | return -ENOMEM; |
1593 | } | 1618 | } |
1594 | 1619 | ||
1595 | /* Set the netdev name early so intr vectors are properly | ||
1596 | * named and any error msgs can include netdev->name | ||
1597 | */ | ||
1598 | |||
1599 | rtnl_lock(); | ||
1600 | err = dev_alloc_name(netdev, netdev->name); | ||
1601 | rtnl_unlock(); | ||
1602 | if (err < 0) { | ||
1603 | printk(KERN_ERR PFX "Unable to allocate netdev name.\n"); | ||
1604 | goto err_out_free_netdev; | ||
1605 | } | ||
1606 | |||
1607 | pci_set_drvdata(pdev, netdev); | 1620 | pci_set_drvdata(pdev, netdev); |
1608 | 1621 | ||
1609 | SET_NETDEV_DEV(netdev, &pdev->dev); | 1622 | SET_NETDEV_DEV(netdev, &pdev->dev); |
@@ -1618,16 +1631,14 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1618 | err = pci_enable_device(pdev); | 1631 | err = pci_enable_device(pdev); |
1619 | if (err) { | 1632 | if (err) { |
1620 | printk(KERN_ERR PFX | 1633 | printk(KERN_ERR PFX |
1621 | "%s: Cannot enable PCI device, aborting.\n", | 1634 | "Cannot enable PCI device, aborting.\n"); |
1622 | netdev->name); | ||
1623 | goto err_out_free_netdev; | 1635 | goto err_out_free_netdev; |
1624 | } | 1636 | } |
1625 | 1637 | ||
1626 | err = pci_request_regions(pdev, DRV_NAME); | 1638 | err = pci_request_regions(pdev, DRV_NAME); |
1627 | if (err) { | 1639 | if (err) { |
1628 | printk(KERN_ERR PFX | 1640 | printk(KERN_ERR PFX |
1629 | "%s: Cannot request PCI regions, aborting.\n", | 1641 | "Cannot request PCI regions, aborting.\n"); |
1630 | netdev->name); | ||
1631 | goto err_out_disable_device; | 1642 | goto err_out_disable_device; |
1632 | } | 1643 | } |
1633 | 1644 | ||
@@ -1643,25 +1654,22 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1643 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | 1654 | err = pci_set_dma_mask(pdev, DMA_32BIT_MASK); |
1644 | if (err) { | 1655 | if (err) { |
1645 | printk(KERN_ERR PFX | 1656 | printk(KERN_ERR PFX |
1646 | "%s: No usable DMA configuration, aborting.\n", | 1657 | "No usable DMA configuration, aborting.\n"); |
1647 | netdev->name); | ||
1648 | goto err_out_release_regions; | 1658 | goto err_out_release_regions; |
1649 | } | 1659 | } |
1650 | err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); | 1660 | err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); |
1651 | if (err) { | 1661 | if (err) { |
1652 | printk(KERN_ERR PFX | 1662 | printk(KERN_ERR PFX |
1653 | "%s: Unable to obtain 32-bit DMA " | 1663 | "Unable to obtain 32-bit DMA " |
1654 | "for consistent allocations, aborting.\n", | 1664 | "for consistent allocations, aborting.\n"); |
1655 | netdev->name); | ||
1656 | goto err_out_release_regions; | 1665 | goto err_out_release_regions; |
1657 | } | 1666 | } |
1658 | } else { | 1667 | } else { |
1659 | err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK); | 1668 | err = pci_set_consistent_dma_mask(pdev, DMA_40BIT_MASK); |
1660 | if (err) { | 1669 | if (err) { |
1661 | printk(KERN_ERR PFX | 1670 | printk(KERN_ERR PFX |
1662 | "%s: Unable to obtain 40-bit DMA " | 1671 | "Unable to obtain 40-bit DMA " |
1663 | "for consistent allocations, aborting.\n", | 1672 | "for consistent allocations, aborting.\n"); |
1664 | netdev->name); | ||
1665 | goto err_out_release_regions; | 1673 | goto err_out_release_regions; |
1666 | } | 1674 | } |
1667 | using_dac = 1; | 1675 | using_dac = 1; |
@@ -1672,8 +1680,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1672 | 1680 | ||
1673 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { | 1681 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { |
1674 | printk(KERN_ERR PFX | 1682 | printk(KERN_ERR PFX |
1675 | "%s: BAR0 not memory-map'able, aborting.\n", | 1683 | "BAR0 not memory-map'able, aborting.\n"); |
1676 | netdev->name); | ||
1677 | err = -ENODEV; | 1684 | err = -ENODEV; |
1678 | goto err_out_release_regions; | 1685 | goto err_out_release_regions; |
1679 | } | 1686 | } |
@@ -1684,8 +1691,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1684 | 1691 | ||
1685 | if (!enic->bar0.vaddr) { | 1692 | if (!enic->bar0.vaddr) { |
1686 | printk(KERN_ERR PFX | 1693 | printk(KERN_ERR PFX |
1687 | "%s: Cannot memory-map BAR0 res hdr, aborting.\n", | 1694 | "Cannot memory-map BAR0 res hdr, aborting.\n"); |
1688 | netdev->name); | ||
1689 | err = -ENODEV; | 1695 | err = -ENODEV; |
1690 | goto err_out_release_regions; | 1696 | goto err_out_release_regions; |
1691 | } | 1697 | } |
@@ -1696,8 +1702,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1696 | enic->vdev = vnic_dev_register(NULL, enic, pdev, &enic->bar0); | 1702 | enic->vdev = vnic_dev_register(NULL, enic, pdev, &enic->bar0); |
1697 | if (!enic->vdev) { | 1703 | if (!enic->vdev) { |
1698 | printk(KERN_ERR PFX | 1704 | printk(KERN_ERR PFX |
1699 | "%s: vNIC registration failed, aborting.\n", | 1705 | "vNIC registration failed, aborting.\n"); |
1700 | netdev->name); | ||
1701 | err = -ENODEV; | 1706 | err = -ENODEV; |
1702 | goto err_out_iounmap; | 1707 | goto err_out_iounmap; |
1703 | } | 1708 | } |
@@ -1708,8 +1713,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1708 | err = enic_dev_open(enic); | 1713 | err = enic_dev_open(enic); |
1709 | if (err) { | 1714 | if (err) { |
1710 | printk(KERN_ERR PFX | 1715 | printk(KERN_ERR PFX |
1711 | "%s: vNIC dev open failed, aborting.\n", | 1716 | "vNIC dev open failed, aborting.\n"); |
1712 | netdev->name); | ||
1713 | goto err_out_vnic_unregister; | 1717 | goto err_out_vnic_unregister; |
1714 | } | 1718 | } |
1715 | 1719 | ||
@@ -1726,8 +1730,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1726 | err = vnic_dev_init(enic->vdev, 0); | 1730 | err = vnic_dev_init(enic->vdev, 0); |
1727 | if (err) { | 1731 | if (err) { |
1728 | printk(KERN_ERR PFX | 1732 | printk(KERN_ERR PFX |
1729 | "%s: vNIC dev init failed, aborting.\n", | 1733 | "vNIC dev init failed, aborting.\n"); |
1730 | netdev->name); | ||
1731 | goto err_out_dev_close; | 1734 | goto err_out_dev_close; |
1732 | } | 1735 | } |
1733 | 1736 | ||
@@ -1737,8 +1740,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1737 | err = enic_get_vnic_config(enic); | 1740 | err = enic_get_vnic_config(enic); |
1738 | if (err) { | 1741 | if (err) { |
1739 | printk(KERN_ERR PFX | 1742 | printk(KERN_ERR PFX |
1740 | "%s: Get vNIC configuration failed, aborting.\n", | 1743 | "Get vNIC configuration failed, aborting.\n"); |
1741 | netdev->name); | ||
1742 | goto err_out_dev_close; | 1744 | goto err_out_dev_close; |
1743 | } | 1745 | } |
1744 | 1746 | ||
@@ -1754,18 +1756,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1754 | err = enic_set_intr_mode(enic); | 1756 | err = enic_set_intr_mode(enic); |
1755 | if (err) { | 1757 | if (err) { |
1756 | printk(KERN_ERR PFX | 1758 | printk(KERN_ERR PFX |
1757 | "%s: Failed to set intr mode, aborting.\n", | 1759 | "Failed to set intr mode, aborting.\n"); |
1758 | netdev->name); | ||
1759 | goto err_out_dev_close; | ||
1760 | } | ||
1761 | |||
1762 | /* Request interrupt vector(s) | ||
1763 | */ | ||
1764 | |||
1765 | err = enic_request_intr(enic); | ||
1766 | if (err) { | ||
1767 | printk(KERN_ERR PFX "%s: Unable to request irq.\n", | ||
1768 | netdev->name); | ||
1769 | goto err_out_dev_close; | 1760 | goto err_out_dev_close; |
1770 | } | 1761 | } |
1771 | 1762 | ||
@@ -1775,8 +1766,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1775 | err = enic_alloc_vnic_resources(enic); | 1766 | err = enic_alloc_vnic_resources(enic); |
1776 | if (err) { | 1767 | if (err) { |
1777 | printk(KERN_ERR PFX | 1768 | printk(KERN_ERR PFX |
1778 | "%s: Failed to alloc vNIC resources, aborting.\n", | 1769 | "Failed to alloc vNIC resources, aborting.\n"); |
1779 | netdev->name); | ||
1780 | goto err_out_free_vnic_resources; | 1770 | goto err_out_free_vnic_resources; |
1781 | } | 1771 | } |
1782 | 1772 | ||
@@ -1792,19 +1782,7 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1792 | ig_vlan_strip_en); | 1782 | ig_vlan_strip_en); |
1793 | if (err) { | 1783 | if (err) { |
1794 | printk(KERN_ERR PFX | 1784 | printk(KERN_ERR PFX |
1795 | "%s: Failed to config nic, aborting.\n", | 1785 | "Failed to config nic, aborting.\n"); |
1796 | netdev->name); | ||
1797 | goto err_out_free_vnic_resources; | ||
1798 | } | ||
1799 | |||
1800 | /* Setup notification buffer area | ||
1801 | */ | ||
1802 | |||
1803 | err = enic_notify_set(enic); | ||
1804 | if (err) { | ||
1805 | printk(KERN_ERR PFX | ||
1806 | "%s: Failed to alloc notify buffer, aborting.\n", | ||
1807 | netdev->name); | ||
1808 | goto err_out_free_vnic_resources; | 1786 | goto err_out_free_vnic_resources; |
1809 | } | 1787 | } |
1810 | 1788 | ||
@@ -1831,9 +1809,8 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1831 | err = enic_set_mac_addr(netdev, enic->mac_addr); | 1809 | err = enic_set_mac_addr(netdev, enic->mac_addr); |
1832 | if (err) { | 1810 | if (err) { |
1833 | printk(KERN_ERR PFX | 1811 | printk(KERN_ERR PFX |
1834 | "%s: Invalid MAC address, aborting.\n", | 1812 | "Invalid MAC address, aborting.\n"); |
1835 | netdev->name); | 1813 | goto err_out_free_vnic_resources; |
1836 | goto err_out_notify_unset; | ||
1837 | } | 1814 | } |
1838 | 1815 | ||
1839 | netdev->open = enic_open; | 1816 | netdev->open = enic_open; |
@@ -1887,18 +1864,14 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1887 | err = register_netdev(netdev); | 1864 | err = register_netdev(netdev); |
1888 | if (err) { | 1865 | if (err) { |
1889 | printk(KERN_ERR PFX | 1866 | printk(KERN_ERR PFX |
1890 | "%s: Cannot register net device, aborting.\n", | 1867 | "Cannot register net device, aborting.\n"); |
1891 | netdev->name); | 1868 | goto err_out_free_vnic_resources; |
1892 | goto err_out_notify_unset; | ||
1893 | } | 1869 | } |
1894 | 1870 | ||
1895 | return 0; | 1871 | return 0; |
1896 | 1872 | ||
1897 | err_out_notify_unset: | ||
1898 | vnic_dev_notify_unset(enic->vdev); | ||
1899 | err_out_free_vnic_resources: | 1873 | err_out_free_vnic_resources: |
1900 | enic_free_vnic_resources(enic); | 1874 | enic_free_vnic_resources(enic); |
1901 | enic_free_intr(enic); | ||
1902 | err_out_dev_close: | 1875 | err_out_dev_close: |
1903 | vnic_dev_close(enic->vdev); | 1876 | vnic_dev_close(enic->vdev); |
1904 | err_out_vnic_unregister: | 1877 | err_out_vnic_unregister: |
@@ -1926,9 +1899,7 @@ static void __devexit enic_remove(struct pci_dev *pdev) | |||
1926 | 1899 | ||
1927 | flush_scheduled_work(); | 1900 | flush_scheduled_work(); |
1928 | unregister_netdev(netdev); | 1901 | unregister_netdev(netdev); |
1929 | vnic_dev_notify_unset(enic->vdev); | ||
1930 | enic_free_vnic_resources(enic); | 1902 | enic_free_vnic_resources(enic); |
1931 | enic_free_intr(enic); | ||
1932 | vnic_dev_close(enic->vdev); | 1903 | vnic_dev_close(enic->vdev); |
1933 | enic_clear_intr_mode(enic); | 1904 | enic_clear_intr_mode(enic); |
1934 | vnic_dev_unregister(enic->vdev); | 1905 | vnic_dev_unregister(enic->vdev); |