drm/udl: handle page mapping in dmabuf export.
Subsystems (3)
PATCH 1/2 drm/udl: handle page mapping in dmabuf export.
Fixes dmabuf export failure with -E_NOMEM when the page is not mapped.
Signed-off-by Haixia Shi <[email protected]>
Reviewed-by Stéphane Marchesin <[email protected]>
--- drivers/gpu/drm/udl/udl_dmabuf.c | 7 +++++-- drivers/gpu/drm/udl/udl_drv.h | 2 ++ drivers/gpu/drm/udl/udl_gem.c | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/udl/udl_dmabuf.c +5 -2
@@ -90,8 +90,11 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach,return &udl_attach->sgt;if (!obj->pages) { -DRM_ERROR ("pages is null.\n" ); -return ERR_PTR (-ENOMEM ); + ret =udl_gem_get_pages (obj); +if (ret) { +DRM_ERROR ("failed to map pages.\n" ); +return ERR_PTR (ret); + } } page_count = obj->base.size /PAGE_SIZE ;
drivers/gpu/drm/udl/udl_drv.h +2 -0
@@ -129,6 +129,8 @@ struct dma_buf *udl_gem_prime_export(struct drm_device *dev,struct drm_gem_object *udl_gem_prime_import (struct drm_device *dev,struct dma_buf *dma_buf); +int udl_gem_get_pages (struct udl_gem_object *obj); +void udl_gem_put_pages (struct udl_gem_object *obj);int udl_gem_vmap (struct udl_gem_object *obj);void udl_gem_vunmap (struct udl_gem_object *obj);int udl_drm_gem_mmap (struct file *filp,struct vm_area_struct *vma);
drivers/gpu/drm/udl/udl_gem.c +2 -2
@@ -127,7 +127,7 @@ int udl_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) } } -static int udl_gem_get_pages (struct udl_gem_object *obj) +int udl_gem_get_pages (struct udl_gem_object *obj) {struct page **pages;
@@ -143,7 +143,7 @@ static int udl_gem_get_pages(struct udl_gem_object *obj)return 0 ; } -static void udl_gem_put_pages (struct udl_gem_object *obj) +void udl_gem_put_pages (struct udl_gem_object *obj) {if (obj->base.import_attach) {drm_free_large (obj->pages);
Signature · 6 lines
2.2.0.rc0.207.ga3a616c _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/udl: properly check for error pointers
The drm_prime_pages_to_sg() function never returns NULL pointers, only error pointers and valid pointers.
Signed-off-by Haixia Shi <[email protected]>
Reviewed-by Stéphane Marchesin <[email protected]>
--- drivers/gpu/drm/udl/udl_dmabuf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/udl/udl_dmabuf.c +3 -3
@@ -99,9 +99,9 @@ static struct sg_table *udl_map_dma_buf(struct dma_buf_attachment *attach, page_count = obj->base.size /PAGE_SIZE ; obj->sg =drm_prime_pages_to_sg (obj->pages, page_count); -if (!obj->sg) { -DRM_ERROR ("sg is null.\n" ); -return ERR_PTR (-ENOMEM ); +if (IS_ERR (obj->sg)) { +DRM_ERROR ("failed to allocate sgt.\n" ); +return ERR_CAST (obj->sg); } sgt = &udl_attach->sgt;
Signature · 6 lines
2.2.0.rc0.207.ga3a616c _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel