mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 04:34:11 +08:00
drm/udl: use gem get/put page helpers
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
parent
8b9ba7a38c
commit
5dc9e1e872
@ -117,55 +117,23 @@ int udl_gem_init_object(struct drm_gem_object *obj)
|
|||||||
|
|
||||||
static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask)
|
static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask)
|
||||||
{
|
{
|
||||||
int page_count, i;
|
struct page **pages;
|
||||||
struct page *page;
|
|
||||||
struct inode *inode;
|
|
||||||
struct address_space *mapping;
|
|
||||||
|
|
||||||
if (obj->pages)
|
if (obj->pages)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
page_count = obj->base.size / PAGE_SIZE;
|
pages = drm_gem_get_pages(&obj->base, gfpmask);
|
||||||
BUG_ON(obj->pages != NULL);
|
if (IS_ERR(pages))
|
||||||
obj->pages = drm_malloc_ab(page_count, sizeof(struct page *));
|
return PTR_ERR(pages);
|
||||||
if (obj->pages == NULL)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
inode = file_inode(obj->base.filp);
|
obj->pages = pages;
|
||||||
mapping = inode->i_mapping;
|
|
||||||
gfpmask |= mapping_gfp_mask(mapping);
|
|
||||||
|
|
||||||
for (i = 0; i < page_count; i++) {
|
|
||||||
page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
|
|
||||||
if (IS_ERR(page))
|
|
||||||
goto err_pages;
|
|
||||||
obj->pages[i] = page;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err_pages:
|
|
||||||
while (i--)
|
|
||||||
page_cache_release(obj->pages[i]);
|
|
||||||
drm_free_large(obj->pages);
|
|
||||||
obj->pages = NULL;
|
|
||||||
return PTR_ERR(page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void udl_gem_put_pages(struct udl_gem_object *obj)
|
static void udl_gem_put_pages(struct udl_gem_object *obj)
|
||||||
{
|
{
|
||||||
int page_count = obj->base.size / PAGE_SIZE;
|
drm_gem_put_pages(&obj->base, obj->pages, false, false);
|
||||||
int i;
|
|
||||||
|
|
||||||
if (obj->base.import_attach) {
|
|
||||||
drm_free_large(obj->pages);
|
|
||||||
obj->pages = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < page_count; i++)
|
|
||||||
page_cache_release(obj->pages[i]);
|
|
||||||
|
|
||||||
drm_free_large(obj->pages);
|
|
||||||
obj->pages = NULL;
|
obj->pages = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user