Skip to content

Commit

Permalink
graphics/nvidia-drm-66-kmod: add new port
Browse files Browse the repository at this point in the history
This adds the corresponding nvidia-drm port for drm-66-kmod. This
chases commit 00508c0.

Sponsored by:	NVIDIA
Reviewed by:	kbowling (mentor), manu
Differential Revision:	https://reviews.freebsd.org/D49065
  • Loading branch information
Austin Shafer authored and Austin Shafer committed Feb 20, 2025
1 parent e30c064 commit 3dc2b5a
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 3 deletions.
1 change: 1 addition & 0 deletions graphics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@
SUBDIR += nvidia-drm-510-kmod
SUBDIR += nvidia-drm-515-kmod
SUBDIR += nvidia-drm-61-kmod
SUBDIR += nvidia-drm-66-kmod
SUBDIR += nvidia-drm-kmod
SUBDIR += nvidia-texture-tools
SUBDIR += ocaml-cairo
Expand Down
2 changes: 1 addition & 1 deletion graphics/nvidia-drm-510-kmod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CATEGORIES= graphics

BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-510-kmod
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-510-kmod
CONFLICTS_INSTALL= nvidia-drm-515-kmod nvidia-drm-61-kmod
CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-61-kmod nvidia-drm-66-kmod

.include "${.CURDIR}/../drm-510-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
Expand Down
2 changes: 1 addition & 1 deletion graphics/nvidia-drm-515-kmod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CATEGORIES= graphics

BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-515-kmod
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-515-kmod
CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-61-kmod
CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-61-kmod nvidia-drm-66-kmod

.include "${.CURDIR}/../drm-515-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
Expand Down
2 changes: 1 addition & 1 deletion graphics/nvidia-drm-61-kmod/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CATEGORIES= graphics

BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-61-kmod
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-61-kmod
CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-515-kmod
CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-515-kmod nvidia-drm-66-kmod

.include "${.CURDIR}/../drm-61-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"
Expand Down
11 changes: 11 additions & 0 deletions graphics/nvidia-drm-66-kmod/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PORTNAME= nvidia-drm-66-kmod
CATEGORIES= graphics

BUILD_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-66-kmod
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-66-kmod
CONFLICTS_INSTALL= nvidia-drm-510-kmod nvidia-drm-515-kmod nvidia-drm-61-kmod

.include "${.CURDIR}/../drm-66-kmod/Makefile.version"
.include "${.CURDIR}/../nvidia-drm-kmod/Makefile.common"

.include <bsd.port.mk>
5 changes: 5 additions & 0 deletions graphics/nvidia-drm-66-kmod/distinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TIMESTAMP = 1739992459
SHA256 (NVIDIA-FreeBSD-x86_64-550.127.05.tar.xz) = 74557d328ad74f604599ee2df3d42defc86ebe231e7cbe99c860f928f16a0bc3
SIZE (NVIDIA-FreeBSD-x86_64-550.127.05.tar.xz) = 143641432
SHA256 (freebsd-drm-kmod-drm_v6.6.25_1_GH0.tar.gz) = 9de65da6907e2b61b09e9836e923b48dc029e68e2cb4521c17df75f3529fa640
SIZE (freebsd-drm-kmod-drm_v6.6.25_1_GH0.tar.gz) = 38488410
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 3 additions & 0 deletions graphics/nvidia-drm-66-kmod/pkg-descr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FreeBSD port of Linux's nvidia-drm.ko Kernel module.

This version is compatible with drm.ko 6.6.
8 changes: 8 additions & 0 deletions graphics/nvidia-drm-66-kmod/pkg-message
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Modesetting must be enabled to use nvidia-drm.ko for graphics. This can be done
by setting the modeset sysctl, the equivalent of the modeset kernel parameter
on Linux.

hw.nvidiadrm.modeset=1

This must be set before loading nvdidia-drm.ko, most easily done by placing the
above in /boot/loader.conf.

0 comments on commit 3dc2b5a

Please sign in to comment.