git: 479c61bd5f66 - main - linuxkpi: Add `pci_get_base_class()`
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 31 Jan 2025 16:03:11 UTC
The branch main has been updated by dumbbell:
URL: https://cgit.FreeBSD.org/src/commit/?id=479c61bd5f661f0e5927276c7eaea074235f6acc
commit 479c61bd5f661f0e5927276c7eaea074235f6acc
Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
AuthorDate: 2024-12-22 16:26:49 +0000
Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
CommitDate: 2025-01-31 16:00:47 +0000
linuxkpi: Add `pci_get_base_class()`
[Why]
This new API is used by the amdgpu DRM driver is Linux 6.7.
[How]
This is the same as `pci_get_class()` except that it searches a PCI
device matching the base class only; the subclass is ignored.
Reviewed by: manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48746
---
sys/compat/linuxkpi/common/include/linux/pci.h | 3 +++
sys/compat/linuxkpi/common/src/linux_pci.c | 18 ++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index aa6b778c3477..782f79080873 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -1355,6 +1355,9 @@ pci_bus_write_config_word(struct pci_bus *bus, unsigned int devfn, int pos,
struct pci_dev *lkpi_pci_get_class(unsigned int class, struct pci_dev *from);
#define pci_get_class(class, from) lkpi_pci_get_class(class, from)
+struct pci_dev *lkpi_pci_get_base_class(unsigned int class,
+ struct pci_dev *from);
+#define pci_get_base_class(class, from) lkpi_pci_get_base_class(class, from)
/* -------------------------------------------------------------------------- */
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
index 366731081072..a9942a657dce 100644
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -400,6 +400,24 @@ lkpi_pci_get_class(unsigned int class, struct pci_dev *from)
return (pdev);
}
+struct pci_dev *
+lkpi_pci_get_base_class(unsigned int baseclass, struct pci_dev *from)
+{
+ device_t dev;
+ device_t devfrom = NULL;
+ struct pci_dev *pdev;
+
+ if (from != NULL)
+ devfrom = from->dev.bsddev;
+
+ dev = pci_find_base_class_from(baseclass, devfrom);
+ if (dev == NULL)
+ return (NULL);
+
+ pdev = lkpinew_pci_dev(dev);
+ return (pdev);
+}
+
struct pci_dev *
lkpi_pci_get_domain_bus_and_slot(int domain, unsigned int bus,
unsigned int devfn)