{"id":833281,"url":"http://patchwork.ozlabs.org/api/1.2/patches/833281/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171102103531.5514-2-vkuznets@redhat.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171102103531.5514-2-vkuznets@redhat.com>","list_archive_url":null,"date":"2017-11-02T10:35:30","name":"[net-next,v2,1/2] hv_netvsc: netvsc_teardown_gpadl() split","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"5c57f80bc905a591ea60b101252349e7e5d358b3","submitter":{"id":65701,"url":"http://patchwork.ozlabs.org/api/1.2/people/65701/?format=json","name":"Vitaly Kuznetsov","email":"vkuznets@redhat.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171102103531.5514-2-vkuznets@redhat.com/mbox/","series":[{"id":11472,"url":"http://patchwork.ozlabs.org/api/1.2/series/11472/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=11472","date":"2017-11-02T10:35:30","name":"hv_netvsc: fix a hang on channel/mtu changes","version":2,"mbox":"http://patchwork.ozlabs.org/series/11472/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/833281/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/833281/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=vkuznets@redhat.com"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3ySM1c45V6z9t3m\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu,  2 Nov 2017 21:35:48 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1755548AbdKBKfi (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tThu, 2 Nov 2017 06:35:38 -0400","from mx1.redhat.com ([209.132.183.28]:42896 \"EHLO mx1.redhat.com\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1752780AbdKBKfg (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tThu, 2 Nov 2017 06:35:36 -0400","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 4BE7780469;\n\tThu,  2 Nov 2017 10:35:36 +0000 (UTC)","from vitty.brq.redhat.com (unknown [10.43.2.155])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id 5C1AC60602;\n\tThu,  2 Nov 2017 10:35:34 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 4BE7780469","From":"Vitaly Kuznetsov <vkuznets@redhat.com>","To":"netdev@vger.kernel.org","Cc":"linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,\n\t\"K. Y. Srinivasan\" <kys@microsoft.com>,\n\tHaiyang Zhang <haiyangz@microsoft.com>,\n\tStephen Hemminger <sthemmin@microsoft.com>,\n\tEric Dumazet <eric.dumazet@gmail.com>","Subject":"[PATCH net-next v2 1/2] hv_netvsc: netvsc_teardown_gpadl() split","Date":"Thu,  2 Nov 2017 11:35:30 +0100","Message-Id":"<20171102103531.5514-2-vkuznets@redhat.com>","In-Reply-To":"<20171102103531.5514-1-vkuznets@redhat.com>","References":"<20171102103531.5514-1-vkuznets@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Greylist":"Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.28]);\n\tThu, 02 Nov 2017 10:35:36 +0000 (UTC)","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"It was found that in some cases host refuses to teardown GPADL for send/\nreceive buffers (probably when some work with these buffere is scheduled or\nongoing). Change the teardown logic to be:\n1) Send NVSP_MSG1_TYPE_REVOKE_* messages\n2) Close the channel\n3) Teardown GPADLs.\nThis seems to work reliably.\n\nSigned-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>\n---\n drivers/net/hyperv/netvsc.c | 69 +++++++++++++++++++++++----------------------\n 1 file changed, 36 insertions(+), 33 deletions(-)","diff":"diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c\nindex 5bb6a20072dd..bfc79698b8f4 100644\n--- a/drivers/net/hyperv/netvsc.c\n+++ b/drivers/net/hyperv/netvsc.c\n@@ -100,12 +100,11 @@ static void free_netvsc_device_rcu(struct netvsc_device *nvdev)\n \tcall_rcu(&nvdev->rcu, free_netvsc_device);\n }\n \n-static void netvsc_destroy_buf(struct hv_device *device)\n+static void netvsc_revoke_buf(struct hv_device *device,\n+\t\t\t      struct netvsc_device *net_device)\n {\n \tstruct nvsp_message *revoke_packet;\n \tstruct net_device *ndev = hv_get_drvdata(device);\n-\tstruct net_device_context *ndc = netdev_priv(ndev);\n-\tstruct netvsc_device *net_device = rtnl_dereference(ndc->nvdev);\n \tint ret;\n \n \t/*\n@@ -148,28 +147,6 @@ static void netvsc_destroy_buf(struct hv_device *device)\n \t\tnet_device->recv_section_cnt = 0;\n \t}\n \n-\t/* Teardown the gpadl on the vsp end */\n-\tif (net_device->recv_buf_gpadl_handle) {\n-\t\tret = vmbus_teardown_gpadl(device->channel,\n-\t\t\t\t\t   net_device->recv_buf_gpadl_handle);\n-\n-\t\t/* If we failed here, we might as well return and have a leak\n-\t\t * rather than continue and a bugchk\n-\t\t */\n-\t\tif (ret != 0) {\n-\t\t\tnetdev_err(ndev,\n-\t\t\t\t   \"unable to teardown receive buffer's gpadl\\n\");\n-\t\t\treturn;\n-\t\t}\n-\t\tnet_device->recv_buf_gpadl_handle = 0;\n-\t}\n-\n-\tif (net_device->recv_buf) {\n-\t\t/* Free up the receive buffer */\n-\t\tvfree(net_device->recv_buf);\n-\t\tnet_device->recv_buf = NULL;\n-\t}\n-\n \t/* Deal with the send buffer we may have setup.\n \t * If we got a  send section size, it means we received a\n \t * NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE msg (ie sent\n@@ -210,7 +187,35 @@ static void netvsc_destroy_buf(struct hv_device *device)\n \t\t}\n \t\tnet_device->send_section_cnt = 0;\n \t}\n-\t/* Teardown the gpadl on the vsp end */\n+}\n+\n+static void netvsc_teardown_gpadl(struct hv_device *device,\n+\t\t\t\t  struct netvsc_device *net_device)\n+{\n+\tstruct net_device *ndev = hv_get_drvdata(device);\n+\tint ret;\n+\n+\tif (net_device->recv_buf_gpadl_handle) {\n+\t\tret = vmbus_teardown_gpadl(device->channel,\n+\t\t\t\t\t   net_device->recv_buf_gpadl_handle);\n+\n+\t\t/* If we failed here, we might as well return and have a leak\n+\t\t * rather than continue and a bugchk\n+\t\t */\n+\t\tif (ret != 0) {\n+\t\t\tnetdev_err(ndev,\n+\t\t\t\t   \"unable to teardown receive buffer's gpadl\\n\");\n+\t\t\treturn;\n+\t\t}\n+\t\tnet_device->recv_buf_gpadl_handle = 0;\n+\t}\n+\n+\tif (net_device->recv_buf) {\n+\t\t/* Free up the receive buffer */\n+\t\tvfree(net_device->recv_buf);\n+\t\tnet_device->recv_buf = NULL;\n+\t}\n+\n \tif (net_device->send_buf_gpadl_handle) {\n \t\tret = vmbus_teardown_gpadl(device->channel,\n \t\t\t\t\t   net_device->send_buf_gpadl_handle);\n@@ -420,7 +425,8 @@ static int netvsc_init_buf(struct hv_device *device,\n \tgoto exit;\n \n cleanup:\n-\tnetvsc_destroy_buf(device);\n+\tnetvsc_revoke_buf(device, net_device);\n+\tnetvsc_teardown_gpadl(device, net_device);\n \n exit:\n \treturn ret;\n@@ -539,11 +545,6 @@ static int netvsc_connect_vsp(struct hv_device *device,\n \treturn ret;\n }\n \n-static void netvsc_disconnect_vsp(struct hv_device *device)\n-{\n-\tnetvsc_destroy_buf(device);\n-}\n-\n /*\n  * netvsc_device_remove - Callback when the root bus device is removed\n  */\n@@ -557,7 +558,7 @@ void netvsc_device_remove(struct hv_device *device)\n \n \tcancel_work_sync(&net_device->subchan_work);\n \n-\tnetvsc_disconnect_vsp(device);\n+\tnetvsc_revoke_buf(device, net_device);\n \n \tRCU_INIT_POINTER(net_device_ctx->nvdev, NULL);\n \n@@ -570,6 +571,8 @@ void netvsc_device_remove(struct hv_device *device)\n \t/* Now, we can close the channel safely */\n \tvmbus_close(device->channel);\n \n+\tnetvsc_teardown_gpadl(device, net_device);\n+\n \t/* And dissassociate NAPI context from device */\n \tfor (i = 0; i < net_device->num_chn; i++)\n \t\tnetif_napi_del(&net_device->chan_table[i].napi);\n","prefixes":["net-next","v2","1/2"]}