drm/tyr: clamp va_bits to available bits
Subsystems (4)
PATCH 1/1 drm/tyr: clamp va_bits to available bits
Tyr creates a virtual memory space using the number of bits supported in virtual addresses as reported by the gpu. But the page table mapping operations limit the width of the input virtual addresses to unsigned long. This can result in tyr creating a virtual memory space that is larger than a 32-bit system can support.
Check if the virtual address space bits supported by the gpu are larger than the width of unsigned long, and if so, clamp the virtual address space bits to this smaller size.
This reproduces the clamping that already occurs in panthor_mmu_init().
Signed-off-by Deborah Brouwer <[email protected]>
--- drivers/gpu/drm/tyr/gpu.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/tyr/gpu.rs +10 -1
@@ -36,6 +36,15 @@impl GpuInfo {pub (crate )fn new (io: &IoMem <'_>) ->Self { +let mut mmu_features = io.read (MMU_FEATURES ); + +// In io_pgtable_ops, input virtual addresses can't exceed unsigned long. +// Check that the virtual address bits reported by the gpu are +// architecturally supported and, if not, clamp them to the available bits. +if mmu_features.va_bits ().get () > usize::BITS { + mmu_features = mmu_features.with_const_va_bits ::<{ usize::BITS }>(); + } +Self (uapi::drm_panthor_gpu_info { gpu_id: io.read (GPU_ID ).into_raw (), gpu_rev: io.read (REVIDR ).into_raw (),
@@ -43,7 +52,7 @@ pub(crate) fn new(io: &IoMem<'_>) -> Self { l2_features: io.read(L2_FEATURES).into_raw(), tiler_features: io.read(TILER_FEATURES).into_raw(), mem_features: io.read(MEM_FEATURES).into_raw(), - mmu_features: io.read(MMU_FEATURES).into_raw(), + mmu_features: mmu_features.into_raw(), thread_features: io.read(THREAD_FEATURES).into_raw(), max_threads: io.read(THREAD_MAX_THREADS).into_raw(), thread_max_workgroup_size: io.read(THREAD_MAX_WORKGROUP_SIZE).into_raw(),
---
base-commit: 7402dd230f4497954b465145a22cff7a5a488629
change-id: 20261125-b4-va_bits_clamp-4af5a92c1e68
Best regards,
Signature · 1 line
Deborah Brouwer <[email protected]>
Reviewed-by Daniel Almeida <[email protected]>