Date: Fri, 31 Jan 2025 16:03:10 GMT From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= <dumbbell@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: c118e4da1296 - main - pci: Add `pci_find_base_class_from()` Message-ID: <202501311603.50VG3AAH038457@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=c118e4da12969b98f52b3b6f35857c32541d7fa5 commit c118e4da12969b98f52b3b6f35857c32541d7fa5 Author: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> AuthorDate: 2024-12-22 16:23:34 +0000 Commit: Jean-Sébastien Pédron <dumbbell@FreeBSD.org> CommitDate: 2025-01-31 16:00:47 +0000 pci: Add `pci_find_base_class_from()` [Why] linuxkpi needs to export `pci_get_base_class()` for DRM drivers from Linux 6.7. [How] This new function searches a PCI device with the given base class and returns it, regardless of its subclass. The behavior is the same as `pci_find_class_from()` but the subclass is ignored. Reviewed by: manu Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48745 --- sys/dev/pci/pci.c | 21 +++++++++++++++++++++ sys/dev/pci/pcivar.h | 1 + 2 files changed, 22 insertions(+) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index 30a95298a114..edebb718ec53 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -523,6 +523,27 @@ pci_find_class_from(uint8_t class, uint8_t subclass, device_t from) return (NULL); } +device_t +pci_find_base_class_from(uint8_t class, device_t from) +{ + struct pci_devinfo *dinfo; + bool found = false; + + STAILQ_FOREACH(dinfo, &pci_devq, pci_links) { + if (from != NULL && found == false) { + if (from != dinfo->cfg.dev) + continue; + found = true; + continue; + } + if (dinfo->cfg.baseclass == class) { + return (dinfo->cfg.dev); + } + } + + return (NULL); +} + static int pci_printf(pcicfgregs *cfg, const char *fmt, ...) { diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h index c2c1f055def9..1c7b772afea9 100644 --- a/sys/dev/pci/pcivar.h +++ b/sys/dev/pci/pcivar.h @@ -670,6 +670,7 @@ device_t pci_find_dbsf(uint32_t, uint8_t, uint8_t, uint8_t); device_t pci_find_device(uint16_t, uint16_t); device_t pci_find_class(uint8_t class, uint8_t subclass); device_t pci_find_class_from(uint8_t class, uint8_t subclass, device_t devfrom); +device_t pci_find_base_class_from(uint8_t class, device_t devfrom); /* Can be used by drivers to manage the MSI-X table. */ int pci_pending_msix(device_t dev, u_int index);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202501311603.50VG3AAH038457>