[PATCH v2 1/2] drm: call drm_gem_object_funcs.mmap with fake offset

Rob Herring robh at kernel.org
Fri Nov 22 16:33:38 UTC 2019


On Fri, Nov 22, 2019 at 12:37 AM Gerd Hoffmann <kraxel at redhat.com> wrote:
>
> The fake offset is going to stay, so change the calling convention for
> drm_gem_object_funcs.mmap to include the fake offset.  Update all users
> accordingly.
>
> Note that this reverts 83b8a6f242ea ("drm/gem: Fix mmap fake offset
> handling for drm_gem_object_funcs.mmap") and on top then adds the fake
> offset to  drm_gem_prime_mmap to make sure all paths leading to
> obj->funcs->mmap are consistent.

IOW, v1 of my original fix. :) Though you did it a little differently:

> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index 0814211b0f3f..a9633bd241bb 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -714,6 +714,9 @@ int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
>         int ret;
>
>         if (obj->funcs && obj->funcs->mmap) {
> +               /* Add the fake offset */
> +               vma->vm_pgoff += drm_vma_node_start(&obj->vma_node);
> +

Can't this be moved out of the if and then the same thing later down
removed? Unless there's some requirement that drm_vma_node_allow() be
called before drm_vma_node_start() in that case. Doesn't look like it
to me, but I'm not really sure.

>                 ret = obj->funcs->mmap(obj, vma);
>                 if (ret)
>                         return ret;


More information about the dri-devel mailing list