41 Commits

Author SHA1 Message Date
c777e5cc67 feat(display): standalone Stage 2 desktop video (nvidia_rs_modeset + nvidia_rs_drm) (#608)
* feat(desktop-video): Stage 2 standalone nvidia_rs_modeset + nvidia_rs_drm cutover

Complete Stage 2 standalone clean-room desktop video implementation
matching exact NVIDIA 580.178.04 DRM and NVKMS UAPI layouts (rebased
onto #587 GEM_EXPORT_DMABUF_MEMORY):

- DRM (24/24 PORTED):
  - Harden atomic KMS compositor paths in nvidia_rs_drm.c:
    atomic_disable vblank event delivery (prevents Wayland hangs /
    WARN_ON), crtc_atomic_check, cursor plane <=256x256 validation,
    and async_page_flip capability advertisement.
  - Add KAPI kms_grant_permissions / kms_revoke_permissions backing
    and end-to-end QEMU smoke coverage for GEM_EXPORT_DMABUF_MEMORY,
    atomic modeset + vblank flips, CRTC disable, and DRM permissions.
- NVKMS (62/66 PORTED, 4 Quadro Sync framelock honestly PARTIAL):
  - Connect /dev/nvidia-rs-modeset (/dev/nvidia-modeset) chardev to
    refcounted shared nv_rs_kms_device instances (real heads, disps,
    connectors, EDID, hardware commit & CRC32).
  - Add #![no_std] low-stack EDID 1.4 / CEA-861 mode enumerator and
    validator (src/nvidia/src/nvkms/modes.rs) and stateful NVKMS
    backends for permissions, deferred request FIFOs, swap groups,
    DPY/DISP attributes, vblank sync/sem controls, fliplock, mux,
    and 580 cmd 63/64 (src/nvidia/src/nvkms/state.rs).
  - Add per-file event ring buffer + wait_queue_head_t poll() wakeups
    and exact 580 grant/unicast-event fd roles.
- Verification (offline + disposable QEMU/KVM Linux 7.0 guest only):
  - make modules + check_kernel_module.py: PASS (0 GOT, 0 SIMD,
    0 memcpy/memset/memmove, largest_stack=1016).
  - cargo fmt --check, cargo clippy -D warnings, cargo test nvkms (76/76),
    NV_RS_KERNEL_IBT=1 kernel-module-gate (37/37): ALL PASS.
  - tools/vm/run_desktop_drm_guest.py: 19/19 checks PASS with clean unload.

* nvkms/drm: address CodeRabbit review findings for Stage 2 desktop video

- EDID/mode parsing (modes.rs): use exact 64-bit FNV-1a timing dedup key
  (preserving nearby refresh rates like 1080p60 vs 1080p62 with zero memset),
  decode CTA-861 Video Data Block Short Video Descriptors (VICs), normalize
  interlaced DTD vertical field counts to full frame lines, and reject
  htotal/vtotal > 0x7fff.
- Permissions & swap-group transactional safety (state.rs, mod.rs,
  modeset_ffi.rs, nvidia_rs_modeset.c, nvidia_rs_drm.c): align permission
  type enum to exact 580 values (1=FLIPPING, 2=MODESET, 3=SUB_OWNER),
  validate modeset fd role and share grant fd publication between DRM KAPI
  and NVKMS chardev, scope DRM grants to per-drm_file issuer_id with
  postclose cleanup, support explicit NvKmsPermissions revocation
  (typeMask==0), scope release_device() permission/swap-group cleanup to
  the released device handle, and roll back ACQUIRE_PERMISSIONS /
  ACQUIRE_SWAP_GROUP on copy_to_user -EFAULT.
- Concurrency, refcounting & vblank delivery (nvidia_rs_modeset.c,
  nvidia_rs_drm.c): serialize first-open per GPU with nv_rs_kms_open_lock,
  refcount direct kms_dev lookups via kms_dev_get(), deliver NOTIFY_VBLANK
  asynchronously on real vblank ticks (with fd >= 0 support and release
  cleanup), only consume atomic_disable page-flip events when !active, and
  remove unlatched async_page_flip shortcut.
- Honest -EOPNOTSUPP & parity ledger (nvidia_rs_modeset.c, nvidia_rs_drm.c,
  build_parity_ledger.py, desktop_drm_smoke.c): enforce connector membership
  and connector-specific DigitalSignal on DPY attributes, tighten CRC32 head
  check (< 4) and return -EOPNOTSUPP/supported=0 until HW CRC32 is wired,
  return -EOPNOTSUPP after validation/ownership checks on unimplemented
  chardev hardware-programming ioctls, and update parity ledger & 19/19
  QEMU desktop DRM smoke tests.

* nvkms/drm: resolve round-2 CodeRabbit findings and rebase onto master

- Preserve the full 128-byte 580 NvKmsPermissions union payload verbatim
  across GRANT_PERMISSIONS, ACQUIRE_PERMISSIONS, and explicit
  REVOKE_PERMISSIONS (using black_box copy to keep 0 memcpy/memset).
- Enforce issuer authority (owner or SUB_OWNER) under owner lock before
  publishing chardev permission grants; reject explicit SUB_OWNER
  revocation without mutating state; subtract explicit revocation bits
  rather than deleting partially matching rows; ignore explicit payload
  bytes on non-zero typeMask revocations.
- Reserve consumed permission and swap-group grant slots (pending_commit)
  across copy_to_user and release via commit_acquire / un-reserve via
  rollback_acquire (without resurrecting grants for freed swap groups).
- In NOTIFY_VBLANK, write the reply before mutating ev_f->fd_role or
  linking the waiter, revalidate the device handle under f->lock ->
  nv_rs_kms_lock, wake physical-display waiters from real HW vblank IRQs
  only (keeping synthetic timer as virtual-display fallback).
- Return honest -EOPNOTSUPP for IDLE_BASE_CHANNEL and SET_MODE (both
  commit=0 and commit=1) until full decode/HW wait is implemented; move
  disable completion event delivery back to atomic_flush so disable does
  not signal before scanout stops.

* nvkms/drm: fix stock 580 ABI layouts, transactional grants, vblank sync, and EOPNOTSUPP stubs

* desktop/nvkms: address remaining minor CodeRabbit findings on Stage 2

* desktop/nvkms: resolve round-4 CodeRabbit review findings on Stage 2

* desktop/nvkms: fix irq-safe vblank disable lock and connector probe init

* fix(nvkms): address CodeRabbit review on probe errors, vblank, CursorImm auth, pclk, and attrs

* fix(nvkms,drm): track connector probe validity, add vblank barriers, keep 64-bit refresh checks

---------

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-05 13:25:22 -08:00
1ed77198c8 feat(blackwell): adapt desktop video Stage 1 & Stage 2 for RTX 50 (GB202-GB207) (#621)
* feat(blackwell): adapt desktop video Stage 1 & Stage 2 for RTX 50 (GB202-GB207)

* fix(blackwell): address CodeRabbit review on DP 2.1 UHBR training and GB10 preflight

---------

Co-authored-by: morebrackets <19673572+morebrackets@users.noreply.github.com>
2026-12-05 13:05:22 -08:00
b95d30a698 ada/desktop: adapt Stage 1 & Stage 2 desktop video for RTX 40 series (AD102-AD107) (#620)
* 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>
2026-12-05 12:26:38 -08:00
f3862b6300 drm: implement GEM_EXPORT_DMABUF_MEMORY (24/24 DRM ioctls ported) (#587)
* drm: implement GEM_EXPORT_DMABUF_MEMORY via RM 0x71 external sgt bridge (24/24 DRM)

* rmapi: enforce external_gpu_id on DMA lookups and mirror forwarded GSP devices

* rmapi: keep locally registered memory RM_FREE on native execute_full path

* rmapi: scope local RM_FREE bypass to local UserPages (0x0071) backings only

* rmapi: mirror forwarded GSP peer device on import_slot and clean up local entries on forwarded FREE

* rmapi: recursively free native subtrees on GSP object free and keep UserPages MAP_MEMORY_DMA native

* rmapi: return NOT_SUPPORTED for UserPages MAP_MEMORY_DMA on legacy gsp_bringup sessions

* rmapi: verify client ownership before returning NOT_SUPPORTED on legacy GSP UserPages MAP_MEMORY_DMA

---------

Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-05 04:20:19 -08:00
72543d1e2e fix(drm): harden DMABUF scanout/export guards and mark nvkms export PORTED (23/24 DRM) (#515)
- 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>
2026-12-04 17:03:12 -08:00
e86d83cc64 fix(kernel-open): define DRM_PLANE_NO_SCALING on Linux <6.1 and fix C90 declaration warning in pci_adapter (#560)
Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-04 16:23:47 -08:00
7f7dce5fa1 nvidia-drm: build against kernels that renamed drm_atomic_state to drm_atomic_commit (#541)
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>
2026-12-04 16:15:30 -08:00
9f70f56020 chore: update repository references from QuixiAI/nvdriver to nvdriver/nvdriver (#520)
Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-03 21:34:14 -08:00
366b416498 fix(pr383): address CodeRabbit Round-6 PRIME fence and mapper bounds findings
- nvidia_rs_drm.c:
  - Implement legacy 580.178.04 PRIME fence context memory-import path
    (NV_RS_GEM_PRIME_FENCE_CTX) via nv_kms.import_memory_fd (28-byte
    NvKmsKapiImportMemoryParams) / import_memory (8-byte import ID), kernel
    mapping, and 16-byte-stride GPU completion polling with clean teardown,
    keeping SEMSURF import separate.
- gsp_route.rs:
  - Enforce kernel-only permission check (owner == KERNEL_MODESET_OWNER) on
    the early 0x0002_0101 ContextDma update path.
  - Validate full physical backing range and page-rounded virtual span
    (including phys_off & 0xfff) in exec_mm_op MAP before writing PTEs.
  - Chunk unmaps > 4 GiB in unmap_dma_ga10x_no_flush() instead of silently
    capping at 1,048,576 pages.
  - Propagate ST_INVALID_STATE when write_semsurf_value() fails in
    exec_mm_op SEMAPHORE_SIGNAL.
- .coderabbit.yaml:
  - Update comment to match auto_incremental_review: true and
    auto_pause_after_reviewed_commits: 0.
2026-12-03 18:07:34 -08:00
d61030a3e6 fix(pr383): address CodeRabbit Round-5 DRM/GSP/RMAPI review findings
- 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.
2026-12-03 17:09:42 -08:00
b52978f2a5 Address round-3 CodeRabbit PR #383 findings (all 12 remaining items) 2026-12-03 16:33:41 -08:00
c5a9dd147d Address round-2 CodeRabbit PR #383 findings across RMAPI, kernel glue, KMS/DRM, and tools 2026-12-03 16:13:36 -08:00
5a1b9a659e Merge origin/master (ca3d44e3, NVKMS surface FFI #471 + DRM PAGE_SIZE #458) into feat/ga102-desktop-master 2026-12-03 13:10:52 -08:00
4e46f44f43 feat(drm): implement GEM_ALLOC_NVKMS_MEMORY, shmem GEM mmap, and host PAGE_SIZE FFI validation (15/24 DRM PORTED) (#458)
* feat(drm): implement GEM_ALLOC_NVKMS_MEMORY, shmem GEM mmap, and host PAGE_SIZE FFI validation

* fix(drm): use probed NV_RS_HAVE_VM_FLAGS_SET / RHEL_RELEASE_CODE / vma_flags_set_word helpers

---------

Co-authored-by: Eric Hartford <eric@quixi.ai>
2026-12-03 10:27:33 -08:00
2e86387188 Address CodeRabbit PR #383 review findings across RMAPI, kernel glue, KMS/DRM, and tools 2026-12-03 08:58:32 -08:00
b60c3dd220 Merge origin/master into feat/ga102-desktop-master 2026-12-03 07:55:02 -08:00
d09f42fb81 fix(drm): install drm_gem_vm_ops on mmap and pass host PAGE_SIZE to Rust validator
- 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)
2026-12-03 12:28:11 +00:00
1491262671 fix(drm): add version-guarded MODULE_IMPORT_NS(DMA_BUF) for dma_buf_mmap 2026-12-03 12:20:37 +00:00
bf68a44087 fix(drm): fix GEM_IDENTIFY_OBJECT wire constants, DMA-BUF mmap delegation, and honest NVKMS/DMABUF probes
- 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)
2026-12-03 12:15:37 +00:00
ac68f4b59b fix(drm): add real GEM mmap/get_sg_table callbacks and wire Rust validators via FFI
- 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
2026-12-03 12:07:00 +00:00
0c23742ae5 fix(drm): address all 7 CodeRabbit findings (RLIMIT_MEMLOCK, FOLL_LONGTERM, no placeholder stubs)
- Enforce RLIMIT_MEMLOCK / mm->pinned_vm accounting (with mmgrab/mmdrop)
  and FOLL_LONGTERM on pin_user_pages_fast in GEM_IMPORT_USERSPACE_MEMORY
- Keep genuinely backed GEM_ALLOC_NVKMS_MEMORY, GEM_IMPORT_USERSPACE_MEMORY,
  .gem_prime_import_sg_table (DMA-BUF import), and GEM_IDENTIFY_OBJECT
- Restore honest -EOPNOTSUPP (PARTIAL in docs/PARITY_LEDGER.md) for the 9
  NVKMS-export/import and semaphore-threshold PRIME/semsurf fence ioctls
  (and supports_semsurf = 0 / FENCE_SUPPORTED = -EOPNOTSUPP) until their
  hardware semaphore callback & KAPI export backends exist
2026-12-03 11:37:10 +00:00
fa51866df9 feat(drm): implement all 11 remaining stock 580.178.04 DRM GEM/PRIME/semsurf ioctls
- Add clean-room #![no_std] Rust DRM GEM/fence/semsurf validation &
  monotonic timeline module (src/nvidia/src/drm/mod.rs) with unit tests
  covering all 11 ioctls' stock 580.178.04 error precedence & boundaries
- Implement typed nv_rs_drm_gem_object backend in kernel-open/nvidia-drm/nvidia_rs_drm.c:
  * NVKMS memory GEM alloc/import/export (shmem-backed drm_gem_object_init)
  * Userspace memory GEM import (pin_user_pages_fast / unpin_user_pages)
  * DMA-BUF GEM import (.gem_prime_import_sg_table) & export lookup
  * PRIME fence context create + dma_resv fence attach (5.15..7.3+ compat)
  * Semsurf fence context create, sync_file fence create, sync_file wait
    with monotonic timeline update, and shared/excl dma_resv fence attach
  * Accurate GEM_IDENTIFY_OBJECT type reporting & GET_DEV_INFO / FENCE_SUPPORTED
    / DMABUF_SUPPORTED capability flags
- Drives drm_ioctls to 24/24 PORTED, 0 PARTIAL, 0 MISSING in docs/PARITY_LEDGER.md
2026-12-03 11:23:51 +00:00
3fbdd7a4b9 Merge origin/master and wire remaining 18 stock 580.178.04 DRM_IOCTL_NVIDIA_* UAPI ioctls
- Resolve gpu_tests.rs merge conflict against master and adapt test helpers.
- Wire all 18 remaining stock 580.178.04 DRM_IOCTL_NVIDIA_* UAPI structs
  and handlers in kernel-open/nvidia-drm/nvidia_rs_drm.c (GEM identify,
  CRTC CRC32 v1/v2, connector/dpy ID, DRM_MASTER grant/revoke permissions,
  and -EOPNOTSUPP UAPI descriptors for GEM/PRIME/semsurf fence ioctls).
- Update tools/build_parity_ledger.py and docs/PARITY_LEDGER.md:
  2,502 PORTED, 11 PARTIAL, 0 MISSING, 15 INTENTIONALLY_EXCLUDED.
2026-12-03 09:33:27 +00:00
11782f4a24 Merge origin/master and address Greptile review findings on #266
- 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.
2026-12-02 16:46:36 -08:00
bf31aae07a Return registration error when real GPUs fail DRM init and unify class_db arch table
- 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.
2026-12-02 16:03:55 -08:00
2d5eb284c3 Merge origin/master (ec7c96a) into feat/ga102-desktop-master 2026-12-02 14:08:14 -08:00
a2707a4c99 ga102: Stage 1 desktop bring-up, 0x00da/0x0002 parity, 2M/64K MMU, BAR1 WC PT pool & lockless GSP queues 2026-12-02 13:52:08 -08:00
2075a7ff74 Merge branch 'master' into feat/issue-172-headless-mining-3d-prime
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.
2026-12-02 10:31:37 -08:00
3561350317 Merge branch 'master' into feat/ga10x-vulkan-dmabuf-render-148
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.
2026-12-02 10:26:35 -08:00
6793f9c3c3 ga107m: live RTX 3050 Mobile bring-up, GSP-RM control/hwmon parity, Linux 7.0 VFIO (#187)
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>
2026-12-02 17:55:07 +00:00
cd0bb9df8d fix(ga10x,drm,rmapi,vk): address all 15 CodeRabbit review findings on PR #266
- 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).
2026-12-02 03:49:47 -08:00
915ed42ac0 feat(ga10x,drm,rmapi): live Vulkan 1.4 compute/transfer + DRM/NVKMS UAPI parity (#148, #172)
Brings up end-to-end Vulkan 1.4 device creation, VRAM DMA transfer, and hardware
SPIR-V compute shader execution on live GA107M (RTX 3050 Mobile) silicon alongside
stock 580.126.09 DRM/NVKMS UAPI parity and CUDA coexistence.

Key changes:
- nvidia_rs_drm: exact 580.126.09 DRM_IOCTL_NVIDIA_* command numbers/structs
  (GET_DEV_INFO 0x03, FENCE_SUPPORTED 0x04, GET_CLIENT_CAPABILITY 0x08,
  GEM_MAP_OFFSET 0x0a, DMABUF_SUPPORTED 0x0f, GET_DRM_FILE_UNIQUE_ID 0x18),
  multi-GPU display/3D PCI discovery skipping HDA audio, .name = "nvidia-drm",
  and race-free per-drm_file unique IDs.
- nvidia_rs_modeset: register /dev/nvidia-modeset compat node and handle
  NVKMS_IOCTL_IOWR ALLOC_DEVICE / FREE_DEVICE.
- RM API escapes & controls: implement NV_ESC_RM_VID_HEAP_CONTROL (0x4a),
  NV_ESC_RM_ALLOC_CONTEXT_DMA2 (0x54), NV_ESC_RM_BIND_CONTEXT_DMA (0x59),
  0x27 ALLOC_NONE (0x3f/0x70/0x40), V1 embedded-pointer nested_plan translations,
  0x102/0x204/0x301 root controls, NV_SEMAPHORE_SURFACE BIND/UNBIND_CHANNEL
  (0x00da_0002 / 0x00da_0006), NV_MEMORY_MAPPER (0x00fe), and DUP_OBJECT
  VA-space/GSP-RM mirroring.
- VOLTA_USERMODE_A (0xc361): map BAR0+0xbb_0000 on Turing-Blackwell GSP-RM
  GPUs (per 580.126.09 gpuGetRegBaseOffset_TU102) while keeping 0x81_0000 on Volta.
- GSP-RM / GA10x kernel-managed VAS & GR path: map/unmap 4 KiB GPU PTEs on
  RM_MAP/UNMAP_MEMORY_DMA (0x57/0x58), promote full GR context buffers with
  GPU VAs for kernel-managed VA spaces, support standalone CE channels under
  NV01_DEVICE_0, handle 0xc36f_010a / 0x2080_2a03 / 0x902d / 0xa140 / 0x9072 /
  0x9096 / 0x05 events.
- Add host unit tests and zero-dependency tools/vm/vulkan_smoke.c.
2026-12-02 03:14:46 -08:00
ef9a1def3d drm/rmapi/hw: headless mining card 3D class mapping & per-GPU DRM PRIME render nodes (#172)
- 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
2026-12-01 22:02:44 -08:00
857a6044b9 kernel-open/kms: fix multi-head scanout, SOR/cursor/C9+ commits, and NVKMS/SEMSURF ABI 2026-12-01 19:59:50 -08:00
fc49ee5f23 kernel-open: implement standalone nvidia_rs_modeset and nvidia_rs_drm KMS/DRM modules 2026-12-01 19:20:50 -08:00
7f7021e218 Wave 7: complete RM escape dispatch (0x27-0x5f/0xd5/0xd8) and x86_64/ARM64 kernel hardening gates 2026-12-01 19:19:30 +00:00
373e801f8c rmapi/drm/uvm: multi-arch RMAPI, PCI-bound DRM atomic/syncobj/NVIDIA ioctls, and 5 R620 UVM symbols (Wave 5)
- src/nvidia/src/rmapi/gpu.rs: remove GV100-only gate (line 5250) and add chip-derived GPU names across Maxwell, Pascal, Volta (Titan V / Quadro GV100), Turing, Ampere, Ada, Hopper, and Blackwell.
- kernel-open/nvidia-drm/nvidia_rs_drm.c: bind real NVIDIA PCI GPUs when present (platform fallback), enable DRIVER_SYNCOBJ | DRIVER_SYNCOBJ_TIMELINE | DRIVER_MODESET | DRIVER_ATOMIC, and implement core DRM_IOCTL_NVIDIA_* ioctls matching stock nvidia-drm-drv.c.
- interface_dispatch.rs, uvm_interface_ffi.rs, src/nvidia/Makefile, uvm_iface_exports.c, uvm_bridge.c: implement and export all 5 new R620 nvUvmInterface* symbols (AccessBitsBufAlloc/Free/Dump, RegisterUvmEvents/DeRegisterUvmEvents -> 81 total exported symbols).
- Update HANDOFF.md and docs/PARITY_AND_UNLOCKS.md with Wave 1-5 summary.

Validated: fmt, clippy -D warnings, 1067/1067 nv-rs-core tests, IBT=1 & IBT=0 modules + check_kernel_module.py (largest_stack: 1016, 0 GOT/memcpy/SIMD), uvm-bridge, QEMU EDU non-IOMMU + IOMMU.
2026-12-01 17:05:11 +00:00
5a02e03a79 Merge pull request #16 from morebrackets/fix/v100-16gb-iommu-irq-linux7
Fix 16GB V100 VRAM sizing, strict IOMMU DMA, IRQ deadlock, and Linux 7.0 build
2026-11-30 20:00:37 -05:00
33ff608a88 Add MIT LICENSE and unify repository SPDX/Cargo/module licensing
- 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.
2026-12-01 00:20:02 +00:00
2d90287ede Fix 16GB V100 VRAM sizing, strict IOMMU DMA, IRQ top-half deadlock, and Linux 7.0 build
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.
2026-11-30 10:53:36 -08:00
1da14ed862 Implement Round 5 580.178.04 ports (NVLS Multicast 0x00fd, RC Watchdog, VRR/G-Sync, standalone nvidia_rs_drm.ko & nvidia_rs_peermem.ko) 2026-11-30 15:54:18 +00:00