From: Stephen Hemminger <stephen@networkplumber.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, Vitaly Kuznetsov <vkuznets@redhat.com>
Subject: [PATCH net-stable 06/24] hv_netvsc: netvsc_teardown_gpadl() split
Date: Mon, 14 May 2018 15:32:05 -0700 [thread overview]
Message-ID: <20180514223223.25433-7-sthemmin@microsoft.com> (raw)
In-Reply-To: <20180514223223.25433-1-sthemmin@microsoft.com>
From: Vitaly Kuznetsov <vkuznets@redhat.com>
commit 0cf737808ae7cb25e952be619db46b9147a92f46 upstream.
It was found that in some cases host refuses to teardown GPADL for send/
receive buffers (probably when some work with these buffere is scheduled or
ongoing). Change the teardown logic to be:
1) Send NVSP_MSG1_TYPE_REVOKE_* messages
2) Close the channel
3) Teardown GPADLs.
This seems to work reliably.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
drivers/net/hyperv/netvsc.c | 69 +++++++++++++++++++------------------
1 file changed, 36 insertions(+), 33 deletions(-)
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 73999214d444..4bc8a1d529d9 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -100,12 +100,11 @@ static void free_netvsc_device_rcu(struct netvsc_device *nvdev)
call_rcu(&nvdev->rcu, free_netvsc_device);
}
-static void netvsc_destroy_buf(struct hv_device *device)
+static void netvsc_revoke_buf(struct hv_device *device,
+ struct netvsc_device *net_device)
{
struct nvsp_message *revoke_packet;
struct net_device *ndev = hv_get_drvdata(device);
- struct net_device_context *ndc = netdev_priv(ndev);
- struct netvsc_device *net_device = rtnl_dereference(ndc->nvdev);
int ret;
/*
@@ -148,28 +147,6 @@ static void netvsc_destroy_buf(struct hv_device *device)
net_device->recv_section_cnt = 0;
}
- /* Teardown the gpadl on the vsp end */
- if (net_device->recv_buf_gpadl_handle) {
- ret = vmbus_teardown_gpadl(device->channel,
- net_device->recv_buf_gpadl_handle);
-
- /* If we failed here, we might as well return and have a leak
- * rather than continue and a bugchk
- */
- if (ret != 0) {
- netdev_err(ndev,
- "unable to teardown receive buffer's gpadl\n");
- return;
- }
- net_device->recv_buf_gpadl_handle = 0;
- }
-
- if (net_device->recv_buf) {
- /* Free up the receive buffer */
- vfree(net_device->recv_buf);
- net_device->recv_buf = NULL;
- }
-
/* Deal with the send buffer we may have setup.
* If we got a send section size, it means we received a
* NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE msg (ie sent
@@ -210,7 +187,35 @@ static void netvsc_destroy_buf(struct hv_device *device)
}
net_device->send_section_cnt = 0;
}
- /* Teardown the gpadl on the vsp end */
+}
+
+static void netvsc_teardown_gpadl(struct hv_device *device,
+ struct netvsc_device *net_device)
+{
+ struct net_device *ndev = hv_get_drvdata(device);
+ int ret;
+
+ if (net_device->recv_buf_gpadl_handle) {
+ ret = vmbus_teardown_gpadl(device->channel,
+ net_device->recv_buf_gpadl_handle);
+
+ /* If we failed here, we might as well return and have a leak
+ * rather than continue and a bugchk
+ */
+ if (ret != 0) {
+ netdev_err(ndev,
+ "unable to teardown receive buffer's gpadl\n");
+ return;
+ }
+ net_device->recv_buf_gpadl_handle = 0;
+ }
+
+ if (net_device->recv_buf) {
+ /* Free up the receive buffer */
+ vfree(net_device->recv_buf);
+ net_device->recv_buf = NULL;
+ }
+
if (net_device->send_buf_gpadl_handle) {
ret = vmbus_teardown_gpadl(device->channel,
net_device->send_buf_gpadl_handle);
@@ -425,7 +430,8 @@ static int netvsc_init_buf(struct hv_device *device,
goto exit;
cleanup:
- netvsc_destroy_buf(device);
+ netvsc_revoke_buf(device, net_device);
+ netvsc_teardown_gpadl(device, net_device);
exit:
return ret;
@@ -544,11 +550,6 @@ static int netvsc_connect_vsp(struct hv_device *device,
return ret;
}
-static void netvsc_disconnect_vsp(struct hv_device *device)
-{
- netvsc_destroy_buf(device);
-}
-
/*
* netvsc_device_remove - Callback when the root bus device is removed
*/
@@ -562,7 +563,7 @@ void netvsc_device_remove(struct hv_device *device)
cancel_work_sync(&net_device->subchan_work);
- netvsc_disconnect_vsp(device);
+ netvsc_revoke_buf(device, net_device);
RCU_INIT_POINTER(net_device_ctx->nvdev, NULL);
@@ -575,6 +576,8 @@ void netvsc_device_remove(struct hv_device *device)
/* Now, we can close the channel safely */
vmbus_close(device->channel);
+ netvsc_teardown_gpadl(device, net_device);
+
/* And dissassociate NAPI context from device */
for (i = 0; i < net_device->num_chn; i++)
netif_napi_del(&net_device->chan_table[i].napi);
--
2.17.0
next prev parent reply other threads:[~2018-05-14 22:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-14 22:31 [PATCH net-stable 00/24] hv_netvsc patches for 4.14 stable Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 01/24] hv_netvsc: Fix the real number of queues of non-vRSS cases Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 02/24] hv_netvsc: Rename ind_table to rx_table Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 03/24] hv_netvsc: Rename tx_send_table to tx_table Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 04/24] hv_netvsc: Add initialization of tx_table in netvsc_device_add() Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 05/24] hv_netvsc: Set tx_table to equal weight after subchannels open Stephen Hemminger
2018-05-14 22:32 ` Stephen Hemminger [this message]
2018-05-14 22:32 ` [PATCH net-stable 07/24] hv_netvsc: preserve hw_features on mtu/channels/ringparam changes Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 08/24] hv_netvsc: empty current transmit aggregation if flow blocked Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 09/24] hv_netvsc: Use the num_online_cpus() for channel limit Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 10/24] hv_netvsc: avoid retry on send during shutdown Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 11/24] hv_netvsc: only wake transmit queue if link is up Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 12/24] hv_netvsc: fix error unwind handling if vmbus_open fails Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 13/24] hv_netvsc: cancel subchannel setup before halting device Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 14/24] hv_netvsc: fix race in napi poll when rescheduling Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 15/24] hv_netvsc: defer queue selection to VF Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 16/24] hv_netvsc: disable NAPI before channel close Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 17/24] hv_netvsc: use RCU to fix concurrent rx and queue changes Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 18/24] hv_netvsc: change GPAD teardown order on older versions Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 19/24] hv_netvsc: common detach logic Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 20/24] hv_netvsc: Use Windows version instead of NVSP version on GPAD teardown Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 21/24] hv_netvsc: Split netvsc_revoke_buf() and netvsc_teardown_gpadl() Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 22/24] hv_netvsc: Ensure correct teardown message sequence order Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 23/24] hv_netvsc: Fix net device attach on older Windows hosts Stephen Hemminger
2018-05-14 22:32 ` [PATCH net-stable 24/24] hv_netvsc: set master device 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=20180514223223.25433-7-sthemmin@microsoft.com \
--to=stephen@networkplumber.org \
--cc=davem@davemloft.net \
--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