Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3540905pxj; Mon, 24 May 2021 09:00:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqD5K2en81pc8WIR3C5wf2aOjMZGGQIa+7xX/qEFCE/c8khrZBCvIa7rWITm4zy/koBd4r X-Received: by 2002:a92:d48e:: with SMTP id p14mr14861758ilg.33.1621872024644; Mon, 24 May 2021 09:00:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872024; cv=none; d=google.com; s=arc-20160816; b=rOPFMa238vq0ipx5c2mjpZkDY66gVQSVyWs8/eAR51nkRpWSwC95MWHx1mhtRLN67x dnCoT+Iky6QiwZtKfMjNdDZ/Bv4Vy76UUmuMZ7mtHvMFielJgIO7rv4EBZ3Fbr6K5S0A 0UwaoaBYlebdkrsCgxpGwE+BSOav03eywRDTblIh3vIosiQ5AzNn0go1uaYNT0N85P5f GhA+NIqHlX9dIygaqJcTaVMEWpyM/mBIrV5oI4xOpkhiSjO2ijsRRg88EfGCGCK7Ta66 ioW0+XRZPj/cxV/QqPmZLSpSOzhPZgq5wAA/2ZiaETVi7pOr8U4qO3VBTJTVIrO39abT 0N9A== 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=XFIwBxKsdqMKPo0RZnwwvL+H9YCqC4msFmB2GdWNrHAjjbZMV8RP7kR0fP3uK4XqtR 9oNTFm77/ZSZZnZEXRrWA8rT2+9dtVVGPKmA70zUVUu6lD06IXTb/MUCxkJo5rE2DZFF XxF1IdAkXLjc2lhOjxj1dt7jHbffyAIpUOgXadil6wYbamVkTZDjbOcPCWKm0vL3BiKs ucwX3MUh+vvM9MAAateNNF9omZJyKsC0FqIDS/P8Jvh8/R5Y6u6E34Tm0W6Rspqoy8bt TnBx16hj6+OpY5H1vOvF3jMtXA4LgirNNiU72f+UAEmsr2+clp3XMNrhKzY1YHohsW5E zstw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yba6IaOV; 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 v17si15420310jat.82.2021.05.24.09.00.09; Mon, 24 May 2021 09:00:24 -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=yba6IaOV; 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 S235206AbhEXQA1 (ORCPT + 99 others); Mon, 24 May 2021 12:00:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40490 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235338AbhEXPzG (ORCPT ); Mon, 24 May 2021 11:55:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A49CD6192E; Mon, 24 May 2021 15:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870860; bh=5ES2YZQKfiX6RzirXVDJOVDKo/CI4se+BaBAsnud5O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yba6IaOVZLfu3AbXDrF0WLGCcy3JQ2AvxpijO6zJB98J7kMAbunUCCFfugu4iOG3g 9Z7ofWo8ou7r4x79yCfPyM7+e8FwgOJ7wIde5oF7Q5jLDgyebbX+IrbV96eKp7MFDP Svn5NwSU7gkjaqxY1PIimbIR2JCJEHBvZz/9Fj78= 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.10 068/104] xen-pciback: reconfigure also from backend watch handler Date: Mon, 24 May 2021 17:26:03 +0200 Message-Id: <20210524152335.111589801@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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; }