Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3549877pxj; Mon, 24 May 2021 09:09:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMSEI8Zk50T0L2RLHWNEwxhQJ8HDKlu309AspKwfU3kvaLCwuPrrtm3iYvpw7lixs0Losf X-Received: by 2002:a50:f1ca:: with SMTP id y10mr26067743edl.294.1621872584946; Mon, 24 May 2021 09:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872584; cv=none; d=google.com; s=arc-20160816; b=m9ouFpiWpAJ+VkW09pvdSej4g7Txv/ZVx8VwSNy7jd7JTa/5hS8Qxkae1wjIBK1Yo1 WCOlqz3JviVKackbrM1kYU5MbW0UM/7QY7EY4dJTFi/v1dmh1/h0cA0XZPy4rMFUcX31 dlLKfhoz5kgdSYItaAOSG+ND6h2mqbxzHOy95dbmKs+RB8Q6D+8ACiLwFLgK+tHEk3Rk uINRAM7GgExxy+VPDNMzQBVZMzZKLay4EZRaZgAH909tGlNOaykuooKsoN70HflBR+Yt sSFGMVKUEhkYFxYcpdDea+Pn24JRY9c8H1klTfm+9HKsbLirclxgRtGydZl+3mrAWaTs H3Zg== 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=kcKkJdFZxmi9Fvgtq4MbGmohTfh5+emJjT09qEe5fgE=; b=aZ9f6WdnkeZ4+o8IX+Rx4nahla6XgcNUvnLYqvKBoKdKlS92UmUpzQcBQeuZJBj/m2 /PNAp/phvzwkCSpugB1bjTCvlq7jPdqU0WinleNohqSSpCqHkFBlJxSBeCdiTFQhP4NX oFYz0m7oUDmHBxtn9NffhTciBuOAPO/8CwusGBrG+JGIH7y7CInSsIz+o5TSVtyg56at ZnJXgIunqtLMPjHeHLjoDFm18Okk2iBZhujmSmdYserI4xjOjgYaLFXHDt6iPTk62gbF Pk98m8kRV1TNXXxPjut71aOYHL7hQVm3GRmarlK9zPfsk8kG3KZ+64v6YG9OfM5jdSj2 24ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eB0uC0VS; 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 y15si11123913ejw.484.2021.05.24.09.09.21; Mon, 24 May 2021 09:09:44 -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=eB0uC0VS; 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 S236564AbhEXQGy (ORCPT + 99 others); Mon, 24 May 2021 12:06:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:40506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233542AbhEXP75 (ORCPT ); Mon, 24 May 2021 11:59:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 06FEA61979; Mon, 24 May 2021 15:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871135; bh=5ES2YZQKfiX6RzirXVDJOVDKo/CI4se+BaBAsnud5O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eB0uC0VSwszBYU/5/4KMhvRaIevK5dvo311WB7/tqG1aRiTxF2JMFQHavX+AbE44+ ezPCBTVaELyN1NpNTlOgGB/rVwvoOCZhkXG7+psoCKQf//GnBStx1cfELx71/TgX/A RmvwN/MySbJ1tZP3WI0Sgu84ym3lMJBwGS0XHYBQ= 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 5.12 089/127] xen-pciback: reconfigure also from backend watch handler Date: Mon, 24 May 2021 17:26:46 +0200 Message-Id: <20210524152337.867519235@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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 @@ -359,7 +359,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; @@ -373,9 +374,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", @@ -500,6 +499,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, @@ -525,7 +528,7 @@ static void xen_pcibk_frontend_changed(s break; case XenbusStateReconfiguring: - xen_pcibk_reconfigure(pdev); + xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring); break; case XenbusStateConnected: @@ -664,6 +667,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; }