Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3530861pxj; Mon, 24 May 2021 08:46:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSA5sX+uh3Ok9HgIO+I4Qs60aPhuWKyC6hxUA1P7104hDHBFfr6EFpSqMk71dz5wxFnwKd X-Received: by 2002:a17:907:c01:: with SMTP id ga1mr4743724ejc.80.1621871215877; Mon, 24 May 2021 08:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871215; cv=none; d=google.com; s=arc-20160816; b=Tr5bWrhSsr3iP/rozBj2iNH8A8RuMyzoi4ejEMx6N/JNXA/b2r9/Y4IHYC3izayPSR ojWyzZuaRRaWOsqPCdaNvaRnOGtYmdOMsDuaNIv437FuyJMzGwXUwzaQnaA3WvYBg5XC iRzljHbGqWc48g6Q+F7Kpb78z1+H4d0mm46v4umh3aIisnhyTtPwye8iaOCyryvnwxuL vSccSEldzpZRXOw6J1rO/+YUu70XjvmjDQCNbP5MOafC/50n+tD5boyVPbtNjVOC/XoB QORsnjSp9FI5Z0xV4EqHd9MEGlPFbkoCU+p/cRXLy/LCqVs912mnKwm1vaeoIQXDqezF DZCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=I/rP7GeRz7mSjL7VKek1kJXGto7LgH+puWfvAlJJ32A=; b=1JM3HymT/0V5PInow3lNrwQHQTsKLlNzLgzXKxpS8qss+OZ+lTpi+/a1AR1eNaiwoW UZLn+0w6oZUAUA7KpxxwtSjWOTv2DgEwxuGINBMNh60Q+E/2s2K1FJt3L7fFK8Kxl4Rd ng0PI6LQDacxrbEoRNPUo+O8K0pRuLpz38Y0ZWvw3S9x6MlId+yhaVE+8I5VJ0jVZXR1 F40yqUPn7XlRyN6a9qu0Duo5wivNLKsYswBV0KmqcvoqeGJ/BF45wH0klMnlIJOiMl0o 8joXdy33w2pT4idePoHOfxgzVpwpmElUeXHv6YucCouI/+ZxNMXR7o5PuMK1YPV8pa5y YRMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2fLnwVTM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e20si12495307eds.560.2021.05.24.08.46.33; Mon, 24 May 2021 08:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2fLnwVTM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234556AbhEXPoX (ORCPT + 99 others); Mon, 24 May 2021 11:44:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:56262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233774AbhEXPkS (ORCPT ); Mon, 24 May 2021 11:40:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 40E3B61439; Mon, 24 May 2021 15:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870451; bh=4y53AlV7J/GunMYGYqM0s5l56bGEUAVQa7NrzwKwNJo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2fLnwVTMjkw9kNjAWEE86COV4MPrxlk/lQP3X97R0imAYQv3MR6Ix45/jRxXhL4l6 Zci53QjMGemsyFh05o0H1Q95T90fQYx4VOyjc0tc5+ESp/bVT/+KVJhV0gmWOy4v1w i+LHShmJWCNJhvRd1lI04WgpI037Wkp49BMHE6KE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Beulich , Boris Ostrovsky , Juergen Gross Subject: [PATCH 4.14 13/37] xen-pciback: reconfigure also from backend watch handler Date: Mon, 24 May 2021 17:25:17 +0200 Message-Id: <20210524152324.646191260@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jan Beulich commit c81d3d24602540f65256f98831d0a25599ea6b87 upstream. When multiple PCI devices get assigned to a guest right at boot, libxl incrementally populates the backend tree. The writes for the first of the devices trigger the backend watch. In turn xen_pcibk_setup_backend() will set the XenBus state to Initialised, at which point no further reconfigures would happen unless a device got hotplugged. Arrange for reconfigure to also get triggered from the backend watch handler. Signed-off-by: Jan Beulich Cc: stable@vger.kernel.org Reviewed-by: Boris Ostrovsky Link: https://lore.kernel.org/r/2337cbd6-94b9-4187-9862-c03ea12e0c61@suse.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/xen-pciback/xenbus.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) --- a/drivers/xen/xen-pciback/xenbus.c +++ b/drivers/xen/xen-pciback/xenbus.c @@ -358,7 +358,8 @@ out: return err; } -static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev) +static int xen_pcibk_reconfigure(struct xen_pcibk_device *pdev, + enum xenbus_state state) { int err = 0; int num_devs; @@ -372,9 +373,7 @@ static int xen_pcibk_reconfigure(struct dev_dbg(&pdev->xdev->dev, "Reconfiguring device ...\n"); mutex_lock(&pdev->dev_lock); - /* Make sure we only reconfigure once */ - if (xenbus_read_driver_state(pdev->xdev->nodename) != - XenbusStateReconfiguring) + if (xenbus_read_driver_state(pdev->xdev->nodename) != state) goto out; err = xenbus_scanf(XBT_NIL, pdev->xdev->nodename, "num_devs", "%d", @@ -499,6 +498,10 @@ static int xen_pcibk_reconfigure(struct } } + if (state != XenbusStateReconfiguring) + /* Make sure we only reconfigure once. */ + goto out; + err = xenbus_switch_state(pdev->xdev, XenbusStateReconfigured); if (err) { xenbus_dev_fatal(pdev->xdev, err, @@ -524,7 +527,7 @@ static void xen_pcibk_frontend_changed(s break; case XenbusStateReconfiguring: - xen_pcibk_reconfigure(pdev); + xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring); break; case XenbusStateConnected: @@ -663,6 +666,15 @@ static void xen_pcibk_be_watch(struct xe xen_pcibk_setup_backend(pdev); break; + case XenbusStateInitialised: + /* + * We typically move to Initialised when the first device was + * added. Hence subsequent devices getting added may need + * reconfiguring. + */ + xen_pcibk_reconfigure(pdev, XenbusStateInitialised); + break; + default: break; }