Commit 8b9ba7a3 authored by Rob Clark's avatar Rob Clark Committed by Dave Airlie

drm/gma500: use gem get/put page helpers

Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent bcc5c9d5
...@@ -196,37 +196,17 @@ void psb_gtt_roll(struct drm_device *dev, struct gtt_range *r, int roll) ...@@ -196,37 +196,17 @@ void psb_gtt_roll(struct drm_device *dev, struct gtt_range *r, int roll)
*/ */
static int psb_gtt_attach_pages(struct gtt_range *gt) static int psb_gtt_attach_pages(struct gtt_range *gt)
{ {
struct inode *inode; struct page **pages;
struct address_space *mapping;
int i;
struct page *p;
int pages = gt->gem.size / PAGE_SIZE;
WARN_ON(gt->pages); WARN_ON(gt->pages);
/* This is the shared memory object that backs the GEM resource */ pages = drm_gem_get_pages(&gt->gem, 0);
inode = file_inode(gt->gem.filp); if (IS_ERR(pages))
mapping = inode->i_mapping; return PTR_ERR(pages);
gt->pages = kmalloc(pages * sizeof(struct page *), GFP_KERNEL); gt->pages = pages;
if (gt->pages == NULL)
return -ENOMEM;
gt->npage = pages;
for (i = 0; i < pages; i++) {
p = shmem_read_mapping_page(mapping, i);
if (IS_ERR(p))
goto err;
gt->pages[i] = p;
}
return 0; return 0;
err:
while (i--)
page_cache_release(gt->pages[i]);
kfree(gt->pages);
gt->pages = NULL;
return PTR_ERR(p);
} }
/** /**
...@@ -240,13 +220,7 @@ static int psb_gtt_attach_pages(struct gtt_range *gt) ...@@ -240,13 +220,7 @@ static int psb_gtt_attach_pages(struct gtt_range *gt)
*/ */
static void psb_gtt_detach_pages(struct gtt_range *gt) static void psb_gtt_detach_pages(struct gtt_range *gt)
{ {
int i; drm_gem_put_pages(&gt->gem, gt->pages, true, false);
for (i = 0; i < gt->npage; i++) {
/* FIXME: do we need to force dirty */
set_page_dirty(gt->pages[i]);
page_cache_release(gt->pages[i]);
}
kfree(gt->pages);
gt->pages = NULL; gt->pages = NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment