62 src = obj->
pages->sgl;
64 for (i = 0; i < obj->
pages->nents; i++) {
65 sg_set_page(dst, sg_page(src),
PAGE_SIZE, 0);
77 i915_gem_object_pin_pages(obj);
97 if (obj->
base.export_dma_buf == dma_buf) {
100 drm_gem_object_unreference_unlocked(&obj->
base);
104 static void *i915_gem_dmabuf_vmap(
struct dma_buf *dma_buf)
127 pages = drm_malloc_ab(obj->
pages->nents,
sizeof(
struct page *));
132 pages[i] = sg_page(sg);
134 obj->dma_buf_vmapping =
vmap(pages, obj->pages->nents, 0, PAGE_KERNEL);
135 drm_free_large(pages);
137 if (!obj->dma_buf_vmapping)
140 obj->vmapping_count = 1;
141 i915_gem_object_pin_pages(obj);
144 return obj->dma_buf_vmapping;
151 static
void i915_gem_dmabuf_vunmap(
struct dma_buf *dma_buf,
void *
vaddr)
165 i915_gem_object_unpin_pages(obj);
170 static void *i915_gem_dmabuf_kmap_atomic(
struct dma_buf *dma_buf,
unsigned long page_num)
175 static void i915_gem_dmabuf_kunmap_atomic(
struct dma_buf *dma_buf,
unsigned long page_num,
void *
addr)
179 static void *i915_gem_dmabuf_kmap(
struct dma_buf *dma_buf,
unsigned long page_num)
184 static void i915_gem_dmabuf_kunmap(
struct dma_buf *dma_buf,
unsigned long page_num,
void *
addr)
189 static int i915_gem_dmabuf_mmap(
struct dma_buf *dma_buf,
struct vm_area_struct *vma)
210 static const struct dma_buf_ops i915_dmabuf_ops = {
211 .map_dma_buf = i915_gem_map_dma_buf,
212 .unmap_dma_buf = i915_gem_unmap_dma_buf,
213 .release = i915_gem_dmabuf_release,
214 .kmap = i915_gem_dmabuf_kmap,
215 .kmap_atomic = i915_gem_dmabuf_kmap_atomic,
216 .kunmap = i915_gem_dmabuf_kunmap,
217 .kunmap_atomic = i915_gem_dmabuf_kunmap_atomic,
218 .mmap = i915_gem_dmabuf_mmap,
219 .vmap = i915_gem_dmabuf_vmap,
220 .vunmap = i915_gem_dmabuf_vunmap,
221 .begin_cpu_access = i915_gem_begin_cpu_access,
225 struct drm_gem_object *gem_obj,
int flags)
253 .get_pages = i915_gem_object_get_pages_dmabuf,
254 .put_pages = i915_gem_object_put_pages_dmabuf,
258 struct dma_buf *dma_buf)
265 if (dma_buf->
ops == &i915_dmabuf_ops) {
268 if (obj->
base.dev == dev) {
269 drm_gem_object_reference(&obj->
base);
277 return ERR_CAST(attach);