Skip to content

Commit

Permalink
drm/udl: handle page mapping in dmabuf export.
Browse files Browse the repository at this point in the history
Fixes dmabuf export failure with -E_NOMEM when the page is not mapped.

Signed-off-by: Haixia Shi <hshi@chromium.org>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
  • Loading branch information
Haixia Shi authored and Dave Airlie committed Nov 26, 2014
1 parent 0a3d775 commit 4bc158e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions drivers/gpu/drm/udl/udl_dmabuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/drm/udl/udl_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/udl/udl_gem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down

0 comments on commit 4bc158e

Please sign in to comment.