On Wed, Oct 10, 2018 at 09:14:50PM +0200, Noralf Trønnes wrote: > Den 01.10.2018 09.46, skrev Daniel Vetter: > > On Wed, Sep 26, 2018 at 04:59:32PM +0200, Noralf Trønnes wrote: > > > +int drm_gem_shmem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma) > > > +{ > > > + struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); > > > + int ret; > > > + > > > + ret = drm_gem_mmap_obj(obj, obj->size, vma); > > > + if (ret) > > > + return ret; > > > + > > > + return drm_gem_shmem_mmap_obj(shmem, vma); > > > +} > > If we'd use the gem vma offset manager and adjust offsets and then call > > into the gem mmap stuff I think we could make this 100% generic. That > > would also avoid the need to add the gem_ops->prime_mmap callback, since > > we'll have a default that should work for everyone. > > Is this what you had in mind? > > int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct > *vma) > { > /* Used by drm_gem_mmap() to lookup the GEM object */ > struct drm_file priv = { > .minor = obj->dev->primary, > }; > struct file fil = { > .private_data = &priv, > }; > int ret; > > ret = drm_vma_node_allow(&obj->vma_node, &priv); > if (ret) > return ret; > > vma->vm_pgoff += drm_vma_node_start(&obj->vma_node); Yup, this offset adjusting is what I had in mind. -Daniel > ret = obj->dev->driver->fops->mmap(&fil, vma); > > drm_vma_node_revoke(&obj->vma_node, &priv); > > return ret; > } -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel