DMA allocations carry device resources (e.g. IOMMU mappings) that must not outlive the device's bound lifetime. Add lifetime parameters to the DMA allocation types (Coherent, CoherentBox, CoherentHandle) to enforce at compile time that they are freed before the device is unbound.
Since DMA types with lifetime parameters are exposed through debugfs in the nova-core driver, first drop the unnecessary T: 'static bound from the debugfs ScopedDir file creation methods by formalizing a type invariant on FileOps. Danilo Krummrich (4): rust: debugfs: drop 'static bound from ScopedDir file creation methods rust: dma: tie CoherentHandle to the device's bound lifetime samples: rust_dma: separate driver type from driver data rust: dma: tie Coherent and CoherentBox to the device's bound lifetime drivers/gpu/nova-core/falcon.rs | 2 +- drivers/gpu/nova-core/fb.rs | 4 +- drivers/gpu/nova-core/firmware/booter.rs | 2 +- drivers/gpu/nova-core/firmware/fsp.rs | 8 +- .../nova-core/firmware/fwsec/bootloader.rs | 12 +- drivers/gpu/nova-core/firmware/gsp.rs | 14 +- drivers/gpu/nova-core/firmware/riscv.rs | 8 +- drivers/gpu/nova-core/fsp.rs | 20 +-- drivers/gpu/nova-core/gpu.rs | 4 +- drivers/gpu/nova-core/gsp.rs | 30 ++-- drivers/gpu/nova-core/gsp/boot.rs | 10 +- drivers/gpu/nova-core/gsp/cmdq.rs | 35 +++-- drivers/gpu/nova-core/gsp/commands.rs | 2 +- drivers/gpu/nova-core/gsp/fw.rs | 12 +- drivers/gpu/nova-core/gsp/hal.rs | 14 +- drivers/gpu/nova-core/gsp/hal/gh100.rs | 16 +- drivers/gpu/nova-core/gsp/hal/tu102.rs | 34 ++--- drivers/gpu/nova-core/gsp/sequencer.rs | 6 +- rust/kernel/debugfs.rs | 26 +--- rust/kernel/debugfs/entry.rs | 4 +- rust/kernel/debugfs/file_ops.rs | 52 ++++--- rust/kernel/dma.rs | 141 +++++++++--------- rust/kernel/uaccess.rs | 4 +- samples/rust/rust_dma.rs | 30 ++-- 24 files changed, 241 insertions(+), 249 deletions(-) base-commit: 45c13f3f9e3bb15fd89ff2864c6f627a3b4b4229 -- 2.55.0
