From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: rust: device: Higher-Ranked Lifetime Types for device drivers Date: Thu, 07 May 2026 13:02:03 +1000 Message-ID: In-Reply-To: <20260506215113.851360-1-dakr@kernel.org> References: <20260506215113.851360-1-dakr@kernel.org> X-Mailer: Claude Code Patch Reviewer Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 Overall Series Review Subject: rust: device: Higher-Ranked Lifetime Types for device drivers Author: Danilo Krummrich Patches: 27 Reviewed: 2026-05-07T13:02:03.232583 --- This is a well-designed and substantial 25-patch series by Danilo Krummrich (with Gary Guo contributing the `ForLt` trait) that introduces Higher-Ranked Lifetime Types (HRT) for Rust device drivers in the Linux kernel. The core idea is sound and represents a significant ergonomic and safety improvement: by tying device resources (BAR mappings, I/O memory) to the driver's binding scope via a lifetime parameter `'bound`, drivers can hold direct references instead of going through `Devres` indirection with runtime revocation checks. **Strengths:** - The architectural approach is well-motivated and solves real pain points (boilerplate `Devres::access()`, `try_access()` in destructors, forced `Arc>` for sharing) - The C-side ordering change (patch 1) is minimal and the key safety prerequisite is clearly explained - The `ForLt` trait is a clean encoding of higher-kinded types within Rust's type system - The series is well-structured: foundational trait work first, then bus-by-bus driver trait conversion, then resource lifetime conversion, then driver adoption - The end-state code (e.g., the PCI sample driver, Tyr, nova-core) is dramatically simpler and cleaner **Concerns:** - The `into_devres()` methods use `core::mem::transmute` to cast `'bound` to `'static`, which requires careful reasoning about Devres revocation semantics - The nova-core self-referential `unsafe` in patch 22 is acknowledged as a TODO pending pin-init support, but deserves scrutiny - The `set_drvdata`/`drvdata_obtain` path stores `F::Of<'bound>` as `F::Of<'static>` via raw pointer casting -- sound given layout guarantees, but the safety argument could be stated more precisely Overall this is high-quality infrastructure work. The main risk areas are the lifetime erasure/restoration in `drvdata` and `into_devres`, which I discuss per-patch below. --- Generated by Claude Code Patch Reviewer