aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2022-03-04 00:06:34 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2022-03-30 15:46:17 +0000
commit7380d82b53d664c4bc1ff9eb853ee26787cb3b89 (patch)
tree79622ac42bc8124409c27ffc535323105844e521
parent3b4a991fa67ffd05d4a8865bf8e696f77543981d (diff)
LinuxKPI: pci.h MODULE_DEVICE_TABLE to MODULE_PNP_INFO
Implement MODULE_PNP_INFO() support in LinuxKPI for the Linux MODULE_DEVICE_TABLE. This will allow us to auto-load LinuxKPI PCI drivers (drm-kmod do not currently as they attach to vgapci0 which in turn grabs the PCI to my understanding) and make any loading from loader or kld_list in rc.conf unnecessary; see devmatch(8) for more information. We need to ensure there is a DRIVER_MODULE() (or probably just a DECLARE_MODULE but that makes not much difference) before the MODULE_PNP_INFO (which we otherwise would not need). Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Reviewed by: imp, hselasky, manu Differential Revision: https://reviews.freebsd.org/D26651 (cherry picked from commit 5493c6277a264e91ea4bdc7e2d4ee69fe4210918) (cherry picked from commit a94b233d5d718258e2e57e114aab00714441a79f)
-rw-r--r--sys/compat/linuxkpi/common/include/linux/pci.h22
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h
index df18c98a6278..361600a55397 100644
--- a/sys/compat/linuxkpi/common/include/linux/pci.h
+++ b/sys/compat/linuxkpi/common/include/linux/pci.h
@@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/bus.h>
+#include <sys/module.h>
#include <sys/nv.h>
#include <sys/pciio.h>
#include <sys/rman.h>
@@ -69,7 +70,26 @@ struct pci_device_id {
uintptr_t driver_data;
};
-#define MODULE_DEVICE_TABLE(bus, table)
+/* Linux has an empty element at the end of the ID table -> nitems() - 1. */
+#define MODULE_DEVICE_TABLE(_bus, _table) \
+ \
+static device_method_t _ ## _bus ## _ ## _table ## _methods[] = { \
+ DEVMETHOD_END \
+}; \
+ \
+static driver_t _ ## _bus ## _ ## _table ## _driver = { \
+ "lkpi_" #_bus #_table, \
+ _ ## _bus ## _ ## _table ## _methods, \
+ 0 \
+}; \
+ \
+static devclass_t _ ## _bus ## _ ## _table ## _devclass; \
+ \
+DRIVER_MODULE(lkpi_ ## _table, pci, _ ## _bus ## _ ## _table ## _driver,\
+ _ ## _bus ## _ ## _table ## _devclass, 0, 0); \
+ \
+MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \
+ _bus, lkpi_ ## _table, _table, nitems(_table) - 1)
#define PCI_ANY_ID -1U