From: Danilo Krummrich <dakr@kernel.org>
To: acourbot@nvidia.com
Cc: nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Danilo Krummrich <dakr@kernel.org>
Subject: [PATCH] gpu: nova-core: take advantage of pci::Device::unbind()
Date: Sat, 30 Aug 2025 15:32:53 +0200 [thread overview]
Message-ID: <20250830133255.62380-1-dakr@kernel.org> (raw)
Now that we have pci::Device::unbind() we can unregister the sysmem
flush page with a direct access the I/O resource, i.e. without RCU read
side critical section.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
drivers/gpu/nova-core/driver.rs | 4 ++++
drivers/gpu/nova-core/gpu.rs | 20 ++++++++++----------
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/nova-core/driver.rs b/drivers/gpu/nova-core/driver.rs
index 274989ea1fb4..02514e1e2529 100644
--- a/drivers/gpu/nova-core/driver.rs
+++ b/drivers/gpu/nova-core/driver.rs
@@ -54,4 +54,8 @@ fn probe(pdev: &pci::Device<Core>, _info: &Self::IdInfo) -> Result<Pin<KBox<Self
Ok(this)
}
+
+ fn unbind(pdev: &pci::Device<Core>, this: Pin<&Self>) {
+ this.gpu.unbind(pdev);
+ }
}
diff --git a/drivers/gpu/nova-core/gpu.rs b/drivers/gpu/nova-core/gpu.rs
index 8caecaf7dfb4..2db9afdc6087 100644
--- a/drivers/gpu/nova-core/gpu.rs
+++ b/drivers/gpu/nova-core/gpu.rs
@@ -163,7 +163,7 @@ fn new(bar: &Bar0) -> Result<Spec> {
}
/// Structure holding the resources required to operate the GPU.
-#[pin_data(PinnedDrop)]
+#[pin_data]
pub(crate) struct Gpu {
spec: Spec,
/// MMIO mapping of PCI BAR 0
@@ -174,15 +174,6 @@ pub(crate) struct Gpu {
sysmem_flush: SysmemFlush,
}
-#[pinned_drop]
-impl PinnedDrop for Gpu {
- fn drop(self: Pin<&mut Self>) {
- // Unregister the sysmem flush page before we release it.
- self.bar
- .try_access_with(|b| self.sysmem_flush.unregister(b));
- }
-}
-
impl Gpu {
/// Helper function to load and run the FWSEC-FRTS firmware and confirm that it has properly
/// created the WPR2 region.
@@ -309,4 +300,13 @@ pub(crate) fn new(
sysmem_flush,
}))
}
+
+ pub(crate) fn unbind(&self, pdev: &pci::Device<device::Bound>) {
+ // Unregister the sysmem flush page before we release it.
+ kernel::warn_on!(self.bar.access(pdev.as_ref()).map_or(true, |bar| {
+ self.sysmem_flush.unregister(bar);
+
+ false
+ }));
+ }
}
base-commit: 09f90256e8902793f594517ef440698585eb3595
--
2.51.0
next reply other threads:[~2025-08-30 13:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-30 13:32 Danilo Krummrich [this message]
2025-08-30 13:51 ` [PATCH] gpu: nova-core: take advantage of pci::Device::unbind() Danilo Krummrich
2025-08-31 13:50 ` Alexandre Courbot
2025-09-01 10:41 ` Danilo Krummrich
2025-09-01 13:13 ` Alexandre Courbot
2025-09-01 14:54 ` 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=20250830133255.62380-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=nouveau@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.