From nobody Wed Sep 6 17:37:31 2023 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 4RgqMH6PkVz4sQds; Wed, 6 Sep 2023 17:37:31 +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 4RgqMH5hKkz3d0q; Wed, 6 Sep 2023 17:37:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694021851; 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=63dy905nXIIfaai72DSfYjl6cdlQlISKKsetGXrqCtE=; b=IgEPUXPIfKnXJz1emLOqppCra6YfcQr/opVB3gPSHIg1SGTUHAVBLZQgptsCclpYYmlRuU v0GLp7LISXWuiA8exHAibqGAQqsxMfNoG052buRoX+Es7dD+UhLIF5MgthRtXaK05Cwx0H SuEoFiZPD2GclAq/PdcFaC7znyx8sa+d9oKoAR8JiUpS/xXugUmG5iHJ3rV9FUbYobCJZO +JA+dqWXGtgx3UhtgoWDJSR60oMf83n3YULoFGnjk2XCJLz94oGh7kxLwoov6Xeq06tlY5 v9CnPSaAKsureEdXSGrXTuT3nRME77Zv7pHW06UDMv6GzMisJ/YYQumeTAL3mw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694021851; a=rsa-sha256; cv=none; b=dWnDgyx+6n4raEycGzjbvp4kmIdW5kexbmNoUqK5M26Mnzsq4fl4OzD/4hpZVRBkXO7aMR KALhHK/5jSxuHt6h7TnrBAqFGpWGE6efXkUtc6/XPkjMqp50KjV+BSJiB3sYBiQkhdAw5I ZA7xRM8K4iDH/ccKBOehIjrMIUi6pB38NfxRwttyOpbDupMcluc+P0cUtAy8e07YEHXZ+R w/Elipda31x8l4yGTh/mI9zg9m/h85Vw7/YPvsgyhmWc4chSNjDV6ES9xu9IyWJQsn0oFU nvrY8vIRjjGgC1qppp24Yup4l00GJW58/Z7frOhnrrV/jMTXgVjfW5n71VZGkw== 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=1694021851; 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=63dy905nXIIfaai72DSfYjl6cdlQlISKKsetGXrqCtE=; b=Pt9DR0PzjAx7JT5OdTnqVm783wPVcoPEUxW5WsGrFcGG6wDuK9GTxCC+gmQ91PT7kjrqK2 FP8I5v3uUJ+o+FEWEKJ3YA8XOD2uQrPZ5cPUchf0/lR0KM8OTJBSkasPzQmAla2GK4nRGK a98p2PPEtSCWCJgu9to2eWQPemjy5dKpESh7A1Z33LiuWLAc2t4qvsDQgd56d6d/0MQyx7 J999TyPGzuLsvcPuMVIi6OQcHiVs3XO8ZUql7Zo3VpuB/MOI5fIA1tL6rtxNu1q5W9HDig 2aNRxGEQdgz+bJR53ybWTJLc28Fhz4XCiL4TzuWFCtOnnSK5k4o6MW0TRkxSVw== 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 4RgqMH4NlKzBKT; Wed, 6 Sep 2023 17:37:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 386HbVmw086399; Wed, 6 Sep 2023 17:37:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 386HbVLG086396; Wed, 6 Sep 2023 17:37:31 GMT (envelope-from git) Date: Wed, 6 Sep 2023 17:37:31 GMT Message-Id: <202309061737.386HbVLG086396@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Tetlow Subject: git: e80d2d894ff1 - releng/13.2 - pcib: Allocate the memory BAR with the MSI-X table. 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gordon X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: e80d2d894ff1afbdb932aac1f4ceb50922a779bb Auto-Submitted: auto-generated The branch releng/13.2 has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=e80d2d894ff1afbdb932aac1f4ceb50922a779bb commit e80d2d894ff1afbdb932aac1f4ceb50922a779bb Author: John Baldwin AuthorDate: 2023-06-19 16:15:48 +0000 Commit: Gordon Tetlow CommitDate: 2023-09-06 16:57:02 +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 Approved by: so Security: FreeBSD-EN-23:10.pci Differential Revision: https://reviews.freebsd.org/D40581 (cherry picked from commit e6b838363fb473b5e35a8ae6a1da5e15f5b52960) (cherry picked from commit 12ce57e6d3e770db9ca83a8cbaa8f332515ce3d7) --- 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;