| .. | .. |
|---|
| 3 | 3 | * Copyright (C) 2014-2018 Etnaviv Project |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | |
|---|
| 6 | +#include <drm/drm_prime.h> |
|---|
| 6 | 7 | #include <linux/dma-buf.h> |
|---|
| 8 | + |
|---|
| 7 | 9 | #include "etnaviv_drv.h" |
|---|
| 8 | 10 | #include "etnaviv_gem.h" |
|---|
| 9 | 11 | |
|---|
| .. | .. |
|---|
| 17 | 19 | if (WARN_ON(!etnaviv_obj->pages)) /* should have already pinned! */ |
|---|
| 18 | 20 | return ERR_PTR(-EINVAL); |
|---|
| 19 | 21 | |
|---|
| 20 | | - return drm_prime_pages_to_sg(etnaviv_obj->pages, npages); |
|---|
| 22 | + return drm_prime_pages_to_sg(obj->dev, etnaviv_obj->pages, npages); |
|---|
| 21 | 23 | } |
|---|
| 22 | 24 | |
|---|
| 23 | 25 | void *etnaviv_gem_prime_vmap(struct drm_gem_object *obj) |
|---|
| .. | .. |
|---|
| 91 | 93 | static int etnaviv_gem_prime_mmap_obj(struct etnaviv_gem_object *etnaviv_obj, |
|---|
| 92 | 94 | struct vm_area_struct *vma) |
|---|
| 93 | 95 | { |
|---|
| 94 | | - return dma_buf_mmap(etnaviv_obj->base.dma_buf, vma, 0); |
|---|
| 96 | + int ret; |
|---|
| 97 | + |
|---|
| 98 | + ret = dma_buf_mmap(etnaviv_obj->base.dma_buf, vma, 0); |
|---|
| 99 | + if (!ret) { |
|---|
| 100 | + /* Drop the reference acquired by drm_gem_mmap_obj(). */ |
|---|
| 101 | + drm_gem_object_put(&etnaviv_obj->base); |
|---|
| 102 | + } |
|---|
| 103 | + |
|---|
| 104 | + return ret; |
|---|
| 95 | 105 | } |
|---|
| 96 | 106 | |
|---|
| 97 | 107 | static const struct etnaviv_gem_ops etnaviv_gem_prime_ops = { |
|---|
| .. | .. |
|---|
| 109 | 119 | int ret, npages; |
|---|
| 110 | 120 | |
|---|
| 111 | 121 | ret = etnaviv_gem_new_private(dev, size, ETNA_BO_WC, |
|---|
| 112 | | - attach->dmabuf->resv, |
|---|
| 113 | 122 | &etnaviv_gem_prime_ops, &etnaviv_obj); |
|---|
| 114 | 123 | if (ret < 0) |
|---|
| 115 | 124 | return ERR_PTR(ret); |
|---|
| .. | .. |
|---|
| 135 | 144 | return &etnaviv_obj->base; |
|---|
| 136 | 145 | |
|---|
| 137 | 146 | fail: |
|---|
| 138 | | - drm_gem_object_put_unlocked(&etnaviv_obj->base); |
|---|
| 147 | + drm_gem_object_put(&etnaviv_obj->base); |
|---|
| 139 | 148 | |
|---|
| 140 | 149 | return ERR_PTR(ret); |
|---|
| 141 | | -} |
|---|
| 142 | | - |
|---|
| 143 | | -struct reservation_object *etnaviv_gem_prime_res_obj(struct drm_gem_object *obj) |
|---|
| 144 | | -{ |
|---|
| 145 | | - struct etnaviv_gem_object *etnaviv_obj = to_etnaviv_bo(obj); |
|---|
| 146 | | - |
|---|
| 147 | | - return etnaviv_obj->resv; |
|---|
| 148 | 150 | } |
|---|