Received: by 10.223.164.202 with SMTP id h10csp3645697wrb; Mon, 20 Nov 2017 02:42:07 -0800 (PST) X-Google-Smtp-Source: AGs4zMY8Myh1SUv6O5zYwUoMomSUv+Ez+qVpAJz/qpTRbZDFfVKAoMVwjGfXjshgLYYXVBdTZ1je X-Received: by 10.101.101.215 with SMTP id y23mr9021399pgv.391.1511174527875; Mon, 20 Nov 2017 02:42:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511174527; cv=none; d=google.com; s=arc-20160816; b=klRZi/po5oPdyELeNzep3gfNuCA0B3QqKE4odDSqjuH2+xjMy7wgWh/hccIIx5sRaJ aVfQFdf0ROoFsUGgbJr5IosM6lg+mON5z5Jr5hIqhRRIEr30UfbViWAe3Fkbk9Yj3dF/ GCpJwckS++RiClvZPSkBPfUnZfbirEBHU0ZYmtwuzpW9q3pb2Gj/l+Wn4hY0PJz0GjhZ Qsya+OoJzN9IyInrgIJaCIIg2bySfkaP8H27MAlWnn1HePeODfWHDT5FYEO/nqN0N15Z GZOlfnzaO34E0vWIkDVELbPaUi1r1pwqbKd5Xnk81p++06iCVxa7NDr1A65ykOaAMu6z jaaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=wqa3oOZqj2iiTWeBA9N+AumdkoJvlJSYHVFH+I2dfis=; b=FG5sbKnbdQZTB497kVzpugEEOmFINkpGE24BBJPU0ZUqKML+EmA12eS1ZPqIhfrYOl pA1vZp8cBHv7VfJO1TDXmAQrG3Fbxf/ClybHLFIcxcczUP/BVjrKfzFngBIF/7aGmuBY oFO4jwE4aH48RpXfwBZzsiAo/AL94uSWWekbxE/MTydDaAjizzfafOW4zyzRYPnsxDcP FNdWAaT2fY1CPvNP4Sxdwguuf7yY5QC0vgsuwpYYF3Xzb0DdMldvLoP89vlf0tqQ4b16 n/CCegDOj3IJd+rgGtjlsrUzA77ZIHp8YfjLUwSJ726crIpg+7B1dMY2XnaUQFuofgWc kjDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t191si7837707pgc.187.2017.11.20.02.41.57; Mon, 20 Nov 2017 02:42:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751145AbdKTKlV (ORCPT + 68 others); Mon, 20 Nov 2017 05:41:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42390 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbdKTKlU (ORCPT ); Mon, 20 Nov 2017 05:41:20 -0500 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 Cc: netdev@vger.kernel.org, paul.durrant@citrix.com, wei.liu2@citrix.com, linux-kernel@vger.kernel.org, vkuznets@redhat.com, cavery@redhat.com, cheshi@redhat.com, mgamal@redhat.com, Eduardo Otubo Subject: [PATCH] xen-netfront: remove warning when unloading module 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) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.13.6 From 1583633709007357886@xxx Thu Nov 09 23:39:54 +0000 2017 X-GM-THRID: 1583633709007357886 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread