linux/drivers/fwctl
Zhi Wang e052daab94 rust: introduce abstractions for fwctl
Introduce safe Rust wrappers around struct fwctl_device and struct
fwctl_uctx. This lets Rust drivers register fwctl devices and implement
firmware RPC callbacks through a typed trait interface.

The abstraction keeps lifetime and reference-count handling inside the
wrapper, exposes pinned per-FD user contexts to drivers, and validates the
layout assumptions required by the C fwctl allocation model. Allocation
sizes are padded so the kmalloc-backed C allocations also satisfy Rust
alignment requirements.

Registration owns driver private data with a lifetime tied to the bound
parent device and verifies the parent identity before registration.
Callbacks access that data through a higher-ranked closure, preventing its
erased lifetime from escaping, while Device remains only the refcounted
fwctl object. This avoids requiring Rust drop glue from the fwctl_device
release path after unregister or module teardown.

RPC callbacks receive typed scope information, a mutable request/response
buffer, and the userspace output-buffer size. Response pointer conversion,
length validation, and raw output-length handling remain inside the
abstraction.

Add the Rust sources to the FWCTL MAINTAINERS entry and add myself as the
maintainer for the Rust abstractions.

Link: https://patch.msgid.link/r/20260813152312.1311142-2-zhiw@nvidia.com
Co-developed-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Signed-off-by: Zhi Wang <zhiw@nvidia.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2026-08-14 19:21:17 -03:00
..
bnxt fwctl/bnxt: Add DMA buffer support for HWRM commands 2026-08-07 14:18:13 -03:00
mlx5 Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
pds fwctl: pds: Validate RPC input size before parsing 2026-05-19 10:44:32 -03:00
Kconfig rust: introduce abstractions for fwctl 2026-08-14 19:21:17 -03:00
main.c fwctl: Fix class init ordering to avoid NULL pointer dereference on device removal 2026-04-10 11:21:06 -03:00
Makefile fwctl/bnxt_fwctl: Add bnxt fwctl device 2026-03-31 13:33:54 -03:00