diff options
author | Michael Chan <mchan@broadcom.com> | 2007-05-03 16:20:19 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2007-05-03 16:20:19 -0400 |
commit | 1b2f922f6869eb13dadfe1ba3f8337bd42e50a2e (patch) | |
tree | ab6f02ff18a01b80501aa7b0dda70be64fb2e0e5 /drivers/net/bnx2.c | |
parent | 40453c839fdbf86738256cae1c9c1ebe55645d4a (diff) |
[BNX2]: Fix race conditions when calling register_netdev().
Hot-plug scripts can call bnx2_open() as soon as register_netdev() is
called in bnx2_init_one(). We need to call pci_set_drvdata() and
setup everything before calling register_netdev(). netif_carrier_off()
also needs to be moved to bnx2_open() to avoid race conditions with
the irq.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r-- | drivers/net/bnx2.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index 679ee669e1e0..cffdec3d5b5a 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -4350,6 +4350,8 @@ bnx2_open(struct net_device *dev) | |||
4350 | struct bnx2 *bp = netdev_priv(dev); | 4350 | struct bnx2 *bp = netdev_priv(dev); |
4351 | int rc; | 4351 | int rc; |
4352 | 4352 | ||
4353 | netif_carrier_off(dev); | ||
4354 | |||
4353 | bnx2_set_power_state(bp, PCI_D0); | 4355 | bnx2_set_power_state(bp, PCI_D0); |
4354 | bnx2_disable_int(bp); | 4356 | bnx2_disable_int(bp); |
4355 | 4357 | ||
@@ -6086,6 +6088,18 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6086 | dev->poll_controller = poll_bnx2; | 6088 | dev->poll_controller = poll_bnx2; |
6087 | #endif | 6089 | #endif |
6088 | 6090 | ||
6091 | pci_set_drvdata(pdev, dev); | ||
6092 | |||
6093 | memcpy(dev->dev_addr, bp->mac_addr, 6); | ||
6094 | memcpy(dev->perm_addr, bp->mac_addr, 6); | ||
6095 | bp->name = board_info[ent->driver_data].name; | ||
6096 | |||
6097 | dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; | ||
6098 | #ifdef BCM_VLAN | ||
6099 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | ||
6100 | #endif | ||
6101 | dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; | ||
6102 | |||
6089 | if ((rc = register_netdev(dev))) { | 6103 | if ((rc = register_netdev(dev))) { |
6090 | dev_err(&pdev->dev, "Cannot register net device\n"); | 6104 | dev_err(&pdev->dev, "Cannot register net device\n"); |
6091 | if (bp->regview) | 6105 | if (bp->regview) |
@@ -6097,11 +6111,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6097 | return rc; | 6111 | return rc; |
6098 | } | 6112 | } |
6099 | 6113 | ||
6100 | pci_set_drvdata(pdev, dev); | ||
6101 | |||
6102 | memcpy(dev->dev_addr, bp->mac_addr, 6); | ||
6103 | memcpy(dev->perm_addr, bp->mac_addr, 6); | ||
6104 | bp->name = board_info[ent->driver_data].name, | ||
6105 | printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz found at mem %lx, " | 6114 | printk(KERN_INFO "%s: %s (%c%d) PCI%s %s %dMHz found at mem %lx, " |
6106 | "IRQ %d, ", | 6115 | "IRQ %d, ", |
6107 | dev->name, | 6116 | dev->name, |
@@ -6119,15 +6128,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
6119 | printk("%2.2x", dev->dev_addr[i]); | 6128 | printk("%2.2x", dev->dev_addr[i]); |
6120 | printk("\n"); | 6129 | printk("\n"); |
6121 | 6130 | ||
6122 | dev->features |= NETIF_F_SG; | ||
6123 | dev->features |= NETIF_F_IP_CSUM; | ||
6124 | #ifdef BCM_VLAN | ||
6125 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | ||
6126 | #endif | ||
6127 | dev->features |= NETIF_F_TSO | NETIF_F_TSO_ECN; | ||
6128 | |||
6129 | netif_carrier_off(bp->dev); | ||
6130 | |||
6131 | return 0; | 6131 | return 0; |
6132 | } | 6132 | } |
6133 | 6133 | ||