git: 62c3b77d1d10 - stable/15 - LinuxKPI: pci: implementation of [lkpi_]pci_get_slot()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Sep 2025 22:21:05 UTC
The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=62c3b77d1d1084dc46663eed52e288307b5c7e64 commit 62c3b77d1d1084dc46663eed52e288307b5c7e64 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2025-09-04 20:19:48 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2025-09-30 21:45:29 +0000 LinuxKPI: pci: implementation of [lkpi_]pci_get_slot() Like lkpi_pci_get_domain_bus_and_slot() implement lkpi_pci_get_slot() using pci_find_bsf() instead of pci_find_dbsf() (no domain). This is needed for a wireless driver. Unfortunately the name [pci_get_slot()] collides with the native PCI function. Add a guard around it and disable the use when the native version is required (in lkpifill_pci_dev() and in bnxt/bnxt_en; if the latter gets fixed we can probably also fix work around it in the former; further conflicts in drm-kmod 6.1-lts, 6.6-lts, and master were resolved). Sponsored by: The FreeBSD Foundation (initially) Reviewed by: dumbbell Differential Revision: https://reviews.freebsd.org/D52065 (cherry picked from commit 4179e6b78297369f0cf0eae1076e01e5151c5cbe) --- sys/compat/linuxkpi/common/include/linux/pci.h | 6 ++++++ sys/compat/linuxkpi/common/src/linux_pci.c | 15 +++++++++++++++ sys/dev/bnxt/bnxt_en/if_bnxt.c | 1 + 3 files changed, 22 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index d891d0df3546..ffc2be600c22 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -1332,6 +1332,12 @@ struct pci_dev *lkpi_pci_get_domain_bus_and_slot(int domain, #define pci_get_domain_bus_and_slot(domain, bus, devfn) \ lkpi_pci_get_domain_bus_and_slot(domain, bus, devfn) +struct pci_dev *lkpi_pci_get_slot(struct pci_bus *, unsigned int); +#ifndef WANT_NATIVE_PCI_GET_SLOT +#define pci_get_slot(_pbus, _devfn) \ + lkpi_pci_get_slot(_pbus, _devfn) +#endif + static inline int pci_domain_nr(struct pci_bus *pbus) { diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index d0f1d5e3f9c5..8507a59a8df3 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -67,6 +67,7 @@ #include <linux/mm.h> #include <linux/io.h> #include <linux/vmalloc.h> +#define WANT_NATIVE_PCI_GET_SLOT #include <linux/pci.h> #include <linux/compat.h> @@ -485,6 +486,20 @@ lkpi_pci_get_domain_bus_and_slot(int domain, unsigned int bus, return (pdev); } +struct pci_dev * +lkpi_pci_get_slot(struct pci_bus *pbus, unsigned int devfn) +{ + device_t dev; + struct pci_dev *pdev; + + dev = pci_find_bsf(pbus->number, PCI_SLOT(devfn), PCI_FUNC(devfn)); + if (dev == NULL) + return (NULL); + + pdev = lkpinew_pci_dev(dev); + return (pdev); +} + static int linux_pci_probe(device_t dev) { diff --git a/sys/dev/bnxt/bnxt_en/if_bnxt.c b/sys/dev/bnxt/bnxt_en/if_bnxt.c index feac3ce54a29..471e26a4b252 100644 --- a/sys/dev/bnxt/bnxt_en/if_bnxt.c +++ b/sys/dev/bnxt/bnxt_en/if_bnxt.c @@ -48,6 +48,7 @@ #include <net/ethernet.h> #include <net/iflib.h> +#define WANT_NATIVE_PCI_GET_SLOT #include <linux/pci.h> #include <linux/kmod.h> #include <linux/module.h>