diff options
Diffstat (limited to 'drivers/gpu/drm/udl/udl_gem.c')
-rw-r--r-- | drivers/gpu/drm/udl/udl_gem.c | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index b5e3b8038253..8dbe9d0ae9a7 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c | |||
@@ -117,55 +117,23 @@ int udl_gem_init_object(struct drm_gem_object *obj) | |||
117 | 117 | ||
118 | static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask) | 118 | static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask) |
119 | { | 119 | { |
120 | int page_count, i; | 120 | struct page **pages; |
121 | struct page *page; | ||
122 | struct inode *inode; | ||
123 | struct address_space *mapping; | ||
124 | 121 | ||
125 | if (obj->pages) | 122 | if (obj->pages) |
126 | return 0; | 123 | return 0; |
127 | 124 | ||
128 | page_count = obj->base.size / PAGE_SIZE; | 125 | pages = drm_gem_get_pages(&obj->base, gfpmask); |
129 | BUG_ON(obj->pages != NULL); | 126 | if (IS_ERR(pages)) |
130 | obj->pages = drm_malloc_ab(page_count, sizeof(struct page *)); | 127 | return PTR_ERR(pages); |
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); | ||
137 | 128 | ||
138 | for (i = 0; i < page_count; i++) { | 129 | obj->pages = pages; |
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 | } | ||
144 | 130 | ||
145 | return 0; | 131 | 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); | ||
152 | } | 132 | } |
153 | 133 | ||
154 | static void udl_gem_put_pages(struct udl_gem_object *obj) | 134 | static void udl_gem_put_pages(struct udl_gem_object *obj) |
155 | { | 135 | { |
156 | int page_count = obj->base.size / PAGE_SIZE; | 136 | drm_gem_put_pages(&obj->base, obj->pages, false, false); |
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); | ||
169 | obj->pages = NULL; | 137 | obj->pages = NULL; |
170 | } | 138 | } |
171 | 139 | ||