* 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>
* fix(ga10x/rmapi/modeset): R620 control translation, rmmod refcnt, modeset RM ops (#504, #491, #466, #501)
* chore(pr513): drop gsp_route R620 hunk in favor of live-verified #514
* fix(gpu_owner): balance get_task_struct with put_task_struct after kthread_stop
* fix(gpu_owner/irq): wait for runtime worker join & pin/teardown failed runtime IRQ close
Addresses CodeRabbit review findings on PR #513 (and #491/#528):
- gpu_owner.c: Wait for runtime_stopped in a 10s warning loop and always join
via kthread_stop() + put_task_struct() so an unpinned runtime worker can
never outlive module text during PCI removal / rmmod.
- irq_adapter.c: When nv_rs_irq_close() fails to quiesce an unpinned
runtime-kthread IRQ owner, acquire THIS_MODULE before returning the error
(or force-disable/synchronize/free handlers if the module is already
unloading so no callback can outlive module text).
- ga10x_events.rs: Check nv_rs_irq_close() status in stop() and restore e.irq
on failure instead of discarding the handle.
- tests/irq-mock: Cover both live-pin and unloading-force-teardown paths.
* fix(pci,irq): disable PCI INTx on forced IRQ close and bound AER/shutdown runtime stop
Address follow-up review findings on #513:
- In nv_rs_irq_close() forced teardown (unpinned runtime worker after mask
failure), call pci_intx(owner->pdev, 0) for legacy INTx mode so the
device stops asserting its level-triggered line without disabling a
shared IRQ line for other devices, and add an irq-mock regression test.
- Add nv_rs_gpu_owner_runtime_stop_bounded(owner, timeout_ms) preserving
runtime_task and runtime_stopping on timeout (preventing restart races
and allowing a later nv_rs_remove() stop to complete the join).
- In nv_rs_shutdown() and nv_rs_aer_error_detected(), call pci_clear_master()
first for immediate DMA containment, then use a bounded runtime stop so
shutdown and PCIe AER callbacks never wedge indefinitely.
* fix(pci,pm): bound runtime_lock wait, reclaim retired worker on start/AER, and reassert BME clear
Address follow-up review findings on #513:
- Include runtime_lock acquisition inside nv_rs_gpu_owner_runtime_stop_bounded()'s
deadline via bounded mutex_trylock() polling so shutdown/AER cannot hang when
startup holds runtime_lock waiting for runtime_ready.
- Reclaim a retired worker in nv_rs_gpu_owner_runtime_start() via
nv_rs_gpu_owner_runtime_reclaim_locked() and in nv_rs_aer_resume() so a
timed-out bounded stop never strands runtime engines unavailable after recovery.
- Reassert pci_clear_master(pdev) after the serialized stop attempt in
nv_rs_shutdown() and nv_rs_aer_error_detected() so in-flight GPU bring-up
cannot leave Bus Master enabled.
- Use nv_rs_gpu_owner_runtime_stop_bounded() in PM suspend/runtime_suspend with
full state rollback on timeout so suspend cannot wedge indefinitely while
nv_rs_remove() keeps the unconditional join required before module unload.
* fix(pci): keep Bus Master enabled during bounded GSP unload on shutdown
Address final review comment on #513:
- In nv_rs_shutdown(), invoke nv_rs_gpu_owner_runtime_stop_bounded(owner, 10000)
before pci_clear_master(pdev) so an active GSP session can complete its
DMA unload RPC during clean shutdown, then clear Bus Master Enable once
the stop finishes or hits its bounded deadline.
* fix(pci,pm): return DISCONNECT on AER stop timeout and keep full PM suspend stop
Address review findings on #513:
- In nv_rs_aer_error_detected(), return PCI_ERS_RESULT_DISCONNECT rather than
PCI_ERS_RESULT_NEED_RESET if nv_rs_gpu_owner_runtime_stop_bounded() times
out, preventing a PCIe slot reset while a live runtime worker could still
issue MMIO or re-enable Bus Master.
- In nv_rs_pm_do_suspend() and nv_rs_pmops_runtime_suspend(), wait for worker
retirement via nv_rs_gpu_owner_runtime_stop() before entering D3hot rather
than half-aborting after modeset suspend and USERD VMA revocation.
---------
Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
- Add exact 580.178.04 ABI Rust decoders/validators and unit tests (69/69)
in src/nvidia/src/nvkms/mod.rs + kernel FFI exports in modeset_ffi.rs,
modeset_iface_exports.c, and src/nvidia/Makefile for all remaining NVKMS
ioctl commands.
- Wire per-command exact 580 ABI + handle validation in
kernel-open/nvidia-modeset/nvidia_rs_modeset.c, returning honest -EINVAL
(missing disp/head/framelock/swap-group) or -EOPNOTSUPP for unbacked
display, framelock, permissions, deferred FIFO, swap-group join/leave/clip,
and unicast-event handlers rather than fake success.
- Update tools/build_parity_ledger.py to inspect C handler function bodies
and exclude -EOPNOTSUPP handlers from PORTED (keeping nvkms_ioctls honestly
at 14 PORTED / 52 PARTIAL).
Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
- Export nv_rs_nvkms_ownership_{grab,release,is_owner,release_device,release_file}
and nv_rs_nvkms_validate_{free_device,get_next_event,free_swap_group} from
nvidia_rs.ko backed by nv_rs_core::nvkms
- Remove duplicated C nv_rs_modeset_owners[] table from nvidia_rs_modeset.c
and route GRAB_OWNERSHIP, RELEASE_OWNERSHIP, FREE_DEVICE, GET_NEXT_EVENT,
and FREE_SWAP_GROUP through the live Rust FFI entry points
- Add dedicated per-command unit tests (test_free_device, test_get_next_event,
test_grab_ownership, test_release_ownership, test_free_swap_group) and
update tools/build_parity_ledger.py + docs/PARITY_LEDGER.md
(nvkms_ioctls 4 -> 9 PORTED, total 2,549 PORTED / 67 PARTIAL / 0 MISSING)
- Export nv_rs_nvkms_validate_fbcon_disabled_userspace from nvidia_rs.ko
and call it directly from nvidia_rs_modeset.c
- Split nvkms unit tests into dedicated per-command tests (test_alloc_device,
test_declare_event_interest, test_alloc_swap_group, test_fbcon_disabled_userspace)
- Update audit_nvkms() in tools/build_parity_ledger.py to check an explicit
per-command (ffi_symbol, test_fn_name) map and record each command's exact
test in verification (4 PORTED, 62 PARTIAL, 0 MISSING)
- Add clean-room #![no_std] nv_rs_core::nvkms (src/nvidia/src/nvkms/mod.rs)
holding the single-source-of-truth 66-entry 580.178.04 NVKMS_PARAM_SIZES_580
table (verified against target/stock-580-kmods/nvidia-modeset.ko:.rodata+0x25ee0),
device/event-interest/swap-group/fbcon validators, OwnershipTable, and
unit tests (cargo test nvkms::tests::*)
- Export nv_rs_nvkms_param_size_580, nv_rs_nvkms_validate_alloc_device,
nv_rs_nvkms_validate_event_interest, and nv_rs_nvkms_validate_alloc_swap_group
from nvidia_rs.ko and call them directly from nvidia_rs_modeset.c (removing
the duplicated C size table)
- Update tools/build_parity_ledger.py and docs/PARITY_LEDGER.md:
nvkms_ioctls 0 -> 9 PORTED (with Rust FFI + cargo test verification),
total 2,549 PORTED, 67 PARTIAL, 0 MISSING, 19 EXCL
- Clear global owner entry and swap groups under owner_lock -> f->lock
when ALLOC_DEVICE rolls back on kzalloc or copy_to_user failure
- Return -EOPNOTSUPP in CLEAR_UNICAST_EVENT for non-unicast-event
modeset descriptors until NvKmsPerOpenTypeUnicastEvent is implemented
- Add nv_rs_modeset_poll() callback (report EPOLLIN only when pending) and
reject non-zero DECLARE_EVENT_INTEREST subscriptions with -EOPNOTSUPP
- Reject userspace NVKMS_IOCTL_FRAMEBUFFER_CONSOLE_DISABLED with -EPERM
(kernel-only in stock 580.178.04 _nv000413kms)
- Validate rm_device_id < 32 (NV_MAX_DEVICES) and mig_device == 0 on
ALLOC_DEVICE and index exclusive ownership directly by rm_device_id
- Reject non-owner RELEASE_OWNERSHIP with -EPERM before any cleanup
- Copy and validate full 36-byte NvKmsAllocSwapGroupRequest headMask[8]
(reject nonzero masks on headless numDisps==0 devices) and enforce
modeset-owner check on ALLOC/FREE_SWAP_GROUP
- Publish bar1_ext_bytes in extend_bar1_identity_map() only after BAR1
TLB invalidation readiness + ack polls succeed
- Reject both bus-loss (u32::MAX) and Poll32 timeout in Maxwell/Pascal
flush_tlb() branches
- Include read_pascal_register() loops (wait_pascal_bar1_bind,
flush_pascal_bar1, wait_pascal_mmu) in audit_mmio_bus_loss_guards()
(32/32 verified) and emit honest PARTIAL for NVKMS until behavioral
parity tests exist
- Restore exact 580.178.04 66-entry NVKMS command numbering (retaining
CHECK_LUT_NOTIFIER at 13, REGISTER_SURFACE at 17, GET_NEXT_EVENT at 32,
ALLOC_SWAP_GROUP at 46, FRAMEBUFFER_CONSOLE_DISABLED at 65) and exact
paramsSize table dumped directly from stock nvidia-modeset.ko (.rodata+0x25ee0)
- Use exact 40-byte NvKmsAllocSwapGroupParams layout (reply at offset 36)
separately from 12-byte NvKmsFreeSwapGroupParams (reply at offset 8)
- Track display ownership per underlying (rm_device_id, mig_device) across
opens with consistent lock ordering (owner_lock -> f->lock), reject competing
owners with -EBUSY, and clear swap groups on ownership release and file close
- Give CLEAR_UNICAST_EVENT a dedicated unicastEventFd handler (fget/fput +
f_op validation)
- Return -EOPNOTSUPP for REGISTER_SURFACE until fd surface import is implemented
(never fabricate an unbacked handle)
- Propagate flush_tlb() bus-loss/timeout failures (bool #[must_use]) through
uvm_map_range, uvm_map_pages, map_rm_default_sysmem, map_rm_default_vram,
and scrub-CE/WFI paths with PTE rollback on failure
- Harden audit_mmio_bus_loss_guards() to parse comment-stripped balanced-brace
loop bodies for an explicit u32::MAX/0xffff_ffff condition + break/return exit
and populate stock_evidence/rust_location/verification fields; audit all 66
NVKMS entries directly against stock 580.178.04 nvidia-modeset.ko
- Port NVKMS_IOCTL_ALLOC_SWAP_GROUP (45) and FREE_SWAP_GROUP (46) with
per-file tracking and device-free cleanup in nvidia_rs_modeset.c.
- Add exact gcc-verified 580.178.04 nv_rs_kms_param_sizes[65] table and
deviceHandle validation for all remaining display-dependent NVKMS ioctls.
- Update docs/PARITY_LEDGER.md: 2,548 PORTED, 62 PARTIAL (display/GEM
backends), 0 MISSING, 21 INTENTIONALLY_EXCLUDED across all 8 domains.
- 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).
- 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.