Lines Matching refs:xen_obj
44 static int gem_alloc_pages_array(struct xen_gem_object *xen_obj, in gem_alloc_pages_array() argument
47 xen_obj->num_pages = DIV_ROUND_UP(buf_size, PAGE_SIZE); in gem_alloc_pages_array()
48 xen_obj->pages = kvmalloc_array(xen_obj->num_pages, in gem_alloc_pages_array()
50 return !xen_obj->pages ? -ENOMEM : 0; in gem_alloc_pages_array()
53 static void gem_free_pages_array(struct xen_gem_object *xen_obj) in gem_free_pages_array() argument
55 kvfree(xen_obj->pages); in gem_free_pages_array()
56 xen_obj->pages = NULL; in gem_free_pages_array()
62 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_object_mmap() local
92 ret = vm_map_pages(vma, xen_obj->pages, xen_obj->num_pages); in xen_drm_front_gem_object_mmap()
116 struct xen_gem_object *xen_obj; in gem_create_obj() local
119 xen_obj = kzalloc(sizeof(*xen_obj), GFP_KERNEL); in gem_create_obj()
120 if (!xen_obj) in gem_create_obj()
123 xen_obj->base.funcs = &xen_drm_front_gem_object_funcs; in gem_create_obj()
125 ret = drm_gem_object_init(dev, &xen_obj->base, size); in gem_create_obj()
127 kfree(xen_obj); in gem_create_obj()
131 return xen_obj; in gem_create_obj()
137 struct xen_gem_object *xen_obj; in gem_create() local
141 xen_obj = gem_create_obj(dev, size); in gem_create()
142 if (IS_ERR(xen_obj)) in gem_create()
143 return xen_obj; in gem_create()
150 ret = gem_alloc_pages_array(xen_obj, size); in gem_create()
158 ret = xen_alloc_unpopulated_pages(xen_obj->num_pages, in gem_create()
159 xen_obj->pages); in gem_create()
162 xen_obj->num_pages, ret); in gem_create()
163 gem_free_pages_array(xen_obj); in gem_create()
167 xen_obj->be_alloc = true; in gem_create()
168 return xen_obj; in gem_create()
174 xen_obj->num_pages = DIV_ROUND_UP(size, PAGE_SIZE); in gem_create()
175 xen_obj->pages = drm_gem_get_pages(&xen_obj->base); in gem_create()
176 if (IS_ERR(xen_obj->pages)) { in gem_create()
177 ret = PTR_ERR(xen_obj->pages); in gem_create()
178 xen_obj->pages = NULL; in gem_create()
182 return xen_obj; in gem_create()
192 struct xen_gem_object *xen_obj; in xen_drm_front_gem_create() local
194 xen_obj = gem_create(dev, size); in xen_drm_front_gem_create()
195 if (IS_ERR(xen_obj)) in xen_drm_front_gem_create()
196 return ERR_CAST(xen_obj); in xen_drm_front_gem_create()
198 return &xen_obj->base; in xen_drm_front_gem_create()
203 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_free_object_unlocked() local
205 if (xen_obj->base.import_attach) { in xen_drm_front_gem_free_object_unlocked()
206 drm_prime_gem_destroy(&xen_obj->base, xen_obj->sgt_imported); in xen_drm_front_gem_free_object_unlocked()
207 gem_free_pages_array(xen_obj); in xen_drm_front_gem_free_object_unlocked()
209 if (xen_obj->pages) { in xen_drm_front_gem_free_object_unlocked()
210 if (xen_obj->be_alloc) { in xen_drm_front_gem_free_object_unlocked()
211 xen_free_unpopulated_pages(xen_obj->num_pages, in xen_drm_front_gem_free_object_unlocked()
212 xen_obj->pages); in xen_drm_front_gem_free_object_unlocked()
213 gem_free_pages_array(xen_obj); in xen_drm_front_gem_free_object_unlocked()
215 drm_gem_put_pages(&xen_obj->base, in xen_drm_front_gem_free_object_unlocked()
216 xen_obj->pages, true, false); in xen_drm_front_gem_free_object_unlocked()
221 kfree(xen_obj); in xen_drm_front_gem_free_object_unlocked()
226 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_get_pages() local
228 return xen_obj->pages; in xen_drm_front_gem_get_pages()
233 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_get_sg_table() local
235 if (!xen_obj->pages) in xen_drm_front_gem_get_sg_table()
239 xen_obj->pages, xen_obj->num_pages); in xen_drm_front_gem_get_sg_table()
248 struct xen_gem_object *xen_obj; in xen_drm_front_gem_import_sg_table() local
253 xen_obj = gem_create_obj(dev, size); in xen_drm_front_gem_import_sg_table()
254 if (IS_ERR(xen_obj)) in xen_drm_front_gem_import_sg_table()
255 return ERR_CAST(xen_obj); in xen_drm_front_gem_import_sg_table()
257 ret = gem_alloc_pages_array(xen_obj, size); in xen_drm_front_gem_import_sg_table()
261 xen_obj->sgt_imported = sgt; in xen_drm_front_gem_import_sg_table()
263 ret = drm_prime_sg_to_page_array(sgt, xen_obj->pages, in xen_drm_front_gem_import_sg_table()
264 xen_obj->num_pages); in xen_drm_front_gem_import_sg_table()
269 xen_drm_front_dbuf_to_cookie(&xen_obj->base), in xen_drm_front_gem_import_sg_table()
271 xen_obj->pages); in xen_drm_front_gem_import_sg_table()
278 return &xen_obj->base; in xen_drm_front_gem_import_sg_table()
284 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_prime_vmap() local
287 if (!xen_obj->pages) in xen_drm_front_gem_prime_vmap()
291 vaddr = vmap(xen_obj->pages, xen_obj->num_pages, in xen_drm_front_gem_prime_vmap()