From nobody Wed Sep 23 06:44:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1780585736; cv=none; d=zohomail.com; s=zohoarc; b=MLpoWiexoG/Nc4Ge3/zA2fJ9ZfBfEQDcOcd8zVkQ4+2s0FplZXK1WtrZfJIsk2e26DIyqdY26rDFSshsAvRzrYsPRotCP/S6YW5SUo5q0srpYv7oTjehb01vBf5clYKQxi1k4XOmWqSil2LcruXfWMD/Bwrc/r2AwV9oXJtxzwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1780585736; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xRdDzAJ66h/qKzlMtNZ7QYJac4Hlkm37yqxsR8KWCKU=; b=VQnSB+QSe6oasxV6hIobJd3XeAPexUTNEDkaCoUTUBNfsororATy/W1PyIZWLecVATkzfBKOQ9pYXqJTNRgJVyOnF7f3p71L5OM9dLy7CRGHRguPkl8TWay/2C/jbz3mhRioYoZn+wLa8vOqMyqBY5ci0qh5fzIxzieLFefFetY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1780585736899134.88275335204446; Thu, 4 Jun 2026 08:08:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1328054.1592772 (Exim 4.92) (envelope-from ) id 1wV9gH-0006sG-18; Thu, 04 Jun 2026 15:08:25 +0000 Received: by outflank-mailman (output) from mailman id 1328054.1592772; Thu, 04 Jun 2026 15:08:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9gG-0006ou-Bg; Thu, 04 Jun 2026 15:08:24 +0000 Received: by outflank-mailman (input) for mailman id 1328054; Thu, 04 Jun 2026 15:02:58 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wV9b0-0004G8-Qj for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 15:02:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wV9b0-007lC5-7F for xen-devel@lists.xenproject.org; Thu, 04 Jun 2026 17:02:58 +0200 Received: from [10.42.69.5] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a21939b-bab6-0a2a0a5309dd-0a2a4505d594-24 for ; Thu, 04 Jun 2026 17:02:58 +0200 Received: from [209.85.221.171] (helo=mail-vk1-f171.google.com) by tlsNG-c201ff.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.1) (envelope-from ) id 6a2193a1-aaa8-0a2a45050019-d155ddabe126-3 for ; Thu, 04 Jun 2026 17:02:58 +0200 Received: by mail-vk1-f171.google.com with SMTP id 71dfb90a1353d-59c9b666822so552106e0c.3 for ; Thu, 04 Jun 2026 08:02:57 -0700 (PDT) Received: from localhost ([2a03:2880:7ff:51::]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8428291a837sm6331464b3a.60.2026.06.04.08.02.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2026 08:02:15 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=20251104 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780585377; x=1781190177; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xRdDzAJ66h/qKzlMtNZ7QYJac4Hlkm37yqxsR8KWCKU=; b=oUfZtYvKlpaVeaaEzGPr5Z5k9SglbnrqSdw0ipnhKlBApyFVl2MUGcu2F5K4jSpSug 6PEbkxcbUxOE+6DvX23RKjqh0Hx+pOHgBw9fjMpsqHoUw35Cs4/pr4dY9oQMo3iP3AP8 9X86AH7aJuAvX2q+BqmNN59e8TFAm7xOeagjaeTq/xTJhgrH9giDLpZFx0xH9CszJUni EJVL5U6GWCpRL7gj3aQYKSmoV+cHZ6qsemX+M3S+nBX2NQGkqNeh3e9lZH4KTf/tHxVc AQHiTpdyUUTr3lma23X/pQqzo5bLKCC3PJGMLlxgMSnKmAylGnh8sX+PBOxIBnV0hX9i EtXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780585377; x=1781190177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xRdDzAJ66h/qKzlMtNZ7QYJac4Hlkm37yqxsR8KWCKU=; b=UR6FMUYn3QvgLbWfs9cLmIRPM8BihqpFXUJ6k4++iTutVz/25+yhXVvllt7V8bpETR FA8DcN6NNXk41kUwo+jcWaJ6YcfXor9I73xSHjm0OzzDZFJdOhusnRK3T36EONH2v7YE XewBQjLKf3iuYHUTZ8OtySgQj4MJzkNgTiDtvRDs3Fd2xpLZurPMA7veRGHENmTtXzzr MJaN6ehMPjUDfOB+zGmSdHCi+RI4wqnQL+kgf0JgvQuK4O2Hi8p0dOgsHE5LfhfM4MV2 4RHISHsfLk+27Wps66QGqhkMUZvsY/BWLYZ2twMyqNPt/2yXAIbHc6XzKPwP1PBXVjsj pOcA== X-Forwarded-Encrypted: i=1; AFNElJ+Bj0he9nrjQAT1Zrn9DO8liukS2lS1efS4DacKACjT81dZAqqZWqIOk4wifONAJZoLmyr+Bj+xsik=@lists.xenproject.org X-Gm-Message-State: AOJu0Ywxk0VFkllnSbUAEsyc600O/0xfwQNeM2NQXh9RQNfhyAxiaBqq h8TALIthS4tAp9pq9AHiBG+k2+BgOgJJiCOtm1uhTyixDz3014CI9/p90G2zkg== X-Gm-Gg: Acq92OFnAYgCrHmcdAw/51KgRbScroToyS1QlSKIp4+zb/hfByMaB4AvrXtjfvXhOvP UQu1KymD9uHbseKLRj9iV2D/8wH87CNc6yRJpSdjbdxaxz1RNUDoJB/B5+pddOhraWGAnvrzp/1 dRAYS2D/BwlmiaG8i8ML0/hffsV3z5Mqx7bQCKuBETdJ6/wG0oxFyclZTGlNRo1Hj9dGe9yDGFE xFlQM1pMENAH0cZTEZNz+arqbbzrRtDdlgSsA6bMTfHJoAP7xX1jpL7SJBj+d9jB4GVGGqb9UaR eqgbYiSpz4r2WFny0GtkbmAj0vAznWiwQEhxMb7zfu7cTyqfMCj/WrgVAB7OjbIHjg4uyXxsyRO VrGYulVPF/EkgJLtTWnGppuZPjvBguAsNVYWuVrzcJQp58meGEdJ6llP7Yh8FoAPEDXDSJipO7D wfMpBemskkxBGKcD3eNK0xv/lR/2pg8euYNeTxcKY= X-Received: by 2002:a05:6a00:218e:b0:842:5ad6:2d3 with SMTP id d2e1a72fcca58-84284ef2c41mr8159937b3a.38.1780585335784; Thu, 04 Jun 2026 08:02:15 -0700 (PDT) From: Dimitri Daskalakis To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Mahesh J Salgaonkar , Oliver O'Halloran , Niklas Schnelle , Gerald Schaefer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alex Williamson , Jason Gunthorpe , Kevin Tian , Ankit Agrawal , Leon Romanovsky , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko , Keith Busch , Alexander Duyck , Jakub Kicinski , Dimitri Daskalakis , linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [RFC 12/12] PCI: Reserve bus range for SIOV devices Date: Thu, 4 Jun 2026 08:01:53 -0700 Message-ID: <20260604150153.3619662-13-dimitri.daskalakis1@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> References: <20260604150153.3619662-1-dimitri.daskalakis1@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-c201ff/1780585378-D8F7E443-070AF77C/0/0 X-purgate-type: clean X-purgate-size: 2550 X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1780585738274158500 Content-Type: text/plain; charset="utf-8" From: Dimitri Daskalakis SDI routing IDs are computed from the PF's devfn plus an offset and stride, exactly like SR-IOV VFs. When the stride pushes routing IDs past the current bus number, additional bus numbers must be reserved during PCI bus scanning to ensure the SDIs can be enumerated. Add pci_siov_bus_range(), which walks all SIOV-capable PFs on a bus and returns the maximum number of additional buses required. This parallels pci_iov_bus_range() for SR-IOV. The bus range is pre-computed during siov_init() by computing the bus number of the last valid SDI. Note: The PCIe 7.0 spec outlines an alternative RID assignment algorithm for SDIs. The spec states a Virtualization Intermediary (likely a hypervisor) after boot can compute the set of RIDs that are valid for SDIs. There is a six step algorithm to compute this RID allowlist. To keep things simple, we are only adding support for strided RID assignments. Assisted-by: Claude:claude-opus-4.7 Signed-off-by: Dimitri Daskalakis --- drivers/pci/probe.c | 4 ++-- drivers/pci/siov.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index bebc32c8d374..9ef6827ab345 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -3100,8 +3100,8 @@ static unsigned int pci_scan_child_bus_extend(struct = pci_bus *bus, for (devnr =3D 0; devnr < PCI_MAX_NR_DEVS; devnr++) pci_scan_slot(bus, PCI_DEVFN(devnr, 0)); =20 - /* Reserve buses for SR-IOV capability */ - used_buses =3D pci_iov_bus_range(bus); + /* Reserve buses for SR-IOV and SIOV capability */ + used_buses =3D max(pci_iov_bus_range(bus), pci_siov_bus_range(bus)); max +=3D used_buses; =20 /* diff --git a/drivers/pci/siov.c b/drivers/pci/siov.c index 7372ce95714b..6405a8830052 100644 --- a/drivers/pci/siov.c +++ b/drivers/pci/siov.c @@ -111,3 +111,24 @@ void pci_siov_release(struct pci_dev *dev) if (dev->siov) siov_release(dev); } + +/** + * pci_siov_bus_range - find the max bus number consumed by SDIs + * @bus: the PCI bus + * + * Returns max additional buses consumed across all SIOV PFs on this bus. + */ +int pci_siov_bus_range(struct pci_bus *bus) +{ + int max =3D 0; + struct pci_dev *dev; + + list_for_each_entry(dev, &bus->devices, bus_list) { + if (!dev->siov) + continue; + if (dev->siov->max_SDI_buses > max) + max =3D dev->siov->max_SDI_buses; + } + + return max ? max - bus->number : 0; +} --=20 2.52.0