Re: [PATCH 2/3] drm/vgem: Enable dmabuf interface for export

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 01, 2016 at 05:56:25PM +0100, Matthew Auld wrote:
> > +static struct sg_table *vgem_prime_get_sg_table(struct drm_gem_object *obj)
> > +{
> > +       long n_pages = obj->size >> PAGE_SHIFT;
> > +       struct sg_table *st;
> > +       struct page **pages;
> > +       int ret;
> > +
> > +       st = kmalloc(sizeof(struct sg_table), GFP_KERNEL);
> > +       if (st == NULL)
> > +               return ERR_PTR(-ENOMEM);
> > +
> > +       pages = drm_gem_get_pages(obj);
> > +       if (IS_ERR(pages)) {
> > +               ret = PTR_ERR(pages);
> > +               goto err;
> > +       }
> > +
> > +       ret = sg_alloc_table_from_pages(st, pages, n_pages,
> > +                                       0, obj->size, GFP_KERNEL);
> > +       drm_gem_put_pages(obj, pages, false, false);
> > +       if (ret)
> > +               goto err;
> > +
> > +       return st;
> > +
> > +err:
> > +       kfree(st);
> > +       return ERR_PTR(ret);
> > +}
> > +
> Couldn't this be written more simply as:
> 
> pages = drm_gem_get_pages(obj);
> if (IS_ERR(pages))
>         return ERR_CAST(pages);
> 
> st = drm_prime_pages_to_sg(pages, n_pages);
> drm_gem_put_pages(obj, pages, false, false);
> 
> return st;

That looks better, thanks.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux