The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Danilo Krummrich <dakr@kernel.org>
To: dakr@kernel.org, acourbot@nvidia.com, aliceryhl@google.com,
	airlied@gmail.com, simona@ffwll.ch, lossin@kernel.org,
	gary@garyguo.net, ecourtney@nvidia.com, jhubbard@nvidia.com
Cc: nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 4/4] gpu: nova-core: mm: remove SharedPramin
Date: Thu, 26 Nov 2026 22:36:05 +0100	[thread overview]
Message-ID: <20261126213652.3716162-5-dakr@kernel.org> (raw)
In-Reply-To: <20261126213652.3716162-1-dakr@kernel.org>

SharedPramin was introduced as a temporary wrapper so its mutex could be
pin-initialized separately while GpuMm remained movable. This allowed
PRAMIN locking to remove the need for mutable GpuMm references before
converting GpuMm itself to pin initialization.

Now that GpuMm is pin-initialized, it can embed Mutex<Pramin> directly
and hide the mutex's invariant resource lifetime itself. Remove the
temporary wrapper.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
 drivers/gpu/nova-core/mm.rs        | 19 +++++++++++------
 drivers/gpu/nova-core/mm/pramin.rs | 34 ------------------------------
 2 files changed, 13 insertions(+), 40 deletions(-)

diff --git a/drivers/gpu/nova-core/mm.rs b/drivers/gpu/nova-core/mm.rs
index 94c6f425c867..7aa8906d2cb2 100644
--- a/drivers/gpu/nova-core/mm.rs
+++ b/drivers/gpu/nova-core/mm.rs
@@ -44,13 +44,15 @@ macro_rules! impl_pfn_bounded {
         GpuBuddy,
         GpuBuddyParams, //
     },
+    new_mutex,
     num::Bounded,
     prelude::*,
     ptr::{
         Alignable,
         Alignment, //
     },
-    sizes::SZ_4K, //
+    sizes::SZ_4K,
+    sync::Mutex, //
 };
 
 use crate::{
@@ -72,13 +74,18 @@ macro_rules! impl_pfn_bounded {
 ///
 /// Provides centralized ownership of memory management resources:
 /// - [`GpuBuddy`] allocator for VRAM page table allocation.
-/// - [`pramin::SharedPramin`] for direct VRAM access.
+/// - [`pramin::Pramin`] for direct VRAM access.
 /// - [`Tlb`] manager for translation buffer flush operations.
 #[pin_data]
-pub(crate) struct GpuMm<'gpu> {
+pub(crate) struct GpuMm<'gpu>
+where
+    // Hide the mutex's invariant resource lifetime so `GpuMm` remains covariant.
+    exists<'res>: 'gpu,
+{
     buddy: GpuBuddy,
     #[pin]
-    pramin: pramin::SharedPramin<'gpu>,
+    #[uses('res: invariant)]
+    pramin: Mutex<pramin::Pramin<'res>>,
     #[pin]
     tlb: Tlb<'gpu>,
 }
@@ -97,7 +104,7 @@ pub(crate) fn new(
 
         try_pin_init!(Self {
             buddy: GpuBuddy::new(buddy_params)?,
-            pramin <- pramin::SharedPramin::new(bar, chipset, vram_region),
+            pramin <- new_mutex!(pramin::Pramin::new(bar, chipset, vram_region)?, "pramin"),
             tlb <- Tlb::new(bar),
         })
     }
@@ -111,7 +118,7 @@ pub(crate) fn buddy(&self) -> &GpuBuddy {
     ///
     /// Do not perform reclaimable allocations in `f`.
     fn with_pramin_locked<R>(&self, f: impl FnOnce(&mut pramin::Pramin<'_>) -> R) -> R {
-        self.pramin.with_locked(f)
+        self.with_pramin(|pramin| f(&mut pramin.lock()))
     }
 
     /// Access the [`Tlb`] manager.
diff --git a/drivers/gpu/nova-core/mm/pramin.rs b/drivers/gpu/nova-core/mm/pramin.rs
index 841289d7bccc..c83b1681d241 100644
--- a/drivers/gpu/nova-core/mm/pramin.rs
+++ b/drivers/gpu/nova-core/mm/pramin.rs
@@ -13,7 +13,6 @@
         Io,
         Mmio, //
     },
-    new_mutex,
     prelude::*,
     ptr::{
         Alignable,
@@ -23,7 +22,6 @@
         SizeConstants,
         SZ_1M, //
     },
-    sync::Mutex, //
 };
 
 use crate::{
@@ -56,38 +54,6 @@
     PRAMIN: PraminWindow @ 0x700000;
 }
 
-/// A [`Pramin`] shared between users, serialized by a mutex.
-#[pin_data]
-pub(super) struct SharedPramin<'gpu>
-where
-    // Hide the mutex's invariant resource lifetime so `SharedPramin` remains covariant.
-    exists<'res>: 'gpu,
-{
-    #[pin]
-    #[uses('res: invariant)]
-    inner: Mutex<Pramin<'res>>,
-}
-
-impl<'gpu> SharedPramin<'gpu> {
-    /// Creates the shared window manager for the given VRAM region.
-    pub(super) fn new(
-        bar: Bar0<'gpu>,
-        chipset: Chipset,
-        vram_range: Range<VramAddress>,
-    ) -> impl PinInit<Self, Error> {
-        try_pin_init!(Self {
-            inner <- new_mutex!(Pramin::new(bar, chipset, vram_range)?, "pramin"),
-        })
-    }
-
-    /// Runs `f` with exclusive access to the PRAMIN window.
-    ///
-    /// Do not perform reclaimable allocations in `f`.
-    pub(super) fn with_locked<R>(&self, f: impl FnOnce(&mut Pramin<'_>) -> R) -> R {
-        self.with_inner(|inner| f(&mut inner.lock()))
-    }
-}
-
 /// Owner of the PRAMIN window state.
 ///
 /// [`Pramin::window_at()`] repositions the window as needed and returns a typed MMIO view into
-- 
2.56.1


      parent reply	other threads:[~2026-11-26 21:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 21:36 [PATCH 0/4] gpu: nova-core: prepare GpuMm for shared access Danilo Krummrich
2026-11-26 21:36 ` [PATCH 1/4] gpu: nova-core: mm: serialize PRAMIN access Danilo Krummrich
2026-11-26 21:36 ` [PATCH 2/4] gpu: nova-core: mm: use shared references to GpuMm Danilo Krummrich
2026-11-26 21:36 ` [PATCH 3/4] gpu: nova-core: mm: initialize GpuMm in place Danilo Krummrich
2026-11-26 21:36 ` Danilo Krummrich [this message]

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=20261126213652.3716162-5-dakr@kernel.org \
    --to=dakr@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ecourtney@nvidia.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nova-gpu@lists.linux.dev \
    --cc=simona@ffwll.ch \
    /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