* [PATCH 0/4] drm/tyr: fix partial 2MB block unmaps on GPUVM remap
@ 2026-11-17 19:32 Alice Ryhl
2026-11-17 19:32 ` [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor Alice Ryhl
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Alice Ryhl @ 2026-11-17 19:32 UTC (permalink / raw)
To: Daniel Almeida, Deborah Brouwer, Sami Tolvanen
Cc: Danilo Krummrich, Matthew Brost, Thomas Hellström,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Boris Brezillon, dri-devel,
rust-for-linux, linux-kernel, iommu, Alice Ryhl
Tyr configures its ARM64 LPAE page tables with 4KB and 2MB block sizes,
but arm-lpae rejects unmapping part of a 2MB block. As a result, a
partial unmap or overlapping remap that splits a 2MB block in
GpuVmData::sm_step_remap() fails in __arm_lpae_unmap().
This series ports the remap fix and supporting accessors from tyr-dev
onto drm-rust-next, along with a defensive bounds check in pt_unmap():
1. Add the GpuVa::data_ref() accessor.
2. Add the IoPageTable::iova_to_phys() accessor.
3. Expand sub-block unmaps in sm_step_remap() to 2MB boundaries when
the swept head/tail fragment is physically contiguous, widen the AS
lock over the expanded range, rebuild the surviving fragments, and
take the preallocated GPUVAs before mutating page tables.
4. Check the remaining-length subtraction in pt_unmap() against
underflow.
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Sami Tolvanen (4):
rust: drm/gpuvm: add GpuVa::data_ref accessor
rust: iommu: pgtable: add iova_to_phys
drm/tyr: vm: expand sub-block unmaps to 2MB boundaries on remap
drm/tyr: vm: check the remaining length in pt_unmap()
drivers/gpu/drm/tyr/mmu.rs | 13 +++
drivers/gpu/drm/tyr/mmu/address_space.rs | 29 ++++++
drivers/gpu/drm/tyr/vm.rs | 152 ++++++++++++++++++++++++++++---
rust/kernel/drm/gpuvm/va.rs | 6 ++
rust/kernel/iommu/pgtable.rs | 23 +++++
5 files changed, 209 insertions(+), 14 deletions(-)
---
base-commit: 8045d0e7d208ad389a387f1407ce0db9070805af
change-id: 20261116-tyr-remap-2mb-7a53b8475cfc
Best regards,
--
Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor
2026-11-17 19:32 [PATCH 0/4] drm/tyr: fix partial 2MB block unmaps on GPUVM remap Alice Ryhl
@ 2026-11-17 19:32 ` Alice Ryhl
2026-11-17 19:40 ` Danilo Krummrich
2026-11-17 19:32 ` [PATCH 2/4] rust: iommu: pgtable: add iova_to_phys Alice Ryhl
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Alice Ryhl @ 2026-11-17 19:32 UTC (permalink / raw)
To: Daniel Almeida, Deborah Brouwer, Sami Tolvanen
Cc: Danilo Krummrich, Matthew Brost, Thomas Hellström,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Boris Brezillon, dri-devel,
rust-for-linux, linux-kernel, iommu, Alice Ryhl
From: Sami Tolvanen <samitolvanen@google.com>
Tyr's VM_BIND remap path rebuilds page-table mappings for the fragments
that survive a split, and those fragments must keep the protection flags
of the original mapping. Add GpuVa::data_ref() so the remap step can
read the VaData of an existing mapping.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
[aliceryhl: split into separate gpuvm and iommu commits]
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
rust/kernel/drm/gpuvm/va.rs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/rust/kernel/drm/gpuvm/va.rs b/rust/kernel/drm/gpuvm/va.rs
index 46493f0ec5a6..f81302faba61 100644
--- a/rust/kernel/drm/gpuvm/va.rs
+++ b/rust/kernel/drm/gpuvm/va.rs
@@ -87,6 +87,12 @@ pub fn obj(&self) -> &T::Object {
unsafe { <T::Object as IntoGEMObject>::from_raw((*self.as_raw()).gem.obj) }
}
+ /// Access the driver-private [`VaData`](DriverGpuVm::VaData) associated with this mapping.
+ #[inline]
+ pub fn data_ref(&self) -> &T::VaData {
+ &self.data
+ }
+
/// Returns the underlying [`GpuVmBo`] object that backs this [`GpuVa`].
#[inline]
pub fn vm_bo(&self) -> &GpuVmBo<T> {
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] rust: iommu: pgtable: add iova_to_phys
2026-11-17 19:32 [PATCH 0/4] drm/tyr: fix partial 2MB block unmaps on GPUVM remap Alice Ryhl
2026-11-17 19:32 ` [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor Alice Ryhl
@ 2026-11-17 19:32 ` Alice Ryhl
2026-11-17 19:32 ` [PATCH 3/4] drm/tyr: vm: expand sub-block unmaps to 2MB boundaries on remap Alice Ryhl
2026-11-17 19:32 ` [PATCH 4/4] drm/tyr: vm: check the remaining length in pt_unmap() Alice Ryhl
3 siblings, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2026-11-17 19:32 UTC (permalink / raw)
To: Daniel Almeida, Deborah Brouwer, Sami Tolvanen
Cc: Danilo Krummrich, Matthew Brost, Thomas Hellström,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Boris Brezillon, dri-devel,
rust-for-linux, linux-kernel, iommu, Alice Ryhl
From: Sami Tolvanen <samitolvanen@google.com>
Tyr's VM_BIND remap path rebuilds the page-table mappings that a partial
unmap sweeps away, recovering their backing from the still-present
entries. Add IoPageTable::iova_to_phys(), which returns the physical
address that an iova maps to.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
[aliceryhl: split into separate gpuvm and iommu commits]
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
rust/kernel/iommu/pgtable.rs | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/rust/kernel/iommu/pgtable.rs b/rust/kernel/iommu/pgtable.rs
index 5f9b42ca92c2..306c03862a72 100644
--- a/rust/kernel/iommu/pgtable.rs
+++ b/rust/kernel/iommu/pgtable.rs
@@ -199,6 +199,29 @@ pub unsafe fn unmap_pages(&self, iova: usize, pgsize: usize, pgcount: usize) ->
// SAFETY: The safety requirements of this method are sufficient to call `unmap_pages`.
unsafe { (unmap_pages)(self.raw_ops(), iova, pgsize, pgcount, core::ptr::null_mut()) }
}
+
+ /// Translate an `iova` to the physical address it maps to.
+ ///
+ /// Returns [`None`] if `iova` is not mapped. As in the underlying C op, a mapping to physical
+ /// address 0 is indistinguishable from unmapped and also reports [`None`]. The returned address
+ /// includes the offset of `iova` within the mapping block, so it is exact for any `iova`, not
+ /// just block-aligned ones. This walk is lock-free and does not allocate.
+ ///
+ /// # Safety
+ ///
+ /// No other io-pgtable operation may modify the entry covering `iova` while this walk
+ /// executes.
+ #[inline]
+ pub unsafe fn iova_to_phys(&self, iova: usize) -> Option<PhysAddr> {
+ // SAFETY: The `iova_to_phys` function in `io_pgtable_ops` is never null.
+ let iova_to_phys = unsafe { (*self.raw_ops()).iova_to_phys.unwrap_unchecked() };
+
+ // SAFETY: The safety requirements of this method are sufficient to call `iova_to_phys`.
+ let paddr = unsafe { (iova_to_phys)(self.raw_ops(), iova) };
+
+ // A zero return means `iova` is not mapped.
+ (paddr != 0).then_some(paddr)
+ }
}
// For the initial users of these rust bindings, the GPU FW is managing the IOTLB and performs all
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] drm/tyr: vm: expand sub-block unmaps to 2MB boundaries on remap
2026-11-17 19:32 [PATCH 0/4] drm/tyr: fix partial 2MB block unmaps on GPUVM remap Alice Ryhl
2026-11-17 19:32 ` [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor Alice Ryhl
2026-11-17 19:32 ` [PATCH 2/4] rust: iommu: pgtable: add iova_to_phys Alice Ryhl
@ 2026-11-17 19:32 ` Alice Ryhl
2026-11-17 19:32 ` [PATCH 4/4] drm/tyr: vm: check the remaining length in pt_unmap() Alice Ryhl
3 siblings, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2026-11-17 19:32 UTC (permalink / raw)
To: Daniel Almeida, Deborah Brouwer, Sami Tolvanen
Cc: Danilo Krummrich, Matthew Brost, Thomas Hellström,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Boris Brezillon, dri-devel,
rust-for-linux, linux-kernel, iommu, Alice Ryhl
From: Sami Tolvanen <samitolvanen@google.com>
Backing GEM shmem with transparent huge pages lets Tyr install 2MB block
entries. arm-lpae refuses to unmap part of a block, so a sparse partial
rebind that splits one in sm_step_remap fails the VM_BIND and poisons
the VM.
Grow such an unmap to the block boundary and rebuild the surviving
fragment, expanding only when contiguous.
Fixes: f2dc32d5a133 ("drm/tyr: add GPU virtual memory (VM) support")
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
[aliceryhl: tweaks for drm-rust-next and use safe casts instead of 'as']
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
drivers/gpu/drm/tyr/mmu.rs | 13 +++
drivers/gpu/drm/tyr/mmu/address_space.rs | 29 ++++++
drivers/gpu/drm/tyr/vm.rs | 146 ++++++++++++++++++++++++++++---
3 files changed, 176 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/tyr/mmu.rs b/drivers/gpu/drm/tyr/mmu.rs
index 5e88c9e6a4cd..99739a3a8aa1 100644
--- a/drivers/gpu/drm/tyr/mmu.rs
+++ b/drivers/gpu/drm/tyr/mmu.rs
@@ -109,6 +109,19 @@ pub(crate) fn start_vm_update(
self.as_manager.lock().start_vm_update(vm_as_data, region)
}
+ /// Widens the active lock to cover a larger region.
+ ///
+ /// `region` must contain the currently locked range so the GPU stays
+ /// stalled over it while the update completes. If the region is empty or
+ /// the VM is not resident, this is a NOP.
+ pub(crate) fn extend_vm_update(
+ &self,
+ vm_as_data: &VmAsData<'drm>,
+ region: &Range<u64>,
+ ) -> Result {
+ self.as_manager.lock().extend_vm_update(vm_as_data, region)
+ }
+
/// Flags the end of a VM update.
///
/// If the VM is resident, this will let GPU accesses on the updated
diff --git a/drivers/gpu/drm/tyr/mmu/address_space.rs b/drivers/gpu/drm/tyr/mmu/address_space.rs
index 76e3d2df6afd..666af82a37b7 100644
--- a/drivers/gpu/drm/tyr/mmu/address_space.rs
+++ b/drivers/gpu/drm/tyr/mmu/address_space.rs
@@ -475,6 +475,35 @@ pub(super) fn start_vm_update(
}
}
+ /// Widens the active lock to cover a larger region.
+ ///
+ /// Re-issues the LOCKADDR and Lock command over `region`, which the
+ /// caller has computed as the union of the currently locked region and
+ /// the wider range it is about to rebuild. The hardware lock is replaced
+ /// in place, so `region` must contain the previously locked range to keep
+ /// the GPU stalled over it.
+ ///
+ /// If the region is empty or the VM is not resident in a hardware slot,
+ /// this is a no-op.
+ pub(super) fn extend_vm_update(
+ &mut self,
+ vm_as_data: &VmAsData<'drm>,
+ region: &Range<u64>,
+ ) -> Result {
+ if region.is_empty() {
+ return Ok(());
+ }
+
+ let seat = vm_as_data.as_seat.access(self);
+ match seat.slot() {
+ Some(slot) => {
+ let as_nr = usize::from(slot);
+ self.as_start_update(as_nr, region)
+ }
+ _ => Ok(()),
+ }
+ }
+
/// Completes translation table updates and unlocks the region.
pub(super) fn end_vm_update(&mut self, vm_as_data: &VmAsData<'drm>) -> Result {
let seat = vm_as_data.as_seat.access(self);
diff --git a/drivers/gpu/drm/tyr/vm.rs b/drivers/gpu/drm/tyr/vm.rs
index 1dd11b2b1253..bcc864b17428 100644
--- a/drivers/gpu/drm/tyr/vm.rs
+++ b/drivers/gpu/drm/tyr/vm.rs
@@ -42,7 +42,12 @@
},
new_mutex,
prelude::*,
+ ptr::{
+ Alignable,
+ Alignment, //
+ },
sizes::{
+ SizeConstants,
SZ_1G,
SZ_2M,
SZ_4K, //
@@ -290,6 +295,22 @@ fn return_preallocated_gpuva(&mut self, gpuva: GpuVaAlloc<GpuVmData<'drm>>) {
*slot = Some(gpuva);
}
}
+
+ /// Widens the AS lock to also cover `region`.
+ ///
+ /// A remap can rebuild fragments beyond the originally locked request,
+ /// so the lock is grown to the union of the two before those fragments
+ /// are torn down. The locked region only ever grows, so several remaps
+ /// in one unmap union onto a single widening lock.
+ fn extend_lock(&mut self, region: Range<u64>) -> Result {
+ let union =
+ u64::min(self.region.start, region.start)..u64::max(self.region.end, region.end);
+ if union != self.region {
+ self.mmu.extend_vm_update(self.as_data, &union)?;
+ self.region = union;
+ }
+ Ok(())
+ }
}
impl Drop for PtUpdateContext<'_, '_> {
@@ -312,6 +333,16 @@ pub(crate) struct GpuVmData<'drm> {
_phantom: PhantomData<&'drm ()>,
}
+/// Per-mapping private data stored on each `GpuVa`.
+///
+/// A remap splits an existing mapping and may have to rebuild page-table
+/// entries for the surviving fragments. Those fragments keep the protection
+/// of the original mapping, so the protection flags are recorded here.
+pub(crate) struct GpuVaData {
+ /// Memory protection flags of this mapping, as passed to `pt_map`.
+ prot: u32,
+}
+
/// GPU virtual address space.
///
/// Each VM can be mapped into a hardware address space slot.
@@ -599,7 +630,7 @@ impl<'drm> DriverGpuVm for GpuVmData<'drm> {
type Driver = TyrDrmDriver;
type Object = Bo;
type VmBoData = ();
- type VaData = ();
+ type VaData = GpuVaData;
type SmContext<'ctx>
= PtUpdateContext<'ctx, 'drm>
where
@@ -701,7 +732,7 @@ fn sm_step_map<'op>(
}
let gpuva = context.preallocated_gpuva()?;
- let op = op.insert(gpuva, pin_init::init_zeroed());
+ let op = op.insert(gpuva, GpuVaData { prot });
Ok(op)
}
@@ -749,10 +780,50 @@ fn sm_step_remap<'op>(
op.va_to_unmap().addr() + op.va_to_unmap().length()
};
- let unmap_length = unmap_end - unmap_start;
+ // The surviving fragments inherit the protection of the mapping being
+ // split.
+ let prot = op.va_to_unmap().data_ref().prot;
+
+ let block = Alignment::SZ_2M;
+ let aligned_start = unmap_start.align_down(block);
+ let aligned_end = unmap_end.align_up(block).ok_or(EINVAL)?;
+
+ // An end may only be expanded if the fragment the expansion sweeps and
+ // rebuilds is fully mapped and physically contiguous, because the
+ // rebuild maps it linearly from a single recovered address. A genuine
+ // 2MB block is always contiguous, so this never misses one and the
+ // partial-block unmap can never reach arm-lpae. A fragmented region is
+ // never expanded, so its sub-range unmap stays correct.
+ let head_paddr = match op.prev() {
+ Some(prev) if aligned_start < unmap_start && prev.addr() <= aligned_start => {
+ contiguous_phys(context.pt, aligned_start..unmap_start)
+ }
+ _ => None,
+ };
+ let tail_paddr = match op.next() {
+ Some(next) if aligned_end > unmap_end && next.addr() + next.length() >= aligned_end => {
+ contiguous_phys(context.pt, unmap_end..aligned_end)
+ }
+ _ => None,
+ };
+
+ let region_start = if head_paddr.is_some() {
+ aligned_start
+ } else {
+ unmap_start
+ };
+ let region_end = if tail_paddr.is_some() {
+ aligned_end
+ } else {
+ unmap_end
+ };
+
+ let prev_va = context.preallocated_gpuva()?;
+ let next_va = context.preallocated_gpuva()?;
- if unmap_length > 0 {
- let region = unmap_start..(unmap_start + unmap_length);
+ if region_end > region_start {
+ let region = region_start..region_end;
+ context.extend_lock(region.clone())?;
pt_unmap(context.dev, context.pt, region.clone()).inspect_err(|e| {
dev_err!(
context.dev,
@@ -764,14 +835,29 @@ fn sm_step_remap<'op>(
})?;
}
- let prev_va = context.preallocated_gpuva()?;
- let next_va = context.preallocated_gpuva()?;
+ if let Some(head_paddr) = head_paddr {
+ pt_map(
+ context.dev,
+ context.pt,
+ aligned_start,
+ head_paddr,
+ unmap_start - aligned_start,
+ prot,
+ )?;
+ }
+ if let Some(tail_paddr) = tail_paddr {
+ pt_map(
+ context.dev,
+ context.pt,
+ unmap_end,
+ tail_paddr,
+ aligned_end - unmap_end,
+ prot,
+ )?;
+ }
- let (op_remapped, remap_ret) = op.remap(
- [prev_va, next_va],
- pin_init::init_zeroed(),
- pin_init::init_zeroed(),
- );
+ let (op_remapped, remap_ret) =
+ op.remap([prev_va, next_va], GpuVaData { prot }, GpuVaData { prot });
if let Some(unused_va) = remap_ret.unused_va {
context.return_preallocated_gpuva(unused_va);
@@ -781,6 +867,42 @@ fn sm_step_remap<'op>(
}
}
+/// Returns the base physical address of `range` if every 4KB page in it is
+/// mapped and the whole range is physically contiguous, otherwise `None`.
+///
+/// `range` is a sub-block fragment, so its length is below 2MB and the walk
+/// visits at most 511 pages.
+fn contiguous_phys(pt: &IoPageTable<'_, ARM64LPAES1>, range: Range<u64>) -> Option<u64> {
+ let start_usize = usize::try_from(range.start).ok()?;
+
+ // SAFETY: The page table is exclusively accessed through the
+ // `&mut UniqueRefGpuVm` held under the `gpuvm_unique` mutex for the duration of
+ // the VM update, so no other io-pgtable operation runs concurrently.
+ let base = unsafe { pt.iova_to_phys(start_usize) }?;
+ // Expressly convert to u64 to work with arm 32-bit builds.
+ #[allow(clippy::useless_conversion)]
+ let base = u64::from(base);
+
+ let mut iova = range.start + u64::SZ_4K;
+ while iova < range.end {
+ let offset = iova - range.start;
+ let iova_usize = usize::try_from(iova).ok()?;
+ // SAFETY: The page table is exclusively accessed through the
+ // `&mut UniqueRefGpuVm` held under the `gpuvm_unique` mutex, so no
+ // concurrent io-pgtable operation runs.
+ let paddr = unsafe { pt.iova_to_phys(iova_usize) }?;
+ // Expressly convert to u64 to work with arm 32-bit builds.
+ #[allow(clippy::useless_conversion)]
+ let paddr = u64::from(paddr);
+ if paddr != base + offset {
+ return None;
+ }
+ iova += u64::SZ_4K;
+ }
+
+ Some(base)
+}
+
/// This function selects the largest supported block size (currently 4KB or 2MB)
/// that can be used for a mapping at the given address and size, respecting alignment constraints.
///
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] drm/tyr: vm: check the remaining length in pt_unmap()
2026-11-17 19:32 [PATCH 0/4] drm/tyr: fix partial 2MB block unmaps on GPUVM remap Alice Ryhl
` (2 preceding siblings ...)
2026-11-17 19:32 ` [PATCH 3/4] drm/tyr: vm: expand sub-block unmaps to 2MB boundaries on remap Alice Ryhl
@ 2026-11-17 19:32 ` Alice Ryhl
3 siblings, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2026-11-17 19:32 UTC (permalink / raw)
To: Daniel Almeida, Deborah Brouwer, Sami Tolvanen
Cc: Danilo Krummrich, Matthew Brost, Thomas Hellström,
Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Trevor Gross, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, Joerg Roedel (AMD),
Will Deacon, Robin Murphy, Boris Brezillon, dri-devel,
rust-for-linux, linux-kernel, iommu, Alice Ryhl
From: Sami Tolvanen <samitolvanen@google.com>
pt_unmap() subtracts each unmapped chunk from the remaining length and
relies on unmap_pages() never unmapping more than it was asked to.
Check this subtraction and fail with EINVAL on underflow.
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
[aliceryhl: use safe casts instead of 'as']
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
drivers/gpu/drm/tyr/vm.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tyr/vm.rs b/drivers/gpu/drm/tyr/vm.rs
index bcc864b17428..acbca552d133 100644
--- a/drivers/gpu/drm/tyr/vm.rs
+++ b/drivers/gpu/drm/tyr/vm.rs
@@ -41,6 +41,7 @@
ARM64LPAES1, //
},
new_mutex,
+ num::casts::FromSafeCast,
prelude::*,
ptr::{
Alignable,
@@ -1063,8 +1064,9 @@ fn pt_unmap(dev: &Device, pt: &IoPageTable<'_, ARM64LPAES1>, range: Range<u64>)
return Err(EINVAL);
}
- bytes_left_to_unmap -= unmapped as u64;
- iova += unmapped as u64;
+ let unmapped = u64::from_safe_cast(unmapped);
+ bytes_left_to_unmap = bytes_left_to_unmap.checked_sub(unmapped).ok_or(EINVAL)?;
+ iova += unmapped;
}
Ok(())
--
2.56.1.703.gf848ed807c-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor
2026-11-17 19:32 ` [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor Alice Ryhl
@ 2026-11-17 19:40 ` Danilo Krummrich
0 siblings, 0 replies; 6+ messages in thread
From: Danilo Krummrich @ 2026-11-17 19:40 UTC (permalink / raw)
To: Alice Ryhl
Cc: Daniel Almeida, Deborah Brouwer, Sami Tolvanen, Matthew Brost,
Thomas Hellström, Miguel Ojeda, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, Joerg Roedel (AMD), Will Deacon, Robin Murphy,
Boris Brezillon, dri-devel, rust-for-linux, linux-kernel, iommu
On 11/17/26 8:32 PM, Alice Ryhl wrote:
> From: Sami Tolvanen <samitolvanen@google.com>
>
> Tyr's VM_BIND remap path rebuilds page-table mappings for the fragments
> that survive a split, and those fragments must keep the protection flags
> of the original mapping. Add GpuVa::data_ref() so the remap step can
> read the VaData of an existing mapping.
>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> [aliceryhl: split into separate gpuvm and iommu commits]
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
One question below, otherwise:
Acked-by: Danilo Krummrich <dakr@kernel.org>
> ---
> rust/kernel/drm/gpuvm/va.rs | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/rust/kernel/drm/gpuvm/va.rs b/rust/kernel/drm/gpuvm/va.rs
> index 46493f0ec5a6..f81302faba61 100644
> --- a/rust/kernel/drm/gpuvm/va.rs
> +++ b/rust/kernel/drm/gpuvm/va.rs
> @@ -87,6 +87,12 @@ pub fn obj(&self) -> &T::Object {
> unsafe { <T::Object as IntoGEMObject>::from_raw((*self.as_raw()).gem.obj) }
> }
>
> + /// Access the driver-private [`VaData`](DriverGpuVm::VaData) associated with this mapping.
> + #[inline]
> + pub fn data_ref(&self) -> &T::VaData {
> + &self.data
> + }
> +
Why data_ref() instead of just data() or a Deref impl?
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-17 19:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 19:32 [PATCH 0/4] drm/tyr: fix partial 2MB block unmaps on GPUVM remap Alice Ryhl
2026-11-17 19:32 ` [PATCH 1/4] rust: drm/gpuvm: add GpuVa::data_ref accessor Alice Ryhl
2026-11-17 19:40 ` Danilo Krummrich
2026-11-17 19:32 ` [PATCH 2/4] rust: iommu: pgtable: add iova_to_phys Alice Ryhl
2026-11-17 19:32 ` [PATCH 3/4] drm/tyr: vm: expand sub-block unmaps to 2MB boundaries on remap Alice Ryhl
2026-11-17 19:32 ` [PATCH 4/4] drm/tyr: vm: check the remaining length in pt_unmap() Alice Ryhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox