Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3525350pxj; Mon, 24 May 2021 08:39:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzn5NGFKOt7TaZgPLDwDTHGqWrhYVJMD8+UX+HQc0oCwt0Q0Fqv7o3QE0nsTtzFk6lfKRqz X-Received: by 2002:a92:d983:: with SMTP id r3mr16918519iln.262.1621870745624; Mon, 24 May 2021 08:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870745; cv=none; d=google.com; s=arc-20160816; b=yfy6Yfs4ZaKuVKYm4ST4TTGydAh6fv6kDp+58PubjlawMO3IS4HAa2EXi/WU29+wGJ NZk0hbjlWtbHGKlberxIWlpx5m1loNOKbG6MxF72P/sEaaT7/pAqOrYho8kuYUrdhWjQ hPnVURv6xp+K1w2B+iewt937OEbPdLv5w99EsWvEKlRBv6n8daEWp40b60B7fIy4+cuZ BMeGZnxtyJi92FtM/YIDTCHlOoO2poZ0cBsVVJ/3nLUlPFs304beaG6GIl3pEXeWdzNy bEsU1ER4A05vkSm44IzqmjUtMoOKWiEyMrLkPUO4WV+Dj4RaHaSkBL3UB/LE92IvyrY+ 2dZg== 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=v2pAj/h3lJgpapfR1Ayl8pk+IPQloq8rxBViFS3P8gY=; b=u1aN2TeE6SZmaEkEOHrX/Cp2bIyJxhLNfTiLQwHw7Jc5+6oNPGvONgWty7kp3Bt+BR P4xZnzyG7LCWKqW4NXWdCDlrq9s76cmBRGElZhTK1winvPCjU4c4XCD/2giP3xcKKdiT NCJQrzeDkyGR8qwwV0IMaIQxro0JjfWzImTX16MUr3uFWdFhVihLjhQ4aAjNqF4ccpjT oae3ide8A7mZn47jf1qEMnPQJ61spUSUxbXPKLHNYDHzX3FT22316KGox2Bz1NX0S4dD v9bCsCHXdpaHQwHtshEmsPgzHeKgN/6ISzYwTfdTqc/92tzNGCFAB78TdxZpPzG1c78N 6Iyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bUxMAe8s; 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 g9si15710821ila.105.2021.05.24.08.38.52; Mon, 24 May 2021 08:39:05 -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=bUxMAe8s; 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 S233235AbhEXPi2 (ORCPT + 99 others); Mon, 24 May 2021 11:38:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:51548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233494AbhEXPe4 (ORCPT ); Mon, 24 May 2021 11:34:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98BA5613CB; Mon, 24 May 2021 15:32:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870338; bh=e83ixzFhwqcm//uNVLg944pU45V0gzbbaEJ2HEppjKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bUxMAe8sAAmvNm83R59jbcZg9ylQyb31Bg/CeNZFgioxJRxyEnGoXYSt3FiUSfLxW maadQ8dvzSiFYAiCvXVaRHIpcqyUBNyK40Est3ao4i+67SWJ4TNCBwsxpMBCB6oeGH A08vJQ09k3nbtDS8l1An3nAoPS8UfSM8oMKKyD70= 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.9 12/36] xen-pciback: reconfigure also from backend watch handler Date: Mon, 24 May 2021 17:24:57 +0200 Message-Id: <20210524152324.571062366@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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 @@ -357,7 +357,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; @@ -371,9 +372,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; }