Remove the unnecessary Arc around BarUser and get rid of Result<impl PinInit<T>> in favor of impl PinInit<T, Error>.
Signed-off-by: Danilo Krummrich <[email protected]> --- drivers/gpu/nova-core/gpu.rs | 24 +++++++++++------------- drivers/gpu/nova-core/mm.rs | 5 ++--- drivers/gpu/nova-core/mm/bar_user.rs | 16 +++++++++------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs index 1ae287c9e776..123e605fa2c2 100644 --- a/drivers/gpu/nova-core/gpu.rs +++ b/drivers/gpu/nova-core/gpu.rs @@ -16,7 +16,6 @@ SizeConstants, SZ_4K, // }, - sync::Arc, }; use crate::{ @@ -309,7 +308,8 @@ pub(crate) struct Gpu<'gpu> { /// the GSP is still operational. mm: GpuMm<'gpu>, /// BAR1 user interface for CPU access to GPU virtual memory. - bar_user: Arc<BarUser<'gpu>>, + #[pin] + bar_user: BarUser<'gpu>, /// GSP and its resources. #[pin] gsp_resources: GspResources<'gpu>, @@ -465,19 +465,17 @@ pub(crate) fn new<'a>( }, // Create BAR1 user interface for CPU access to GPU virtual memory. - bar_user: { + bar_user <- { let pdb_addr = VramAddress::from_raw(gsp_static_info.bar1_pde_base); let bar1_idx = crate::driver::bar1_resource_index(pdev)?; let bar1_size = pdev.resource_len(bar1_idx)?; - Arc::pin_init( - BarUser::new( - pdb_addr, - gsp_resources.spec.chipset, - bar1_size, - bar1, - )?, - GFP_KERNEL, - )? + + BarUser::new( + pdb_addr, + gsp_resources.spec.chipset, + bar1_size, + bar1, + ) }, }) } @@ -493,7 +491,7 @@ pub(crate) fn run_selftests(self: Pin<&mut Self>, pdev: &pci::Device<device::Bou dev, this.mm, regions, - this.bar_user, + &this.bar_user, this.gsp_static_info.bar1_pde_base, this.spec.chipset, ) { diff --git a/drivers/gpu/nova-core/mm.rs b/drivers/gpu/nova-core/mm.rs index a5bc4042577b..8a934c55169f 100644 --- a/drivers/gpu/nova-core/mm.rs +++ b/drivers/gpu/nova-core/mm.rs @@ -298,8 +298,7 @@ pub(crate) mod selftest { use kernel::{ device, - sizes::SizeConstants, - sync::Arc, // + sizes::SizeConstants, // }; use super::*; @@ -309,7 +308,7 @@ pub(crate) fn run( dev: &device::Device<device::Bound>, mm: &mut GpuMm<'_>, usable_fb_regions: &[Range<u64>], - bar_user: &Arc<bar_user::BarUser<'_>>, + bar_user: &bar_user::BarUser<'_>, bar1_pdb: u64, chipset: Chipset, ) -> Result { diff --git a/drivers/gpu/nova-core/mm/bar_user.rs b/drivers/gpu/nova-core/mm/bar_user.rs index 86b5d302188e..6c8fa06d9f4b 100644 --- a/drivers/gpu/nova-core/mm/bar_user.rs +++ b/drivers/gpu/nova-core/mm/bar_user.rs @@ -51,12 +51,14 @@ pub(crate) fn new( chipset: Chipset, va_size: u64, bar1: Bar1<'gpu>, - ) -> Result<impl PinInit<Self> + 'gpu> { - let vmm = Vmm::new(pdb_addr, chipset.mmu_version(), va_size)?; - Ok(pin_init!(Self { - vmm <- new_mutex!(vmm, "bar_user_vmm"), + ) -> impl PinInit<Self, Error> + 'gpu { + try_pin_init!(Self { + vmm <- new_mutex!( + Vmm::new(pdb_addr, chipset.mmu_version(), va_size)?, + "bar_user_vmm", + ), bar1, - })) + }) } /// Map physical pages to a contiguous BAR1 virtual range. @@ -183,7 +185,7 @@ fn drop(&mut self) { pub(crate) fn run_self_test( dev: &device::Device<device::Bound>, mm: &mut GpuMm<'_>, - bar_user: &Arc<BarUser<'_>>, + bar_user: &BarUser<'_>, bar1_pdb: u64, chipset: Chipset, ) -> Result { @@ -389,7 +391,7 @@ pub(crate) fn run_self_test( // Test 4: Exercise `BarUser::map()` end-to-end. let bar_user = Arc::pin_init( - BarUser::new(pdb_addr, chipset, SZ_64K.into_safe_cast(), bar1)?, + BarUser::new(pdb_addr, chipset, SZ_64K.into_safe_cast(), bar1), GFP_KERNEL, )?; let access = bar_user.map(mm, &[test_pfn], true)?; -- 2.55.0
