Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1855350imm; Fri, 7 Sep 2018 07:12:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY0hpZ/qZrdSzNB2d6p2zSLc+cT+egpufeMYMuyfNAn8j9OyUatbkhKai7BuBj+ghndwmjE X-Received: by 2002:a63:de10:: with SMTP id f16-v6mr8336933pgg.97.1536329577236; Fri, 07 Sep 2018 07:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536329577; cv=none; d=google.com; s=arc-20160816; b=AxU7/zzWlMZFLFfkkZ/uSDiZbxXbcBV/iLCujNnZhXVz5IJ/3eqrTLrgbze629EpRp EFNKm/8gK4BNHOD5r8xw+qGxr3Rcq06ozIMOiKH9Y/hT+NENo+AtvLuE4/9Pl+a6Luin /piDvnHnRSRfG/Enjj9c6AVyug4y6J1pY0iu2NDGAjXB6hAFOTShV/gjw1+J/MubrShR bPR9d+nTqArtrbbkwb5Sg5W8F+wSBHGNSTafNf9bhQXnjPEhgEGCQNj49oWSkXX4+4U8 j40DSe/MXsvJLPgPmziQbbknDdWCxnmcncoXznnB5gVS80Zjgw7u8tbsKbgFYivwgNd4 H0uQ== 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; bh=PV/CUbU5AacpmYX0EiFOZ9X/LkoJjYmJ2lDepX5D9Ow=; b=RhT1da4aCozjQ6tYQbFIp/aCq8gVSKj+GD2V28tSJ7KShinML/mLzhNRdcXNDbMPnw CFRFZ6eumkjY4yFvGKMO521OFGxuCl6HAEfhkEZAfeP8NAL+CbofdHa4TRtLdfED6vh/ YDFPxceB87+WcQl+4jIpsY5vyvFXJ7hGnlxGPFKzi9xp6DKTSahIPDXkebD3wXoB3BaV +RfOcEzpSEorRC2oDqdpmSV3V/nTngUP65sqGQ7YyXgTGlRT5kSybt8C2T45wYn+ZLy0 ftHmFx5PiH08zPKLLd7ptnKSzXwFuY4WFXktk7+JcIr+Hl4KXzpK5bLJgmBcXHy2NSQD 27bw== 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 d4-v6si9264087pfc.219.2018.09.07.07.12.41; Fri, 07 Sep 2018 07:12:57 -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 S1729098AbeIGRCR (ORCPT + 99 others); Fri, 7 Sep 2018 13:02:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:50526 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727679AbeIGRCR (ORCPT ); Fri, 7 Sep 2018 13:02:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E1C44AD24; Fri, 7 Sep 2018 12:21:32 +0000 (UTC) From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, netdev@vger.kernel.org Cc: boris.ostrovsky@oracle.com, davem@davemloft.net, Juergen Gross , stable@vger.kernel.org Subject: [PATCH] xen/netfront: fix waiting for xenbus state change Date: Fri, 7 Sep 2018 14:21:30 +0200 Message-Id: <20180907122130.30810-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/net/xen-netfront.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 73f596a90c69..9407acbd19a9 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -87,8 +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); +static DECLARE_WAIT_QUEUE_HEAD(module_wq); struct netfront_stats { u64 packets; @@ -1332,11 +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); + wait_event(module_wq, + xenbus_read_driver_state(dev->otherend) != + XenbusStateClosed && + xenbus_read_driver_state(dev->otherend) != + XenbusStateUnknown); return netdev; exit: @@ -2010,15 +2009,14 @@ static void netback_changed(struct xenbus_device *dev, 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: @@ -2034,12 +2032,10 @@ static void netback_changed(struct xenbus_device *dev, 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; } @@ -2147,14 +2143,14 @@ static int xennet_remove(struct xenbus_device *dev) 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) == -- 2.16.4