summaryrefslogtreecommitdiff
path: root/drivers/gpu
diff options
context:
space:
mode:
authorDanilo Krummrich <dakr@kernel.org>2026-09-26 14:43:26 +0200
committerDanilo Krummrich <dakr@kernel.org>2026-09-27 14:00:46 +0200
commit05e647ea406967ee18ebc075cde67f0ba368917c (patch)
tree235743578c033a2e81bc21f4221d49c8b6adce81 /drivers/gpu
parent2246188075757345be21291d2e130814b9e51768 (diff)
downloadlinux-next-05e647ea406967ee18ebc075cde67f0ba368917c.tar.gz
linux-next-05e647ea406967ee18ebc075cde67f0ba368917c.zip
gpu: nova-core: mm: get rid of Arc<BarUser> in BarUserAccess
There is no need for a reference count here. BarUserAccess can just borrow from BarUser. Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Link: https://patch.msgid.link/20260926124405.604707-4-dakr@kernel.org [ Update stale comment in run_self_test(). - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/nova-core/mm/bar_user.rs24
1 files changed, 9 insertions, 15 deletions
diff --git a/drivers/gpu/nova-core/mm/bar_user.rs b/drivers/gpu/nova-core/mm/bar_user.rs
index 6c8fa06d9f4b..56caa6b26c41 100644
--- a/drivers/gpu/nova-core/mm/bar_user.rs
+++ b/drivers/gpu/nova-core/mm/bar_user.rs
@@ -7,10 +7,7 @@ use kernel::{
io::Io,
new_mutex,
prelude::*,
- sync::{
- Arc,
- Mutex, //
- },
+ sync::Mutex, //
};
use crate::{
@@ -63,11 +60,11 @@ impl<'gpu> BarUser<'gpu> {
/// Map physical pages to a contiguous BAR1 virtual range.
pub(crate) fn map(
- self: &Arc<Self>,
+ &self,
mm: &mut GpuMm<'_>,
pfns: &[Pfn],
writable: bool,
- ) -> Result<BarUserAccess<'gpu>> {
+ ) -> Result<BarUserAccess<'_>> {
if pfns.is_empty() {
return Err(EINVAL);
}
@@ -75,15 +72,17 @@ impl<'gpu> BarUser<'gpu> {
let mapped = vmm.map_pages(mm, pfns, None, writable)?;
Ok(BarUserAccess {
- bar_user: self.clone(),
+ bar_user: self,
mapped: Some(mapped),
})
}
}
/// Access object for a mapped BAR1 region.
-pub(crate) struct BarUserAccess<'gpu> {
- bar_user: Arc<BarUser<'gpu>>,
+///
+/// Borrows the [`BarUser`] managing the mapping for the lifetime of the access object.
+pub(crate) struct BarUserAccess<'a> {
+ bar_user: &'a BarUser<'a>,
/// [`BarUserAccess::release`] [`Option::take`]s this; `Some` at
/// drop time means `release()` was never called.
mapped: Option<MappedRange>,
@@ -385,15 +384,10 @@ pub(crate) fn run_self_test(
test3_passed = false;
}
- // Release Tests 1-3's Vmm before Test 4 constructs a fresh BarUser on
- // the same PDB.
+ // Release Tests 1-3's Vmm before Test 4 uses the GPU's BarUser on the same PDB.
drop(vmm);
// 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),
- GFP_KERNEL,
- )?;
let access = bar_user.map(mm, &[test_pfn], true)?;
// Write pattern via PRAMIN, read via BarUserAccess.