dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: dakr@kernel.org, acourbot@nvidia.com
Cc: nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org
Subject: [PATCH 3/4] gpu: nova-core: mm: get rid of Arc<BarUser> in BarUserAccess
Date: Sat, 26 Sep 2026 14:43:26 +0200	[thread overview]
Message-ID: <20260926124405.604707-4-dakr@kernel.org> (raw)
In-Reply-To: <20260926124405.604707-1-dakr@kernel.org>

There is no need for a reference count here. BarUserAccess can just
borrow from BarUser.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 drivers/gpu/nova-core/mm/bar_user.rs | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/nova-core/mm/bar_user.rs b/drivers/gpu/nova-core/mm/bar_user.rs
index 6c8fa06d9f4b..855244f06983 100644
--- a/drivers/gpu/nova-core/mm/bar_user.rs
+++ b/drivers/gpu/nova-core/mm/bar_user.rs
@@ -7,10 +7,7 @@
     io::Io,
     new_mutex,
     prelude::*,
-    sync::{
-        Arc,
-        Mutex, //
-    },
+    sync::Mutex, //
 };
 
 use crate::{
@@ -63,11 +60,11 @@ pub(crate) fn new(
 
     /// 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 @@ pub(crate) fn map(
         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>,
@@ -390,10 +389,6 @@ pub(crate) fn run_self_test(
     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.
-- 
2.55.0


  parent reply	other threads:[~2026-09-26 12:44 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 12:43 [PATCH 0/4] nova-core: align Bar0/Bar1 and remvove unnecessary Arc Danilo Krummrich
2026-09-26 12:43 ` [PATCH 1/4] gpu: nova-core: align Bar1 alias with Bar0 Danilo Krummrich
2026-09-28  5:39   ` Eliot Courtney
2026-09-26 12:43 ` [PATCH 2/4] gpu: nova-core: remove unnecessary Arc around BarUser Danilo Krummrich
2026-09-28  5:39   ` Eliot Courtney
2026-09-26 12:43 ` Danilo Krummrich [this message]
2026-09-26 12:58   ` [PATCH 3/4] gpu: nova-core: mm: get rid of Arc<BarUser> in BarUserAccess sashiko-bot
2026-09-28  5:40   ` Eliot Courtney
2026-09-26 12:43 ` [PATCH 4/4] gpu: nova-core: mm: fix lifetime name in BarUser Danilo Krummrich
2026-09-28  5:40   ` Eliot Courtney
2026-09-26 15:34 ` [PATCH 0/4] nova-core: align Bar0/Bar1 and remvove unnecessary Arc Alexandre Courbot
2026-09-27 12:15 ` Danilo Krummrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260926124405.604707-4-dakr@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nova-gpu@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox