mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v4 0/2] rust: io: convert ResourceSize into a transparent newtype
@ 2026-09-27 18:11 Lorenzo Delgado
  2026-09-27 18:11 ` [PATCH v4 1/2] rust: scatterlist: return u32 from SGEntry::dma_len() Lorenzo Delgado
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lorenzo Delgado @ 2026-09-27 18:11 UTC (permalink / raw)
  To: Daniel Almeida, Alice Ryhl, Danilo Krummrich, David Airlie,
	Simona Vetter, Abdiel Janulgue, Robin Murphy, Andreas Hindborg,
	Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Trevor Gross, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan
  Cc: Lorenzo Delgado, dri-devel, linux-kernel, driver-core, rust-for-linux

This turns ResourceSize from a type alias into a #[repr(transparent)]
newtype, so that every conversion at the FFI boundary is explicit.

The first patch changes SGEntry::dma_len() to return u32. The length of
a DMA segment is an unsigned int on the C side, so it was never a
ResourceSize. Doing that first means the newtype patch no longer has to
touch tyr or nova-core.

Note that Alexandre's nova_num series [1] rewrites the dma_len() line in
nova-core's gsp.rs to usize::from_safe_cast_arch(), which takes a u64.
With patch 1 applied, that line needs usize::from_safe_cast() instead,
and the FromSafeCastArch import goes away. The two series apply on top
of each other without conflicts, so this only shows up as a build
error. I can rebase on top of nova_num if it lands first.

[1] https://lore.kernel.org/r/20260828-nova_num-v1-0-e21f17ba4127@nvidia.com

Signed-off-by: Lorenzo Delgado <lnsdev@proton.me>
---
Changes in v4:
- New patch 1: return u32 from SGEntry::dma_len(), as suggested by
  Danilo.
- Patch 2 no longer touches scatterlist.rs, tyr or nova-core.
- Drop FromSafeCastArch<ResourceSize> for usize. Its only user was the
  dma_len() conversion in nova-core.
- Link to v3: https://patch.msgid.link/20260920-resource-size-newtype-v3-1-9451444e83bb@proton.me

Changes in v3:
- Rebase on rust-next (v7.3-rc4).
- Implement FromSafeCastArch<ResourceSize> for usize in the kernel
  crate, next to the type, now that the lossless casts live in
  kernel::num::casts. Drop the impl from nova-core's num.rs, and switch
  gsp.rs to usize::from_safe_cast_arch(), the same line the nova-core
  conversion to kernel::num uses.
- Convert the dma_len() user in tyr, added since v2. Without it, tyr
  fails to build on 32-bit ARM without LPAE.
- Link to v2: https://lore.kernel.org/r/20260719200945.687904-1-lnsdev@proton.me
- Link to v1: https://lore.kernel.org/r/20260712113602.389060-1-lnsdev@proton.me

---
Lorenzo Delgado (2):
      rust: scatterlist: return u32 from SGEntry::dma_len()
      rust: io: convert ResourceSize into a transparent newtype

 drivers/gpu/drm/tyr/vm.rs  |  1 -
 rust/kernel/io.rs          | 74 ++++++++++++++++++++++++++++++++++++++++++----
 rust/kernel/io/resource.rs |  6 ++--
 rust/kernel/scatterlist.rs |  9 ++----
 4 files changed, 75 insertions(+), 15 deletions(-)
---
base-commit: 93f51579e7df248780214094418f205253383cc5
change-id: 20260920-resource-size-newtype-63a82d4f2cdb

Best regards,
--  
Lorenzo Delgado <lnsdev@proton.me>



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-01 22:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-27 18:11 [PATCH v4 0/2] rust: io: convert ResourceSize into a transparent newtype Lorenzo Delgado
2026-09-27 18:11 ` [PATCH v4 1/2] rust: scatterlist: return u32 from SGEntry::dma_len() Lorenzo Delgado
2026-09-27 18:11 ` [PATCH v4 2/2] rust: io: convert ResourceSize into a transparent newtype Lorenzo Delgado
2026-10-01 22:15 ` [PATCH v4 0/2] " Danilo Krummrich

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®