linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Shchepetkov <shchepetkov@ispras.ru>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Ilya Shchepetkov <shchepetkov@ispras.ru>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	"David S. Miller" <davem@davemloft.net>,
	devel@linuxdriverproject.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, ldv-project@ispras.ru
Subject: [PATCH 5/5] net/hyperv: Call netif_carrier_off() after register_netdev()
Date: Tue, 14 Aug 2012 14:28:55 +0400	[thread overview]
Message-ID: <1344940135-17079-6-git-send-email-shchepetkov@ispras.ru> (raw)
In-Reply-To: <1344940135-17079-1-git-send-email-shchepetkov@ispras.ru>

For carrier detection to work properly when binding the driver with a
cable unplugged, netif_carrier_off() should be called after
register_netdev(), not before.

Calling netif_carrier_off() before register_netdev() was causing the
network interface to miss a linkwatch pending event leading to an
inconsistent state if the link is not up when interface is initialized.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Ilya Shchepetkov <shchepetkov@ispras.ru>
---
 drivers/net/hyperv/netvsc_drv.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 8c5a1c4..5734ad0 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -416,9 +416,6 @@ static int netvsc_probe(struct hv_device *dev,
 	if (!net)
 		return -ENOMEM;
 
-	/* Set initial state */
-	netif_carrier_off(net);
-
 	net_device_ctx = netdev_priv(net);
 	net_device_ctx->device_ctx = dev;
 	hv_set_drvdata(dev, net);
@@ -441,6 +438,9 @@ static int netvsc_probe(struct hv_device *dev,
 		goto out;
 	}
 
+	/* Set initial state */
+	netif_carrier_off(net);
+
 	/* Notify the netvsc driver of the new device */
 	device_info.ring_size = ring_size;
 	ret = rndis_filter_device_add(dev, &device_info);
-- 
1.7.7


  parent reply	other threads:[~2012-08-14 10:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14 10:28 [PATCH 0/5] Call netif_carrier_off() after register_netdev() Ilya Shchepetkov
2012-08-14 10:28 ` [PATCH 1/5] sgi-xp: " Ilya Shchepetkov
2012-08-14 14:22   ` Robin Holt
2012-08-14 10:28 ` [PATCH 2/5] de2104x: " Ilya Shchepetkov
2012-08-14 10:28 ` [PATCH 3/5] net/mlx4_en: " Ilya Shchepetkov
2012-08-14 12:36   ` Sathya.Perla
2012-08-14 14:56     ` Ben Hutchings
2012-08-14 10:28 ` [PATCH 4/5] sungem: " Ilya Shchepetkov
2012-08-14 10:28 ` Ilya Shchepetkov [this message]
2012-08-14 15:32   ` [PATCH 5/5] net/hyperv: " Haiyang Zhang
2012-08-14 21:00 ` [PATCH 0/5] " David Miller
2012-08-14 22:47   ` Ben Hutchings
2012-08-15 11:40     ` Bjørn Mork
2012-08-17  7:55       ` Ilya Shchepetkov
2012-08-17 16:20         ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1344940135-17079-6-git-send-email-shchepetkov@ispras.ru \
    --to=shchepetkov@ispras.ru \
    --cc=davem@davemloft.net \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=ldv-project@ispras.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).