From: Danilo Krummrich <dakr@kernel.org>
To: dakr@kernel.org, abdiel.janulgue@gmail.com,
daniel.almeida@collabora.com, robin.murphy@arm.com,
a.hindborg@kernel.org, ojeda@kernel.org, boqun@kernel.org,
gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
aliceryhl@google.com, tmgross@umich.edu, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev
Cc: driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] samples: rust_dma: construct driver data by value
Date: Sun, 22 Nov 2026 18:15:32 +0100 [thread overview]
Message-ID: <20261122171610.967066-1-dakr@kernel.org> (raw)
Now that SGTable no longer requires pinning, construct DmaSampleData by
value and replace PinnedDrop with Drop.
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
---
samples/rust/rust_dma.rs | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/samples/rust/rust_dma.rs b/samples/rust/rust_dma.rs
index 844e137cddc8..b5d71ada8521 100644
--- a/samples/rust/rust_dma.rs
+++ b/samples/rust/rust_dma.rs
@@ -31,7 +31,6 @@
struct DmaSampleDriver;
-#[pin_data(PinnedDrop)]
struct DmaSampleData<'bound> {
pdev: &'bound pci::Device<Bound>,
ca: Coherent<'bound, [MyStruct]>,
@@ -77,28 +76,26 @@ fn probe<'bound>(
pdev: &'bound pci::Device<Core<'_>>,
_info: Option<&'bound Self::IdInfo>,
) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
- pin_init::pin_init_scope(move || {
- dev_info!(pdev, "Probe DMA test driver.\n");
+ dev_info!(pdev, "Probe DMA test driver.\n");
- let mask = DmaMask::new::<64>();
+ let mask = DmaMask::new::<64>();
- // SAFETY: There are no concurrent calls to DMA allocation and mapping primitives.
- unsafe { pdev.dma_set_mask_and_coherent(mask)? };
+ // SAFETY: There are no concurrent calls to DMA allocation and mapping primitives.
+ unsafe { pdev.dma_set_mask_and_coherent(mask)? };
- let ca: Coherent<'_, [MyStruct]> =
- Coherent::zeroed_slice(pdev.as_ref(), TEST_VALUES.len(), GFP_KERNEL)?;
+ let ca: Coherent<'_, [MyStruct]> =
+ Coherent::zeroed_slice(pdev.as_ref(), TEST_VALUES.len(), GFP_KERNEL)?;
- for (i, value) in TEST_VALUES.into_iter().enumerate() {
- io_project!(ca, [panic: i]).copy_write(MyStruct::new(value.0, value.1));
- }
+ for (i, value) in TEST_VALUES.into_iter().enumerate() {
+ io_project!(ca, [panic: i]).copy_write(MyStruct::new(value.0, value.1));
+ }
- let size = 4 * page::PAGE_SIZE;
- let pages = VVec::with_capacity(size, GFP_KERNEL)?;
+ let size = 4 * page::PAGE_SIZE;
+ let pages = VVec::with_capacity(size, GFP_KERNEL)?;
- let sgt = SGTable::new(pdev.as_ref(), pages, DataDirection::ToDevice, GFP_KERNEL)?;
+ let sgt = SGTable::new(pdev.as_ref(), pages, DataDirection::ToDevice, GFP_KERNEL)?;
- Ok(try_pin_init!(Self::Data { pdev, ca, sgt }))
- })
+ Ok(Self::Data { pdev, ca, sgt })
}
}
@@ -114,9 +111,8 @@ fn check_dma(&self) {
}
}
-#[pinned_drop]
-impl PinnedDrop for DmaSampleData<'_> {
- fn drop(self: Pin<&mut Self>) {
+impl Drop for DmaSampleData<'_> {
+ fn drop(&mut self) {
dev_info!(self.pdev, "Unload DMA test driver.\n");
self.check_dma();
base-commit: 0504beeb95d1be229d7cce00a12033468f5ac50b
--
2.56.1
reply other threads:[~2026-11-22 17:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261122171610.967066-1-dakr@kernel.org \
--to=dakr@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=abdiel.janulgue@gmail.com \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=driver-core@lists.linux.dev \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=robin.murphy@arm.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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
all inboxes | Powered by JetHome®