netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: netdev@vger.kernel.org, Haiyang Zhang <haiyangz@microsoft.com>,
	linux-kernel@vger.kernel.org, devel@linuxdriverproject.org
Subject: [RFC 1/2] netvsc: reference counting fix
Date: Sat, 13 Aug 2016 11:35:59 -0700	[thread overview]
Message-ID: <20160813113559.617b7c55@xeon-e3> (raw)
In-Reply-To: <1470913137-29167-3-git-send-email-vkuznets@redhat.com>

This is how I think it should be fixed, but not tested yet.

Subjec: netvsc: use device not module reference counts

Fix how the cross-device reference counting is handled.  When VF is
associated with the synthetic interface, the VF driver module should
still be able to be unloaded.  The module unload code will callback
with NETDEV_UNREGISTER event which breaks the connection safely.
(Fixes 9f4b5ba5db4 hv_netvsc: Implement support for VF drivers on Hyper-V)

Signed-off-by: Stephen Hemminger <sthemmin@linuxonhyperv.com>


--- a/drivers/net/hyperv/netvsc_drv.c	2016-08-13 11:25:40.243995863 -0700
+++ b/drivers/net/hyperv/netvsc_drv.c	2016-08-13 11:25:40.239995844 -0700
@@ -1220,10 +1220,8 @@ static int netvsc_register_vf(struct net
 		return NOTIFY_DONE;
 
 	netdev_info(ndev, "VF registering: %s\n", vf_netdev->name);
-	/*
-	 * Take a reference on the module.
-	 */
-	try_module_get(THIS_MODULE);
+
+	dev_hold(vf_netdev);
 	netvsc_dev->vf_netdev = vf_netdev;
 	return NOTIFY_OK;
 }
@@ -1345,7 +1343,7 @@ static int netvsc_unregister_vf(struct n
 	netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
 
 	netvsc_dev->vf_netdev = NULL;
-	module_put(THIS_MODULE);
+	dev_put(vf_netdev);
 	return NOTIFY_OK;
 }

  parent reply	other threads:[~2016-08-13 18:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-11 10:58 [PATCH net 0/4] hv_netvsc: fixes for VF removal path Vitaly Kuznetsov
2016-08-11 10:58 ` [PATCH net 1/4] hv_netvsc: don't lose VF information Vitaly Kuznetsov
2016-08-11 15:38   ` Haiyang Zhang
2016-08-11 10:58 ` [PATCH net 2/4] hv_netvsc: reset vf_inject on VF removal Vitaly Kuznetsov
2016-08-11 11:46   ` Yuval Mintz
2016-08-11 12:09     ` Vitaly Kuznetsov
2016-08-12 14:47       ` Stephen Hemminger
2016-08-11 15:38   ` Haiyang Zhang
2016-08-13  3:40   ` David Miller
2016-08-13 18:35   ` Stephen Hemminger [this message]
2016-08-13 18:38     ` [RFC 2/2] netvsc: use RCU for VF net device reference Stephen Hemminger
2016-08-15 10:06       ` Vitaly Kuznetsov
2016-08-15  4:31     ` [RFC 1/2] netvsc: reference counting fix David Miller
2016-08-11 10:58 ` [PATCH net 3/4] hv_netvsc: protect module refcount by checking net_device_ctx->vf_netdev Vitaly Kuznetsov
2016-08-11 15:38   ` Haiyang Zhang
2016-08-11 10:58 ` [PATCH net 4/4] hv_netvsc: avoid deadlocks between rtnl lock and netvsc_inject_disable() Vitaly Kuznetsov
2016-08-11 15:38   ` Haiyang Zhang

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=20160813113559.617b7c55@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vkuznets@redhat.com \
    /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).