git: 485ffe067324 - main - LinuxKPI: Add drm support to dev_is_pci() function

From: Vladimir Kondratyev <wulf_at_FreeBSD.org>
Date: Wed, 04 Nov 2026 17:14:55 UTC
The branch main has been updated by wulf:

URL: https://cgit.FreeBSD.org/src/commit/?id=485ffe067324e314a08411fd11ec89f0581c7cfa

commit 485ffe067324e314a08411fd11ec89f0581c7cfa
Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
AuthorDate: 2026-11-04 17:13:50 +0000
Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
CommitDate: 2026-11-04 17:13:50 +0000

    LinuxKPI: Add drm support to dev_is_pci() function
    
    drmn driver is attached to PCI bus via intermediate vgapci driver.
    Check for it presence in device tree branch too to handle drm-kmod
    cases.
    
    MFC after:      2 month
    Reviewed by:    emaste (LGTM)
    Differential Revision:  https://reviews.freebsd.org/D60138
---
 sys/compat/linuxkpi/common/include/linux/pci.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index a68fd6b13254..c8a919bb4677 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -399,6 +399,17 @@ int _lkpi_pci_enable_msi_range(struct pci_dev *pdev, int minvec, int maxvec);
 static inline bool
 dev_is_pci(struct device *dev)
 {
+	device_t parent = device_get_parent(dev->bsddev);
+
+	if (parent == NULL)
+		return (false);
+	/*
+	 * drmn driver is attached to PCI bus via intermediate vgapci
+	 * driver. Check for it presence in device tree branch too to
+	 * handle drm-kmod cases.
+	 */
+	if (device_get_devclass(parent) == devclass_find("vgapci"))
+		return (true);
 	return (is_pci_device(dev->bsddev));
 }