aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/v3d/v3d_gem.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/v3d/v3d_gem.c')
-rw-r--r--drivers/gpu/drm/v3d/v3d_gem.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index b88c96911453..1e8947c7d954 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -210,14 +210,11 @@ static void
210v3d_attach_object_fences(struct v3d_exec_info *exec) 210v3d_attach_object_fences(struct v3d_exec_info *exec)
211{ 211{
212 struct dma_fence *out_fence = exec->render_done_fence; 212 struct dma_fence *out_fence = exec->render_done_fence;
213 struct v3d_bo *bo;
214 int i; 213 int i;
215 214
216 for (i = 0; i < exec->bo_count; i++) { 215 for (i = 0; i < exec->bo_count; i++) {
217 bo = to_v3d_bo(&exec->bo[i]->base);
218
219 /* XXX: Use shared fences for read-only objects. */ 216 /* XXX: Use shared fences for read-only objects. */
220 reservation_object_add_excl_fence(bo->resv, out_fence); 217 reservation_object_add_excl_fence(exec->bo[i]->resv, out_fence);
221 } 218 }
222} 219}
223 220
@@ -228,11 +225,8 @@ v3d_unlock_bo_reservations(struct drm_device *dev,
228{ 225{
229 int i; 226 int i;
230 227
231 for (i = 0; i < exec->bo_count; i++) { 228 for (i = 0; i < exec->bo_count; i++)
232 struct v3d_bo *bo = to_v3d_bo(&exec->bo[i]->base); 229 ww_mutex_unlock(&exec->bo[i]->resv->lock);
233
234 ww_mutex_unlock(&bo->resv->lock);
235 }
236 230
237 ww_acquire_fini(acquire_ctx); 231 ww_acquire_fini(acquire_ctx);
238} 232}
@@ -251,13 +245,13 @@ v3d_lock_bo_reservations(struct drm_device *dev,
251{ 245{
252 int contended_lock = -1; 246 int contended_lock = -1;
253 int i, ret; 247 int i, ret;
254 struct v3d_bo *bo;
255 248
256 ww_acquire_init(acquire_ctx, &reservation_ww_class); 249 ww_acquire_init(acquire_ctx, &reservation_ww_class);
257 250
258retry: 251retry:
259 if (contended_lock != -1) { 252 if (contended_lock != -1) {
260 bo = to_v3d_bo(&exec->bo[contended_lock]->base); 253 struct v3d_bo *bo = exec->bo[contended_lock];
254
261 ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, 255 ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
262 acquire_ctx); 256 acquire_ctx);
263 if (ret) { 257 if (ret) {
@@ -270,19 +264,16 @@ retry:
270 if (i == contended_lock) 264 if (i == contended_lock)
271 continue; 265 continue;
272 266
273 bo = to_v3d_bo(&exec->bo[i]->base); 267 ret = ww_mutex_lock_interruptible(&exec->bo[i]->resv->lock,
274 268 acquire_ctx);
275 ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx);
276 if (ret) { 269 if (ret) {
277 int j; 270 int j;
278 271
279 for (j = 0; j < i; j++) { 272 for (j = 0; j < i; j++)
280 bo = to_v3d_bo(&exec->bo[j]->base); 273 ww_mutex_unlock(&exec->bo[j]->resv->lock);
281 ww_mutex_unlock(&bo->resv->lock);
282 }
283 274
284 if (contended_lock != -1 && contended_lock >= i) { 275 if (contended_lock != -1 && contended_lock >= i) {
285 bo = to_v3d_bo(&exec->bo[contended_lock]->base); 276 struct v3d_bo *bo = exec->bo[contended_lock];
286 277
287 ww_mutex_unlock(&bo->resv->lock); 278 ww_mutex_unlock(&bo->resv->lock);
288 } 279 }
@@ -303,9 +294,7 @@ retry:
303 * before we commit the CL to the hardware. 294 * before we commit the CL to the hardware.
304 */ 295 */
305 for (i = 0; i < exec->bo_count; i++) { 296 for (i = 0; i < exec->bo_count; i++) {
306 bo = to_v3d_bo(&exec->bo[i]->base); 297 ret = reservation_object_reserve_shared(exec->bo[i]->resv, 1);
307
308 ret = reservation_object_reserve_shared(bo->resv, 1);
309 if (ret) { 298 if (ret) {
310 v3d_unlock_bo_reservations(dev, exec, acquire_ctx); 299 v3d_unlock_bo_reservations(dev, exec, acquire_ctx);
311 return ret; 300 return ret;