From: Zhi Wang Temporary BAR1 access needs a borrow of the GPU-owned BarUser. Store BarUser inline in Gpu and borrow it in BarUserAccess, avoiding a separate allocation and reference counting for these accesses. Update the existing self-test entry points to accept the borrowed interface. No functional change is intended. Cc: Alistair Popple Signed-off-by: Zhi Wang Signed-off-by: Alok Kumar --- drivers/gpu/nova-core/gpu.rs | 2 +- drivers/gpu/nova-core/mm/bar_user.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index cf7173b72a13..03d0411008c9 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -656,7 +656,7 @@ pub(crate) fn run_selftests(self: Pin<&mut Self>, pdev: &pci::Device( + &'access self, mm: &mut GpuMm<'_>, pfns: &[Pfn], writable: bool, - ) -> Result> { + ) -> Result> { if pfns.is_empty() { return Err(EINVAL); } @@ -85,14 +85,14 @@ pub(crate) fn map( /// Access object for a mapped BAR1 region. /// /// Borrows the [`BarUser`] managing the mapping for the lifetime of the access object. -pub(crate) struct BarUserAccess<'a> { - bar_user: &'a BarUser<'a>, +pub(crate) struct BarUserAccess<'access, 'gpu> { + bar_user: &'access BarUser<'gpu>, /// Cleared only after PTE invalidation and its TLB flush succeed. mapped: Option, } #[expect(dead_code)] -impl BarUserAccess<'_> { +impl BarUserAccess<'_, '_> { /// Tear down the BAR1 mapping. pub(crate) fn release(mut self, mm: &mut GpuMm<'_>) -> Result { self.unmap(mm) @@ -159,7 +159,7 @@ pub(crate) fn view(&self, offset: usize) -> Result> { } } -impl Drop for BarUserAccess<'_> { +impl Drop for BarUserAccess<'_, '_> { fn drop(&mut self) { if self.mapped.is_some() { kernel::pr_warn!( @@ -177,7 +177,7 @@ fn drop(&mut self) { /// address space. Uses the `GpuMm`'s buddy allocator to allocate page tables /// and test pages as needed. #[cfg(CONFIG_NOVA_CORE_SELFTESTS)] -pub(crate) fn run_self_test( +pub(super) fn run_self_test( dev: &device::Device, mm: &mut GpuMm<'_>, bar_user: &BarUser<'_>, -- 2.53.0