mirror of
https://github.com/QuixiAI/nvdriver.git
synced 2026-12-06 06:28:39 +00:00
- Updated tools/post_reboot.sh to check kernel oops taint bit and stuck driver tasks instead of <86400s uptime - Level 7 hardware regression passed on 0000:b3:00.0 (module 37e6fa430835eee2b426019db3ad70eeb7a9e9070c09c84bd9b973cf56cbe529, 107 inventory words, 0 static mismatches, CUDA baseline verified before and after) - Updated .gitignore to exclude build archives (*.a, *.rlib), __pycache__, and raw trace dumps
160 lines
11 KiB
Plaintext
160 lines
11 KiB
Plaintext
Read-only design: concrete per-device timeout identity and parent association
|
|
|
|
No implementation or physical changes in this followup. Current timeout/runtime
|
|
and common build sources remain frozen. This report inspects current code rather
|
|
than deriving architecture from guessed native offsets.
|
|
|
|
Current facts
|
|
KernelGpu (kernel/gpu.rs55) contains lifetime/cleanup/PCI/DMA/BOOT identity only.
|
|
It does not contain PfSoftware despite that module's introductory comment.
|
|
GpuLease already pins exact storage/probe generation and module code. Its actual
|
|
C owner operation mutex drains removal; registry Key is(index,u64generation).
|
|
The prepared registry has32slots and acquires leases under its IRQ-saving lock.
|
|
Its index is neither allocated RMgpuInstance nor timeoutGpuId. No global software
|
|
Instances/ArchitectureRegistry/SystemOs/SystemPlatform manager is installed yet.
|
|
|
|
Shortest concrete design
|
|
1. Add a module-owned SoftwareManager initialized before PCI-driver registration,
|
|
destroyed after PCI unregister AND gpu_owner_queue_destroy has drained every
|
|
retained owner. Own/serialize actual Instances, ArchitectureRegistry<32>,
|
|
SystemOs, SystemPlatform and a checked private logical-object arena here.
|
|
This is a sleepable manager mutex, NOT the prepared registry IRQ-spinlock.
|
|
Root must choose and document lock order; use operation->manager where both
|
|
are necessary, and never manager->operation or registryspin->operation.
|
|
Do not hold registryspin across allocation/constructor/registry reads.
|
|
2. At the real attach/open software-factory boundary, under the same GPU's
|
|
operation guard, construct and retain PerDeviceSoftware in
|
|
KernelGpu.software: UnsafeCell<Option<PerDeviceSoftware>>. The existing C
|
|
cleanup callbacks/base ref must already be installed, so every failed
|
|
partial graph has the existing retained cleanup/retry path. Do not silently
|
|
move original RmInitAdapter/StateInit/Load into PCI preparation.
|
|
Construction prerequisites are actual Profile::from_normal_pci inputs:
|
|
BOOT42; actual offset4 snapshot(current ProbeInfo.boot1, namedboot4 by profile);
|
|
actual8f020 only for virtualizationtype1; actual Linuxis_virtfn; retained
|
|
GpuArchOwner with matching four factors; allocatedRMInstance; actualPCI-derived
|
|
gpu_id and optional UUID only from its original owner. Unknown paths fail.
|
|
Installing this CPU graph does not call timeoutInitialize early: call it only
|
|
when the actual parent graph reaches031028->059507. No ready bit is set.
|
|
3. Allocate timeoutGpuId once per installed association using private checked
|
|
AtomicU32 monotonic allocation starting1, never recycling on failure/removal.
|
|
Fail exhaustion before wrap. Burn failed-attempt keys. Do not cast/truncate
|
|
u64generation, pointer/BDF/PCI ID, RMinstance, prepared index or FIFOchid.
|
|
This key is private owner identity, not ABI GPU-ID or a security credential.
|
|
Module reload may reset only after all owner/module leases have drained.
|
|
4. Reserve globally disjoint logical ranges with checked AtomicU64/manager arena,
|
|
not raw allocation addresses plus fabricated offsets. PfSoftware currently
|
|
needs base+0..6e70, scratchbase+10000/100a0 and register-aperturebase+20000.
|
|
Reserve a documented sufficient block(e.g.40000, after confirming all factory
|
|
subobjects), never overlapping architecture/SYS/device-context logical ranges;
|
|
prefer no reuse. These are explicit private logical identifiers, never DMA or
|
|
native executable pointer addresses. Keep them out of UAPI.
|
|
5. Concrete PinnedTimeoutIdentity is an external operation/view object containing
|
|
GpuLease plus private immutable {logicalGPU,timeoutKey}. Its constructor is
|
|
private to this same-owner operation factory; capture and validate the actual
|
|
installed association under the mutex. resolve compares the exact logical
|
|
object, rejects removal, and returns only that owner's stored key. It never
|
|
re-resolves a preparedslot by index and never locks the mutex recursively.
|
|
Keep this view outside KernelGpu: embedding its GpuLease creates a reference/
|
|
module-pin cycle that blocks final cleanup and idle-device module unload.
|
|
A private implementation of the existing unsafe Identity trait can then be
|
|
justified by real ownership instead of caller promises.
|
|
|
|
Interior mutability and operational borrowing
|
|
Do not add a mutable Option<PfSoftware> then form &mutKernelGpu while leases
|
|
exist. The existing protocol explicitly forbids that. Use UnsafeCell around
|
|
only the operation-mutex-protected software graph; immutable lifetime/PCI facts
|
|
stay separate. A factory checks removal after acquiring the mutex, forms one
|
|
short exclusive borrow of that cell and invokes a higher-ranked scoped closure.
|
|
No &PfSoftware/&mutPfSoftware/record/guard may escape; no callback may reacquire
|
|
the same operation mutex. Callback interfaces must reuse the borrowed guard.
|
|
External identity snapshots contain no references into the mutable graph.
|
|
Removal sets removed first, retires lookup, drains the mutex, marks PCI removed,
|
|
and hands off the driver base as today. Existing operations may fail due to
|
|
removal; do not promise arbitrary MMIO after drain. Hardware quiescence remains
|
|
a separate mandatory protocol.
|
|
|
|
Persistent timeout state without self-reference
|
|
Current State<'owner> borrows an Identity provider for its lifetime. A KernelGpu
|
|
containing State that borrows its own external view is self-referential; putting
|
|
GpuLease beside State does not make it safe. Do not use State<'static>, transmute,
|
|
raw borrowed identity, or recreate fresh State after errors (loses quarantine).
|
|
Minimal refactor is pointer-free owned Record {phase,logical,key,partialDefaults,
|
|
pendingDatabase,lastErrors} embedded in PerDeviceSoftware. A scoped BoundState
|
|
borrows &mutRecord and &PinnedTimeoutIdentity only for one operation. Existing
|
|
staged initialize/override algorithms move unchanged onto this scoped view.
|
|
Split-borrow PfSoftware and Record fields under the one operation guard.
|
|
Record survives every call/failure; replacing it requires explicit full cleanup
|
|
and a new association/key. with_data requires configuredRecord and the same
|
|
external identity. A timeout wait may copy its Data only into a bound wait owner
|
|
that retains the real GPU lease and validates the key on each scoped poll.
|
|
No timer/engine readiness follows from a configuredRecord.
|
|
|
|
Actual Linux per-device association: not OBJOS
|
|
Original049787 uses NV_GET_NV_STATE(pGpu) (GPU9d8), then RmReadRegistryDword;
|
|
matching580 unix/os.c1901 and registry.c239 corroborate this. Registry lookup
|
|
uses actual per-device local entries before globalthe_registry. SystemOs at
|
|
GPU1e60 is a different NVOC child and cannot substitute for nv_state.
|
|
Shortest Rust implementation needs a private typed DeviceContext owned by the
|
|
same PerDeviceSoftware, with unique logical identity, same owner token/PCI facts
|
|
and actual registry context/local storage. Link9d8 through a narrow checked
|
|
PfSoftware method once; do not reinterpret existing Cgpu_owner as closed
|
|
nv_state layout. LinuxRegistry must validate parentlogical + actual9d8DeviceContext
|
|
association as well as the retained global1e60SystemOs. Providers access actual
|
|
Rust types, not cloned unused private NVOC/nv_state heap layouts. DeviceContext
|
|
contains no GpuLease; external access requires the scoped pinned operation.
|
|
The existing C registry has per-context copies of global configuration. For this
|
|
read-only timeout path immutable module options can supply those real values;
|
|
full cross-device global-write parity requires a genuinely shared global store
|
|
with per-device local lists, rather than claiming copied globals are equivalent.
|
|
Actual named NBSI reference stays mandatory and expires at its real table-init
|
|
phase. Do not replace missing/expired system state with absent-key status.
|
|
|
|
Failed construction and teardown
|
|
Existing Instances::Reservation borrows the global allocator and Drop releases
|
|
its slot. That is unsafe for a returned CreationFailure whose partialPfSoftware
|
|
cannot yet close. Add an owned pending-reservation/retain_for_cleanup transition
|
|
(no success/readiness publication), so the partial graph keeps the actualslot.
|
|
Commit fully constructed instance only at the documented constructor boundary;
|
|
release on failure only after all partial resources are really gone.
|
|
PerDeviceSoftware owns every successful or partial constructor owner, registry/
|
|
DeviceContext, instance credential and configRecord, with no external-lease cycle.
|
|
Replace current finalizer close_dma with idempotent close_resources: close
|
|
children/context/PF in verified dependency order, keep failed owners in place,
|
|
close DMA, then release the actual instance after no GPU/cleanup resource remains.
|
|
Do not consume a field permanently then return Err on later steps and retry the
|
|
old dmaNone->EINVAL path. Preserve cleanup error provenance. Only after every
|
|
resource closes may finalizer drop KernelGpu and Cdestroy free storage/PCI.
|
|
A permanent cleanup failure retains the owner and can block module exit under
|
|
the current policy; do not silently free it or claim successful unload.
|
|
|
|
Exact implementation scope proposed (not yet authorized in this followup)
|
|
- kernel/gpu.rs: UnsafeCell software field, private same-owner scoped factory,
|
|
immutable timeout association, idempotent close_resources/finalizer integration.
|
|
- new kernel/device_software.rs: actual CPU factory transaction, DeviceContext,
|
|
private PinnedTimeoutIdentity, nonreused key/logical allocators and ownedfailure.
|
|
- new kernel/software_manager.rs plus narrow C sleepable lock if no existing
|
|
adequate manager mutex: actual system/cache/instance lifetimes and shutdown.
|
|
- kernel/timeout_runtime.rs: split persistent Record from borrowed operation view;
|
|
retain all existing boundary semantics/tests; no change to core timeout policy.
|
|
- kernel/pf_software.rs +registry.rs: checked actual9d8context link/validation;
|
|
correct introductory embedding claim only when field exists.
|
|
- coregpu/instances.rs: owned pending-reservation retention for failed-close path.
|
|
- common imports/deps/Cmoduleinit-exit wiring owned by root; no GPU-ready change.
|
|
|
|
Required acceptance tests before producer hookup
|
|
Actual C/Rust GPU owner tests: two devices with identical PCI tuples still have
|
|
distinct storage/key/logical/instance identities; different GPU/PF/DeviceContext
|
|
rejected; registry slot reuse and failed installs never recycle timeoutkeys;
|
|
u32/u64 exhaustion fails without wrap/truncation. Real same-GPU guard reuse and
|
|
concurrent removal reject new views; final lease retains storage/module/PCI.
|
|
Factory fault injection after each allocation/link/registry/instance stage,
|
|
including partialPf.close failure, retains slot and graph until final retry;
|
|
no reservation rollback before cleanup. Finalclose fault after prior CPU/DMA
|
|
success retries idempotently and joins workqueue before globalmanager teardown.
|
|
Compile-fail tests reject escaping graph borrows/scopedState or short identity;
|
|
quarantine/pendingDatabase survive subsequent scoped calls. CanonicalGPU9d8/1e60
|
|
links observed at real base/NBSI boundaries; wrong DeviceContext fails before
|
|
Cread. Existing six timeoutRuntime/sixPF tests and all owner/module/QEMU tests
|
|
remain required. QEMU CPU factory test should use explicit fixture Profile proof
|
|
without claiming EDU is GV100; production GPU bindings stay untouched.
|