Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1116026imm; Wed, 1 Aug 2018 10:26:39 -0700 (PDT) X-Google-Smtp-Source: AAOMgpei6VUmMeFHD4wqxPTHrIm3xOEq5zhW7XzBb+3MhQfy/XACQbetFZnxSk94Q25lzxFLfrIN X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr26010500pla.227.1533144398997; Wed, 01 Aug 2018 10:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144398; cv=none; d=google.com; s=arc-20160816; b=mr9eK3RyOUyXjZ2RCwCwIIdBrunXDzhQhWsCoJXpUS7ayC1U6BVKZKx7yfoOL6tpnu Him74nt6VQ8vRxrMI17AIJ+xJ+jT4G5eABfF6IhRUbhdEdk5wUU5G+diPl9ca0WQEy9Z IOX87XVnn/kGADrydFyzuceQ/9WqG36oi6zFV9B5DtIiF/38wW/NGI0hUammGJFb9w9z ehBdxTWUV/l01rC5BhQuSTeay+uqH91Gr4mnOhA4uXrVS6VJaXB7owmzI7m+e7M4Khdx y3E0L1WgYRvnfsEX4spD2nPiWPPmm9IrHTI95uV+2WEOnRZ/6pPZ2gJ49JnXCMpMOPlx FJCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iK6fPIUJA8jAGfyP6Mayo0H4FWDPhBjdYU7qeRRTMIM=; b=HdJQ0XV4J9r7Ap6aW5E5+708Dd+QO8ZZUHSFUMyVZ9oV2S999j4hk6c6YZJ1lZP68c TbLQ4sbXSL6hXPqmtfrzX3dDN3Xth6y+eoEhmo3/mbpR3PQDcKUGfNGifdnyiwkjtgJ/ Ok4NWJE6hWKK+yrm9hREspopkEVTO3UR5JaBFHbbAAqPuqrxpaiGE3IV4A05PA7ynubh yl2RygtfiV9A4TxHa8Esea7Hc5ZfQgLk2DN9h+htamEa/L+pd+h5F/Dm7s1wrSgKUVs0 Nep3Ak2pxbi3SuN7Kpv0tdKwJQgNlfk6Hf0hAGTbHh9cxsmpoe83Kbuo/1//R+rqTIdq iYZw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y71-v6si16241942pgd.223.2018.08.01.10.26.24; Wed, 01 Aug 2018 10:26:38 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406600AbeHATLT (ORCPT + 99 others); Wed, 1 Aug 2018 15:11:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51160 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404840AbeHATLS (ORCPT ); Wed, 1 Aug 2018 15:11:18 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4AEBCCC3; Wed, 1 Aug 2018 17:24:36 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiao Liang , "David S. Miller" Subject: [PATCH 4.14 239/246] xen-netfront: wait xenbus state change when load module manually Date: Wed, 1 Aug 2018 18:52:29 +0200 Message-Id: <20180801165023.182578979@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiao Liang [ Upstream commit 822fb18a82abaf4ee7058793d95d340f5dab7bfc ] When loading module manually, after call xenbus_switch_state to initializes the state of the netfront device, the driver state did not change so fast that may lead no dev created in latest kernel. This patch adds wait to make sure xenbus knows the driver is not in closed/unknown state. Current state: [vm]# ethtool eth0 Settings for eth0: Link detected: yes [vm]# modprobe -r xen_netfront [vm]# modprobe xen_netfront [vm]# ethtool eth0 Settings for eth0: Cannot get device settings: No such device Cannot get wake-on-lan settings: No such device Cannot get message level: No such device Cannot get link status: No such device No data available With the patch installed. [vm]# ethtool eth0 Settings for eth0: Link detected: yes [vm]# modprobe -r xen_netfront [vm]# modprobe xen_netfront [vm]# ethtool eth0 Settings for eth0: Link detected: yes Signed-off-by: Xiao Liang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/xen-netfront.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -87,6 +87,7 @@ struct netfront_cb { /* IRQ name is queue name with "-tx" or "-rx" appended */ #define IRQ_NAME_SIZE (QUEUE_NAME_SIZE + 3) +static DECLARE_WAIT_QUEUE_HEAD(module_load_q); static DECLARE_WAIT_QUEUE_HEAD(module_unload_q); struct netfront_stats { @@ -1330,6 +1331,11 @@ static struct net_device *xennet_create_ netif_carrier_off(netdev); xenbus_switch_state(dev, XenbusStateInitialising); + wait_event(module_load_q, + xenbus_read_driver_state(dev->otherend) != + XenbusStateClosed && + xenbus_read_driver_state(dev->otherend) != + XenbusStateUnknown); return netdev; exit: