Hi, On 1/10/25 00:45, Sasha Finkelstein via B4 Relay wrote: > From: Sasha Finkelstein <fnkl.kernel@xxxxxxxxx> > > Those are useful to implement coherent cross-vm mmap. > > Signed-off-by: Sasha Finkelstein <fnkl.kernel@xxxxxxxxx> > --- > drivers/gpu/drm/virtio/virtgpu_vram.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/virtio/virtgpu_vram.c b/drivers/gpu/drm/virtio/virtgpu_vram.c > index 25df81c027837c248a746e41856b5aa7e216b8d5..64e2c6dbdd678ac4c0da89fdd4c9dbf937c2c335 100644 > --- a/drivers/gpu/drm/virtio/virtgpu_vram.c > +++ b/drivers/gpu/drm/virtio/virtgpu_vram.c > @@ -56,12 +56,11 @@ static int virtio_gpu_vram_mmap(struct drm_gem_object *obj, > else if (vram->map_info == VIRTIO_GPU_MAP_CACHE_UNCACHED) > vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); > > - /* Partial mappings of GEM buffers don't happen much in practice. */ > - if (vm_size != vram->vram_node.size) > + if (vm_size > vram->vram_node.size) > return -EINVAL; > > ret = io_remap_pfn_range(vma, vma->vm_start, > - vram->vram_node.start >> PAGE_SHIFT, > + (vram->vram_node.start >> PAGE_SHIFT) + vma->vm_pgoff, > vm_size, vma->vm_page_prot); > return ret; > } The vma->vm_pgoff is fake in DRM, it's used for looking up DRM GEM object based on the vma->vm_pgoff value when mmap is invoked. The vma->vm_pgoff should be treated as zero here. Hence we can map a part of GEM, but only from its start. See drm_gem_mmap(). BTW, partial mapping is wanted by Intel native context that I work on. The intent of this patch is correct. There are practical uses for partial mappings. Please correct vma->vm_pgoff in v2. -- Best regards, Dmitry