Lines Matching refs:xen_obj
45 static int gem_alloc_pages_array(struct xen_gem_object *xen_obj, in gem_alloc_pages_array() argument
48 xen_obj->num_pages = DIV_ROUND_UP(buf_size, PAGE_SIZE); in gem_alloc_pages_array()
49 xen_obj->pages = kvmalloc_array(xen_obj->num_pages, in gem_alloc_pages_array()
51 return !xen_obj->pages ? -ENOMEM : 0; in gem_alloc_pages_array()
54 static void gem_free_pages_array(struct xen_gem_object *xen_obj) in gem_free_pages_array() argument
56 kvfree(xen_obj->pages); in gem_free_pages_array()
57 xen_obj->pages = NULL; in gem_free_pages_array()
63 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_object_mmap() local
94 ret = vm_map_pages(vma, xen_obj->pages, xen_obj->num_pages); in xen_drm_front_gem_object_mmap()
118 struct xen_gem_object *xen_obj; in gem_create_obj() local
121 xen_obj = kzalloc(sizeof(*xen_obj), GFP_KERNEL); in gem_create_obj()
122 if (!xen_obj) in gem_create_obj()
125 xen_obj->base.funcs = &xen_drm_front_gem_object_funcs; in gem_create_obj()
127 ret = drm_gem_object_init(dev, &xen_obj->base, size); in gem_create_obj()
129 kfree(xen_obj); in gem_create_obj()
133 return xen_obj; in gem_create_obj()
139 struct xen_gem_object *xen_obj; in gem_create() local
143 xen_obj = gem_create_obj(dev, size); in gem_create()
144 if (IS_ERR(xen_obj)) in gem_create()
145 return xen_obj; in gem_create()
152 ret = gem_alloc_pages_array(xen_obj, size); in gem_create()
160 ret = xen_alloc_unpopulated_pages(xen_obj->num_pages, in gem_create()
161 xen_obj->pages); in gem_create()
164 xen_obj->num_pages, ret); in gem_create()
165 gem_free_pages_array(xen_obj); in gem_create()
169 xen_obj->be_alloc = true; in gem_create()
170 return xen_obj; in gem_create()
176 xen_obj->num_pages = DIV_ROUND_UP(size, PAGE_SIZE); in gem_create()
177 xen_obj->pages = drm_gem_get_pages(&xen_obj->base); in gem_create()
178 if (IS_ERR(xen_obj->pages)) { in gem_create()
179 ret = PTR_ERR(xen_obj->pages); in gem_create()
180 xen_obj->pages = NULL; in gem_create()
184 return xen_obj; in gem_create()
194 struct xen_gem_object *xen_obj; in xen_drm_front_gem_create() local
196 xen_obj = gem_create(dev, size); in xen_drm_front_gem_create()
197 if (IS_ERR(xen_obj)) in xen_drm_front_gem_create()
198 return ERR_CAST(xen_obj); in xen_drm_front_gem_create()
200 return &xen_obj->base; in xen_drm_front_gem_create()
205 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_free_object_unlocked() local
207 if (xen_obj->base.import_attach) { in xen_drm_front_gem_free_object_unlocked()
208 drm_prime_gem_destroy(&xen_obj->base, xen_obj->sgt_imported); in xen_drm_front_gem_free_object_unlocked()
209 gem_free_pages_array(xen_obj); in xen_drm_front_gem_free_object_unlocked()
211 if (xen_obj->pages) { in xen_drm_front_gem_free_object_unlocked()
212 if (xen_obj->be_alloc) { in xen_drm_front_gem_free_object_unlocked()
213 xen_free_unpopulated_pages(xen_obj->num_pages, in xen_drm_front_gem_free_object_unlocked()
214 xen_obj->pages); in xen_drm_front_gem_free_object_unlocked()
215 gem_free_pages_array(xen_obj); in xen_drm_front_gem_free_object_unlocked()
217 drm_gem_put_pages(&xen_obj->base, in xen_drm_front_gem_free_object_unlocked()
218 xen_obj->pages, true, false); in xen_drm_front_gem_free_object_unlocked()
223 kfree(xen_obj); in xen_drm_front_gem_free_object_unlocked()
228 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_get_pages() local
230 return xen_obj->pages; in xen_drm_front_gem_get_pages()
235 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_get_sg_table() local
237 if (!xen_obj->pages) in xen_drm_front_gem_get_sg_table()
241 xen_obj->pages, xen_obj->num_pages); in xen_drm_front_gem_get_sg_table()
250 struct xen_gem_object *xen_obj; in xen_drm_front_gem_import_sg_table() local
255 xen_obj = gem_create_obj(dev, size); in xen_drm_front_gem_import_sg_table()
256 if (IS_ERR(xen_obj)) in xen_drm_front_gem_import_sg_table()
257 return ERR_CAST(xen_obj); in xen_drm_front_gem_import_sg_table()
259 ret = gem_alloc_pages_array(xen_obj, size); in xen_drm_front_gem_import_sg_table()
263 xen_obj->sgt_imported = sgt; in xen_drm_front_gem_import_sg_table()
265 ret = drm_prime_sg_to_page_array(sgt, xen_obj->pages, in xen_drm_front_gem_import_sg_table()
266 xen_obj->num_pages); in xen_drm_front_gem_import_sg_table()
271 xen_drm_front_dbuf_to_cookie(&xen_obj->base), in xen_drm_front_gem_import_sg_table()
273 xen_obj->pages); in xen_drm_front_gem_import_sg_table()
280 return &xen_obj->base; in xen_drm_front_gem_import_sg_table()
286 struct xen_gem_object *xen_obj = to_xen_gem_obj(gem_obj); in xen_drm_front_gem_prime_vmap() local
289 if (!xen_obj->pages) in xen_drm_front_gem_prime_vmap()
293 vaddr = vmap(xen_obj->pages, xen_obj->num_pages, in xen_drm_front_gem_prime_vmap()