On Wed, 2026-03-11 at 15:52 -0400, Lyude Paul wrote:
- /// Attempt to create a [`RawIoSysMap`] from the gem object.
- fn raw_vmap(&self) -> Result<*mut c_void> {
let mut map: MaybeUninit<bindings::iosys_map> = MaybeUninit::uninit();// SAFETY: drm_gem_shmem_vmap can be called with the DMA reservation lock heldto_result(unsafe {// TODO: see top of filebindings::dma_resv_lock(self.raw_dma_resv(), ptr::null_mut());let ret = bindings::drm_gem_shmem_vmap_locked(self.as_raw_shmem(), map.as_mut_ptr());bindings::dma_resv_unlock(self.raw_dma_resv());ret})?;// SAFETY: The call to drm_gem_shmem_vunmap_locked succeeded above, so we are guaranteed// that map is properly initialized.let map = unsafe { map.assume_init() };// XXX: We don't currently support iomem allocationsif map.is_iomem {// SAFETY:// - The vmap operation above succeeded, making it safe to call vunmap// - We checked that this is an iomem allocation, making it safe to read vaddr_iomemunsafe { self.raw_vunmap(map.__bindgen_anon_1.vaddr_iomem) };Err(ENOTSUPP)} else {// SAFETY: We checked that this is not an iomem allocation, making it safe to read vaddrOk(unsafe { map.__bindgen_anon_1.vaddr })}- }
I am missing a size check here to confirm that SIZE is valid, whoops. Will fix in the next version (though, hopefully that will be the final one)