提交 aed0628d 编写于 作者: B Ben Hutchings 提交者: David S. Miller

sfc: Fix ordering of device registration and initial netif_carrier_off()

We must call netif_carrier_off() after the device is registered, not
before, to set the operational state and user-space IFF_RUNNING flag
correctly.

Since we don't want observers to see an intermediate state, open-code
register_netdev() and add efx_update_name() and netif_carrier_off()
into the locked region.
Signed-off-by: NBen Hutchings <bhutchings@solarflare.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7c6a3ed5
...@@ -1614,21 +1614,24 @@ static int efx_register_netdev(struct efx_nic *efx) ...@@ -1614,21 +1614,24 @@ static int efx_register_netdev(struct efx_nic *efx)
SET_NETDEV_DEV(net_dev, &efx->pci_dev->dev); SET_NETDEV_DEV(net_dev, &efx->pci_dev->dev);
SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops); SET_ETHTOOL_OPS(net_dev, &efx_ethtool_ops);
/* Always start with carrier off; PHY events will detect the link */
netif_carrier_off(efx->net_dev);
/* Clear MAC statistics */ /* Clear MAC statistics */
efx->mac_op->update_stats(efx); efx->mac_op->update_stats(efx);
memset(&efx->mac_stats, 0, sizeof(efx->mac_stats)); memset(&efx->mac_stats, 0, sizeof(efx->mac_stats));
rc = register_netdev(net_dev);
if (rc) {
EFX_ERR(efx, "could not register net dev\n");
return rc;
}
rtnl_lock(); rtnl_lock();
rc = dev_alloc_name(net_dev, net_dev->name);
if (rc < 0)
goto fail_locked;
efx_update_name(efx); efx_update_name(efx);
rc = register_netdevice(net_dev);
if (rc)
goto fail_locked;
/* Always start with carrier off; PHY events will detect the link */
netif_carrier_off(efx->net_dev);
rtnl_unlock(); rtnl_unlock();
rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type); rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_type);
...@@ -1639,6 +1642,11 @@ static int efx_register_netdev(struct efx_nic *efx) ...@@ -1639,6 +1642,11 @@ static int efx_register_netdev(struct efx_nic *efx)
return 0; return 0;
fail_locked:
rtnl_unlock();
EFX_ERR(efx, "could not register net dev\n");
return rc;
fail_registered: fail_registered:
unregister_netdev(net_dev); unregister_netdev(net_dev);
return rc; return rc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册