From nobody Tue Feb 10 09:30:41 2026 X-Original-To: dev-commits-src-all@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 4f9GWj5rhpz6RlcL for ; Tue, 10 Feb 2026 09:30:41 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f9GWj3Lrdz3CnC for ; Tue, 10 Feb 2026 09:30:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770715841; 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=88pyhemmKjXRK1XQugAXZutybubMr0/4DahQwOeoC2A=; b=ndS1fsSATkOTuvrHAxn/HI/UVex2GPbQWR+b+UW+iMGVXC+/j21atXPsD6m9ai5YbGK0FM SuYYm9eF8JV7PGBkEPQfs6oTOKDpgxak/vcOA/1MMohlFMmYTIwvXFXWf2XEPfUJ14FrSW x2ZR4z5IiyCiFZF48v6gaiFM3CJNSodasXlTq5m7jJZjelW33gQgEQjY8GZPxTu+ZM6wZ/ McR1EXYOB8nSf0w2g4W6WeIqYADLN5SAgkJ3C/gBJeVKyKCWQvOqPC2NejQ+RzEMUPNgB5 6e4T+lqitD7TFkQWX2iAF9PqRO63ItjX1pOIqUIXuudKUjCqWrZjWd6+t/udwQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770715841; a=rsa-sha256; cv=none; b=iW6smtb8kqivGqasL8K/QbDLF1VPUt9Aoqd8SXWb9J33Sm7u1lnEZ8jqcAU8VOa4V/V505 E9nbbcsU65qjHToUIkM/VQgU/dS24Vue2+nkiq8Ka7u1sp8kt2in8voJcbt9yiPqVUS1fu qF5H0OZdjTf/5Ymzfx+9PuAY4cAtMSKkzZky+Zn6OvxDJKhWwgKEjK0eF5EvxwHQUzKfuq k5oPB+E2C0wckUUb3zMbmND0BiAht4iThwRs2Fy/KTqvv+AHZr4Ji8dXGaLUkdwniYAd1p 3xNs3QWxIH/rwTtKimhhR2v2Oy4OveQlBFUd90dkF5rncoR0/3KWt0OxHLojMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770715841; 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=88pyhemmKjXRK1XQugAXZutybubMr0/4DahQwOeoC2A=; b=sjKs8me4qjXSdr4fOtW+HlmQH4swYH9w5tPu6Xwvv5X5UwJxMofPRJ6K+Tx0U8g2RsWLXU X7vkiyjbs/t5+7S7df0bl4LsAvmI7S3r4PYo1Oeu5dI8Ye1aYgt+3HjmNU2XyLmko3fz/i OoED1qRGHxqnZkt5wtPYyf/j0Fi3cK6irv2ffew74/DFQiEcj7KCKeGYmRWcWswmMz5v9d n6m6a/2imPbPQdl95AR9REm2u+BDwkGlojBVMXE+D9GnX+omP7ae8uBpdNV1i22La+w32h 0R3FiXBV+tj1rptaRZnFQkneb8U+rMYnBWTxZvQaPKvFRRJly+EJQJAvfttA3g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f9GWj1wVPz1BZK for ; Tue, 10 Feb 2026 09:30:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 18e09 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Feb 2026 09:30:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Chandrakanth Patil From: Sumit Saxena Subject: git: feb0a7e19f3c - main - pci_iov: Reuse downstream bridge bus window if it already covers VF bus List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ssaxena X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: feb0a7e19f3c2e4c7eb90668b1e3dc34b5bb6dd6 Auto-Submitted: auto-generated Date: Tue, 10 Feb 2026 09:30:41 +0000 Message-Id: <698afac1.18e09.6eae697b@gitrepo.freebsd.org> The branch main has been updated by ssaxena: URL: https://cgit.FreeBSD.org/src/commit/?id=feb0a7e19f3c2e4c7eb90668b1e3dc34b5bb6dd6 commit feb0a7e19f3c2e4c7eb90668b1e3dc34b5bb6dd6 Author: Chandrakanth Patil AuthorDate: 2026-02-10 09:23:16 +0000 Commit: Sumit Saxena CommitDate: 2026-02-10 09:30:06 +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 MFC After: 1 week --- 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 e0e47e11d401..0e6104fe37f2 100644 --- a/sys/dev/pci/pci_iov.c +++ b/sys/dev/pci/pci_iov.c @@ -735,16 +735,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; + } } }