From patchwork Mon Nov 20 10:41:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Otubo X-Patchwork-Id: 10066279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4FD4602B7 for ; Mon, 20 Nov 2017 10:43:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4D1E290C2 for ; Mon, 20 Nov 2017 10:43:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9972290D2; Mon, 20 Nov 2017 10:43:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C245D290C2 for ; Mon, 20 Nov 2017 10:43:57 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGjW1-0006uC-E0; Mon, 20 Nov 2017 10:41:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGjVz-0006u6-P9 for xen-devel@lists.xenproject.org; Mon, 20 Nov 2017 10:41:23 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 92/8A-32721-251B21A5; Mon, 20 Nov 2017 10:41:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysWW7jG7gRqE og4ebjSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ow7q86wFDRyV3zd8Z6lgXE3ZxcjF4eQwGwm ic7nN9ggnA2MEnvmfmDuYuTkYBNQk7j4/QYriC0ioCRxb9VkJpAiZoF7QEVNU8GKhAWcJd7cn cIEYrMIqEp8+HAArIFXwFTixOFVQDYHh4SAtsT7yXkgvRICfYwSd36/Yp3AyLWAkWEVo0Zxal FZapGukbFeUlFmekZJbmJmjq6hgalebmpxcWJ6ak5iUrFecn7uJkagL+sZGBh3MO5o9zvEKMn BpCTKu6hQKEqILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK/FBqCcYFFqempFWmYOMKhg0hIcPEoi vPwgad7igsTc4sx0iNQpRkuODd8f/GHieDbzdQMzx7zj35qYhVjy8vNSpcR5eUAaBEAaMkrz4 MbBAv8So6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWHeq+uBpvBk5pXAbX0FdBAT0EEuF/hBDi pJREhJNTBWm53hs7/osUA97kbhjgTed//FKlg0olZXpyw1U6lquNlmmcbq3LmvpazLtjfAkbu 5I1HCIq55qXlPQlq1Z4du5AvFYMnjoisfr3blzM3LX/6kRsBb+/Qypt22ER0Xnl1M2ts4S2ey /uqgeZxc3jttPk5qmBNQV/TDqSdmxt47VctFAi+uVWIpzkg01GIuKk4EAOmviyV3AgAA X-Env-Sender: otubo@redhat.com X-Msg-Ref: server-3.tower-206.messagelabs.com!1511174480!104360835!1 X-Originating-IP: [209.132.183.28] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMjA5LjEzMi4xODMuMjggPT4gNTQwNjQ=\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54777 invoked from network); 20 Nov 2017 10:41:21 -0000 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by server-3.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Nov 2017 10:41:21 -0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 09B527EA85; Mon, 20 Nov 2017 10:41:20 +0000 (UTC) Received: from vader.redhat.com (ovpn-117-18.ams2.redhat.com [10.36.117.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 132CC6BF96; Mon, 20 Nov 2017 10:41:12 +0000 (UTC) From: Eduardo Otubo To: xen-devel@lists.xenproject.org Date: Mon, 20 Nov 2017 11:41:09 +0100 Message-Id: <20171120104109.11585-1-otubo@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 (mx1.redhat.com [10.5.110.28]); Mon, 20 Nov 2017 10:41:20 +0000 (UTC) Cc: Eduardo Otubo , wei.liu2@citrix.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, paul.durrant@citrix.com, cheshi@redhat.com, vkuznets@redhat.com, mgamal@redhat.com, cavery@redhat.com Subject: [Xen-devel] [PATCH] xen-netfront: remove warning when unloading module X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP When unloading module xen_netfront from guest, dmesg would output warning messages like below: [ 105.236836] xen:grant_table: WARNING: g.e. 0x903 still in use! [ 105.236839] deferring g.e. 0x903 (pfn 0x35805) This problem relies on netfront and netback being out of sync. By the time netfront revokes the g.e.'s netback didn't have enough time to free all of them, hence displaying the warnings on dmesg. The trick here is to make netfront to wait until netback frees all the g.e.'s and only then continue to cleanup for the module removal, and this is done by manipulating both device states. Signed-off-by: Eduardo Otubo --- drivers/net/xen-netfront.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 8b8689c6d887..b948e2a1ce40 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -2130,6 +2130,17 @@ static int xennet_remove(struct xenbus_device *dev) dev_dbg(&dev->dev, "%s\n", dev->nodename); + xenbus_switch_state(dev, XenbusStateClosing); + while (xenbus_read_driver_state(dev->otherend) != XenbusStateClosing){ + cpu_relax(); + schedule(); + } + xenbus_switch_state(dev, XenbusStateClosed); + while (dev->xenbus_state != XenbusStateClosed){ + cpu_relax(); + schedule(); + } + xennet_disconnect_backend(info); unregister_netdev(info->netdev);