From nobody Sun Aug 16 00:02:29 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 4hMx3n6q1wz6p4Nd for ; Sun, 16 Aug 2026 00:02:29 +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 4hMx3n5V57z3Jln for ; Sun, 16 Aug 2026 00:02:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1786838549; 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=FLS52my4viy59LklNeGH0i+EIfay+oxZKwwIO1p8R2s=; b=nO36k0ufg2D5UI7uf5vhTZSWS2R7rQJRQo9Fsy6EF59tEeDw8KPrVcZdY1+o3XFGycBp5a JTr4Z3MJKmrGPD7+DeOuwFu6RG30XYKk01cD2oXwnHTXhTwci+lfGFHjg1TYI7wcb4dg7y H9DX12NqkkzdCnhzAoIaXL01bPHFGi86ejmjK/KDlEhtfeM3clYiCNdTx399tqMV+A3ev9 qWNZf455O4053iRgCBTzmlcZy+2F8XBaRX8OyUD56KERSq3SZhwlOEkRmKDPWOCPQdA2r/ J3cMQ6uYS6Np+scTkWt/lbFU8AWRqZcyUyu05Tp7Tz3tmNjo25owOCpumTyFQA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1786838549; a=rsa-sha256; cv=none; b=RGDmqACcyG1BXEfgi264T2eKNQFGGxmVPkTG3dqmN7QmaAV6Fshz365rOY0s4eV/umA8tp ZUOjb4f9krv7QPPZ9Ub9USim4GW8mA7YpDtmIRqeJJv9am+rqSTKD10LeFXkJIABsY+jY8 Fy3+NyRJtYsqbaGIgoCNBZQ4SqCxsXek/GMZZ1m4evRrkFCx9i4iRXynFZyKUmvkU4C2cq 0En42wP2s4JAi/Z+O6mPo+Iqil2P4UDunHQfkCXDVpl30OCF0S5gPhXabG2kbGvvwxsyMj Zl+XaQWrwFtwx5rbUJ6MsF/lSphvw+ektONTknJmvSiB9Ifu7H+xpKpmLajNJw== 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=1786838549; 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=FLS52my4viy59LklNeGH0i+EIfay+oxZKwwIO1p8R2s=; b=tLQ3SuX3qi3fsuQiuFkxTuHM8ANvRUE/g8iddCfH8GJB5s71SdCD9u4gGLKmnkmf86BlMu ETYXhISV6BsWee6G2s6cZV70pLX+qjHGSVpORtkoIkohnImlCzNFOi0iujuQIUtO1N1/bT S5Sz+yw0lJoSLX6Mp+D/QZTATFHea3MViNkK7XV/CMesdA5x5/82d8OH4wxG8f3BmjIubm URMWLsmK2W42kUc1Gy7+iKNAbu2h1e+ol0sm4TQ5eQLBg95eMWNqEBcMIBxDa1fXFnKTat 17JfBcBz3ICOxqJP4js0TN/S1PHiJaWz46TGCp5pBxBgp+WHN7X/FND8OvvA6A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hMx3n4Yrfz1443 for ; Sun, 16 Aug 2026 00:02:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3207e by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 16 Aug 2026 00:02:29 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 5b48968c1a57 - main - pci: Export pcie_flr_supported() 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 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/main X-Git-Reftype: branch X-Git-Commit: 5b48968c1a57bd1a7f086d7e09add59afa158340 Auto-Submitted: auto-generated Date: Sun, 16 Aug 2026 00:02:29 +0000 Message-Id: <6a80fe15.3207e.62b58d4c@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=5b48968c1a57bd1a7f086d7e09add59afa158340 commit 5b48968c1a57bd1a7f086d7e09add59afa158340 Author: Kevin Bowling AuthorDate: 2026-08-15 23:47:10 +0000 Commit: Kevin Bowling CommitDate: 2026-08-16 00:01:35 +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. MFC after: 2 weeks Sponsored by: BBOX.io --- 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 c94982f5f218..65d1f0bc867b 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 @@ -863,6 +866,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 34ee261604a2..430eca38c0b9 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -7078,6 +7078,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. * @@ -7102,15 +7124,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 27bac22c7896..19ba20a7d1f3 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -711,6 +711,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);