From nobody Tue Apr 05 14:42:33 2022 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 003C01A8F339; Tue, 5 Apr 2022 14:42:35 +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 4KXr2x6c7Qz4cf0; Tue, 5 Apr 2022 14:42:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649169754; 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=0zYWuKddRMQsC6CQhsGl0hf9MN2NQoQ1TYPeL2Pxjl8=; b=VV6ucjCyoiQsmw45uRbmLzQdWs0soDKFqYI/Y50LHX9E6iDvNv7e8rZZL3MWAIViiy7+77 y1Pkau1zVG5VVyaobERCh4xudCxLVRhvIMTuPySo4h1jHz1m9RX9F/Dqj6Fk2Q7GGhBfXZ XQzBkkYWvGIpcWbozpqWRqh/VGRqA7rndQvaGayqVoRT2bIJ9GvRFgagSpXYBURGYaELsM 40J+0rJBUVGyovzFJ2zHuimvLt3cPuJ0zeqqR6s5dc9fU5MoT6X+S7LwKqRHH/1W9xrg8f IwDCD4J+Au95sXuwDmMrWoI203ZWSpTkX84k3UQYJExd7RBdK1TRR7E7EceOYg== 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 86E8F2FB; Tue, 5 Apr 2022 14:42:33 +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 235EgXMZ033131; Tue, 5 Apr 2022 14:42:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 235EgX6Z033130; Tue, 5 Apr 2022 14:42:33 GMT (envelope-from git) Date: Tue, 5 Apr 2022 14:42:33 GMT Message-Id: <202204051442.235EgX6Z033130@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: bc01b383945c - stable/13 - linuxkpi: Move pci_alloc_irq_vectors to .c file 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bc01b383945ca4f327ddb5cc940dcbafa3aaff7c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649169754; 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=0zYWuKddRMQsC6CQhsGl0hf9MN2NQoQ1TYPeL2Pxjl8=; b=Cio5/pQc3TkCujM+4wFTdqGrQVx+1dGsuytBhcLZppJLAhmpw5SUQrVOfKIc6UKuojdmKq +q3Kf6+jWIGWPW/nTPJQCPHHPKko0j6IX02PJUVlLV+aUy8t7c92f/nEOyxsM85Q3raKzz ZFGEwSyUZVq+T7dx/nfN5FYeYHDWMd2UpKprNOJgfZwqM7estz/5Sc3dhN/nXVS7l290OU PnBLBLrQWzpnQ8M1w3h8u95L7byo30SGijVmnTlz/b14zKWtj1BAxN7iUFa5Zuj1vipJ8O 5Cd5WD60xP73bX1Ur758HomoCJ0J+s7DgjZHcZS/NOu6/GFTWxTaC34Sd53xpw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649169754; a=rsa-sha256; cv=none; b=r0WKYdsAXwlMcleellQn+gxnmVNn+6c1NDJapqlF1Y14uM3h9QEgO9gKmddhIWjtKEzQlD C7dwNyMWg9tOXc2F9DLyZ4rBBkAsCY8Vl/52vRlZ+/UlJ351CXFTp4I7ARFTA1FRjkWxt7 opi0RLsS+I66YwWPd1OQP6/PFIUh92LPIYFXyu5fTafrYQclS0IQEqlILG9/MfLVmbrj33 /bezPvK4TvtV/mI7imYfp1PPaNizXAwddfNXDOLpWaQDg5eBKQ8cgJ16Duqom+8wCufRy9 hQY8fsfsNadRLnYdVs/zwRI/YEHoRx5YxLdt4VP1feBrcYasyAYOqcnmsCcsCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=bc01b383945ca4f327ddb5cc940dcbafa3aaff7c commit bc01b383945ca4f327ddb5cc940dcbafa3aaff7c Author: Warner Losh AuthorDate: 2022-04-05 05:06:21 +0000 Commit: Warner Losh CommitDate: 2022-04-05 14:40:11 +0000 linuxkpi: Move pci_alloc_irq_vectors to .c file pci_alloc_irq_vectors encodes the size of struct msix_entry into its code. Move from .h to .c to move this knowledge from client modules to linuxkpi module. Sponsored by: Netflix Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D34774 (cherry picked from commit 36b5c440028b44b22cfc0596125f575ca513656f) --- sys/compat/linuxkpi/common/include/linux/pci.h | 38 ++------------------------ sys/compat/linuxkpi/common/src/linux_pci.c | 36 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 5e4cc1901973..e712477fbe9e 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -339,6 +339,8 @@ struct pcim_iomap_devres { }; int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name); +int pci_alloc_irq_vectors(struct pci_dev *pdev, int minv, int maxv, + unsigned int flags); /* Internal helper function(s). */ struct pci_dev *lkpinew_pci_dev(device_t); @@ -882,42 +884,6 @@ pci_enable_msi(struct pci_dev *pdev) return (0); } -static inline int -pci_alloc_irq_vectors(struct pci_dev *pdev, int minv, int maxv, - unsigned int flags) -{ - int error; - - if (flags & PCI_IRQ_MSIX) { - struct msix_entry *entries; - int i; - - entries = kcalloc(maxv, sizeof(*entries), GFP_KERNEL); - if (entries == NULL) { - error = -ENOMEM; - goto out; - } - for (i = 0; i < maxv; ++i) - entries[i].entry = i; - error = pci_enable_msix(pdev, entries, maxv); -out: - kfree(entries); - if (error == 0 && pdev->msix_enabled) - return (pdev->dev.irq_end - pdev->dev.irq_start); - } - if (flags & PCI_IRQ_MSI) { - error = pci_enable_msi(pdev); - if (error == 0 && pdev->msi_enabled) - return (pdev->dev.irq_end - pdev->dev.irq_start); - } - if (flags & PCI_IRQ_LEGACY) { - if (pdev->irq) - return (1); - } - - return (-EINVAL); -} - static inline int pci_channel_offline(struct pci_dev *pdev) { diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index fb976346c198..328ca9c74bd1 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -875,6 +875,42 @@ linux_pci_unregister_drm_driver(struct pci_driver *pdrv) mtx_unlock(&Giant); } +int +pci_alloc_irq_vectors(struct pci_dev *pdev, int minv, int maxv, + unsigned int flags) +{ + int error; + + if (flags & PCI_IRQ_MSIX) { + struct msix_entry *entries; + int i; + + entries = kcalloc(maxv, sizeof(*entries), GFP_KERNEL); + if (entries == NULL) { + error = -ENOMEM; + goto out; + } + for (i = 0; i < maxv; ++i) + entries[i].entry = i; + error = pci_enable_msix(pdev, entries, maxv); +out: + kfree(entries); + if (error == 0 && pdev->msix_enabled) + return (pdev->dev.irq_end - pdev->dev.irq_start); + } + if (flags & PCI_IRQ_MSI) { + error = pci_enable_msi(pdev); + if (error == 0 && pdev->msi_enabled) + return (pdev->dev.irq_end - pdev->dev.irq_start); + } + if (flags & PCI_IRQ_LEGACY) { + if (pdev->irq) + return (1); + } + + return (-EINVAL); +} + CTASSERT(sizeof(dma_addr_t) <= sizeof(uint64_t)); struct linux_dma_obj {