summaryrefslogtreecommitdiff
path: root/graphics/nvidia-drm-latest-kmod/files
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/nvidia-drm-latest-kmod/files')
-rw-r--r--graphics/nvidia-drm-latest-kmod/files/20-nvidia-drm-outputclass.conf.in8
-rw-r--r--graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-conftest.h14
-rw-r--r--graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-freebsd-lkpi.c54
-rw-r--r--graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-freebsd-lkpi.c-20250918-0147
4 files changed, 123 insertions, 0 deletions
diff --git a/graphics/nvidia-drm-latest-kmod/files/20-nvidia-drm-outputclass.conf.in b/graphics/nvidia-drm-latest-kmod/files/20-nvidia-drm-outputclass.conf.in
new file mode 100644
index 000000000000..15496138f63a
--- /dev/null
+++ b/graphics/nvidia-drm-latest-kmod/files/20-nvidia-drm-outputclass.conf.in
@@ -0,0 +1,8 @@
+Section "OutputClass"
+ Identifier "nvidia"
+ MatchDriver "nvidia-drm"
+ Driver "nvidia"
+ Option "PrimaryGPU" "yes"
+ ModulePath "%%LOCALBASE%%/lib/nvidia/xorg"
+ ModulePath "%%LOCALBASE%%/lib/xorg/modules"
+EndSection
diff --git a/graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-conftest.h b/graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-conftest.h
new file mode 100644
index 000000000000..2c0524341c4d
--- /dev/null
+++ b/graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-conftest.h
@@ -0,0 +1,14 @@
+--- nvidia-drm-conftest.h.orig 2024-02-22 01:03:15 UTC
++++ nvidia-drm-conftest.h
+@@ -85,7 +85,11 @@
+
+ /* For nv_drm_gem_prime_force_fence_signal */
+ #ifndef spin_is_locked
++#if ((__FreeBSD_version >= 1500000) && (__FreeBSD_version < 1500018)) || (__FreeBSD_version < 1401501)
+ #define spin_is_locked(lock) mtx_owned(lock.m)
++#else
++#define spin_is_locked(lock) mtx_owned(lock)
++#endif
+ #endif
+
+ #ifndef rwsem_is_locked
diff --git a/graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-freebsd-lkpi.c b/graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-freebsd-lkpi.c
new file mode 100644
index 000000000000..807e95effe74
--- /dev/null
+++ b/graphics/nvidia-drm-latest-kmod/files/extra-patch-nvidia-drm-freebsd-lkpi.c
@@ -0,0 +1,54 @@
+--- nvidia-drm-freebsd-lkpi.c.orig 2024-02-22 01:03:15 UTC
++++ nvidia-drm-freebsd-lkpi.c
+@@ -115,6 +115,7 @@ int nv_drm_probe_devices(void)
+ * by the native nvidia.ko by using our devclass.
+ */
+ for (int i = 0; i < NV_MAX_DEVICES; i++) {
++ struct pci_dev *pdev;
+ nv_gpu_info_t gpu_info;
+ struct nvidia_softc *sc = devclass_get_softc(nvidia_devclass, i);
+ if (!sc) {
+@@ -124,11 +125,33 @@ int nv_drm_probe_devices(void)
+ nv_state_t *nv = sc->nv_state;
+
+ /*
++ * Set the ivars for this device if they are not already populated. This
++ * is the bus specific data, and linuxkpi will try to use it.
++ */
++ if (!device_get_ivars(sc->dev)) {
++ device_t parent = device_get_parent(sc->dev);
++ struct pci_devinfo *dinfo = device_get_ivars(parent);
++ device_set_ivars(sc->dev, dinfo);
++ }
++
++ /*
+ * Now we have the state (which gives us the device_t), but what nvidia-drm
+ * wants is a pci_dev suitable for use with linuxkpi code. We can use
+- * lkpinew_pci_dev to fill in a pci_dev struct,
++ * lkpinew_pci_dev to fill in a pci_dev struct, or linux_pci_attach on more
++ * recent kernels (introduced by 253dbe7487705).
+ */
+- struct pci_dev *pdev = lkpinew_pci_dev(sc->dev);
++#if __FreeBSD_version < 1300093
++ pdev = lkpinew_pci_dev(sc->dev);
++#else
++ pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK|M_ZERO);
++ if (!pdev) {
++ return -ENOMEM;
++ }
++
++ if (linux_pci_attach_device(sc->dev, NULL, NULL, pdev)) {
++ return -ENOMEM;
++ }
++#endif
+ nv_lkpi_pci_devs[i] = pdev;
+
+ gpu_info.gpu_id = nv->gpu_id;
+@@ -148,7 +171,6 @@ MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1);
+ LKPI_DRIVER_MODULE(nvidia_drm, nv_drm_init, nv_drm_exit);
+ LKPI_PNP_INFO(pci, nvidia_drm, nv_module_device_table);
+ MODULE_DEPEND(nvidia_drm, linuxkpi, 1, 1, 1);
+-MODULE_DEPEND(nvidia_drm, linuxkpi_gplv2, 1, 1, 1);
+ MODULE_DEPEND(nvidia_drm, drmn, 2, 2, 2);
+ MODULE_DEPEND(nvidia_drm, dmabuf, 1, 1, 1);
+ MODULE_DEPEND(nvidia_drm, nvidia, 1, 1, 1);
diff --git a/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-freebsd-lkpi.c-20250918-01 b/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-freebsd-lkpi.c-20250918-01
new file mode 100644
index 000000000000..c703950a0c88
--- /dev/null
+++ b/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-freebsd-lkpi.c-20250918-01
@@ -0,0 +1,47 @@
+--- nvidia-drm-freebsd-lkpi.c.orig 2025-08-27 17:59:14 UTC
++++ nvidia-drm-freebsd-lkpi.c
+@@ -104,6 +104,35 @@ lkpinew_pci_dev(device_t dev)
+ * FreeBSD linuxkpi based loading support code.
+ *************************************************************************/
+
++static int
++dummy_nv_pci_probe(struct pci_dev *pci_dev __unused,
++ const struct pci_device_id *id_table __unused)
++{
++ return (0);
++}
++
++static void
++dummy_nv_pci_remove(struct pci_dev *pci_dev __unused)
++{
++}
++
++static void
++dummy_nv_pci_shutdown(struct pci_dev *pci_dev __unused)
++{
++}
++
++struct pci_driver nv_pci_driver = {
++ .name = "drmn",
++ .id_table = nv_pci_table,
++ .probe = dummy_nv_pci_probe,
++ .remove = dummy_nv_pci_remove,
++ .shutdown = dummy_nv_pci_shutdown,
++#if defined(__FreeBSD__)
++ /* FreeBSD internal/specifc. */
++ .isdrm = true,
++#endif
++};
++
+ static struct pci_dev *nv_lkpi_pci_devs[NV_MAX_DEVICES];
+
+ int nv_drm_probe_devices(void)
+@@ -153,7 +182,7 @@ int nv_drm_probe_devices(void)
+ return -ENOMEM;
+ }
+
+- if (linux_pci_attach_device(sc->dev, NULL, NULL, pdev)) {
++ if (linux_pci_attach_device(sc->dev, &nv_pci_driver, NULL, pdev)) {
+ NV_DRM_LOG_ERR("Failed to attach linuxkpi PCI device");
+ free(pdev, M_DEVBUF);
+ return -ENOMEM;