From: Daniel Almeida <daniel.almeida@collabora.com>
To: "Daniel Almeida" <daniel.almeida@collabora.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Benno Lossin" <lossin@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>
Cc: dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 12/13] drm/tyr: justify the physical address cast in pt_map()
Date: Wed, 25 Nov 2026 19:47:03 -0300 [thread overview]
Message-ID: <20261125-b4-tyr-as-casts-v1-12-2b2f53164d86@collabora.com> (raw)
In-Reply-To: <20261125-b4-tyr-as-casts-v1-0-2b2f53164d86@collabora.com>
An `as` cast silently drops the bits that do not fit the target type,
and nothing at the cast shows whether that can happen. As part of a
larger effort to reduce the number of `as` casts in Tyr, justify the
cast of the DMA address to `PhysAddr` in `pt_map()`. It stays, with a
`// CAST:` comment and an `#[expect(clippy::as_conversions)]`.
No functional change intended.
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
---
drivers/gpu/drm/tyr/vm.rs | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/tyr/vm.rs b/drivers/gpu/drm/tyr/vm.rs
index 673fc6819070..3e2ed43f07a0 100644
--- a/drivers/gpu/drm/tyr/vm.rs
+++ b/drivers/gpu/drm/tyr/vm.rs
@@ -866,22 +866,18 @@ fn pt_map(
}
};
+ // CAST: `PhysAddr` is as wide as a DMA address on the platforms we care about.
+ #[expect(clippy::as_conversions)]
+ let curr_paddr = curr_paddr as PhysAddr;
+
// SAFETY:
// No other io-pgtable operation can currently access this range because Tyr holds
// the gpuvm_unique mutex for the entire sm_map() operation.
// The addresses being mapped won't overlap any existing mappings in this
// page table because drm_gpuvm_sm_map() checks each requested mapping and either unmaps
// or remaps any overlap before creating the new mapping.
- let (mapped, result) = unsafe {
- pt.map_pages(
- curr_iova,
- curr_paddr as PhysAddr,
- pgsize,
- pgcount,
- prot,
- GFP_KERNEL,
- )
- };
+ let (mapped, result) =
+ unsafe { pt.map_pages(curr_iova, curr_paddr, pgsize, pgcount, prot, GFP_KERNEL) };
if let Err(e) = result {
// If map_pages fails, mapped will be zero because the ARM LPAE backend
--
2.56.0
next prev parent reply other threads:[~2026-11-25 22:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 22:46 [PATCH 00/13] drm/tyr: reduce the number of `as` casts Daniel Almeida
2026-11-25 22:46 ` [PATCH 01/13] drm/tyr: convert SeatInfo::slot from u8 to usize Daniel Almeida
2026-11-25 22:46 ` [PATCH 02/13] drm/tyr: convert VmAsData::va_bits from u8 to u32 Daniel Almeida
2026-11-25 22:46 ` [PATCH 03/13] drm/tyr: convert the lock region exponents " Daniel Almeida
2026-11-25 22:46 ` [PATCH 04/13] drm/tyr: convert EntryHeader to `bitfield!` Daniel Almeida
2026-11-25 22:46 ` [PATCH 05/13] drm/tyr: use SizeConstants for the u32 and u64 size constants Daniel Almeida
2026-11-25 22:46 ` [PATCH 06/13] drm/tyr: replace lossless `as` casts with From and FromSafeCast Daniel Almeida
2026-11-25 22:46 ` [PATCH 07/13] drm/tyr: use `cv!` for constant conversions Daniel Almeida
2026-11-25 22:46 ` [PATCH 08/13] drm/tyr: use VmMapFlags::all_bits() to validate map flags Daniel Almeida
2026-11-25 22:47 ` [PATCH 09/13] drm/tyr: justify the casts of enums to their integer value Daniel Almeida
2026-11-25 22:47 ` [PATCH 10/13] drm/tyr: add split_u64() for the 64-bit register values Daniel Almeida
2026-11-25 22:47 ` [PATCH 11/13] drm/tyr: return usize from get_pgsize() Daniel Almeida
2026-11-25 22:47 ` Daniel Almeida [this message]
2026-11-25 22:47 ` [PATCH 13/13] drm/tyr: deny `clippy::as_conversions` Daniel Almeida
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=20261125-b4-tyr-as-casts-v1-12-2b2f53164d86@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--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®