From nobody Thu Oct 29 08:27:39 2026 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jFcmW2JYYz6wKgL for ; Thu, 29 Oct 2026 08:27:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jFcmW1YhNz4dQg for ; Thu, 29 Oct 2026 08:27:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793262459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pc1xw9REtyjl/Es2E3Gk6oAxkd6WUBJxiA+2KMv0Y9I=; b=gfdbpxU7vV8Y4A4LSkasZE0Q1U3VD1c74x7PxkpcEOshraNTk9AmSfLUtgbRAbf5mGtdym Qe3tCsSDw9Oy/qV7aOXIHCxPd+8f0i/xpRv0Ba1rZlV/m6cp2QUPd835oXysmkz5k2hk66 N1c7n3Q6p7QB2n/allsGAnyKJgIwx4LPMhff8XNZ84hrcdyJSay4crPnRrkF5Gsw2Ync34 rqTkN0e6VeqO++VDZROhrNnQgRTzbl5Cikaab+hJrMrOnOI7WPHR3FcKRcbienXsxcrtTj 1pihKTodHvxJSV0oZzZb8orHBndLUzOx+c/eQ1OZsGoUXJs6xZWOhP9wxp7S8A== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793262459; b=Ea/DHvrGIwFwnsmQsRAOdQAja4A44ZbS6J3tJQVgsviZbvsSER2vWjlWAHX8rg2hHj84Nw SUzS8gI6sa9Jc4PxP8gZrn4rlUv53BtetPsnR2L5DRq2pqAL6s68KR/UAsDKm8Pu2vGCXO Nnw73I/sn5ldNJBeapvGGvOF27uw+0TMcyVZ0bcS2505HqeMabPiGG8HBiX9wb9uKFcHwp O7meh0B6TiD0nKFrpEkDUoW/Hk6JwpYAJp252q0ZHNnjQW6+MnRAMCm+0WYx3FEdTrCvz3 rRNkOiEI2aP8u/OKTw+8DA4ZTSViKOa5A969Q2voPNTwK3IYmn5HRCBTRa9PDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793262459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pc1xw9REtyjl/Es2E3Gk6oAxkd6WUBJxiA+2KMv0Y9I=; b=YxpB6XEcoWje525I3aSvWKPgs/sJsBvK5KB/XqV0JMdml/AunGkPMg0Kwc6QbAOZDOT5Zp 28P6Shnvrajb2cbuViwcie/VJjfTymU/FZVc+SfLsq4+Co99iyxVbPH7oDOfgJAiJE3xmm APxUhCQIYCjbRT0YIs6G9ZfAH4+0EtXnkbYhoCASfXIV6oYP1J28ccheJ8dJBhQJ8xOLFV GRKUgCxNJvvUK+jW5Fq+5yN4JyGovY1RKG8RXdu6gk5Xdaiy0C4eDkL+9Xpz8r6//Tp+jl jX4mOfoaHdLSO75ELP5tpgJYxFrltCOvym7Y5AkapERPCrlOyFxHsYbl9QQSXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jFcmW0xzYzWwK for ; Thu, 29 Oct 2026 08:27:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 47748 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Oct 2026 08:27:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Chandrakanth Patil From: Kevin Bowling Subject: git: 3189766d06ae - stable/15 - pci_iov: Reuse downstream bridge bus window if it already covers VF bus List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: Commits to the stable branches of the FreeBSD src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 3189766d06ae0d6a0b71b57cf3c48369e2c7eacd Auto-Submitted: auto-generated Date: Thu, 29 Oct 2026 08:27:39 +0000 Message-Id: <6ae3037b.47748.62ebfd98@gitrepo.freebsd.org> The branch stable/15 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=3189766d06ae0d6a0b71b57cf3c48369e2c7eacd commit 3189766d06ae0d6a0b71b57cf3c48369e2c7eacd Author: Chandrakanth Patil AuthorDate: 2026-02-10 09:23:16 +0000 Commit: Kevin Bowling CommitDate: 2026-10-29 08:23:01 +0000 pci_iov: Reuse downstream bridge bus window if it already covers VF bus If the parent bridge's [secondary, subordinate] window already covers the VF bus (e.g., programmed by BIOS or a prior PF), skip allocating PCI_RES_BUS. This avoids a duplicate rman allocation in the multi-PF case while still allocating when growth is actually needed. Reviewed by: ssaxena Differential Revision: https://reviews.freebsd.org/D52163 (cherry picked from commit feb0a7e19f3c2e4c7eb90668b1e3dc34b5bb6dd6) --- sys/dev/pci/pci_iov.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c index 6497a5599257..daebb416f809 100644 --- a/sys/dev/pci/pci_iov.c +++ b/sys/dev/pci/pci_iov.c @@ -748,16 +748,27 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg) last_rid = first_rid + (num_vfs - 1) * rid_stride; if (pci_get_bus(dev) != PCI_RID2BUS(last_rid)) { - int rid = 0; - uint16_t last_rid_bus = PCI_RID2BUS(last_rid); - - iov->iov_bus_res = bus_alloc_resource(bus, PCI_RES_BUS, &rid, - last_rid_bus, last_rid_bus, 1, RF_ACTIVE); - if (iov->iov_bus_res == NULL) { - device_printf(dev, - "failed to allocate PCIe bus number for VFs\n"); - error = ENOSPC; - goto out; + device_t pcib = device_get_parent(bus); + uint8_t secbus = pci_read_config(pcib, PCIR_SECBUS_1, 1); + uint8_t subbus = pci_read_config(pcib, PCIR_SUBBUS_1, 1); + uint16_t vf_bus = PCI_RID2BUS(last_rid); + + /* + * XXX: This should not be directly accessing the bridge registers and does + * nothing to prevent some other device from releasing this bus number while + * another PF is using it. + */ + if (secbus == 0 || vf_bus < secbus || vf_bus > subbus) { + int rid = 0; + + iov->iov_bus_res = bus_alloc_resource(bus, PCI_RES_BUS, &rid, + vf_bus, vf_bus, 1, RF_ACTIVE); + if (iov->iov_bus_res == NULL) { + device_printf(dev, + "failed to allocate PCIe bus number for VFs\n"); + error = ENOSPC; + goto out; + } } }