Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3549874pxj; Mon, 24 May 2021 09:09:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5EWItp9+kWsHaOqQfIu7VsY0l7RtzDrDIJyXc9Em0u0oVD7T8FK4ozDDxqcUMH9uU2N/e X-Received: by 2002:a05:6402:51ce:: with SMTP id r14mr26811500edd.151.1621872584802; 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=Du5cwe55rHloFUAax812B0FAjJ/LWRL0o30T5HdBj/y+4c7iVdc50kQIuEWPIt2dGz VssEpy/CrecEBtPkBPp1T17fcR9rxAlrI8K4tHZqZxVKYvx3QTYbE736QR/XBCh1lEnp Wo3WIDFGlBOQirEWLXaOeMSget++969d7SN+T39amJdQWbud+xATt0HhA7b0mwVHde0W Bw3q6DNhP539htgCnzHbKVMaD5qZSh7RjoUP/nxOA9fp/lqc4ylsjmxU/bvrzc1K7KJQ dhywNAr1U9nZPSCP825wSavPv8wPngROnbDdI2KQ1qSPnm3ssoDIFaxSyTWXAxlEUzzH k+oQ== 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=jrfYCTI6DFenHsYkHMpDP9be8corfkucGo5gHw+ETyE=; b=m8z2qj/bwkZeHLvMeidal30n9ht3/b9sr6RzdB8PcrW6SnO2iNKmki4n3m/3iXOrsh WU3Gqwh/THxDdg0SrOJBK3KF8sVQkIdMIrLcEUje0o8q8KD/LPSwPpaNNqPCudc0nOU4 K/GS2530CZFX+fHdnZEj1Qt7C1cG73V/cSLWMvuOn3DFuLh8L+wzoJSYDFPP3cxOHbwS oRRXu9meJZdgKTCiQYbKRD3OXTYdX9Lh2MfA9VbrZn9LlmgxEiK9uCQAOAVUYe70QOaX 8R1UQM+3ofPszD664yXNIvjmIxlcKXs+9yWZJICjLWa0L3Wim5Mb6SEg7F4ODgk/aUtw O56Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D7aSZ2Gh; 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 e18si13663335edz.330.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=D7aSZ2Gh; 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 S235381AbhEXQGn (ORCPT + 99 others); Mon, 24 May 2021 12:06:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:41186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235600AbhEXP7s (ORCPT ); Mon, 24 May 2021 11:59:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CE6FA6195F; Mon, 24 May 2021 15:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871133; bh=7hmAbfphgOyVL13LgGdGnRzOmIHoIxlzSnUWIOJjmdA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D7aSZ2Ghce6QHz3u8cXF/Qjex4um1dyzMgn0DXuvH9yODeCEvj/Fx0iFoG+kx0ggk EOIzC1NJLO8EwNuWRxYX2rW6V5qZxc0m/q67skVeAEiQJLuDp3q/inJHqak7oMgKPW KJ3RHy0GXV4idXxjKJK48XvkWShfE79VUeKwG734= 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 088/127] xen-pciback: redo VF placement in the virtual topology Date: Mon, 24 May 2021 17:26:45 +0200 Message-Id: <20210524152337.838032017@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 4ba50e7c423c29639878c00573288869aa627068 upstream. The commit referenced below was incomplete: It merely affected what would get written to the vdev- xenstore node. The guest would still find the function at the original function number as long as __xen_pcibk_get_pci_dev() wouldn't be in sync. The same goes for AER wrt __xen_pcibk_get_pcifront_dev(). Undo overriding the function to zero and instead make sure that VFs at function zero remain alone in their slot. This has the added benefit of improving overall capacity, considering that there's only a total of 32 slots available right now (PCI segment and bus can both only ever be zero at present). Fixes: 8a5248fe10b1 ("xen PV passthru: assign SR-IOV virtual functions to separate virtual slots") Signed-off-by: Jan Beulich Cc: stable@vger.kernel.org Reviewed-by: Boris Ostrovsky Link: https://lore.kernel.org/r/8def783b-404c-3452-196d-3f3fd4d72c9e@suse.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/xen-pciback/vpci.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/drivers/xen/xen-pciback/vpci.c +++ b/drivers/xen/xen-pciback/vpci.c @@ -70,7 +70,7 @@ static int __xen_pcibk_add_pci_dev(struc struct pci_dev *dev, int devid, publish_pci_dev_cb publish_cb) { - int err = 0, slot, func = -1; + int err = 0, slot, func = PCI_FUNC(dev->devfn); struct pci_dev_entry *t, *dev_entry; struct vpci_dev_data *vpci_dev = pdev->pci_dev_data; @@ -95,22 +95,25 @@ static int __xen_pcibk_add_pci_dev(struc /* * Keep multi-function devices together on the virtual PCI bus, except - * virtual functions. + * that we want to keep virtual functions at func 0 on their own. They + * aren't multi-function devices and hence their presence at func 0 + * may cause guests to not scan the other functions. */ - if (!dev->is_virtfn) { + if (!dev->is_virtfn || func) { for (slot = 0; slot < PCI_SLOT_MAX; slot++) { if (list_empty(&vpci_dev->dev_list[slot])) continue; t = list_entry(list_first(&vpci_dev->dev_list[slot]), struct pci_dev_entry, list); + if (t->dev->is_virtfn && !PCI_FUNC(t->dev->devfn)) + continue; if (match_slot(dev, t->dev)) { dev_info(&dev->dev, "vpci: assign to virtual slot %d func %d\n", - slot, PCI_FUNC(dev->devfn)); + slot, func); list_add_tail(&dev_entry->list, &vpci_dev->dev_list[slot]); - func = PCI_FUNC(dev->devfn); goto unlock; } } @@ -123,7 +126,6 @@ static int __xen_pcibk_add_pci_dev(struc slot); list_add_tail(&dev_entry->list, &vpci_dev->dev_list[slot]); - func = dev->is_virtfn ? 0 : PCI_FUNC(dev->devfn); goto unlock; } }