From nobody Tue Apr 05 05:10:06 2022 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 75A451AA3AB8; Tue, 5 Apr 2022 05:10:07 +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 4KXbLR0dcnz3hcK; Tue, 5 Apr 2022 05:10:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649135407; 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=Q7hX7VlCXO2nt6j42UwkytxeuL58LE2wLwZsmwRsR34=; b=T1hQVcDc9iyyjI8N5QxhGrWuSku4yZFJ28t0LOKO7394t4/AhID9IIgDHIzQG5PEzzZqCz a6i+i24kSSHJszlpbvHjCpelcAqOLXSCBMW7DARWLq0FOb+xFP/HUUkXfSGTVrYHWL1TxG oFKEdM593ztFbVPDIL6Y0yF+YPJxOYvHqAKpbORTNuQyqmUjMQGkqI8kv4QT89T+jtRvZK D/yky138zGH9OteNuIJxyz98b2csbnORm+BjRm6CHy06lMAlsq4p/ODI9YJoD6u7SuB2Of C6ORrMIk6DDhAggRf0JQDMU0KQGCuf6sflOcwWoY78deOf6LpT6I0GI3vfPJRw== 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 E68FA20598; Tue, 5 Apr 2022 05:10:06 +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 2355A6BF054137; Tue, 5 Apr 2022 05:10:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2355A6Re054134; Tue, 5 Apr 2022 05:10:06 GMT (envelope-from git) Date: Tue, 5 Apr 2022 05:10:06 GMT Message-Id: <202204050510.2355A6Re054134@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 36b5c440028b - main - linuxkpi: Move pci_alloc_irq_vectors to .c file 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36b5c440028b44b22cfc0596125f575ca513656f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649135407; 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=Q7hX7VlCXO2nt6j42UwkytxeuL58LE2wLwZsmwRsR34=; b=OpR5m3EecxpYHTGi6HD/hzH7dagvfDiczuGd8fCFQYmwlLve/e4ugOIhkApDgMSDkpL1Xq zhI3e26gM9uJ/1C5VzoG7Z3IY4b7a5JS4TiOdsgis7w4T5KWpLLEO1xWAU408SctmmK+UC NDXZ2RhMb68hSo+L9QMJFxrRged5td1EQRNCJDFmREy+VIvkRwjWaUsCaXDnUKV0A1e4Xv OTwWp3y2vorhW/03b6tS6GeoNo7WeQVvjSXp/ZloOwX89OM4yf985/TXdpafa9t6kAyBnn at1nc7NNp9SJp7G12rpyRmpLHWZv6oqiaKjElPAcoNEfRX1kLKeeJ91laOxWnQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649135407; a=rsa-sha256; cv=none; b=EPCC1mZrwFy0DGn5dbcObbyoA9ficHAOGX4LDWiHzVrFKlvpF1usEVUIxELObVef2vhw7s IB1xDytuXYF5L+QTv9KcQiWWQtQVwBCI/wQIHuZHISdnHZwu+gJcJ3MNaTgB6DOi1e6uqS YurLOZOE8+yq5CxwAMuHFEe3N3kqcpJhxylaUTHojiUxFQ3dqD7wxV5N7TGYs8PaRzTngh WG47A+GSJjUXb/edpkO97t6gXGdIXj6YGAp2t0IfCWYFqLlpqg1UKrRas4Lc8+DvnRDCAP 3HaSByiTvO0r81PfmLuPALCSeoPnTTKooo3Ui4hbPugWpqstJBqNGI9b5EV5NQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=36b5c440028b44b22cfc0596125f575ca513656f commit 36b5c440028b44b22cfc0596125f575ca513656f Author: Warner Losh AuthorDate: 2022-04-05 05:06:21 +0000 Commit: Warner Losh CommitDate: 2022-04-05 05:06:21 +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 --- 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 76c6df02bf19..f71bee511d75 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -317,6 +317,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); @@ -860,42 +862,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 43a8cf96d0e3..8b64cbae0e6a 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -883,6 +883,42 @@ linux_pci_unregister_drm_driver(struct pci_driver *pdrv) bus_topo_unlock(); } +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 {