Patchwork [v2] vmxnet3: set carrier state properly on probe

login
register
mail settings
Submitter Neil Horman
Date Jan. 29, 2013, 6:36 p.m.
Message ID <1359484611-23860-1-git-send-email-nhorman@tuxdriver.com>
Download mbox | patch
Permalink /patch/216626/
State Changes Requested
Delegated to: David Miller
Headers show

Comments

Neil Horman - Jan. 29, 2013, 6:36 p.m.
vmxnet3 fails to set netif_carrier_off on probe, meaning that when an interface
is opened the __LINK_STATE_NOCARRIER bit is already cleared, and so
/sys/class/net/<ifname>/operstate remains in the unknown state.  Correct this by
setting netif_carrier_off on probe, like other drivers do.

Also, while we're at it, lets remove the netif_carrier_ok checks from the
link_state_update function, as that check is atomically contained within the
netif_carrier_[on|off] functions anyway

Tested successfully by myself

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
CC: "David S. Miller" <davem@davemloft.net>
CC: "VMware, Inc." <pv-drivers@vmware.com>
CC: Ben Hutchings <bhutchings@solarflare.com>

---
Change notes:

v2) Moved netif_carrier_off above register_netdev to prevent race with dev_open
as per Ben H.
---
 drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Dmitry Torokhov - Jan. 29, 2013, 7:54 p.m.
On Tuesday, January 29, 2013 01:36:51 PM Neil Horman wrote:
> vmxnet3 fails to set netif_carrier_off on probe, meaning that when an
> interface is opened the __LINK_STATE_NOCARRIER bit is already cleared, and
> so /sys/class/net/<ifname>/operstate remains in the unknown state.  Correct
> this by setting netif_carrier_off on probe, like other drivers do.
> 
> Also, while we're at it, lets remove the netif_carrier_ok checks from the
> link_state_update function, as that check is atomically contained within the
> netif_carrier_[on|off] functions anyway
> 
> Tested successfully by myself
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> CC: "David S. Miller" <davem@davemloft.net>
> CC: "VMware, Inc." <pv-drivers@vmware.com>

Acked-by: Dmitry Torokhov <dtor@vmware.com>

> CC: Ben Hutchings <bhutchings@solarflare.com>
> 
> ---
> Change notes:
> 
> v2) Moved netif_carrier_off above register_netdev to prevent race with
> dev_open as per Ben H.
> ---
>  drivers/net/vmxnet3/vmxnet3_drv.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c
> b/drivers/net/vmxnet3/vmxnet3_drv.c index b1c90f8..ffb97b2 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> @@ -150,8 +150,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool
> affectTxQueue) if (ret & 1) { /* Link is up. */
>  		netdev_info(adapter->netdev, "NIC Link is Up %d Mbps\n",
>  			    adapter->link_speed);
> -		if (!netif_carrier_ok(adapter->netdev))
> -			netif_carrier_on(adapter->netdev);
> +		netif_carrier_on(adapter->netdev);
> 
>  		if (affectTxQueue) {
>  			for (i = 0; i < adapter->num_tx_queues; i++)
> @@ -160,8 +159,7 @@ vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool
> affectTxQueue) }
>  	} else {
>  		netdev_info(adapter->netdev, "NIC Link is Down\n");
> -		if (netif_carrier_ok(adapter->netdev))
> -			netif_carrier_off(adapter->netdev);
> +		netif_carrier_off(adapter->netdev);
> 
>  		if (affectTxQueue) {
>  			for (i = 0; i < adapter->num_tx_queues; i++)
> @@ -3060,6 +3058,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
>  	netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
>  	netif_set_real_num_rx_queues(adapter->netdev, adapter->num_rx_queues);
> 
> +	netif_carrier_off(netdev);
>  	err = register_netdev(netdev);
> 
>  	if (err) {
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 29, 2013, 8:44 p.m.
From: Neil Horman <nhorman@tuxdriver.com>
Date: Tue, 29 Jan 2013 13:36:51 -0500

> vmxnet3 fails to set netif_carrier_off on probe, meaning that when an interface
> is opened the __LINK_STATE_NOCARRIER bit is already cleared, and so
> /sys/class/net/<ifname>/operstate remains in the unknown state.  Correct this by
> setting netif_carrier_off on probe, like other drivers do.
> 
> Also, while we're at it, lets remove the netif_carrier_ok checks from the
> link_state_update function, as that check is atomically contained within the
> netif_carrier_[on|off] functions anyway
> 
> Tested successfully by myself
> 
> Signed-off-by: Neil Horman <nhorman@tuxdriver.com>

This doesn't apply to the current 'net' tree.  Please respin.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Neil Horman - Jan. 29, 2013, 9:08 p.m.
On Tue, Jan 29, 2013 at 03:44:30PM -0500, David Miller wrote:
> From: Neil Horman <nhorman@tuxdriver.com>
> Date: Tue, 29 Jan 2013 13:36:51 -0500
> 
> > vmxnet3 fails to set netif_carrier_off on probe, meaning that when an interface
> > is opened the __LINK_STATE_NOCARRIER bit is already cleared, and so
> > /sys/class/net/<ifname>/operstate remains in the unknown state.  Correct this by
> > setting netif_carrier_off on probe, like other drivers do.
> > 
> > Also, while we're at it, lets remove the netif_carrier_ok checks from the
> > link_state_update function, as that check is atomically contained within the
> > netif_carrier_[on|off] functions anyway
> > 
> > Tested successfully by myself
> > 
> > Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
> 
> This doesn't apply to the current 'net' tree.  Please respin.
I based it off net-next.  I'll respin for net
Neil

> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index b1c90f8..ffb97b2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -150,8 +150,7 @@  vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue)
 	if (ret & 1) { /* Link is up. */
 		netdev_info(adapter->netdev, "NIC Link is Up %d Mbps\n",
 			    adapter->link_speed);
-		if (!netif_carrier_ok(adapter->netdev))
-			netif_carrier_on(adapter->netdev);
+		netif_carrier_on(adapter->netdev);
 
 		if (affectTxQueue) {
 			for (i = 0; i < adapter->num_tx_queues; i++)
@@ -160,8 +159,7 @@  vmxnet3_check_link(struct vmxnet3_adapter *adapter, bool affectTxQueue)
 		}
 	} else {
 		netdev_info(adapter->netdev, "NIC Link is Down\n");
-		if (netif_carrier_ok(adapter->netdev))
-			netif_carrier_off(adapter->netdev);
+		netif_carrier_off(adapter->netdev);
 
 		if (affectTxQueue) {
 			for (i = 0; i < adapter->num_tx_queues; i++)
@@ -3060,6 +3058,7 @@  vmxnet3_probe_device(struct pci_dev *pdev,
 	netif_set_real_num_tx_queues(adapter->netdev, adapter->num_tx_queues);
 	netif_set_real_num_rx_queues(adapter->netdev, adapter->num_rx_queues);
 
+	netif_carrier_off(netdev);
 	err = register_netdev(netdev);
 
 	if (err) {