From nobody Wed Jun 28 01:33:12 2023 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 4QrPGx1l8qz4ky7D; Wed, 28 Jun 2023 01:33:13 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QrPGx104vz3Dnw; Wed, 28 Jun 2023 01:33:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687915993; 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=Z7zBacHDQs5XDzK3EQhCsiEsNuCmOtS3dUUC7vdeZwA=; b=ac3x7TdgRXh/pCNkK7sQcl3t2Ul/XcbfdW68YgnNo31+9UFZ9I+pWl5O4gl2MppO07PCtq Pj0ISBII4WciUVEBDXaMa4PVdsUznU5sX2B3b/5Ql6Qp7c3DiaAssCpLkalnm5vvTTZBJC Kz0jP/86b555yY3YJX4uZZm6AB0BE7DtvYUBt/rCoNLQy+Ak9NrkOskGuw6Nipqiefn4J1 PBU84ZX26WQhjT5AXfglP+BgOKVXFvqkaHqvQUq6FnUBL8Vekuqqm7r0yjnLcvBI0GqviS /xpO6fzwM3coB7fiTxCqMyodesNC3tmB90jRYMKiXTqeuynGgzUwTzrKYyQvIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687915993; 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=Z7zBacHDQs5XDzK3EQhCsiEsNuCmOtS3dUUC7vdeZwA=; b=KpAh4GMuSOv7BMlSlfLeqy0Tri5GwUwqvKQ/dVXg49NXrXTpj0KrjpGh1Nr7WLRMBI8ZLe vLCod092U8CbUG5fWtILgO0cwfb+3jk9J+9X2WePsMeQUUaIk/IN55Wwy8TlK2ZYRhnFhJ QgswjTM0wst2UQqQCn91LOxgQLGHQj+VYxR4WYPe2mhWXiMyN2xef7TESuWSaQtJSM8lRL 1Do7JDcJDNhRA2uaz5VYYgFQgUx7nOPV/N1XUt+Vb/WtyGWuah0lbkk4RG3En9uiTGA/4k 2dBsfzAbkBioGanLixGVzppcHv4cwG6u6irn9rvIlPnDYPNWGThOptprmMyraA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687915993; a=rsa-sha256; cv=none; b=g4fTwxwx90rPkgd6oOJhMVLzhJCTMTH+Dh/mOE8mLjWa+A4/czlDjbWxeGp/9qKFBJOajl qyqrjFEsT1OxikTBolwSbutVDJlsT7yI0a8utkY/tJN29noun2MQMqCOsz/W3zyMptaFkS /W8SaPc/LeX3aKCTcKCr9BR5R5dP5eub+LZ/rT3CFER6oMB+D+UxtXD4AoBuPU1eDZ/ouc E8iQvlzRO194YIJNVRIqSROoEgfwddZG67SV+dOGq1+K08B5azniJewR7Q6LhhHB9XMcBP DBFhepKo1ooPv8HgO4qcaEbU64t8pdpfuzBDRiAGwDGXSYrHL3WepBmrRcGfTA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QrPGx00LSzFlM; Wed, 28 Jun 2023 01:33:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35S1XCss045177; Wed, 28 Jun 2023 01:33:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35S1XCkN045176; Wed, 28 Jun 2023 01:33:12 GMT (envelope-from git) Date: Wed, 28 Jun 2023 01:33:12 GMT Message-Id: <202306280133.35S1XCkN045176@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 12ce57e6d3e7 - stable/13 - pcib: Allocate the memory BAR with the MSI-X table. 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: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: 12ce57e6d3e770db9ca83a8cbaa8f332515ce3d7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=12ce57e6d3e770db9ca83a8cbaa8f332515ce3d7 commit 12ce57e6d3e770db9ca83a8cbaa8f332515ce3d7 Author: John Baldwin AuthorDate: 2023-06-19 16:15:48 +0000 Commit: John Baldwin CommitDate: 2023-06-28 01:32:47 +0000 pcib: Allocate the memory BAR with the MSI-X table. This is required for pci_alloc_msix() to work and to thus use MSI-X interrupts for PCI-e hotplug. Reported by: cperciva Reviewed by: cperciva MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D40581 (cherry picked from commit e6b838363fb473b5e35a8ae6a1da5e15f5b52960) --- sys/dev/pci/pci_pci.c | 23 ++++++++++++++++++----- sys/dev/pci/pcib_private.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/pci_pci.c b/sys/dev/pci/pci_pci.c index b735da657a6c..4284b1cbf567 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -1324,7 +1324,7 @@ static int pcib_alloc_pcie_irq(struct pcib_softc *sc) { device_t dev; - int count, error, rid; + int count, error, mem_rid, rid; rid = -1; dev = sc->dev; @@ -1336,9 +1336,17 @@ pcib_alloc_pcie_irq(struct pcib_softc *sc) */ count = pci_msix_count(dev); if (count == 1) { - error = pci_alloc_msix(dev, &count); - if (error == 0) - rid = 1; + mem_rid = pci_msix_table_bar(dev); + sc->pcie_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, + &mem_rid, RF_ACTIVE); + if (sc->pcie_mem == NULL) { + device_printf(dev, + "Failed to allocate BAR for MSI-X table\n"); + } else { + error = pci_alloc_msix(dev, &count); + if (error == 0) + rid = 1; + } } if (rid < 0 && pci_msi_count(dev) > 0) { @@ -1386,7 +1394,12 @@ pcib_release_pcie_irq(struct pcib_softc *sc) error = bus_free_resource(dev, SYS_RES_IRQ, sc->pcie_irq); if (error) return (error); - return (pci_release_msi(dev)); + error = pci_release_msi(dev); + if (error) + return (error); + if (sc->pcie_mem != NULL) + error = bus_free_resource(dev, SYS_RES_MEMORY, sc->pcie_mem); + return (error); } static void diff --git a/sys/dev/pci/pcib_private.h b/sys/dev/pci/pcib_private.h index af0b70a7add3..0dea325b6436 100644 --- a/sys/dev/pci/pcib_private.h +++ b/sys/dev/pci/pcib_private.h @@ -134,6 +134,7 @@ struct pcib_softc uint16_t pcie_link_sta; uint16_t pcie_slot_sta; uint32_t pcie_slot_cap; + struct resource *pcie_mem; struct resource *pcie_irq; void *pcie_ihand; struct task pcie_hp_task;