* ada/desktop: adapt Stage 1 & Stage 2 desktop video for RTX 40 series (AD102-AD107)
Stage 1 & Core Ada GSP-RM / RM fixes (verified against stock 580.196.07):
- ga10x_gsp.rs: stop downgrading Ada's configured 580.x release string when
no bundled 580.178.04 Ada booter exists, add 580.196.07 -> 580.178.04
gsprm_load fallback, read NV_FUSE_STATUS_OPT_DISPLAY at 0x820c04 on
Ampere/Ada+ (_nv030373rm) and propagate display_fused_off into hw facts,
and fail explicitly (instead of silently skipping) when cold-boot Ada
scrubber-580.bin is missing.
- display.rs, display_channels.rs, gsp_boot.rs, ga10x.rs: fix Ada
DispSfUser BAR0 offset (0x6f0000 for all NvDisplay v03_00+ per
_nv005909rm/_nv040109rm), fix Ada copy_engine class (0xc7b5
AMPERE_DMA_COPY_B), enable ce_class_db filtering for ArchFamily::Ada,
and pass real boot0 to configure_live_display().
- gsp_route.rs, rmapi_node.rs, modeset_ffi.rs, modeset_bridge.c: intercept
NV_ESC_RM_BIND_CONTEXT_DMA (0x59) in pre() for host-side 0x0002 ->
NvDisplay channel binds, keep modeset_gsp_alloc_ctxdma 100% host-side
with Node RM video memory lookup via nv_rs_modeset_query_rm_mem, prevent
double GSP memory registration, purge MODESET_MEMS/MODESET_CTXS on
NVOS00 free, validate Stage 1 nv_rs_modeset_get_rm_ops against the
configured 580.x driver_version, and fix NVOS64 debug status trace.
Stage 2 Ada NvDisplay v4.1 (0xc77d/0xc67e) & DRM pipeline fixes:
- nvidia_rs_modeset.c:
- Separate full Core modeset/link-training from fast Window-only page
flips and cursor-only Core updates; program Core FIRST on full modeset.
- Resolve imported compositor/Vulkan/EGL VRAM handles via
nv_rs_modeset_query_rm_mem and bind host-side NV01_CONTEXT_DMA to Core
and Window channels for scanout.
- Enforce BAR1 window bounds on 0x0040 allocations (falling back to
BAR1-constrained nv_rs_modeset_vram_alloc on non-ReBAR 256 MiB GPUs)
and propagate block-linear pte_kind.
- Query NV0073_CTRL_CMD_SPECIFIC_OR_GET_INFO (0x0073028b) for SOR
sublink A/B (DP_A/DP_B, SINGLE_TMDS_A/B, DUAL_TMDS), promote HDMI
>600 MHz to SOR_PROTOCOL_HDMI_FRL (0xc), bracket DP link training with
NV5070_CTRL_CMD_SET_SOR_FLUSH_MODE (0x50700457), support DP 1.4a HBR3
(0x1e) via DP_GET_CAPS (0x00731369), and retry with FALLBACK_CONFIG.
- Honor HSYNC/VSYNC polarity and 10 bpc depth in HEAD_SET_CONTROL_OR,
emit HEAD_SET_CONTROL / PCLK_CFG / USAGE_BOUNDS / STORAGE_CURSOR,
fix WIN_SET_PLANAR_STRG0 13-bit mask (& 0x1fff), add XBGR16161616F,
and back off synthetic vblank timer when real HW vblank IRQs arrive
(removing the 4 ms floor for 240/360 Hz displays).
- nvidia_rs_drm.c: fix VRAM BAR1 mmap vma->vm_pgoff bounds/offset,
validate explicit FB modifiers and reject compressible modifiers, add
XBGR16161616F, remove unimplemented NV12, set preferred_depth=24 and
<6.13 allow_fb_modifiers=true, and pair drm_kms_helper_poll_init/fini.
- install_desktop_boot.sh, reload_stage1.sh: add Ada (ad102) GSP boot &
scrubber firmware preflight check with extract_gsp_boot_ucode.py hint.
- Add unit tests in display.rs, gsp_boot.rs, nvdisp_pushbuf.rs, and
gpu_tests.rs covering Ada classes, fuse register, and pushbuffer encode.
* ada/desktop: resolve all CodeRabbit review findings for RTX 40 desktop video
* ada/desktop: address round-2 CodeRabbit review findings
* ada/desktop: address final CodeRabbit review findings
* ada/desktop: track explicit fb modifiers, order disable before vblank_off, reserve Window room up front
---------
Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
- Harden nv_rs_fb_create() and nv_rs_crtc_atomic_flush() so imported
NV_RS_GEM_DMABUF objects always validate single-segment contiguous sgt
backing and scan out via import_sgt rather than kms_mem.
- Return -EOPNOTSUPP in nv_rs_ioctl_gem_export_nvkms_memory() if the
export_memory_fd hook is unavailable instead of silently succeeding.
- Validate arguments and import_sgt in nv_rs_ioctl_gem_export_dmabuf_memory()
and return -EOPNOTSUPP until an RM external DMA-BUF memory wrapper with
independent attachment lifetime retention exists (avoiding a fake 0x003e
sysmem allocation or premature drm_prime_gem_destroy on GEM close).
- Update tools/build_parity_ledger.py and docs/PARITY_LEDGER.md to mark
nv_drm_gem_export_nvkms_memory_ioctl PORTED (backed by RM 0x00003d05)
and keep nv_drm_gem_export_dmabuf_memory_ioctl honestly PARTIAL (23/24).
Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
Linux 7.3 renamed the atomic state container to struct drm_atomic_commit,
and the plane and CRTC atomic helper callbacks take the renamed type, so
nvidia_rs_drm.c fails to compile there with eight incompatible-pointer
errors (reported in #533).
Probe the definition in <drm/drm_atomic.h> from compat_probes.mk, as the
other DRM guards do, and use a typedef in the five callbacks. No
behaviour change on either side of the rename.
Claude-Session: https://claude.ai/code/session_01W53iUSBQkEg9aqwF4AoBHi
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
- nvidia_rs_drm.c:
- Guard identifier-form MODULE_IMPORT_NS(DMA_BUF) with RHEL_RELEASE_CODE.
- Hold a drm_dev_get/drm_dev_put reference per GEM object across all 6 GEM
creation paths so nv_dev/kms_dev remain valid until pending SEMSURF fences
release their GEM contexts.
- Clear vma->vm_ops and vma->vm_private_data before dma_buf_mmap(), ensure
VM_DONTEXPAND, and drop the drm_gem_mmap_obj() GEM ref on success.
- Honor import_mem_nvkms_params_ptr/size in prime_fence_ctx_create via
nv_kms.semsurf_import (rejecting mismatched/unsupported param sizes and
out-of-bounds semaphore indices).
- Separate NV_RS_HAVE_DMA_RESV_RESERVE_FENCES and NV_RS_HAVE_DMA_RESV_ADD_FENCE
guards in a shared nv_rs_dma_resv_attach_fence() helper.
- Reject non-contiguous (nents != 1) or undersized imported DMA-BUF scanout
buffers in nv_rs_fb_create().
- gsp_route.rs:
- Include page_off in pre_unmap_memory_dma() effective_sz so PTE clearing
matches Node::unmap_memory_dma() without double-adding page_off.
- Propagate nonzero set_disp_channel_pushbuf() errors (mapping 0xffff to
ST_INVALID_STATE) before rm_alloc.
- Re-export KERNEL_MODESET_OWNER from nv_rs_core and drop dead 0x00da /
duplicate 0x0080_0201 code.
- gpu.rs:
- Register userspace 0x05/0x79 OS events under GSP-RM BinaryApi parents via
self.event() so GSP posted events deliver through events.events, falling
back to a BinaryApi placeholder only when no host OS-event registration
applies.
- Add nv_rs_drm_gem_vm_ops (.open = drm_gem_vm_open, .close = drm_gem_vm_close)
to nv_rs_drm_gem_funcs and USER_MEMORY VMAs so GEM refs are released on
munmap; drop drm_gem_mmap_obj's GEM ref after dma_buf_mmap() replaces
vma->vm_file/vm_ops
- Add validate_gem_import_userspace_with_page_size(address, size, page_size)
and pass kernel PAGE_SIZE across FFI so 16/64 KiB ARM64 kernels compute
exact page counts (with 64 KiB unit tests)
- Match stock 580.178.04 wire values: NV_GEM_OBJECT_DMABUF=1,
NV_GEM_OBJECT_USERMEMORY=2 (in both nvidia_rs_drm.c and nv_rs_core::drm)
- Delegate NV_RS_GEM_KIND_DMABUF mmap to dma_buf_mmap()
- Keep NVIDIA_DMABUF_SUPPORTED and NVIDIA_GEM_ALLOC_NVKMS_MEMORY returning
-EOPNOTSUPP (supports_alloc=0) until real NVKMS block-linear VRAM allocation
and NVKMS DMA-BUF conversion are wired (generic PRIME import remains enabled)
- Implement nv_rs_drm_gem_mmap (shmem call_mmap for NVKMS_MEMORY,
vm_insert_page for USER_MEMORY, with >= 6.3 vm_flags_clear/set compat)
and nv_rs_drm_gem_get_sg_table (drm_gem_get_pages + drm_prime_pages_to_sg)
so allocated and imported GEM handles are directly mappable and PRIME-exportable
- Export nv_rs_drm_validate_gem_alloc_nvkms and
nv_rs_drm_validate_gem_import_userspace from nvidia_rs.ko (calling the
unit-tested nv_rs_core::drm validators) and invoke them directly from
kernel-open/nvidia-drm/nvidia_rs_drm.c
- Resolve nvidia_rs_drm.c conflict with origin/master (preserving multi-GPU
per-device DRM slot registration, error propagation, and Vulkan/DMA-BUF ioctls).
- Security (4777606273): add Ga10xMem::map4k_flags() setting MMU v2
PTE_PRIVILEGE_TRUE (bit 5) and PTE_READ_ONLY_TRUE (bit 6); map all kernel
GR context buffers privileged in gr_object_alloc() and PRIV_ACCESS_MAP /
UNRESTRICTED_PRIV_ACCESS_MAP read-only (matching 580.126.09
kgrctxMapGlobalCtxBuffer).
- Correctness (4777606282): pass eff_offset (ContextDma offset + mem_offset)
to the second visit_video_range() call in ControlNode::map_memory_dma(),
with a recording Engine regression test in gpu_tests.rs.
- Resource cleanup (4777606291): roll back duplicated server/memory/space
entries on any post-dup_resource insertion failure in ControlNode::dup_object()
and only write dst_handle back on success.
- Host CPU info (4777606296): probe real host CPU topology/features/cache in
rmapi_node.c via nv_rs_rmapi_set_cpu_info() and have client::system_cpu_info()
return NOT_SUPPORTED when unprobed instead of fabricating CPU data.
- In nvidia_rs_drm_init(), track detected NVIDIA GPUs separately and return
the registration error instead of creating a fallback platform node when
real GPUs exist but all failed DRM slot registration.
- Extract chip_arch::arch_classes() as the single source of truth shared by
chip_arch::profile_for() and class_db::map_class_for_arch(), fixing the
GA10x copy class (0xc7b5) and Blackwell2 split (0xcec0/0xce97/0xca6f/0xcab5).
- Add map_class_for_arch_matches_chip_profile_across_all_splits unit test.
Resolves nvidia_rs_drm.c conflict against #187 by preserving PR #196's per-GPU DRM PRIME render node registration (already matching nv_rs_pci_gpu_id encoding). Verified with nvidia_rs_drm.ko build and 9/9 hardware:: unit tests.
Resolves nvidia_rs_drm.c conflict against #187 by keeping PR #266's multi-GPU DRM slot table while adopting master's nv_rs_pci_gpu_id encoding. Verified with make modules + check_kernel_module.py and 100/100 rmapi unit tests.
Rebased onto master (resolving adjacent-insertion hunks in gsp_route.rs and
ga10x_gsp.rs) and verified with 32/32 offline/build/QEMU/gate checks
(1,048 unit tests passed).
Co-authored-by: morebrackets <morebrackets@users.noreply.github.com>
- Enforce scope.caller.admin on 0x3f (NV01_MEMORY_LOCAL_PRIVILEGED) in gpu.rs
- Return -EOPNOTSUPP for unimplemented fence/dmabuf capability queries in nvidia_rs_drm.c
- Add per-open mutex-protected NVKMS device handle table in nvidia_rs_modeset.c validating NvKmsAllocDeviceRequest and FREE_DEVICE handles
- Require explicit VA-space handle in vas_root() and real Backing::Virtual in post_map_dma/post_unmap_dma
- Isolate per-TSG GR context-buffer VAs in a dedicated 40-bit reserved range [0x00f0_0000_0000, 0x00ff_ffff_ffff], exclude it from user VA allocations/DMA maps, and unmap + TLB-invalidate GR ctx PTEs before freeing PA on failure and tsg_release
- Guard post_map_dma/post_unmap_dma against arithmetic overflow and clamp nonzero req_size against range/mem lengths
- Share space_id across dup_space() so original and duplicated VA-space handles share a single non-overlapping virtual extent set
- Pass real KernelOs into gsp_route::post so drop_failed_alloc() frees System backing pages instead of leaking
- Harden tools/vm/vulkan_smoke.c: discover nvidia-drm node cleanly, require Vulkan 1.4, bind physical device via VK_EXT_physical_device_drm, and add TRANSFER->HOST readback barriers
Verified offline (967/967 unit tests, clippy, fmt, check_kernel_module passed with largest_stack=1000, 11/11 IBT gate) and live on RTX 3050 Mobile (GA107M) VFIO guest (2x consecutive VK_SMOKE_PASS + CUDA_COEXIST_OK, 10/10 GR0 interrupts, 0 MMU faults, clean rmmod).
- rmapi/providers/class_db.rs: extend map_class_for_arch() to translate
3D, compute, channel, and copy classes for Turing (0xc597/0xc5c0),
Ampere (0xc697/0xc797), Hopper (0xcb97), Ada (0xc997), and Blackwell
(0xcd97) in addition to Maxwell/Pascal, and add unit tests verifying
headless display-fused mining cards (P106/P104/P102, CMP 30HX-90HX)
expose their architecture's 3D class for PRIME render offload.
- hardware.rs: add CMP 100-210 (0x1d84) and CMP 70HX (0x220c) entries
to CMP_UNLOCK_PRODUCTS and expand admission tests across all P10x and
CMP 30HX-170HX 3D-controller PCI IDs.
- kernel-open/nvidia-drm/nvidia_rs_drm.c:
* Filter NVIDIA PCI devices to PCI_BASE_CLASS_DISPLAY (matching both
0x0300 VGA and 0x0302 3D controller mining/headless GPUs while
skipping HDA audio/USB-C functions).
* Register a dedicated DRM GEM/PRIME/Syncobj render node
(/dev/dri/renderD*) per NVIDIA GPU (up to 32 GPUs, falling back to
a platform device only when zero NVIDIA GPUs are present).
* Fix DRM_IOCTL_NVIDIA_GET_DEV_INFO gpu_id encoding to match
nv_rs_pci_gpu_id() (domain<<16 | bus<<8 | slot, removing the
erroneous slot<<3 shift) stored per drm_device.
Verified:
- cargo fmt --all -- --check & cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace (all passing including headless 3D class & mining PCI ID tests)
- make modules (nvidia_rs.ko + nvidia_rs_drm.ko) + check_kernel_module.py
- audit-codegen + check_native_codegen.py + test_gate_cases.py (28/28) + test_kernel_archive.py (5/5)
Refs #172
- Add root LICENSE (MIT License, Copyright (c) 2026 QuixiAI / Eric Hartford).
- Set license = "MIT" in workspace Cargo.toml and member crates (zero non-MIT dependencies).
- Update all kernel-open/ and tests/vm/ SPDX headers to MIT and EXPORT_SYMBOL_GPL -> EXPORT_SYMBOL.
- Use MODULE_LICENSE("Dual MIT/GPL") in Linux .ko modules so Linux modpost permits linking against the kernel's own EXPORT_SYMBOL_GPL symbols while keeping the repository source 100% MIT.
Closes#12.
Tested on 4x Tesla V100-SXM2-16GB (Dell PowerEdge C4130) running Ubuntu
7.0.0-44-generic with Intel VT-d enabled (no iommu=pt).
Fixes#2 and a few other things that showed up once 16GB cards came up:
- Derive the GV100 runtime VRAM window, RMAPI VideoRegion ceiling, NVENC
ucode staging address, and UVM descriptor/PMA base from the real FB size
in placement::Placement::usable instead of hardcoding 32 GiB constants.
Also pass the detected VRAM size through fb_info_v2_with_usable so
cards with a smaller BAR1 still report the right total memory.
- Switch LiveEngine::irq_top_half, live_irq_mask, and live_irq_unmask to
the lockless nv_rs_pci_{read,write}32_irq helpers. Using the normal
nv_rs_pci_{read,write}32 path acquires p->access inside hardirq context
and self-deadlocks when an IRQ lands on the same CPU running
irq_thread_service.
- DMA-map sysmem pages per GPU instead of putting raw physical addresses
in GPU page tables and rings: lazy per-GPU dma_map_page for RMAPI
allocations and CPU-mapped UVM semaphore/managed pages, dma_alloc_coherent
for SysmemPageTree and the replayable fault ring, and a live coherent
flush page in 0x100c10 across ACR load/runtime/unload so SYS_MEMBAR does
not hit stale unmapped IOVAs left behind by stock nvidia.ko.
- Add version-guarded compatibility wrappers for Linux 6.3-7.0 API changes
(noop_llseek, vm_flags_set/clear, PCI_IRQ_INTX, timer_container_of,
hrtimer_setup, MAX_PAGE_ORDER, MODULE_IMPORT_NS("DMA_BUF"), and
drm_driver.date).
Verified with cargo fmt/clippy/test (918 passed), make modules +
check_kernel_module.py (10/10, largest_stack 1000), native-hello,
uvm-replayable-fault-test, 4-GPU cuda-multigpu-parity (matches stock
580.178.04), and llama-bench on 1 and 4 GPUs with zero DMAR faults and
clean unbind/rmmod.