Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2462009imm; Mon, 24 Sep 2018 04:56:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV63UJbTkmVxRqIfXZmnyDB6lOabcNoJBg0hZU444qpFa5yUI8rqnpQTRotsxnhhZGmgo9roU X-Received: by 2002:a63:41c2:: with SMTP id o185-v6mr9217295pga.11.1537790202394; Mon, 24 Sep 2018 04:56:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537790202; cv=none; d=google.com; s=arc-20160816; b=hoh2IMbji437v7nRysPqAKxG7K/dbrAu/8IsE43Su7l5XrFk/JU1MUMkt3TMbVedQB 1FdJPGxYVWXH1UTtERamHAoW7uptxbNRbk5OttkiZmQ6CYPry37A2l5111XhuCgEZDSk Z3JEWUVMicnRqXyixzCPYxslfuEsKTdm3WvyRt88ydQ7yK3WqkdKvhnrEBZHFidJHIw2 ChrL/P9uXikp1XSoR0hQ/TD6ugJKm2+g54PYbXahaVNygmFWmipJy/hkDDi5+gJDok/U p1czhEkO4LrnwPntVSlFsnAthUf6m9TKhIY7GfP6ajv38SVLcP0ngQNyZ9EtJG7tupb5 gJng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=F/Xfi2ju2DpFPF77VFLI/dSTsfxLdISZU9HDJaZR0q8=; b=nfRsW/otVB5r8fF9LkM6zOTS4ICrk9r1dyAPVBn//mrv8VPN288PvNnFXkKvP/zCCU dth8Ac2lOOrh05k9zMXhZdXrLfNsjj0XKSWriBi4kXUgXWV0bhjOd126/SJH7eY+908f TjjK3PpitlfUxNFAYsbaNcxI6icYSDRTBYTAKrdxOlvwMElxGTbM8v0GAe3ril0i1MVp fruiFNtSLVs4X0yTJJVTwI7ZawTfLKDYa3gHG7IqJ2s0TujW50W7UkLm9UiIqD5Cwuoc dnmkdxoHnCXcD5uRJohwDfYnpVf570PuRsQ9ZlYr+Kx2A6N9jnhfyR/dg0/Cg1Q0bBo4 t50A== 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 n7-v6si34148749plk.204.2018.09.24.04.56.27; Mon, 24 Sep 2018 04:56:42 -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 S1729854AbeIXR5Y (ORCPT + 99 others); Mon, 24 Sep 2018 13:57:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:51892 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728425AbeIXR5X (ORCPT ); Mon, 24 Sep 2018 13:57:23 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A8C841072; Mon, 24 Sep 2018 11:55:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky , "David S. Miller" Subject: [PATCH 4.4 31/70] xen/netfront: fix waiting for xenbus state change Date: Mon, 24 Sep 2018 13:52:30 +0200 Message-Id: <20180924113102.257241426@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180924113058.420454070@linuxfoundation.org> References: <20180924113058.420454070@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Juergen Gross commit 8edfe2e992b75aee3da9316e9697c531194c2f53 upstream. Commit 822fb18a82aba ("xen-netfront: wait xenbus state change when load module manually") added a new wait queue to wait on for a state change when the module is loaded manually. Unfortunately there is no wakeup anywhere to stop that waiting. Instead of introducing a new wait queue rename the existing module_unload_q to module_wq and use it for both purposes (loading and unloading). As any state change of the backend might be intended to stop waiting do the wake_up_all() in any case when netback_changed() is called. Fixes: 822fb18a82aba ("xen-netfront: wait xenbus state change when load module manually") Cc: #4.18 Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/xen-netfront.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -86,8 +86,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); +static DECLARE_WAIT_QUEUE_HEAD(module_wq); struct netfront_stats { u64 packets; @@ -1336,11 +1335,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); + wait_event(module_wq, + xenbus_read_driver_state(dev->otherend) != + XenbusStateClosed && + xenbus_read_driver_state(dev->otherend) != + XenbusStateUnknown); return netdev; exit: @@ -2025,15 +2024,14 @@ static void netback_changed(struct xenbu dev_dbg(&dev->dev, "%s\n", xenbus_strstate(backend_state)); + wake_up_all(&module_wq); + switch (backend_state) { case XenbusStateInitialising: case XenbusStateInitialised: case XenbusStateReconfiguring: case XenbusStateReconfigured: - break; - case XenbusStateUnknown: - wake_up_all(&module_unload_q); break; case XenbusStateInitWait: @@ -2049,12 +2047,10 @@ static void netback_changed(struct xenbu break; case XenbusStateClosed: - wake_up_all(&module_unload_q); if (dev->state == XenbusStateClosed) break; /* Missed the backend's CLOSING state -- fallthrough */ case XenbusStateClosing: - wake_up_all(&module_unload_q); xenbus_frontend_closed(dev); break; } @@ -2162,14 +2158,14 @@ static int xennet_remove(struct xenbus_d if (xenbus_read_driver_state(dev->otherend) != XenbusStateClosed) { xenbus_switch_state(dev, XenbusStateClosing); - wait_event(module_unload_q, + wait_event(module_wq, xenbus_read_driver_state(dev->otherend) == XenbusStateClosing || xenbus_read_driver_state(dev->otherend) == XenbusStateUnknown); xenbus_switch_state(dev, XenbusStateClosed); - wait_event(module_unload_q, + wait_event(module_wq, xenbus_read_driver_state(dev->otherend) == XenbusStateClosed || xenbus_read_driver_state(dev->otherend) ==