[PATCH 1/2] drm/tyr: get preallocated gpuva before mapping starts

From: Deborah Brouwer

Date: Fri Dec 04 2026 - 18:54:33 EST


Currently, it is possible for a page table mapping to succeed, while the
call to obtain a preallocated gpuva could fail, so that an error is
returned before gpuvm is updated with the new mapping.

Avoid this scenario by obtaining the preallocated gpuva before the page
table is modified.

Signed-off-by: Deborah Brouwer <deborah.brouwer@xxxxxxxxxxxxx>
---
drivers/gpu/drm/tyr/vm.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tyr/vm.rs b/drivers/gpu/drm/tyr/vm.rs
index 323ad647ad19..e80f2cdd0fb5 100644
--- a/drivers/gpu/drm/tyr/vm.rs
+++ b/drivers/gpu/drm/tyr/vm.rs
@@ -659,6 +659,9 @@ fn sm_step_map<'op>(
return Err(EINVAL);
}

+ // Return any error here before modifying the page table.
+ let gpuva = context.preallocated_gpuva()?;
+
let sgt = op.obj().sg_table(context.dev).inspect_err(|e| {
dev_err!(context.dev, "Failed to get sg_table: {:?}", e);
})?;
@@ -729,7 +732,6 @@ fn sm_step_map<'op>(
return Err(EINVAL);
}

- let gpuva = context.preallocated_gpuva()?;
let op = op.insert(gpuva, GpuVaData { prot });

Ok(op)

--
2.56.0