aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2023-05-16 20:59:30 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2023-06-26 09:19:42 +0000
commite7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008 (patch)
tree2bd1caf8fc229a4f3190f0aa4938f4be5ffc96bd
parentd6f5ea1dc1b32021fa623c27bfcfa17f9e4e2567 (diff)
downloadsrc-e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008.tar.gz
src-e7c58fc886ec09fe16bb544a2a3b2e9fcfbc0008.zip
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)
-rw-r--r--sys/compat/linuxkpi/common/include/linux/pci.h24
1 files changed, 24 insertions, 0 deletions
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