#1136776 nvidia-graphics-drivers-tesla-470: FTBFS: nvidia/nv-mmap.c:805:24: error: 'VMA_LOCK_OFFSET' undeclared (first use in this function); did you mean 'VGA_CRTC_OFFSET'?

#1136776#5
Date:
2026-05-15 18:10:18 UTC
From:
To:
Dear maintainer:

During a rebuild of all packages in unstable, this package failed to build.

Below you will find the last part of the build log (probably the most
relevant part, but not necessarily). If required, the full build log
is available here:

https://people.debian.org/~sanvila/build-logs/202605/

About the archive rebuild: The build was made on virtual machines from AWS,
using sbuild and a reduced chroot with only build-essential packages.

If you cannot reproduce the bug please contact me privately, as I
am willing to provide ssh access to a virtual machine where the bug is
fully reproducible.

If this is really a bug in one of the build-depends, please use
reassign and add an affects on src:nvidia-graphics-drivers-tesla-470, so that this is still
visible in the BTS web page for this package.

Thanks.
--------------------------------------------------------------------------------
[...]
# CC [M]  nvidia/nv-p2p.o
   x86_64-linux-gnu-gcc-15 -Wp,-MMD,nvidia/.nv-p2p.o.d -nost [too-long-redacted] idia/nv-p2p.o nvidia/nv-p2p.c
nvidia/nv-mmap.c: In function ‘nv_vma_enter_locked’:
nvidia/nv-mmap.c:805:24: error: ‘VMA_LOCK_OFFSET’ undeclared (first use in this function); did you mean ‘VGA_CRTC_OFFSET’?
  805 |     NvU32 tgt_refcnt = VMA_LOCK_OFFSET;
      |                        ^~~~~~~~~~~~~~~
      |                        VGA_CRTC_OFFSET
nvidia/nv-mmap.c:805:24: note: each undeclared identifier is reported only once for each function it appears in
nvidia/nv-mmap.c: In function ‘nv_vma_start_write’:
nvidia/nv-mmap.c:857:9: error: too many arguments to function ‘__is_vma_write_locked’; expected 1, have 2
  857 |     if (__is_vma_write_locked(vma, &mm_lock_seq))
      |         ^~~~~~~~~~~~~~~~~~~~~      ~~~~~~~~~~~~
In file included from /usr/src/linux-headers-7.0.4+deb14-common/include/linux/mm.h:18,
                 from ././common/inc/nv-pgprot.h:17,
                 from ././common/inc/nv-linux.h:20,
                 from nvidia/nv-mmap.c:14:
/usr/src/linux-headers-7.0.4+deb14-common/include/linux/mmap_lock.h:282:20: note: declared here
  282 | static inline bool __is_vma_write_locked(struct vm_area_struct *vma)
      |                    ^~~~~~~~~~~~~~~~~~~~~
nvidia/nv-mmap.c:866:42: error: ‘VMA_LOCK_OFFSET’ undeclared (first use in this function); did you mean ‘VGA_CRTC_OFFSET’?
  866 |         detached = refcount_sub_and_test(VMA_LOCK_OFFSET, &vma->vm_refcnt);
      |                                          ^~~~~~~~~~~~~~~
      |                                          VGA_CRTC_OFFSET
make[8]: *** [/usr/src/linux-headers-7.0.4+deb14-common/scripts/Makefile.build:294: nvidia/nv-mmap.o] Error 1
make[8]: *** Waiting for unfinished jobs....
make[7]: *** [/usr/src/linux-headers-7.0.4+deb14-common/Makefile:2130: .] Error 2
make[6]: *** [/usr/src/linux-headers-7.0.4+deb14-common/Makefile:260: __sub-make] Error 2
make[6]: Leaving directory '/<<PKGBUILDDIR>>/kernel-source-tree'
make[5]: *** [Makefile:260: __sub-make] Error 2
make[5]: Leaving directory '/usr/src/linux-headers-7.0.4+deb14-common'
make[4]: *** [Makefile:90: modules] Error 2
make[4]: Leaving directory '/<<PKGBUILDDIR>>/kernel-source-tree'
make[3]: *** [debian/rules:314: override_dh_auto_test] Error 2
make[3]: Leaving directory '/<<PKGBUILDDIR>>'
make[2]: *** [debian/rules:225: build] Error 2
make[2]: Leaving directory '/<<PKGBUILDDIR>>'
make[1]: *** [debian/rules:225: install] Error 2
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:225: binary] Error 2
dpkg-buildpackage: error: debian/rules binary subprocess failed with exit status 2
--------------------------------------------------------------------------------

#1136776#10
Date:
2026-05-24 07:16:25 UTC
From:
To:
Hello,

please find the patch attached.
--------------------
Sincerely yours,
Damir Islamov

