Date: Wed, 6 Apr 2022 17:46:10 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: ebd35d1ceb36 - releng/13.1 - linuxkpi: Move pci_alloc_irq_vectors to .c file Message-ID: <202204061746.236HkA6D022734@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch releng/13.1 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ebd35d1ceb36d9c605b8d3d970175c87052b6e18 commit ebd35d1ceb36d9c605b8d3d970175c87052b6e18 Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-04-05 05:06:21 +0000 Commit: Warner Losh <imp@FreeBSD.org> 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 {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202204061746.236HkA6D022734>