git: 1959aaa9de6a - main - graphics/nvidia-drm-*-kmod*: Fix GPF in some configs
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 01 Jul 2026 23:30:54 UTC
The branch main has been updated by kbowling:
URL: https://cgit.FreeBSD.org/ports/commit/?id=1959aaa9de6a660c326fc567bfc650b178f0b63f
commit 1959aaa9de6a660c326fc567bfc650b178f0b63f
Author: Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
AuthorDate: 2026-07-01 23:28:16 +0000
Commit: Kevin Bowling <kbowling@FreeBSD.org>
CommitDate: 2026-07-01 23:28:16 +0000
graphics/nvidia-drm-*-kmod*: Fix GPF in some configs
Fix General Protection Fault in __nv_drm_gem_nvkms_handle_vma_fault,
lkpi_vmf_insert_pnf_prot_locked, vm_page_busy_acquire in specific
configurations, notably KDE on Wayland.
PR: 296195
Reported by: keivan@motavalli.me
Reviewed by: ashafer
Tested by: keivan@motavalli.me
Differential Revision: https://reviews.freebsd.org/D57989
Co-authored by: ashafer@FreeBSD.org
---
graphics/nvidia-drm-515-kmod-580/Makefile | 2 +-
graphics/nvidia-drm-515-kmod-devel/Makefile | 2 +-
graphics/nvidia-drm-515-kmod/Makefile | 2 +-
.../files/patch-nvidia-drm-gem-nvkms-memory.c | 54 +++++++++++++++++++
.../files/patch-nvidia-drm-gem-user-memory.c | 39 ++++++++++++++
.../files/patch-nvidia-drm-gem.c | 18 -------
.../files/patch-nvidia-drm-helper.h | 60 ++++++++++++++++++++++
graphics/nvidia-drm-61-kmod-580/Makefile | 2 +-
graphics/nvidia-drm-61-kmod-devel/Makefile | 2 +-
graphics/nvidia-drm-61-kmod/Makefile | 2 +-
.../files/patch-nvidia-drm-gem-nvkms-memory.c | 54 +++++++++++++++++++
.../files/patch-nvidia-drm-gem-user-memory.c | 39 ++++++++++++++
.../files/patch-nvidia-drm-helper.h | 60 ++++++++++++++++++++++
graphics/nvidia-drm-612-kmod-580/Makefile | 2 +-
graphics/nvidia-drm-612-kmod-devel/Makefile | 2 +-
graphics/nvidia-drm-612-kmod/Makefile | 2 +-
.../files/patch-nvidia-drm-gem-nvkms-memory.c | 54 +++++++++++++++++++
.../files/patch-nvidia-drm-gem-user-memory.c | 39 ++++++++++++++
.../files/patch-nvidia-drm-helper.h | 60 ++++++++++++++++++++++
graphics/nvidia-drm-66-kmod-580/Makefile | 2 +-
graphics/nvidia-drm-66-kmod-devel/Makefile | 2 +-
graphics/nvidia-drm-66-kmod/Makefile | 2 +-
.../files/patch-nvidia-drm-gem-nvkms-memory.c | 54 +++++++++++++++++++
.../files/patch-nvidia-drm-gem-user-memory.c | 39 ++++++++++++++
.../files/patch-nvidia-drm-helper.h | 60 ++++++++++++++++++++++
graphics/nvidia-drm-kmod/Makefile.common | 5 ++
graphics/nvidia-drm-latest-kmod-580/Makefile | 2 +-
graphics/nvidia-drm-latest-kmod-devel/Makefile | 2 +-
graphics/nvidia-drm-latest-kmod/Makefile | 2 +-
.../files/patch-nvidia-drm-gem-nvkms-memory.c | 54 +++++++++++++++++++
.../files/patch-nvidia-drm-gem-user-memory.c | 39 ++++++++++++++
.../files/patch-nvidia-drm-helper.h | 60 ++++++++++++++++++++++
32 files changed, 785 insertions(+), 33 deletions(-)
diff --git a/graphics/nvidia-drm-515-kmod-580/Makefile b/graphics/nvidia-drm-515-kmod-580/Makefile
index 5811c6c05558..6b237d7df0ca 100644
--- a/graphics/nvidia-drm-515-kmod-580/Makefile
+++ b/graphics/nvidia-drm-515-kmod-580/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 580.159.04
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 2
+PORTREVISION= 3
MASTERDIR= ${.CURDIR}/../nvidia-drm-515-kmod
PKGNAMESUFFIX= -580
diff --git a/graphics/nvidia-drm-515-kmod-devel/Makefile b/graphics/nvidia-drm-515-kmod-devel/Makefile
index a12d6ca6d511..3017edd24efc 100644
--- a/graphics/nvidia-drm-515-kmod-devel/Makefile
+++ b/graphics/nvidia-drm-515-kmod-devel/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 610.43.02
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 1
+PORTREVISION= 2
MASTERDIR= ${.CURDIR}/../nvidia-drm-515-kmod
PKGNAMESUFFIX= -devel
diff --git a/graphics/nvidia-drm-515-kmod/Makefile b/graphics/nvidia-drm-515-kmod/Makefile
index 0766514f6d54..fc5f1f0fbdc2 100644
--- a/graphics/nvidia-drm-515-kmod/Makefile
+++ b/graphics/nvidia-drm-515-kmod/Makefile
@@ -1,5 +1,5 @@
PORTNAME= nvidia-drm-515-kmod
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-515-kmod
diff --git a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
new file mode 100644
index 000000000000..4ca6b309249d
--- /dev/null
+++ b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
@@ -0,0 +1,54 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-nvkms-memory.c.orig nvidia-drm-gem-nvkms-memory.c
+index 60f490f89dca..6aa0e40bcb1a 100644
+--- nvidia-drm-gem-nvkms-memory.c.orig
++++ nvidia-drm-gem-nvkms-memory.c
+@@ -124,22 +124,12 @@ static vm_fault_t __nv_drm_gem_nvkms_handle_vma_fault(
+ unsigned long page_offset, pfn;
+ vm_fault_t ret;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+
+ if (nv_nvkms_memory->pages_count == 0) {
+ pfn = (unsigned long)(uintptr_t)nv_nvkms_memory->pPhysicalAddress;
+ pfn >>= PAGE_SHIFT;
+-#if defined(NV_LINUX)
+- /*
+- * FreeBSD doesn't set pgoff. We instead have pfn be the base physical
+- * address, and we will calculate the index pidx from the virtual address.
+- *
+- * This only works because linux_cdev_pager_populate passes the pidx as
+- * vmf->virtual_address. Then we turn the virtual address
+- * into a physical page number.
+- */
+ pfn += page_offset;
+-#endif
+ } else {
+ BUG_ON(page_offset >= nv_nvkms_memory->pages_count);
+ pfn = page_to_pfn(nv_nvkms_memory->pages[page_offset]);
diff --git a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem-user-memory.c b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem-user-memory.c
new file mode 100644
index 000000000000..2bd7c897a50e
--- /dev/null
+++ b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem-user-memory.c
@@ -0,0 +1,39 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-user-memory.c.orig nvidia-drm-gem-user-memory.c
+index 5ce0ba890e52..0ca3a7e2e07d 100644
+--- nvidia-drm-gem-user-memory.c.orig
++++ nvidia-drm-gem-user-memory.c
+@@ -144,7 +144,7 @@ static vm_fault_t __nv_drm_gem_user_memory_handle_vma_fault(
+ unsigned long page_offset;
+ unsigned long pfn;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+ BUG_ON(page_offset >= nv_user_memory->pages_count);
+ pfn = page_to_pfn(nv_user_memory->pages[page_offset]);
+
diff --git a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem.c b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem.c
deleted file mode 100644
index 5693b76d27c4..000000000000
--- a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-gem.c
+++ /dev/null
@@ -1,18 +0,0 @@
---- nvidia-drm-gem.c.orig 2023-12-29 19:08:23 UTC
-+++ nvidia-drm-gem.c
-@@ -68,15 +68,7 @@ void nv_drm_gem_free(struct drm_gem_object *gem)
- #if !defined(NV_DRM_DRIVER_HAS_GEM_PRIME_CALLBACKS) && \
- defined(NV_DRM_GEM_OBJECT_VMAP_HAS_MAP_ARG)
-
--/*
-- * The 'dma_buf_map' structure is renamed to 'iosys_map' by the commit
-- * 7938f4218168 ("dma-buf-map: Rename to iosys-map").
-- */
--#if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
--typedef struct iosys_map nv_sysio_map_t;
--#else
- typedef struct dma_buf_map nv_sysio_map_t;
--#endif
-
- static int nv_drm_gem_vmap(struct drm_gem_object *gem,
- nv_sysio_map_t *map)
diff --git a/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-helper.h b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-helper.h
new file mode 100644
index 000000000000..6929f75cae28
--- /dev/null
+++ b/graphics/nvidia-drm-515-kmod/files/patch-nvidia-drm-helper.h
@@ -0,0 +1,60 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-helper.h.orig nvidia-drm-helper.h
+index bc91858136b2..2ef27fced3c5 100644
+--- nvidia-drm-helper.h.orig
++++ nvidia-drm-helper.h
+@@ -51,6 +51,29 @@
+ #define NV_DRM_USE_EXTENDED_PROPERTIES (DRM_OBJECT_MAX_PROPERTY >= 64)
+
+ #include <drm/drm_prime.h>
++#include <drm/drm_gem.h>
++#include <linux/mm.h>
++
++/*
++ * nv_drm_vma_fault_get_page_offset - compute GEM page offset from a vm_fault
++ *
++ * On Linux, vmf->pgoff carries the file-level page index set by the VM.
++ * On FreeBSD, linux_cdev_pager_populate() sets vmf->pgoff = 0 and instead
++ * passes the page index (pidx) via vmf->virtual_address as IDX_TO_OFF(pidx).
++ * Convert back with OFF_TO_IDX and subtract the GEM vma_node start to get
++ * the page offset within the GEM object.
++ */
++static inline unsigned long
++nv_drm_vma_fault_get_page_offset(struct vm_fault *vmf,
++ struct drm_gem_object *gem)
++{
++#if defined(NV_LINUX)
++ unsigned long offset = vmf->pgoff;
++#else
++ unsigned long offset = OFF_TO_IDX((uintptr_t)vmf->virtual_address);
++#endif
++ return offset - drm_vma_node_start(&gem->vma_node);
++}
+
+ static inline struct sg_table*
+ nv_drm_prime_pages_to_sg(struct drm_device *dev,
diff --git a/graphics/nvidia-drm-61-kmod-580/Makefile b/graphics/nvidia-drm-61-kmod-580/Makefile
index 44e7a72a1f5e..18f21da3b96f 100644
--- a/graphics/nvidia-drm-61-kmod-580/Makefile
+++ b/graphics/nvidia-drm-61-kmod-580/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 580.159.04
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 2
+PORTREVISION= 3
MASTERDIR= ${.CURDIR}/../nvidia-drm-61-kmod
PKGNAMESUFFIX= -580
diff --git a/graphics/nvidia-drm-61-kmod-devel/Makefile b/graphics/nvidia-drm-61-kmod-devel/Makefile
index 39b3624484ef..8902aa09a1f5 100644
--- a/graphics/nvidia-drm-61-kmod-devel/Makefile
+++ b/graphics/nvidia-drm-61-kmod-devel/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 610.43.02
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 1
+PORTREVISION= 2
MASTERDIR= ${.CURDIR}/../nvidia-drm-61-kmod
PKGNAMESUFFIX= -devel
diff --git a/graphics/nvidia-drm-61-kmod/Makefile b/graphics/nvidia-drm-61-kmod/Makefile
index 8f941b48148d..0ff6e9ca78d2 100644
--- a/graphics/nvidia-drm-61-kmod/Makefile
+++ b/graphics/nvidia-drm-61-kmod/Makefile
@@ -1,5 +1,5 @@
PORTNAME= nvidia-drm-61-kmod
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-61-kmod
diff --git a/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
new file mode 100644
index 000000000000..4ca6b309249d
--- /dev/null
+++ b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
@@ -0,0 +1,54 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-nvkms-memory.c.orig nvidia-drm-gem-nvkms-memory.c
+index 60f490f89dca..6aa0e40bcb1a 100644
+--- nvidia-drm-gem-nvkms-memory.c.orig
++++ nvidia-drm-gem-nvkms-memory.c
+@@ -124,22 +124,12 @@ static vm_fault_t __nv_drm_gem_nvkms_handle_vma_fault(
+ unsigned long page_offset, pfn;
+ vm_fault_t ret;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+
+ if (nv_nvkms_memory->pages_count == 0) {
+ pfn = (unsigned long)(uintptr_t)nv_nvkms_memory->pPhysicalAddress;
+ pfn >>= PAGE_SHIFT;
+-#if defined(NV_LINUX)
+- /*
+- * FreeBSD doesn't set pgoff. We instead have pfn be the base physical
+- * address, and we will calculate the index pidx from the virtual address.
+- *
+- * This only works because linux_cdev_pager_populate passes the pidx as
+- * vmf->virtual_address. Then we turn the virtual address
+- * into a physical page number.
+- */
+ pfn += page_offset;
+-#endif
+ } else {
+ BUG_ON(page_offset >= nv_nvkms_memory->pages_count);
+ pfn = page_to_pfn(nv_nvkms_memory->pages[page_offset]);
diff --git a/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-gem-user-memory.c b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-gem-user-memory.c
new file mode 100644
index 000000000000..2bd7c897a50e
--- /dev/null
+++ b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-gem-user-memory.c
@@ -0,0 +1,39 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-user-memory.c.orig nvidia-drm-gem-user-memory.c
+index 5ce0ba890e52..0ca3a7e2e07d 100644
+--- nvidia-drm-gem-user-memory.c.orig
++++ nvidia-drm-gem-user-memory.c
+@@ -144,7 +144,7 @@ static vm_fault_t __nv_drm_gem_user_memory_handle_vma_fault(
+ unsigned long page_offset;
+ unsigned long pfn;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+ BUG_ON(page_offset >= nv_user_memory->pages_count);
+ pfn = page_to_pfn(nv_user_memory->pages[page_offset]);
+
diff --git a/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-helper.h b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-helper.h
new file mode 100644
index 000000000000..6929f75cae28
--- /dev/null
+++ b/graphics/nvidia-drm-61-kmod/files/patch-nvidia-drm-helper.h
@@ -0,0 +1,60 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-helper.h.orig nvidia-drm-helper.h
+index bc91858136b2..2ef27fced3c5 100644
+--- nvidia-drm-helper.h.orig
++++ nvidia-drm-helper.h
+@@ -51,6 +51,29 @@
+ #define NV_DRM_USE_EXTENDED_PROPERTIES (DRM_OBJECT_MAX_PROPERTY >= 64)
+
+ #include <drm/drm_prime.h>
++#include <drm/drm_gem.h>
++#include <linux/mm.h>
++
++/*
++ * nv_drm_vma_fault_get_page_offset - compute GEM page offset from a vm_fault
++ *
++ * On Linux, vmf->pgoff carries the file-level page index set by the VM.
++ * On FreeBSD, linux_cdev_pager_populate() sets vmf->pgoff = 0 and instead
++ * passes the page index (pidx) via vmf->virtual_address as IDX_TO_OFF(pidx).
++ * Convert back with OFF_TO_IDX and subtract the GEM vma_node start to get
++ * the page offset within the GEM object.
++ */
++static inline unsigned long
++nv_drm_vma_fault_get_page_offset(struct vm_fault *vmf,
++ struct drm_gem_object *gem)
++{
++#if defined(NV_LINUX)
++ unsigned long offset = vmf->pgoff;
++#else
++ unsigned long offset = OFF_TO_IDX((uintptr_t)vmf->virtual_address);
++#endif
++ return offset - drm_vma_node_start(&gem->vma_node);
++}
+
+ static inline struct sg_table*
+ nv_drm_prime_pages_to_sg(struct drm_device *dev,
diff --git a/graphics/nvidia-drm-612-kmod-580/Makefile b/graphics/nvidia-drm-612-kmod-580/Makefile
index 30f4499ebec1..9462932f1424 100644
--- a/graphics/nvidia-drm-612-kmod-580/Makefile
+++ b/graphics/nvidia-drm-612-kmod-580/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 580.159.04
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 1
+PORTREVISION= 2
MASTERDIR= ${.CURDIR}/../nvidia-drm-612-kmod
PKGNAMESUFFIX= -580
diff --git a/graphics/nvidia-drm-612-kmod-devel/Makefile b/graphics/nvidia-drm-612-kmod-devel/Makefile
index 0587df6f2cc2..57d0cb4b2c2b 100644
--- a/graphics/nvidia-drm-612-kmod-devel/Makefile
+++ b/graphics/nvidia-drm-612-kmod-devel/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 610.43.02
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 1
+PORTREVISION= 2
MASTERDIR= ${.CURDIR}/../nvidia-drm-612-kmod
PKGNAMESUFFIX= -devel
diff --git a/graphics/nvidia-drm-612-kmod/Makefile b/graphics/nvidia-drm-612-kmod/Makefile
index 1467c5ad5ed4..daae7c7620d9 100644
--- a/graphics/nvidia-drm-612-kmod/Makefile
+++ b/graphics/nvidia-drm-612-kmod/Makefile
@@ -1,5 +1,5 @@
PORTNAME= nvidia-drm-612-kmod
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-612-kmod
diff --git a/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c b/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
new file mode 100644
index 000000000000..4ca6b309249d
--- /dev/null
+++ b/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
@@ -0,0 +1,54 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-nvkms-memory.c.orig nvidia-drm-gem-nvkms-memory.c
+index 60f490f89dca..6aa0e40bcb1a 100644
+--- nvidia-drm-gem-nvkms-memory.c.orig
++++ nvidia-drm-gem-nvkms-memory.c
+@@ -124,22 +124,12 @@ static vm_fault_t __nv_drm_gem_nvkms_handle_vma_fault(
+ unsigned long page_offset, pfn;
+ vm_fault_t ret;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+
+ if (nv_nvkms_memory->pages_count == 0) {
+ pfn = (unsigned long)(uintptr_t)nv_nvkms_memory->pPhysicalAddress;
+ pfn >>= PAGE_SHIFT;
+-#if defined(NV_LINUX)
+- /*
+- * FreeBSD doesn't set pgoff. We instead have pfn be the base physical
+- * address, and we will calculate the index pidx from the virtual address.
+- *
+- * This only works because linux_cdev_pager_populate passes the pidx as
+- * vmf->virtual_address. Then we turn the virtual address
+- * into a physical page number.
+- */
+ pfn += page_offset;
+-#endif
+ } else {
+ BUG_ON(page_offset >= nv_nvkms_memory->pages_count);
+ pfn = page_to_pfn(nv_nvkms_memory->pages[page_offset]);
diff --git a/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-gem-user-memory.c b/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-gem-user-memory.c
new file mode 100644
index 000000000000..2bd7c897a50e
--- /dev/null
+++ b/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-gem-user-memory.c
@@ -0,0 +1,39 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-user-memory.c.orig nvidia-drm-gem-user-memory.c
+index 5ce0ba890e52..0ca3a7e2e07d 100644
+--- nvidia-drm-gem-user-memory.c.orig
++++ nvidia-drm-gem-user-memory.c
+@@ -144,7 +144,7 @@ static vm_fault_t __nv_drm_gem_user_memory_handle_vma_fault(
+ unsigned long page_offset;
+ unsigned long pfn;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+ BUG_ON(page_offset >= nv_user_memory->pages_count);
+ pfn = page_to_pfn(nv_user_memory->pages[page_offset]);
+
diff --git a/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-helper.h b/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-helper.h
new file mode 100644
index 000000000000..6929f75cae28
--- /dev/null
+++ b/graphics/nvidia-drm-612-kmod/files/patch-nvidia-drm-helper.h
@@ -0,0 +1,60 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-helper.h.orig nvidia-drm-helper.h
+index bc91858136b2..2ef27fced3c5 100644
+--- nvidia-drm-helper.h.orig
++++ nvidia-drm-helper.h
+@@ -51,6 +51,29 @@
+ #define NV_DRM_USE_EXTENDED_PROPERTIES (DRM_OBJECT_MAX_PROPERTY >= 64)
+
+ #include <drm/drm_prime.h>
++#include <drm/drm_gem.h>
++#include <linux/mm.h>
++
++/*
++ * nv_drm_vma_fault_get_page_offset - compute GEM page offset from a vm_fault
++ *
++ * On Linux, vmf->pgoff carries the file-level page index set by the VM.
++ * On FreeBSD, linux_cdev_pager_populate() sets vmf->pgoff = 0 and instead
++ * passes the page index (pidx) via vmf->virtual_address as IDX_TO_OFF(pidx).
++ * Convert back with OFF_TO_IDX and subtract the GEM vma_node start to get
++ * the page offset within the GEM object.
++ */
++static inline unsigned long
++nv_drm_vma_fault_get_page_offset(struct vm_fault *vmf,
++ struct drm_gem_object *gem)
++{
++#if defined(NV_LINUX)
++ unsigned long offset = vmf->pgoff;
++#else
++ unsigned long offset = OFF_TO_IDX((uintptr_t)vmf->virtual_address);
++#endif
++ return offset - drm_vma_node_start(&gem->vma_node);
++}
+
+ static inline struct sg_table*
+ nv_drm_prime_pages_to_sg(struct drm_device *dev,
diff --git a/graphics/nvidia-drm-66-kmod-580/Makefile b/graphics/nvidia-drm-66-kmod-580/Makefile
index 66d7a907384a..fe4a66924879 100644
--- a/graphics/nvidia-drm-66-kmod-580/Makefile
+++ b/graphics/nvidia-drm-66-kmod-580/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 580.159.04
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 2
+PORTREVISION= 3
MASTERDIR= ${.CURDIR}/../nvidia-drm-66-kmod
PKGNAMESUFFIX= -580
diff --git a/graphics/nvidia-drm-66-kmod-devel/Makefile b/graphics/nvidia-drm-66-kmod-devel/Makefile
index 7c43544475f6..c2fed27edac2 100644
--- a/graphics/nvidia-drm-66-kmod-devel/Makefile
+++ b/graphics/nvidia-drm-66-kmod-devel/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 610.43.02
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 1
+PORTREVISION= 2
MASTERDIR= ${.CURDIR}/../nvidia-drm-66-kmod
PKGNAMESUFFIX= -devel
diff --git a/graphics/nvidia-drm-66-kmod/Makefile b/graphics/nvidia-drm-66-kmod/Makefile
index f9149f513ad0..55a9e2aaef7a 100644
--- a/graphics/nvidia-drm-66-kmod/Makefile
+++ b/graphics/nvidia-drm-66-kmod/Makefile
@@ -1,5 +1,5 @@
PORTNAME= nvidia-drm-66-kmod
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-66-kmod
diff --git a/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c b/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
new file mode 100644
index 000000000000..4ca6b309249d
--- /dev/null
+++ b/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
@@ -0,0 +1,54 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-nvkms-memory.c.orig nvidia-drm-gem-nvkms-memory.c
+index 60f490f89dca..6aa0e40bcb1a 100644
+--- nvidia-drm-gem-nvkms-memory.c.orig
++++ nvidia-drm-gem-nvkms-memory.c
+@@ -124,22 +124,12 @@ static vm_fault_t __nv_drm_gem_nvkms_handle_vma_fault(
+ unsigned long page_offset, pfn;
+ vm_fault_t ret;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+
+ if (nv_nvkms_memory->pages_count == 0) {
+ pfn = (unsigned long)(uintptr_t)nv_nvkms_memory->pPhysicalAddress;
+ pfn >>= PAGE_SHIFT;
+-#if defined(NV_LINUX)
+- /*
+- * FreeBSD doesn't set pgoff. We instead have pfn be the base physical
+- * address, and we will calculate the index pidx from the virtual address.
+- *
+- * This only works because linux_cdev_pager_populate passes the pidx as
+- * vmf->virtual_address. Then we turn the virtual address
+- * into a physical page number.
+- */
+ pfn += page_offset;
+-#endif
+ } else {
+ BUG_ON(page_offset >= nv_nvkms_memory->pages_count);
+ pfn = page_to_pfn(nv_nvkms_memory->pages[page_offset]);
diff --git a/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-gem-user-memory.c b/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-gem-user-memory.c
new file mode 100644
index 000000000000..2bd7c897a50e
--- /dev/null
+++ b/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-gem-user-memory.c
@@ -0,0 +1,39 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-gem-user-memory.c.orig nvidia-drm-gem-user-memory.c
+index 5ce0ba890e52..0ca3a7e2e07d 100644
+--- nvidia-drm-gem-user-memory.c.orig
++++ nvidia-drm-gem-user-memory.c
+@@ -144,7 +144,7 @@ static vm_fault_t __nv_drm_gem_user_memory_handle_vma_fault(
+ unsigned long page_offset;
+ unsigned long pfn;
+
+- page_offset = vmf->pgoff - drm_vma_node_start(&gem->vma_node);
++ page_offset = nv_drm_vma_fault_get_page_offset(vmf, gem);
+ BUG_ON(page_offset >= nv_user_memory->pages_count);
+ pfn = page_to_pfn(nv_user_memory->pages[page_offset]);
+
diff --git a/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-helper.h b/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-helper.h
new file mode 100644
index 000000000000..6929f75cae28
--- /dev/null
+++ b/graphics/nvidia-drm-66-kmod/files/patch-nvidia-drm-helper.h
@@ -0,0 +1,60 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
+
+Splitted into per-target.
+
+diff --git nvidia-drm-helper.h.orig nvidia-drm-helper.h
+index bc91858136b2..2ef27fced3c5 100644
+--- nvidia-drm-helper.h.orig
++++ nvidia-drm-helper.h
+@@ -51,6 +51,29 @@
+ #define NV_DRM_USE_EXTENDED_PROPERTIES (DRM_OBJECT_MAX_PROPERTY >= 64)
+
+ #include <drm/drm_prime.h>
++#include <drm/drm_gem.h>
++#include <linux/mm.h>
++
++/*
++ * nv_drm_vma_fault_get_page_offset - compute GEM page offset from a vm_fault
++ *
++ * On Linux, vmf->pgoff carries the file-level page index set by the VM.
++ * On FreeBSD, linux_cdev_pager_populate() sets vmf->pgoff = 0 and instead
++ * passes the page index (pidx) via vmf->virtual_address as IDX_TO_OFF(pidx).
++ * Convert back with OFF_TO_IDX and subtract the GEM vma_node start to get
++ * the page offset within the GEM object.
++ */
++static inline unsigned long
++nv_drm_vma_fault_get_page_offset(struct vm_fault *vmf,
++ struct drm_gem_object *gem)
++{
++#if defined(NV_LINUX)
++ unsigned long offset = vmf->pgoff;
++#else
++ unsigned long offset = OFF_TO_IDX((uintptr_t)vmf->virtual_address);
++#endif
++ return offset - drm_vma_node_start(&gem->vma_node);
++}
+
+ static inline struct sg_table*
+ nv_drm_prime_pages_to_sg(struct drm_device *dev,
diff --git a/graphics/nvidia-drm-kmod/Makefile.common b/graphics/nvidia-drm-kmod/Makefile.common
index d303d5331bab..ea6b633c2530 100644
--- a/graphics/nvidia-drm-kmod/Makefile.common
+++ b/graphics/nvidia-drm-kmod/Makefile.common
@@ -81,6 +81,11 @@ post-patch:
${WRKSRC}/nvidia-drm-drv.c
${REINPLACE_CMD} -e 's:struct nv_drm_mst_display_info \*r_info = (struct nv_drm_mst_display_info:const struct nv_drm_mst_display_info \*r_info = (const struct nv_drm_mst_display_info:' \
${WRKSRC}/nvidia-drm-drv.c
+.endif
+ # Workaround for build failure on graphics/nvidia-drm-515-kmod*,
+ # as struct dma_buf_map was renamed to struct iosys_map at Linux 5.18 (DRM5.18).
+.if ${.CURDIR:M*nvidia-drm-515-kmod*}
+ ${REINPLACE_CMD} -e 's:defined(NV_LINUX_IOSYS_MAP_H_PRESENT):0:' ${WRKSRC}/nvidia-drm-gem.c
.endif
# We should support -CURRENT: kill the check (first #if __FreeBSD_version)
linenum=$$(${SED} -ne '/^#if __FreeBSD_version/ { = ; q ; }' \
diff --git a/graphics/nvidia-drm-latest-kmod-580/Makefile b/graphics/nvidia-drm-latest-kmod-580/Makefile
index 0ba4a3131682..9fa7548cfa5c 100644
--- a/graphics/nvidia-drm-latest-kmod-580/Makefile
+++ b/graphics/nvidia-drm-latest-kmod-580/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 580.159.04
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 1
+PORTREVISION= 2
MASTERDIR= ${.CURDIR}/../nvidia-drm-latest-kmod
PKGNAMESUFFIX= -580
diff --git a/graphics/nvidia-drm-latest-kmod-devel/Makefile b/graphics/nvidia-drm-latest-kmod-devel/Makefile
index ca2541b439ff..2a04afca2377 100644
--- a/graphics/nvidia-drm-latest-kmod-devel/Makefile
+++ b/graphics/nvidia-drm-latest-kmod-devel/Makefile
@@ -1,6 +1,6 @@
NVIDIA_DISTVERSION?= 610.43.02
# Explicitly set PORTREVISION as it can be overridden by the master port
-PORTREVISION= 0
+PORTREVISION= 1
MASTERDIR= ${.CURDIR}/../nvidia-drm-latest-kmod
PKGNAMESUFFIX= -devel
diff --git a/graphics/nvidia-drm-latest-kmod/Makefile b/graphics/nvidia-drm-latest-kmod/Makefile
index bff909dfdf6b..67bca41228f5 100644
--- a/graphics/nvidia-drm-latest-kmod/Makefile
+++ b/graphics/nvidia-drm-latest-kmod/Makefile
@@ -1,5 +1,5 @@
PORTNAME= nvidia-drm-latest-kmod
-PORTREVISION= 0
+PORTREVISION= 1
CATEGORIES= graphics
RUN_DEPENDS+= ${KMODDIR}/drm.ko:graphics/drm-latest-kmod
diff --git a/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c b/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
new file mode 100644
index 000000000000..4ca6b309249d
--- /dev/null
+++ b/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-gem-nvkms-memory.c
@@ -0,0 +1,54 @@
+commit c81cb2d87591863cd1d37ccb6143981462f215b7
+Author: Austin Shafer <ashafer@nvidia.com>
+Date: Sun May 17 14:14:58 2026 -0400
+
+ nvidia-drm: fix freebsd page offset during nvkms/user memory faults
+
+ This fixes the page offset calculation on freebsd with nvidia-drm
+ in our nvkms/user memory faults. With this we actually convert
+ virtual_address into a page index and use that to index into
+ our array of pages.
+
+ I found this and ran with it a bit myself, it also recently came
+ up and appears to fix a panic that an end user was running into:
+ https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=296195
+
+ Bug 317957: Clean up module branches
+ Reviewed by: rrameshbabu
+ Signed-off-for-open-source-by: ashafer
+
+ DVS_BUILD_INCLUDE ALL
+ MVS_SET_TESTS all
+ SUBMIT_GVS_OF_CUSTOM_DVS
+ https://builds4u.nvidia.com/dvs/#/change/38366516102499930.6?showTab=DVS
*** 142 LINES SKIPPED ***