On Thu, 17 Apr 2025 14:10:31 +0200 Boris Brezillon <boris.brezil...@collabora.com> wrote:
> > I can't help feeling we can just simplify this to: > > > > u64 mmio_offset = pfile->user_mmio.offset; > > > > if (offset >= mmio_offset) { > > offset -= mmio_offset; > > offset += DRM_PANTHOR_USER_MMIO_OFFSET; > > vma->vm_pgoff = offset >> PAGE_SHIFT; > > > > ret = panthor_device_mmap_io(ptdev, vma); > > } else { > > ret = drm_gem_mmap(filp, vma); > > } > > > > Or even go further and push the offset calculations into > > panthor_device_mmap_io(). > > Sure, I can do that. Actually, if I drop the lock in favor of a u64 mmio_offset = READ_ONCE(pfile->user_mmio.offset); I can't move the vm_pgoff/offset adjustement to panthor_device_mmap_io() because userspace might have called SET_MMIO_OFFSET in the meantime, thus changing the final offset. One option would be to pass the mmio_offset to panthor_device_mmap_io(), but I think I prefer keeping the offset adjustment here if you don't mind.