The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=67c01ebfc241a2ee9037f9ca85efc84ccdd56982
commit 67c01ebfc241a2ee9037f9ca85efc84ccdd56982 Author: Bjoern A. Zeeb <[email protected]> AuthorDate: 2026-08-16 21:32:31 +0000 Commit: Bjoern A. Zeeb <[email protected]> CommitDate: 2026-09-19 09:34:10 +0000 LinuxKPI: pci: add pci_select_bars() and pci_msix_vec_count() For pci_select_bars() we use the LinuxKPI internal information, while for pci_select_bars() we fall back to the native PCI stack. Needed by a wifi driver. Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D58878 (cherry picked from commit 55c07af60172b211116be47010fc0831aafc99e8) --- sys/compat/linuxkpi/common/include/linux/pci.h | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 8cd52707a7bd..6efd43f311cf 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -437,6 +437,24 @@ pci_resource_flags(struct pci_dev *pdev, int bar) return (1 << type); } +static inline int +pci_select_bars(struct pci_dev *pdev, unsigned long flags) +{ + int bars, bar; + + bars = 0; + /* We only support BARs here; Linux may support more types. */ + for (bar = PCIR_MAX_BAR_0; bar >= 0; bar--) { + int bar_flags; + + bar_flags = pci_resource_flags(pdev, bar); + if ((bar_flags & flags) != 0) + bars |= (1 << bar); + } + + return (bars); +} + static inline const char * pci_name(struct pci_dev *d) { @@ -1569,6 +1587,17 @@ pci_irq_vector(struct pci_dev *pdev, unsigned int vector) return (-ENXIO); } +static inline int +pci_msix_vec_count(struct pci_dev *pdev) +{ + int avail; + + avail = pci_msix_count(pdev->dev.bsddev); + if (avail == 0) + return (-EINVAL); + return (avail); +} + static inline int pci_wake_from_d3(struct pci_dev *pdev, bool enable) {
