Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp607461imm; Fri, 27 Jul 2018 02:57:30 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfR1kvvyyqvGLges0AyK9a5HJOtEZ3aJIE+uwjmNOIl1fB+lpG4HULMbCSBKZvDnR0w6qH8 X-Received: by 2002:a63:9902:: with SMTP id d2-v6mr5427497pge.343.1532685450899; Fri, 27 Jul 2018 02:57:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532685450; cv=none; d=google.com; s=arc-20160816; b=ZIKnkweez9ntTXeu8QnesEcvWxpNDdvkZ2557Ud7Q/GtWuYQBx+uPdvkVr5kjqMaDq +z7yKsneT5v/mNEbnEb86DVLsT58cChhRzjZReNptks4hGSawTrI1ND+kH3wl2LcVdex GSwJfrcyM5PnCiVe0kOXL86ZB4cBVb7cclJSKqyWRoKgS18xw8QfPCDSow8wS21HUJj8 8fSIrOsPNHYTqJ7LHKAh1dAzo2c+15jBAnhqYRru7+qjTYwn3F/Oz7gEVkYnHEdoQ9Uu lgDR3IrKOEoJmP8cQphJJNtk0QvG/rtbE7qJkdbHkvM2EJMcT11YxXAK7V4PblCU4Feo pJxA== 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=2NrCCBTQ2/semsXYrj00Pi1TePo5dCvZEQoL/LvdgE4=; b=qLC0xcAcx1/XhKOgqwuzEffci4ekK4nk3PhpZeklTP4GYDwxYjYdXrwBlBpHvzeE10 JJ8m2fDnOH8Q1KFZeaCnzSAnGixvnEt4iG6EVLDrCSuIhYs2ueC8fJVFmqQxlqZ1oKMD LbzW1+nCI4GhahbsH3LSgo/8k9kyhh7MfAJSnvP5cI0gcR4cVuSP2+rfqY6u7CwwdhAx lN3njIW0Jn03OqPpBCKThC02dxTIfn3IVlDUalWy3aQnsaGKzMmtYh2eSB3n2u98w8DB y2z+IyuJQTQk5UdKSjsifasblRaj2dzjHvFdd5sqZqFXXaeC2/yLeA4ZzGxrTFb3xXGX Vz6Q== 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 a3-v6si777898plc.380.2018.07.27.02.57.16; Fri, 27 Jul 2018 02:57:30 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730791AbeG0LRh (ORCPT + 99 others); Fri, 27 Jul 2018 07:17:37 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34046 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729539AbeG0LRh (ORCPT ); Fri, 27 Jul 2018 07:17:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEDDD402346C; Fri, 27 Jul 2018 09:56:28 +0000 (UTC) Received: from dhcp-2-242.nay.redhat.com (dhcp-2-242.nay.redhat.com [10.66.2.242]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F3C602026D74; Fri, 27 Jul 2018 09:56:25 +0000 (UTC) From: Xiao Liang To: netdev@vger.kernel.org, xen-devel@lists.xenproject.org, davem@davemloft.net, jgross@suse.com, boris.ostrovsky@oracle.com Cc: linux-kernel@vger.kernel.org, Xiao Liang Subject: [PATCH] xen-netfront: wait xenbus state change when load module manually Date: Fri, 27 Jul 2018 17:56:08 +0800 Message-Id: <20180727095608.25210-1-xiliang@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 27 Jul 2018 09:56:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 27 Jul 2018 09:56:28 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'xiliang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/xen-netfront.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index a57daecf1d57..2d8812dd1534 100644 --- 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_dev(struct xenbus_device *dev) 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: -- 2.17.1