Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1716666ybl; Thu, 5 Dec 2019 06:02:38 -0800 (PST) X-Google-Smtp-Source: APXvYqxW6RRhvq860TwumIK4Sj7IFOnzTNrnw9hXC32LFS4ZVPbJ+fWfjDkQxGq/4V6I+bJyGOWR X-Received: by 2002:a9d:5d10:: with SMTP id b16mr6639449oti.250.1575554558694; Thu, 05 Dec 2019 06:02:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575554558; cv=none; d=google.com; s=arc-20160816; b=pX50uY5TXRmw1K55jTZfDw4pjvbr/GawJTZL32Zqdtn2qjpPOppS7UoA72Tj0vKLmF fhlujOV9Jh3W9TBVyxMs4X8ndaQiMu2WYgRI+xlaXBGASvAHl68W+TrjA6jAMegmIQQD 2A7CzLVCHZaDw8G2aLn8si4Z5trxzW7WO3JPznJRqkV52BEI2TY0YGHBnGlzP4aNj/9g fBzw5jsLay8MIR0o3kkI0q8WpOPNrfZ+YmfFvMKxYfvXRcN1+wlR3VnsltGa9mewLndu 86khhguPuhSccRwifFT0VVap+EN/wKIJqBQTRCvI6dwr+0u5w1b/LXn9WKRBgh0S6MLE FBlA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:dkim-signature; bh=T78jIw2G+NoTyOExzPIFxHYe8NsRzGe0PdgYlPNaGmg=; b=Vc1hfw6GgESAjMLqDzfsHfnG6k/UZfQibaB5ayMVWmj/XN7LKoRwG1xCNNyW7D+ADD KHTa9mjI/6+xmukdkrZ/4cG5jpP6DCWvfK/5PHbtNFCQ8RE47ND3QDfcsF2wG6S97KVb sR0GmPaKhJus11tGa98H7jTcK9baE+BEG+6chbG8XtdTII/tOoRVMhQolf1hw6kxrPiM 85+2Wu3eUjMjaL94xIlyidrnGZCILZzkbeSYcrVqUj7/OUisGEjImggLF/yp53Ku6Pnn MJJvdFUxHUyGUo5Ow4Wd8CvAMITM0nrdcbzpXfV9nmOY+JL80T300fpxzMw1Y0k+73Wu hZsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=Y9qZ7WYR; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t130si4429914oih.37.2019.12.05.06.02.17; Thu, 05 Dec 2019 06:02:38 -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; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=Y9qZ7WYR; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729497AbfLEOBn (ORCPT + 99 others); Thu, 5 Dec 2019 09:01:43 -0500 Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:42822 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbfLEOBm (ORCPT ); Thu, 5 Dec 2019 09:01:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1575554502; x=1607090502; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T78jIw2G+NoTyOExzPIFxHYe8NsRzGe0PdgYlPNaGmg=; b=Y9qZ7WYRGp3bSBnj6CA+o8XlnU0DLW290xu2P0EhPee4ZKRNpzIY/zs9 0zNF70PHScSvZR++0h9Q/iR5dQn9SP6pZ2RT/+wHyFlFFutyHXvScwynb QWSp4WKT2ij0y7ELrSPyK3oL6mD05wD79DXOYhI5Kr8X5FPDKGnjaaZz1 w=; IronPort-SDR: TrQOkzDuolXJUMTPo2K5HXoHg/ggo3T0ufETrbzTLZWL9eor9HDoWJ13NLIxasnRSejJg9I0w4 O0aBChzSre4Q== X-IronPort-AV: E=Sophos;i="5.69,281,1571702400"; d="scan'208";a="7211159" Received: from iad6-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-f273de60.us-east-1.amazon.com) ([10.124.125.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 05 Dec 2019 14:01:39 +0000 Received: from EX13MTAUEA001.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-f273de60.us-east-1.amazon.com (Postfix) with ESMTPS id 197A6A27D0; Thu, 5 Dec 2019 14:01:39 +0000 (UTC) Received: from EX13D32EUC002.ant.amazon.com (10.43.164.94) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Dec 2019 14:01:38 +0000 Received: from EX13MTAUWC001.ant.amazon.com (10.43.162.135) by EX13D32EUC002.ant.amazon.com (10.43.164.94) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 5 Dec 2019 14:01:37 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.162.232) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 5 Dec 2019 14:01:35 +0000 From: Paul Durrant To: , CC: Paul Durrant , Boris Ostrovsky , Juergen Gross , "Stefano Stabellini" Subject: [PATCH 2/4] xenbus: limit when state is forced to closed Date: Thu, 5 Dec 2019 14:01:21 +0000 Message-ID: <20191205140123.3817-3-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191205140123.3817-1-pdurrant@amazon.com> References: <20191205140123.3817-1-pdurrant@amazon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only force state to closed in the case when the toolstack may need to clean up. This can be detected by checking whether the state in xenstore has been set to closing prior to device removal. Signed-off-by: Paul Durrant --- Cc: Boris Ostrovsky Cc: Juergen Gross Cc: Stefano Stabellini --- drivers/xen/xenbus/xenbus_probe.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index a10311c348b9..c54a53da0106 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c @@ -255,7 +255,6 @@ int xenbus_dev_probe(struct device *_dev) module_put(drv->driver.owner); fail: xenbus_dev_error(dev, err, "xenbus_dev_probe on %s", dev->nodename); - xenbus_switch_state(dev, XenbusStateClosed); return err; } EXPORT_SYMBOL_GPL(xenbus_dev_probe); @@ -264,6 +263,7 @@ int xenbus_dev_remove(struct device *_dev) { struct xenbus_device *dev = to_xenbus_device(_dev); struct xenbus_driver *drv = to_xenbus_driver(_dev->driver); + enum xenbus_state state; DPRINTK("%s", dev->nodename); @@ -276,7 +276,14 @@ int xenbus_dev_remove(struct device *_dev) free_otherend_details(dev); - xenbus_switch_state(dev, XenbusStateClosed); + /* + * If the toolstack had force the device state to closing then set + * the state to closed now to allow it to be cleaned up. + */ + state = xenbus_read_driver_state(dev->nodename); + if (state == XenbusStateClosing) + xenbus_switch_state(dev, XenbusStateClosed); + return 0; } EXPORT_SYMBOL_GPL(xenbus_dev_remove); -- 2.20.1