rust: io: convert ResourceSize into a transparent newtype
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected] change-id 20260920-resource-size-newtype-63a82d4f2cdbVersions newest first
- v4 Latest2 patches 1 replyApplied
- v31 patch 2 repliesSuperseded inferred link
- v21 patch 0 repliesSuperseded inferred link
Earlier versions · 1
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v1 | 1 patch | 5 replies | Superseded |
Changes in v4 from the cover letter
- 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/[email protected]
Patches in v4 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | rust: scatterlist: return u32 from SGEntry::dma_len()drivers/ rust/ | +3 | 0 replies | |
| 2/2 | rust: io: convert ResourceSize into a transparent newtyperust/ rust/ | +72 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v4 yet.
Cover letter [PATCH v4 0/2] rust: io: convert ResourceSize into a transparent newtype
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/[email protected]
---
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/[email protected]
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/[email protected]
- Link to v1: https://lore.kernel.org/r/[email protected]
---
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,
Signature · 1 line
Lorenzo Delgado <[email protected]>