#1136776#15
Date:
2026-07-13 08:31:14 UTC
From:
To:
The attached patch makes the open kernel modules from
nvidia-graphics-drivers 550.163.01-4 (550.163.01) -- binary package
nvidia-open-kernel-dkms, DKMS module nvidia-current-open -- build and
run on Linux 7.1.3+deb14-amd64 (current sid).All behavioural
changes are conftest-guarded or rely on interfaces available throughout
the package's supported kernel range, so the tree remains buildable on
pre-7.x kernels (verified, see below).

The patch incorporates Damir Islamov's earlier VMA-locking fix from
this bug, with two adjustments:

 * the nv_is_vma_write_locked() helper is defined in nvidia/nv-mmap.c
   rather than common/inc/nv-mm.h, as the original hunk does not apply
   against the 550 tree's nv-mm.h;
 * the is_vma_write_locked_has_mm_lock_seq_arg conftest is registered
   in nvidia.Kbuild -- without registration the test never runs, the
   NV_IS_VMA_WRITE_LOCKED_HAS_MM_LOCK_SEQ_ARG macro is never defined,
   and the single-argument path is unconditionally selected, which
   would break the build on older kernels.

Additional Linux 7.x API changes addressed (new conftest tests
pci_resize_resource_has_exclude_bars_arg, dma_map_ops_has_map_resource,
dev_pagemap_ops_has_folio_free, zone_device_page_init_has_pgmap_arg;
registered in nvidia.Kbuild and nvidia-uvm.Kbuild respectively):

 * in_irq() removed: call sites use in_hardirq() (present since 5.11)
   with a preprocessor fallback in nv-time.h for older kernels
   (common/inc/nv-time.h, nvidia/os-interface.c);
 * __vm_flags removed from vm_area_struct: use __vm_flags_mod(), which
   is present on all kernels that can reach the affected
   !NV_CAN_CALL_VMA_START_WRITE branch and does not re-acquire the VMA
   write lock already taken by nv_vma_start_write()
   (common/inc/nv-mm.h);
 * pci_resize_resource() gained an exclude_bars argument: pass 0,
   conftest-guarded (nvidia/nv-pci.c);
 * dma_map_ops lost its .map_resource member: report resource mapping
   as usable when the member is absent, since the 7.x DMA core handles
   dma_map_resource() generically (nvidia/nv-dma.c);
 * ZONE_DEVICE folio conversion: .folio_free callback wrapper and
   3-argument zone_device_page_init(), both conftest-guarded
   (nvidia-uvm/uvm_pmm_gpu.c, nvidia-uvm/uvm_hmm.c);
 * legacy DRM_ERROR/DRM_WARN/DRM_INFO/DRM_DEBUG/DRM_DEBUG_DRIVER
   macros removed: #ifndef-guarded pr_* shims, no-ops where the
   macros still exist (nvidia-drm/nvidia-drm-priv.h);
 * atomic-state iterator fallbacks read the removed .state member:
   switched to .new_state, present since 4.12 and semantically
   identical at the pre-commit atomic_check call sites
   (nvidia-drm/nvidia-drm-helper.h);
 * struct drm_mode_create_dumb no longer visible transitively in
   nvidia-drm-gem-nvkms-memory.h, causing a prototype-scoped struct
   and a conflicting-types error: forward declaration added;
 * dma_fence_signal()/dma_fence_signal_locked() now return void: the
   nv_dma_fence_* wrappers discard the return and report success,
   which compiles on all supported kernels.

Tested with NVIDIA GeForce RTX 4060 Laptop GPU:
 * Runtime-tested (modules load, nvidia-smi, desktop session) on
   7.1.3+deb14-amd64, 6.12.17-amd64, 6.17.13+deb14-amd64.
 * Build-tested on: 6.12.17-amd64,6.17.12+deb14-amd64
6.17.13+deb14-amd64,6.17.7+deb14+1-amd64
6.18.10+deb14-amd64,6.18.15+deb14-amd64 6.18.8+deb14-amd64,7.1.3+deb14-amd64.
   The legacy conftest branches are selected on the pre-7.x kernels
   and the new branches on 7.1.3, as intended.

All building and testing was done with the open flavor
(nvidia-open-kernel-dkms / nvidia-current-open). The patch only touches
kernel-interface files shared between flavors (conftest.sh, common/inc,
nvidia/, nvidia-drm/, nvidia-uvm/), so it should equally fix the
proprietary nvidia-kernel-dkms build against 7.x, but I have not built
that flavor and cannot confirm. The issue matches #1135362, which was
filed against nvidia-kernel-dkms.

One further note: on 7.1.3 the final module link initially fails in
linux-kbuild's scripts/gen-btf.sh (7.1.3-1), where the awk-wrapper
PAHOLE variable is expanded without eval, so its embedded quoting
reaches awk verbatim. That affects all out-of-tree modules and is
reported separately with a patch as #1141979.