Skip to content

Commit 5dc9e1e

Browse files
robclarkairlied
authored andcommitted
drm/udl: use gem get/put page helpers
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 8b9ba7a commit 5dc9e1e

1 file changed

Lines changed: 6 additions & 38 deletions

File tree

‎drivers/gpu/drm/udl/udl_gem.c‎

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -117,55 +117,23 @@ int udl_gem_init_object(struct drm_gem_object *obj)
117117

118118
static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask)
119119
{
120-
int page_count, i;
121-
struct page *page;
122-
struct inode *inode;
123-
struct address_space *mapping;
120+
struct page **pages;
124121

125122
if (obj->pages)
126123
return 0;
127124

128-
page_count = obj->base.size / PAGE_SIZE;
129-
BUG_ON(obj->pages != NULL);
130-
obj->pages = drm_malloc_ab(page_count, sizeof(struct page *));
131-
if (obj->pages == NULL)
132-
return -ENOMEM;
133-
134-
inode = file_inode(obj->base.filp);
135-
mapping = inode->i_mapping;
136-
gfpmask |= mapping_gfp_mask(mapping);
125+
pages = drm_gem_get_pages(&obj->base, gfpmask);
126+
if (IS_ERR(pages))
127+
return PTR_ERR(pages);
137128

138-
for (i = 0; i < page_count; i++) {
139-
page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
140-
if (IS_ERR(page))
141-
goto err_pages;
142-
obj->pages[i] = page;
143-
}
129+
obj->pages = pages;
144130

145131
return 0;
146-
err_pages:
147-
while (i--)
148-
page_cache_release(obj->pages[i]);
149-
drm_free_large(obj->pages);
150-
obj->pages = NULL;
151-
return PTR_ERR(page);
152132
}
153133

154134
static void udl_gem_put_pages(struct udl_gem_object *obj)
155135
{
156-
int page_count = obj->base.size / PAGE_SIZE;
157-
int i;
158-
159-
if (obj->base.import_attach) {
160-
drm_free_large(obj->pages);
161-
obj->pages = NULL;
162-
return;
163-
}
164-
165-
for (i = 0; i < page_count; i++)
166-
page_cache_release(obj->pages[i]);
167-
168-
drm_free_large(obj->pages);
136+
drm_gem_put_pages(&obj->base, obj->pages, false, false);
169137
obj->pages = NULL;
170138
}
171139

0 commit comments

Comments
 (0)