git: e7c58fc886ec - stable/13 - LinuxKPI: implement pci_rescan_bus()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 26 Jun 2023 12:08:52 UTC
The branch stable/13 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008 commit e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2023-05-16 20:59:30 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2023-06-26 09:19:42 +0000 LinuxKPI: implement pci_rescan_bus() Try to implement pci_rescan_bus(). pci_rescan_method() is already doing most of the job. We only have to do the count for the return value again ourselves. Sponsored by: The FreeBSD Foundation Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D40122 (cherry picked from commit 525dd4acaacc59b815131caccfdebc905d4d7bff) --- sys/compat/linuxkpi/common/include/linux/pci.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 55435f6b72bc..f3c495ff1a21 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -277,6 +277,7 @@ _Static_assert(sizeof(struct pci_driver) == __PCI_DRIVER_SIZE, struct pci_bus { struct pci_dev *self; + /* struct pci_bus *parent */ int domain; int number; }; @@ -1425,6 +1426,29 @@ pci_stop_and_remove_bus_device(struct pci_dev *pdev) { } +static inline int +pci_rescan_bus(struct pci_bus *pbus) +{ + device_t *devlist, parent; + int devcount, error; + + if (!device_is_attached(pbus->self->dev.bsddev)) + return (0); + /* pci_rescan_method() will work on the pcib (parent). */ + error = BUS_RESCAN(pbus->self->dev.bsddev); + if (error != 0) + return (0); + + parent = device_get_parent(pbus->self->dev.bsddev); + error = device_get_children(parent, &devlist, &devcount); + if (error != 0) + return (0); + if (devcount != 0) + free(devlist, M_TEMP); + + return (devcount); +} + /* * The following functions can be used to attach/detach the LinuxKPI's * PCI device runtime. The pci_driver and pci_device_id pointer is