Re: [PATCH v5 18/24] rust: pci: make Bar lifetime-parameterized

From: Gary Guo

Date: Wed May 27 2026 - 09:37:22 EST


On Mon May 25, 2026 at 9:21 PM BST, Danilo Krummrich wrote:
> Convert pci::Bar<SIZE> to pci::Bar<'a, SIZE>, storing &'a Device<Bound>
> to tie the BAR mapping lifetime to the device.
>
> iomap_region_sized() now returns Result<Bar<'a, SIZE>> directly instead
> of impl PinInit<Devres<Bar<SIZE>>, Error>.
>
> Since the lifetime ties the mapping to the device's bound state, callers
> no longer need Devres for the common case where the Bar lives in the
> driver's private data.
>
> Add Bar::into_devres() to consume the bar and register it as a
> device-managed resource, returning Devres<Bar<'static, SIZE>>. The
> lifetime is erased to 'static because Devres guarantees the bar does not
> actually outlive the device -- access is revoked on unbind.
>
> Reviewed-by: Eliot Courtney <ecourtney@xxxxxxxxxx>
> Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Reviewed-by: Alexandre Courbot <acourbot@xxxxxxxxxx>
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>

Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>

> ---
> drivers/gpu/nova-core/driver.rs | 7 +++--
> rust/kernel/devres.rs | 2 +-
> rust/kernel/pci/io.rs | 52 +++++++++++++++++++--------------
> samples/rust/rust_driver_pci.rs | 5 ++--
> 4 files changed, 38 insertions(+), 28 deletions(-)