From: Danilo Krummrich <dakr@kernel.org>
To: dakr@kernel.org, acourbot@nvidia.com
Cc: nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] gpu: nova-core: mm: document fence signalling lock dependencies
Date: Thu, 3 Dec 2026 22:50:02 +0100 [thread overview]
Message-ID: <20261203215019.2870117-1-dakr@kernel.org> (raw)
Expand the MM module documentation on locking and DMA fence signalling.
Suggested-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://lore.kernel.org/all/DN6H2GAT9F0Y.2ZZRVU8FZCYZB@nvidia.com/
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
drivers/gpu/nova-core/mm.rs | 25 +++++++++++++++++++++++--
drivers/gpu/nova-core/mm/tlb.rs | 8 ++++----
2 files changed, 27 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/nova-core/mm.rs b/drivers/gpu/nova-core/mm.rs
index 795939a5c8ab..0818358ab12c 100644
--- a/drivers/gpu/nova-core/mm.rs
+++ b/drivers/gpu/nova-core/mm.rs
@@ -2,6 +2,27 @@
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//! Memory management subsystems.
+//!
+//! # Locking
+//!
+//! A reclaimable allocation while holding a lock that may be acquired in the DMA
+//! fence signalling critical path (such as the PRAMIN or TLB lock) can deadlock:
+//! reclaim may wait for a DMA fence whose signalling path needs the same lock.
+//!
+//! The restriction is transitive: if code holding lock A can block acquiring
+//! lock B, and fence signalling needs A, B must not be held across reclaimable
+//! allocations on any path, even outside the signalling path (the same applies to
+//! every lock in the dependency chain). Otherwise a holder of B can enter reclaim
+//! and wait for a fence whose signalling is blocked on A or B.
+//!
+//! The allocation restriction also applies to work needed to signal a fence that
+//! other threads can already wait on, even when no lock is held. If an allocation
+//! in that work enters reclaim and waits for the same fence, the work cannot
+//! reach the code that signals it.
+//!
+//! See the DMA-fence
+//! [contract](https://docs.kernel.org/driver-api/dma-buf.html#dma-fence-cross-driver-contract)
+//! for the full requirements.
#![cfg_attr(not(CONFIG_NOVA_CORE_SELFTESTS), expect(dead_code))]
@@ -116,8 +137,8 @@ pub(crate) fn buddy(&self) -> &GpuBuddy {
/// Runs `f` with exclusive access to the PRAMIN window.
///
- /// Do not perform reclaimable allocations in `f`: reclaim may wait for a DMA
- /// fence whose signalling path needs the PRAMIN lock, causing a deadlock.
+ /// Do not perform reclaimable allocations in `f`; see the
+ /// [MM locking rules](crate::mm#locking).
fn with_pramin_locked<R>(&self, f: impl FnOnce(&mut pramin::Pramin<'_>) -> R) -> R {
self.with_pramin(|pramin| f(&mut pramin.lock()))
}
diff --git a/drivers/gpu/nova-core/mm/tlb.rs b/drivers/gpu/nova-core/mm/tlb.rs
index cc862e8159a1..fff66dc03549 100644
--- a/drivers/gpu/nova-core/mm/tlb.rs
+++ b/drivers/gpu/nova-core/mm/tlb.rs
@@ -66,10 +66,10 @@ pub(crate) enum TlbAckMode with TryFrom<Bounded<u32, 2>> {
#[pin_data]
pub(crate) struct Tlb<'gpu> {
bar: Bar0<'gpu>,
- /// TLB flush serialization lock: This lock is designed to be acquired during
- /// the DMA fence signalling critical path. It should NEVER be held across any
- /// reclaimable CPU memory allocations because the memory reclaim path can
- /// call `dma_fence_wait()` (when implemented), which would deadlock if lock held.
+ /// TLB flush serialization lock.
+ ///
+ /// Do not hold this lock across reclaimable memory allocations; see the
+ /// [MM locking rules](crate::mm#locking).
#[pin]
lock: Mutex<()>,
}
base-commit: d9da44362d77bcbf1f5bfd2ba1c514e776fdb07c
--
2.56.1
next reply other threads:[~2026-12-03 21:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 21:50 Danilo Krummrich [this message]
2026-12-03 21:50 ` [PATCH 2/2] gpu: nova-core: mm: move TLB register access behind the mutex Danilo Krummrich
2026-12-03 22:13 ` Gary Guo
2026-12-03 22:13 ` [PATCH 1/2] gpu: nova-core: mm: document fence signalling lock dependencies Gary Guo
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=20261203215019.2870117-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.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