[Intel-gfx] [PATCH v9 11/70] drm/i915: Disable userptr pread/pwrite support.

Jason Ekstrand jason at jlekstrand.net
Wed Mar 24 13:57:55 UTC 2021


Never used by Mesa AFAIK

Acked-by: Jason Ekstrand <jason at jlekstrand.net>

On Tue, Mar 23, 2021 at 10:51 AM Maarten Lankhorst
<maarten.lankhorst at linux.intel.com> wrote:
>
> Userptr should not need the kernel for a userspace memcpy, userspace
> needs to call memcpy directly.
>
> Specifically, disable i915_gem_pwrite_ioctl() and i915_gem_pread_ioctl().
>
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
> Reviewed-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
>
> -- Still needs an ack from relevant userspace that it won't break, but should be good.
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 20 ++++++++++++++++++++
>  drivers/gpu/drm/i915/i915_gem.c             |  5 +++++
>  2 files changed, 25 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> index 0f9024c62c06..5a19699c2d7e 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
> @@ -700,6 +700,24 @@ i915_gem_userptr_dmabuf_export(struct drm_i915_gem_object *obj)
>         return i915_gem_userptr_init__mmu_notifier(obj, 0);
>  }
>
> +static int
> +i915_gem_userptr_pwrite(struct drm_i915_gem_object *obj,
> +                       const struct drm_i915_gem_pwrite *args)
> +{
> +       drm_dbg(obj->base.dev, "pwrite to userptr no longer allowed\n");
> +
> +       return -EINVAL;
> +}
> +
> +static int
> +i915_gem_userptr_pread(struct drm_i915_gem_object *obj,
> +                      const struct drm_i915_gem_pread *args)
> +{
> +       drm_dbg(obj->base.dev, "pread from userptr no longer allowed\n");
> +
> +       return -EINVAL;
> +}
> +
>  static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = {
>         .name = "i915_gem_object_userptr",
>         .flags = I915_GEM_OBJECT_IS_SHRINKABLE |
> @@ -708,6 +726,8 @@ static const struct drm_i915_gem_object_ops i915_gem_userptr_ops = {
>         .get_pages = i915_gem_userptr_get_pages,
>         .put_pages = i915_gem_userptr_put_pages,
>         .dmabuf_export = i915_gem_userptr_dmabuf_export,
> +       .pwrite = i915_gem_userptr_pwrite,
> +       .pread = i915_gem_userptr_pread,
>         .release = i915_gem_userptr_release,
>  };
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 25444d360f7f..dde12ce4f90b 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -403,6 +403,11 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
>         }
>
>         trace_i915_gem_object_pread(obj, args->offset, args->size);
> +       ret = -ENODEV;
> +       if (obj->ops->pread)
> +               ret = obj->ops->pread(obj, args);
> +       if (ret != -ENODEV)
> +               goto out;
>
>         ret = -ENODEV;
>         if (obj->ops->pread)
> --
> 2.31.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx


More information about the dri-devel mailing list