From nobody Sun Aug 30 00:30:33 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 4hXY1k1sS6z6pjtq for ; Sun, 30 Aug 2026 00:30:34 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hXY1k1LMFz3Yg8 for ; Sun, 30 Aug 2026 00:30:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788049834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mAlk5lswXp+KC5rXjtSaeFq0xy0G+yK2/LhYjVCYaJE=; b=mk884CKFz1rrS61TEbEhniN5HQDKfVhE7biIbQJ+GylFFL56Sl0CX4Z21fxwn4OJFWf/tL NtNpwtiytPye2qj57wB7LglWPjKBlgVMRdbdzpNtpb+B7km+uychD6viT3mATPdT15cjdS NvRMUTFxNjNjrFJ2lHPzrkX2eh1RULknO3oK9vgmjeB60/zMc8Qzu0n2My3fLecpuoc0g6 si5s1W8YMzWW78X+BNSv4ARCwIid7gkKaTDfoQABN7acn1BqIvwwDCVy394m73J6CySvXw 2MPuKh34kk1So8EImpcMMLnm0/r5dgcPsTknUQWIPagmV+vNN/sIiBmYXXJ5tg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788049834; a=rsa-sha256; cv=none; b=anOfHG765byJwSNTaauGg9xR4A9jC37xwUUtmjsQckS8FVFqBKQEPg/3uR1Ho4PhvuSefp xKwz/euiJVzMN4dqd0Fnc4G/Y7gAkudMSXfVs8FJMYZ+p3OvyR4ifdC5YnMWgjMjYlGdE9 +908pAkBliKuHyd1wjRqyryhfwgI4x5RfS9qbK8d8KW3Lkc1uOJ1370scccEZUOQY8k2Hg SoKIiR/BC2SHQYmbLNkXaWWDQQ2Io4MST/02/lojq3TsL4T0ru/BMrKT9bxnECTGSvchXg GGbMwtFB8drfnZn+beI5Y8EuqDjQFs2HF8mu9koKDI/NcjaHGc9ukE0GEd86Iw== 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=1788049834; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mAlk5lswXp+KC5rXjtSaeFq0xy0G+yK2/LhYjVCYaJE=; b=hBAOOGcMruqKwHyOENWF/P4rkIe/Ht1lfZgYGYnbOwV41666Xn9enf0oAnDYTjl2MedOvY AmfYYqAgIP/VAqQ5L+QFkCvq5Jc4QP3jx4jey21vBif93FrBu50FOGJtrz0ycpH4m+dBfM 4EbFBTPZtCFO84IO8DoMbNJx2Tm+KOVWEHwjRVFk+KckPBaUq9yqsV/48asluFSfv4Lc/5 8erut78RaGL/bWlJNyzDvdhNuDnSWwl7bFKrfCogF5kRDjaS1oDe7X0NZQdJU1mD3yE9Gb ZvrG7H1Q41WS872DUT1h30eSCGsS2OJYXC6/FNgB2OwpBGmENkHENdBReq+Zig== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hXY1j725jz12Nt for ; Sun, 30 Aug 2026 00:30:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3909c by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 30 Aug 2026 00:30:33 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 12b31da2a088 - stable/14 - pci: Export pcie_flr_supported() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org List-Id: 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/14 X-Git-Reftype: branch X-Git-Commit: 12b31da2a088af258a70596994b323180cbe2801 Auto-Submitted: auto-generated Date: Sun, 30 Aug 2026 00:30:33 +0000 Message-Id: <6a9379a9.3909c.df0df99@gitrepo.freebsd.org> The branch stable/14 has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=12b31da2a088af258a70596994b323180cbe2801 commit 12b31da2a088af258a70596994b323180cbe2801 Author: Kevin Bowling AuthorDate: 2026-08-15 23:47:10 +0000 Commit: Kevin Bowling CommitDate: 2026-08-30 00:29:29 +0000 pci: Export pcie_flr_supported() Move the capability and quirk checks used by pcie_flr() into a public side effect free helper. This lets callers determine whether an FLR can be attempted before quiescing a device or saving state. The helper considers the advertised PCIe FLR capability and both the enable and disable FLR quirks. Sponsored by: BBOX.io (cherry picked from commit 5b48968c1a57bd1a7f086d7e09add59afa158340) --- share/man/man9/pci.9 | 15 ++++++++++++++- sys/dev/pci/pci.c | 31 ++++++++++++++++++++++++------- sys/dev/pci/pcivar.h | 1 + 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/share/man/man9/pci.9 b/share/man/man9/pci.9 index d7b96f89f6ea..9e45b37b7580 100644 --- a/share/man/man9/pci.9 +++ b/share/man/man9/pci.9 @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 6, 2026 +.Dd August 15, 2026 .Dt PCI 9 .Os .Sh NAME @@ -72,6 +72,7 @@ .Nm pci_write_config , .Nm pcie_adjust_config , .Nm pcie_flr , +.Nm pcie_flr_supported , .Nm pcie_get_max_completion_timeout , .Nm pcie_read_config , .Nm pcie_wait_for_pending_transactions , @@ -169,6 +170,8 @@ .Fc .Ft bool .Fn pcie_flr "device_t dev" "u_int max_delay" "bool force" +.Ft bool +.Fn pcie_flr_supported "device_t dev" .Ft int .Fn pcie_get_max_completion_timeout "device_t dev" .Ft uint32_t @@ -859,6 +862,16 @@ Note that .Nm pcie_flr does not save and restore any state around the reset. The caller should save and restore state as needed. +.Pp +The +.Fn pcie_flr_supported +function returns +.Dv true +if +.Fa dev +supports FLR according to its PCI-express capability and the PCI quirk +policy. +It does not alter the device. .Ss Message Signaled Interrupts Message Signaled Interrupts .Pq MSI diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index e96508ab0fe8..e947d9b4f6b4 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -7086,6 +7086,28 @@ pcie_apei_error(device_t dev, int sev, uint8_t *aerp) } } +/* + * Return true if the device supports FLR, taking both its advertised + * capability and the PCI quirk policy into account. + */ +bool +pcie_flr_supported(device_t dev) +{ + struct pci_devinfo *dinfo = device_get_ivars(dev); + int cap; + + cap = dinfo->cfg.pcie.pcie_location; + if (cap == 0) + return (false); + + if (!(pci_read_config(dev, cap + PCIER_DEVICE_CAP, 4) & PCIEM_CAP_FLR) && + !pci_has_quirk(pci_get_devid(dev), PCI_QUIRK_ENABLE_FLR)) + return (false); + if (pci_has_quirk(pci_get_devid(dev), PCI_QUIRK_DISABLE_FLR)) + return (false); + return (true); +} + /* * Perform a Function Level Reset (FLR) on a device. * @@ -7110,15 +7132,10 @@ pcie_flr(device_t dev, u_int max_delay, bool force) int compl_delay; int cap; - cap = dinfo->cfg.pcie.pcie_location; - if (cap == 0) + if (!pcie_flr_supported(dev)) return (false); - if (!(pci_read_config(dev, cap + PCIER_DEVICE_CAP, 4) & PCIEM_CAP_FLR) && - !pci_has_quirk(pci_get_devid(dev), PCI_QUIRK_ENABLE_FLR)) - return (false); - if (pci_has_quirk(pci_get_devid(dev), PCI_QUIRK_DISABLE_FLR)) - return (false); + cap = dinfo->cfg.pcie.pcie_location; /* * Disable busmastering to prevent generation of new diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index 7e88541c69a3..7701b82cc688 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -697,6 +697,7 @@ uint32_t pcie_adjust_config(device_t dev, int reg, uint32_t mask, uint32_t value, int width); void pcie_apei_error(device_t dev, int sev, uint8_t *aer); bool pcie_flr(device_t dev, u_int max_delay, bool force); +bool pcie_flr_supported(device_t dev); int pcie_get_max_completion_timeout(device_t dev); bool pcie_wait_for_pending_transactions(device_t dev, u_int max_delay); int pcie_link_reset(device_t port, int pcie_location);