[Freedreno] [PATCH libdrm v2 1/2] freedreno: use drmPrime wrappers to import/export prime bo's

Rob Clark robdclark at gmail.com
Wed Aug 26 07:03:39 PDT 2015


On Sun, Aug 23, 2015 at 1:49 PM, Varad Gautam <varadgautam at gmail.com> wrote:
> v2: split to acquire table_lock in a separate commit
>
> Signed-off-by: Varad Gautam <varadgautam at gmail.com>
> ---
>  freedreno/freedreno_bo.c | 26 ++++++++++++++++----------
>  1 file changed, 16 insertions(+), 10 deletions(-)
>
> diff --git a/freedreno/freedreno_bo.c b/freedreno/freedreno_bo.c
> index 596bfbc..0d2847f 100644
> --- a/freedreno/freedreno_bo.c
> +++ b/freedreno/freedreno_bo.c
> @@ -230,18 +230,25 @@ fd_bo_from_dmabuf(struct fd_device *dev, int fd)
>                         .fd = fd,
>         };
>         int ret, size;
> +       uint32_t handle;
>         struct fd_bo *bo;
>
> -       ret = drmIoctl(dev->fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &req);
> +       ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
> +
>         if (ret) {
> -               return NULL;
> +               bo = NULL;
> +               goto out_unlock;
>         }
>
> +       bo = lookup_bo(dev->handle_table, handle);
> +       if (bo)
> +               return bo;
> +
>         /* lseek() to get bo size */
>         size = lseek(fd, 0, SEEK_END);
>         lseek(fd, 0, SEEK_CUR);
>
> -       bo = fd_bo_from_handle(dev, req.handle, size);
> +       bo = bo_from_handle(dev, size, handle);

oh, I was intending for the inlining of fd_bo_from_handle() to be part
of the 2nd patch (since that is related to the locking change).. so
first patch should just be the replacing drmIoctl() with drmPrime*()
part.

Also, somehow patch is ending up utf8 encoded.. and I don't have
patchwork setup for freedreno list (I guess I should figure out who to
ask about that).  I don't suppose you could just send the updated
patches to me as an attachment (or push to branch on your github tree
where I can cherry-pick them from)?

BR,
-R

>         bo->fd = fd;
>
>         return bo;
> @@ -381,19 +388,18 @@ uint32_t fd_bo_handle(struct fd_bo *bo)
>  int fd_bo_dmabuf(struct fd_bo *bo)
>  {
>         if (bo->fd < 0) {
> -               struct drm_prime_handle req = {
> -                               .handle = bo->handle,
> -                               .flags = DRM_CLOEXEC,
> -               };
> -               int ret;
> +               int ret, prime_fd;
> +
> +               ret = drmPrimeHandleToFD(bo->dev->fd, bo->handle, DRM_CLOEXEC,
> +                                        &prime_fd);
>
> -               ret = drmIoctl(bo->dev->fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &req);
>                 if (ret) {
>                         return ret;
>                 }
>
> -               bo->fd = req.fd;
> +               bo->fd = prime_fd;
>         }
> +
>         return dup(bo->fd);
>  }
>
> --
> 2.4.6
>
> _______________________________________________
> Freedreno mailing list
> Freedreno at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/freedreno


More information about the Freedreno mailing list