From nobody Wed Apr 06 17:46:10 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 E30C71AA681A; Wed, 6 Apr 2022 17:46:11 +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 4KYX4L574gz3DRw; Wed, 6 Apr 2022 17:46:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649267171; 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=Ymfo4jX1kgT6x9k5seDmFJVvpjEXNmItpTmabpfGjCU=; b=CD9xkWzWlds6JD+HrWKSa2tSzLkLy3KqHZVB4lAoEGeTWbYSaxIcCBnBnpnZdx1umnEZ4h oi3Drn7C2adkxxsMYu0NlCUEn1MhNwZ+YJ5/nSjhZIyoE092LDXgfF/BB8r5yl7zQe8nw6 bI1oJeZ+h1KAAqglekqz3awcMA+h5XJpq4Sbdyh58b2mzZWfVh2f5G8Lnb0xKP707j0XKu EPfLPxMRxmg0rNOquGmCnZFIQaemeF8thrFL4n/4sJFFskds5LXAYUJ98ecMlnKGHdHsRO lnd0UnyYmxLvosif5+d1xhQPcb+Jz22rfBBMqYwK1i6iwUpwYBF1zQZM9LebxQ== 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 476F11F5CC; Wed, 6 Apr 2022 17:46:10 +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 236HkAfR022735; Wed, 6 Apr 2022 17:46:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 236HkA6D022734; Wed, 6 Apr 2022 17:46:10 GMT (envelope-from git) Date: Wed, 6 Apr 2022 17:46:10 GMT Message-Id: <202204061746.236HkA6D022734@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: ebd35d1ceb36 - releng/13.1 - 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/releng/13.1 X-Git-Reftype: branch X-Git-Commit: ebd35d1ceb36d9c605b8d3d970175c87052b6e18 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649267171; 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=Ymfo4jX1kgT6x9k5seDmFJVvpjEXNmItpTmabpfGjCU=; b=uLa9NJy1dlGerIuBUf92qGUqkvyK2rHnYwcyHKqH6TPsv67HQtOs1eHHTvUmVJyi1QCLRJ iuEpWIF2AJxTClHXgE46KHZOrPZ6CvU6G57T1t/f6MtES4JsskondLv3Mb+L/Y0cIdz+tl 1pXAMBANmr3Q4IVgEPquM4RlTUycOLiBUCXYpNazV0ZPbVRXSVwVnP3aJnRJfimKE7oolz hkNBi4ShEckzUGVzbJig6Kw+BAGKDhwumB6eQ3EnwLPOU+oW5epFPS2d7drgstfD04APqh 81y3xMC8dVx/lkefMtbw6Xl3gFO6pNfScxWm7+fdC2DnaYjdIXOXrrjSbODqmw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649267171; a=rsa-sha256; cv=none; b=mIdTXML2sw6buxiNNl3ffYodAjMEtsSSWd5iB0kMDq7GIMhM+CxKPcG4EdaRPX4hrLo140 lAULpea9+MLbQgUXfqmPWsvN6hLyB9Soug2W88+d0cw+aC60hwNA/EDZhgLLYj8RE7Nc6C NkuCTW1aSDBh2dFarvDlmiRhJlOBNTnp6vHGwrOHg2DqmM593EbEoTt/LwTYs0TdYhYRwD BxpWsMwjwOIDNS5KREGcNdI/kXiYj8xX0O+4h65lbsEdpwtjXzp2z9TxqqDBhzKWXk3Fie OETFiPPwPBbRCkoZBM+6PNtmh9VC6dXOXvkPMCX5X5edPD17WEqkmG806Vd87w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ebd35d1ceb36d9c605b8d3d970175c87052b6e18 commit ebd35d1ceb36d9c605b8d3d970175c87052b6e18 Author: Warner Losh AuthorDate: 2022-04-05 05:06:21 +0000 Commit: Warner Losh CommitDate: 2022-04-06 17:45:38 +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. Approved by: re@ (gjb) Sponsored by: Netflix Reviewed by: hselasky Differential Revision: https://reviews.freebsd.org/D34774 (cherry picked from commit 36b5c440028b44b22cfc0596125f575ca513656f) (cherry picked from commit bc01b383945ca4f327ddb5cc940dcbafa3aaff7c) --- 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 {