Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F176302882
D57989.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
40 KB
Referenced Files
None
Subscribers
None
D57989.diff
View Options
diff --git a/graphics/nvidia-drm-515-kmod-580/Makefile b/graphics/nvidia-drm-515-kmod-580/Makefile
--- 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
--- 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
--- 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
--- /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
--- /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
--- 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
--- /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
--- 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
--- 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
--- 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
--- /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
--- /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
--- /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
--- 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
--- 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
--- 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
--- /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
--- /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
--- /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
--- 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
--- 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
--- 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
--- /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
--- /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
--- /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
--- a/graphics/nvidia-drm-kmod/Makefile.common
+++ b/graphics/nvidia-drm-kmod/Makefile.common
@@ -81,6 +81,11 @@
${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
--- 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
--- 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
--- 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
--- /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
+
+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-latest-kmod/files/patch-nvidia-drm-gem-user-memory.c b/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-gem-user-memory.c
new file mode 100644
--- /dev/null
+++ b/graphics/nvidia-drm-latest-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-latest-kmod/files/patch-nvidia-drm-helper.h b/graphics/nvidia-drm-latest-kmod/files/patch-nvidia-drm-helper.h
new file mode 100644
--- /dev/null
+++ b/graphics/nvidia-drm-latest-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,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 18, 6:58 PM (7 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41009502
Default Alt Text
D57989.diff (40 KB)
Attached To
Mode
D57989: graphics/nvidia-drm-*-kmod*: Fix General Protection Fault in specific configurations
Attached
Detach File
Event Timeline
Log In to Comment