aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
index f6d7f6404a07..8ce74a1d9966 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c
@@ -30,6 +30,8 @@
30#include <drm/amdgpu_drm.h> 30#include <drm/amdgpu_drm.h>
31#include <linux/dma-buf.h> 31#include <linux/dma-buf.h>
32 32
33static const struct dma_buf_ops amdgpu_dmabuf_ops;
34
33struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj) 35struct sg_table *amdgpu_gem_prime_get_sg_table(struct drm_gem_object *obj)
34{ 36{
35 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj); 37 struct amdgpu_bo *bo = gem_to_amdgpu_bo(obj);
@@ -129,20 +131,27 @@ static int amdgpu_gem_map_attach(struct dma_buf *dma_buf,
129 if (unlikely(r != 0)) 131 if (unlikely(r != 0))
130 goto error_detach; 132 goto error_detach;
131 133
132 /* 134
133 * Wait for all shared fences to complete before we switch to future 135 if (dma_buf->ops != &amdgpu_dmabuf_ops) {
134 * use of exclusive fence on this prime shared bo. 136 /*
135 */ 137 * Wait for all shared fences to complete before we switch to future
136 r = reservation_object_wait_timeout_rcu(bo->tbo.resv, true, false, 138 * use of exclusive fence on this prime shared bo.
137 MAX_SCHEDULE_TIMEOUT); 139 */
138 if (unlikely(r < 0)) { 140 r = reservation_object_wait_timeout_rcu(bo->tbo.resv,
139 DRM_DEBUG_PRIME("Fence wait failed: %li\n", r); 141 true, false,
140 goto error_unreserve; 142 MAX_SCHEDULE_TIMEOUT);
143 if (unlikely(r < 0)) {
144 DRM_DEBUG_PRIME("Fence wait failed: %li\n", r);
145 goto error_unreserve;
146 }
141 } 147 }
142 148
143 /* pin buffer into GTT */ 149 /* pin buffer into GTT */
144 r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT, NULL); 150 r = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT, NULL);
145 if (likely(r == 0)) 151 if (r)
152 goto error_unreserve;
153
154 if (dma_buf->ops != &amdgpu_dmabuf_ops)
146 bo->prime_shared_count++; 155 bo->prime_shared_count++;
147 156
148error_unreserve: 157error_unreserve:
@@ -166,7 +175,7 @@ static void amdgpu_gem_map_detach(struct dma_buf *dma_buf,
166 goto error; 175 goto error;
167 176
168 amdgpu_bo_unpin(bo); 177 amdgpu_bo_unpin(bo);
169 if (bo->prime_shared_count) 178 if (dma_buf->ops != &amdgpu_dmabuf_ops && bo->prime_shared_count)
170 bo->prime_shared_count--; 179 bo->prime_shared_count--;
171 amdgpu_bo_unreserve(bo); 180 amdgpu_bo_unreserve(bo);
172 181