sfc: Hold MAC lock for longer in efx_init_port()
authorBen Hutchings <bhutchings@solarflare.com>
Wed, 25 Nov 2009 16:11:19 +0000 (16:11 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 26 Nov 2009 23:59:32 +0000 (15:59 -0800)
Although efx_init_port() is only called at probe time and so cannot
race with port reconfiguration, most of the functions it calls can
expect to be called with the MAC lock held.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/sfc/efx.c

index 4ebad613e6de66bd3ee2995b5700526c87f79a8c..155aa1cca36688c4281f080c13bddfc29eb7ee81 100644 (file)
@@ -737,23 +737,27 @@ static int efx_init_port(struct efx_nic *efx)
 
        EFX_LOG(efx, "init port\n");
 
+       mutex_lock(&efx->mac_lock);
+
        rc = efx->phy_op->init(efx);
        if (rc)
-               return rc;
-       mutex_lock(&efx->mac_lock);
+               goto fail1;
        efx->phy_op->reconfigure(efx);
        rc = falcon_switch_mac(efx);
-       mutex_unlock(&efx->mac_lock);
        if (rc)
-               goto fail;
+               goto fail2;
        efx->mac_op->reconfigure(efx);
 
        efx->port_initialized = true;
        efx_stats_enable(efx);
+
+       mutex_unlock(&efx->mac_lock);
        return 0;
 
-fail:
+fail2:
        efx->phy_op->fini(efx);
+fail1:
+       mutex_unlock(&efx->mac_lock);
        return rc;
 }