Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3523514pxj; Mon, 24 May 2021 08:36:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGlmUEBuqcVr5JQY0u/xLCUaeq+6EXJOC13HSwmoUDmjurBDcjv+FGzQQ8SBBpMxAdKE5h X-Received: by 2002:a05:6e02:c5:: with SMTP id r5mr14463915ilq.48.1621870605541; Mon, 24 May 2021 08:36:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870605; cv=none; d=google.com; s=arc-20160816; b=oU/NYN8Gl2vCGqp7JKKuZloNovOW+w8ZexTC/5TYZQo1H9yhS6n3AxbtUJkdfg/5UT Os6GV+vUU2hzAcvYnoANikfVvHUXM8SqJZs0cFVjyAuXkbYVC+wv5a1CUVTLe8QeArKv jenbasf7BlCCVnMSlfiE2SXMVVnj7xsaTy/xdMvPkdv74Y96S8QPgn3OUNy9TC5N0eqL z7+Btm32Xr8J6NnrrwAkFiru9ufVldwdmKiAZx3eISSFcvRGswrQj4CE7XCr4Jjsk72C K/rdI3Q+tIWmqp4s4PemQuf3GnTJBzEvGzn0R5dnAYWtJII/u6mERkurqknsQuuU8/8Z sgQg== 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=xTi7uipBj8fy81pc4uVodkAv8qp6r/yMeFMJxLobG2Q=; b=pK/3C+Pz5KXET19TRftaQ1HsQuxbZS1wj8LPf9m9Yo7qjpJMQntjNdy/J3jkfsfkNJ lLERAe633lG0fdQkGUZISkn2fBzbAc7xZFe/p4V/Q7KZF3pV1OKnIrXo4TnDTNxJAmnG cWCf8oPZHCEu1KtyERv1kkhVwDbEbeRivZ3QMokHV3XYzGwO+IqjzT+xClQw5dUKidAy dffXSB3nj0tMQNEKokRN7OFgxGdCeoNl/ResRWdUfnzXR8L13U7tv44XQVkRBphmteFg wEst2akYv7OlJmJernazAfcrhjNAVCs+KKgpM5ObA9Bij4G12zOCEHmfpCbMklJKKbCj tYRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CtNF2omH; 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.36.32; Mon, 24 May 2021 08:36:45 -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=CtNF2omH; 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 S233644AbhEXPhA (ORCPT + 99 others); Mon, 24 May 2021 11:37:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:51536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233564AbhEXPdn (ORCPT ); Mon, 24 May 2021 11:33:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9AD97613F5; Mon, 24 May 2021 15:31:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870293; bh=lLykOLkGMiYeAG0/L2bjH5UoqGu6xGw9hr7zFMbHUx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CtNF2omH/MVPUrVO1QV0+QVZa+p+tbIk88FFNWv5dVRL6ayfFuJMNOc+/zTw/i/Cp LeIboFshHvsgCEfFCa0SOgkuqrJCGMPwZ8irgiEBL2JrFttqq87NaVx96tHjeutkkq ypnYEPIsZ+0wjDx5ThGz+Iy1GJal26AIAg0VlaQk= 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.4 08/31] xen-pciback: reconfigure also from backend watch handler Date: Mon, 24 May 2021 17:24:51 +0200 Message-Id: <20210524152323.193073771@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152322.919918360@linuxfoundation.org> References: <20210524152322.919918360@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", @@ -502,6 +501,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, @@ -527,7 +530,7 @@ static void xen_pcibk_frontend_changed(s break; case XenbusStateReconfiguring: - xen_pcibk_reconfigure(pdev); + xen_pcibk_reconfigure(pdev, XenbusStateReconfiguring); break; case XenbusStateConnected: @@ -666,6 +669,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; }