From nobody Thu Jan 29 15:39:56 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 4f23HK0RjZz6Qrhd for ; Thu, 29 Jan 2026 15:39:57 +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 4f23HJ5kYNz3xZm for ; Thu, 29 Jan 2026 15:39:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769701196; 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=dUc9duDZKn4h95yaQxBqGtxXgDdZCLNnpewaZ5GWQxk=; b=e0Radytv2iJWIUyrkfqNrX8WZvjEUWxdwpPZIVjMTcgA5BgpglvJGoNmh6xvlx2OQcLGW/ jOS9Ku8dL+TBV0IzfWA8Nf5MHcjUOOTuGGU7y8yaPn7DlIzt3cyi0kTMkXY3dMzkn/E09f KwLLQRBBem3Rn3iFjO9foncdVyQFxP1NDpJbCg7EfKWcKhF2KODNTdYIoHXzkjqy8kHBIQ pgQ32rbu0F8hSLT06a7028o//tBamwfnK6Fze9DmhY3qVyttw+pzSbbPtmbapvTcZfOvyh x7iMbK1fAbXqUWfHAu90IdRubMQbwab6B5MoA8/5g9acU2eS+4JxTpMonZJafw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769701196; a=rsa-sha256; cv=none; b=xPRx1tEJ03NPXUP34ojQVPZtLlk/K9JpC/y8Rce3rmj9RZ+oQ/9BqXy/MdrNb66ueLTuuy B03dsN0/vf/PrKnEabTOQegnBFIySq4STYjcnUXLMqSSMCtnYVksmdav4R4fzi+3StyLYh S0bfBsPxZEedPzeVyJSd9gHQhxxfLh+VAG3dHHXEdCl9fVeQUtDXmAMT9U4qsuhEOP6hCM 6x0C56uqoMREyKAulwbM28pG372azYgFWy+LJvRmpX6uTHYpgKhu7aLxM7ljR4H5jXOAu4 6+VwiQJGslD2YhTd63BDTJ+Ieg0XVdo6JsGZ5Udkf8lOzogB8Q+BPqUajKh7zg== 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=1769701196; 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=dUc9duDZKn4h95yaQxBqGtxXgDdZCLNnpewaZ5GWQxk=; b=SYUyD6xoF8LAExTJR3iZ6KjozemqAOfsw7UlKwzXLWRnPgJ5/gvObJMwsJ59pNeCGy8wKc mXzZSW73pO86dpEADzrweSrMQz8IxPnZaOAGAEvLC8XM5a9Y0rcOsDLv2bbST6+rk/o+7Y V4djfwyyubWPWycNGspGaI/VQwE5ulKjKixCESwohpv4dEATceei8S3zUGGjfPXk1cb+9Y spzWoUkDmNm+sPJfv2K7FANUn5kajyyB3+zcOiHZLI6JZ+UfihpWib/hTWHdoxv2crbcy1 aKzM922rDVJ/cHrDlil14EdWqMvV/VnfD4Oem3kZYJLf7Y16aLLwjcrZ6MBl0Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f23HJ4r3xzkmK for ; Thu, 29 Jan 2026 15:39:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3959a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 29 Jan 2026 15:39:56 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Chandrakanth Patil From: John Baldwin Subject: git: f3ab9690c2ff - stable/14 - pci_iov: Support dynamic subordinate bus growth during VF creation 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f3ab9690c2ffaed003a9e196d3501efb25890917 Auto-Submitted: auto-generated Date: Thu, 29 Jan 2026 15:39:56 +0000 Message-Id: <697b7f4c.3959a.1038041d@gitrepo.freebsd.org> The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=f3ab9690c2ffaed003a9e196d3501efb25890917 commit f3ab9690c2ffaed003a9e196d3501efb25890917 Author: Chandrakanth Patil AuthorDate: 2025-07-29 00:28:51 +0000 Commit: John Baldwin CommitDate: 2026-01-29 15:22:37 +0000 pci_iov: Support dynamic subordinate bus growth during VF creation Certain SR-IOV devices enumerate Virtual Functions (VFs) on a different PCIe bus than their parent Physical Function (PF). In such cases, the default subordinate bus range assigned by BIOS may be insufficient to cover all VFs. This patch dynamically expands the subordinate bus range by: - Allocating additional bus numbers using bus_alloc_resource() when VFs are initialized - Releasing the reserved bus range during VF deletion via bus_release_resource() Reviewed by: jhb (cherry picked from commit f7951799877c16cb901be1acc8d6643f0693cec4) --- sys/dev/pci/pci_iov.c | 25 +++++++++++++++++++++---- sys/dev/pci/pci_iov_private.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c index b9e22fafe103..920d13e99ea0 100644 --- a/sys/dev/pci/pci_iov.c +++ b/sys/dev/pci/pci_iov.c @@ -734,11 +734,18 @@ pci_iov_config(struct cdev *cdev, struct pci_iov_arg *arg) first_rid = pci_get_rid(dev) + rid_off; last_rid = first_rid + (num_vfs - 1) * rid_stride; - /* We don't yet support allocating extra bus numbers for VFs. */ if (pci_get_bus(dev) != PCI_RID2BUS(last_rid)) { - device_printf(dev, "not enough PCIe bus numbers for VFs\n"); - error = ENOSPC; - goto out; + 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; + } } if (!ari_enabled && PCI_RID2SLOT(last_rid) != 0) { @@ -788,6 +795,11 @@ out: } } + if (iov->iov_bus_res != NULL) { + bus_release_resource(bus, iov->iov_bus_res); + iov->iov_bus_res = NULL; + } + if (iov->iov_flags & IOV_RMAN_INITED) { rman_fini(&iov->rman); iov->iov_flags &= ~IOV_RMAN_INITED; @@ -900,6 +912,11 @@ pci_iov_delete_iov_children(struct pci_devinfo *dinfo) } } + if (iov->iov_bus_res != NULL) { + bus_release_resource(bus, iov->iov_bus_res); + iov->iov_bus_res = NULL; + } + if (iov->iov_flags & IOV_RMAN_INITED) { rman_fini(&iov->rman); iov->iov_flags &= ~IOV_RMAN_INITED; diff --git a/sys/dev/pci/pci_iov_private.h b/sys/dev/pci/pci_iov_private.h index 7ae2219b936d..ecf0a9b21be5 100644 --- a/sys/dev/pci/pci_iov_private.h +++ b/sys/dev/pci/pci_iov_private.h @@ -39,6 +39,8 @@ struct pcicfg_iov { struct cdev *iov_cdev; nvlist_t *iov_schema; + struct resource *iov_bus_res; + struct pci_iov_bar iov_bar[PCIR_MAX_BAR_0 + 1]; struct rman rman; char rman_name[64];