From nobody Mon Jun 19 16:16:12 2023 X-Original-To: dev-commits-src-main@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 4QlFHw5Z0Kz4dtZp; Mon, 19 Jun 2023 16:16:12 +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 4QlFHw3VPpz3N3j; Mon, 19 Jun 2023 16:16:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687191372; 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=mT0ma8m1kFjmruayQiWFZ6TvmFoIncgq5vRgxAIaL1Y=; b=KUywjcNOsZfZeHh1zQQaWFjTmsX8Tv0oFMiDazvgnIWTNeXGh0FF9nWV7ruAdixNHQDTbf L/yKLw1XFYjdzgv3dVUE3UHkwbc0S70gyGTd/+bg86jfCCOmMuV0jcG4QAVdh0BbV+vwQn QCXUO9TU/NAv1iow9Q+r+ta6Zhlo8UME6Z8gnNSrAUn5wQO2calEAZzQen0iVF6stgfdmD DUb6PcmkN0PHpJMkQ+VObAud8Dci7frHpon2rktZFXZWB1Jh0jrk5ZxNZPMhu7Gy6P3rnW JK8WS4XIZy7mq1girCVHuEYVI2uSJseApgRByaL3OswsR+E18pDtnYu58sh+0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687191372; 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=mT0ma8m1kFjmruayQiWFZ6TvmFoIncgq5vRgxAIaL1Y=; b=LfoSxobqpMYKaV9ulBGK+LDqgbgcv2xDLjFnu7OR590yCAIAoJ3D0JbWlqHgkXb5KPHjaU BUdjsSAYwmKAX0I4M2dicWjr0ePNvfPQRwm0702F3UPkrUQ9+gSvph4ieW35dDHNrkz2ZZ YB3TYPrUty8jPtUSvo9BAw6r2P4aSmKpTCS3zBDvb21IzZHcXATYZBHaplSfwH8s4eqefD njAanxs7PLvN/ROxz6qUHTTYjHRVHZIBIySgqV9JDb/4Xjzn8unMu7k+aao4fZgyQNWfnT G40Q/IFwseQ6ZLtF4ObAFsp0rU6Ri8gNUr/eJ0cCmc0Egjdc7WWokTsr7s1N9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687191372; a=rsa-sha256; cv=none; b=mEohK0IL7RGUL4gq2I9la4Kthsty2NQwuhaIxdfWnt1iat4ciSFVs9ndME8joebEeG0OPL 7PWNfJGREXzmVVnREEjE7XXT5VNj+b1ns4q9QbmbmEWhXP7PefA85ROuwz89or1Uh+xpgq 3fF/l27mDOKTTG3kC/GTDIKtXBKF1Tz6auZw5ZEt+5d6FVmD0PhzACEvrjPSmf6mZR5jFI oejqHZzpqPUomGGzXi7nj9EnO9CekgnmWR/nlmEkANVmzPlh49litiid5KMzHcC3NO6wIE /Fnx34T5eNBOByhKSc7zsw2gNENuq+LXI8XSgPWY3h5+CKj0XzHxRRJEd+d6aw== 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 4QlFHw2c5QzP6Y; Mon, 19 Jun 2023 16:16:12 +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 35JGGCUf050012; Mon, 19 Jun 2023 16:16:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35JGGCbd050011; Mon, 19 Jun 2023 16:16:12 GMT (envelope-from git) Date: Mon, 19 Jun 2023 16:16:12 GMT Message-Id: <202306191616.35JGGCbd050011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e6b838363fb4 - main - pcib: Allocate the memory BAR with the MSI-X table. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: e6b838363fb473b5e35a8ae6a1da5e15f5b52960 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e6b838363fb473b5e35a8ae6a1da5e15f5b52960 commit e6b838363fb473b5e35a8ae6a1da5e15f5b52960 Author: John Baldwin AuthorDate: 2023-06-19 16:15:48 +0000 Commit: John Baldwin CommitDate: 2023-06-19 16:15:48 +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 --- 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 a2b0d1f556aa..f05e34527118 100644 --- a/sys/dev/pci/pci_pci.c +++ b/sys/dev/pci/pci_pci.c @@ -1321,7 +1321,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; @@ -1333,9 +1333,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) { @@ -1383,7 +1391,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;