linux/drivers/gpu/drm/v3d/v3d_gem.c
/* Takes the reservation lock on all the BOs being referenced, so that
 * at queue submit time we can update the reservations.
 *
 * We don't lock the RCL the tile alloc/state BOs, or overflow memory
 * (all of which are on exec->unref_list).  They're entirely private
 * to v3d, so we don't attach dma-buf fences to them.
 */
Takes the reservation lock on all the BOs being referenced, so that
at queue submit time we can update the reservations.

We don't lock the RCL the tile alloc/state BOs, or overflow memory
(all of which are on exec->unref_list).  They're entirely private
to v3d, so we don't attach dma-buf fences to them.
Takes the reservation lock on all the BOs being referenced so that at queue submit time we can update the reservations . We don ' t lock the RCL the tile alloc / state BOs or overflow memory ( all of which are on exec - > unref_list ) . They ' re entirely private to v3d so we don ' t attach dma - buf fences to them .
static int
v3d_lock_bo_reservations(struct drm_device *dev,
			 struct v3d_exec_info *exec,
			 struct ww_acquire_ctx *acquire_ctx)
{
	int contended_lock = -1;
	int i, ret;
	struct v3d_bo *bo;
	ww_acquire_init(acquire_ctx, &reservation_ww_class);
retry:
	if (contended_lock != -1) {
		bo = to_v3d_bo(&exec->bo[contended_lock]->base);
		ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
						       acquire_ctx);
		if (ret) {
			ww_acquire_done(acquire_ctx);
			return ret;
		}
	}
	for (i = 0; i < exec->bo_count; i++) {
		if (i == contended_lock)
			continue;
		bo = to_v3d_bo(&exec->bo[i]->base);
		ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx);
		if (ret) {
			int j;
			for (j = 0; j < i; j++) {
				bo = to_v3d_bo(&exec->bo[j]->base);
				ww_mutex_unlock(&bo->resv->lock);
			}
			if (contended_lock != -1 && contended_lock >= i) {
				bo = to_v3d_bo(&exec->bo[contended_lock]->base);
				ww_mutex_unlock(&bo->resv->lock);
			}
			if (ret == -EDEADLK) {
				contended_lock = i;
				goto retry;
			}
			ww_acquire_done(acquire_ctx);
			return ret;
		}
	}
	ww_acquire_done(acquire_ctx);
	for (i = 0; i < exec->bo_count; i++) {
		bo = to_v3d_bo(&exec->bo[i]->base);
		ret = reservation_object_reserve_shared(bo->resv);
		if (ret) {
			v3d_unlock_bo_reservations(dev, exec, acquire_ctx);
			return ret;
		}
	}
	return 0;
}
static int v3d_lock_bo_reservations ( struct drm_device * dev , struct v3d_exec_info * exec , struct ww_acquire_ctx * acquire_ctx ) { int contended_lock = -1 ; int i , ret ; struct v3d_bo * bo ; ww_acquire_init ( acquire_ctx , & reservation_ww_class ) ; retry : if ( contended_lock != -1 ) { bo = to_v3d_bo ( & exec -> bo [ contended_lock ] -> base ) ; ret = ww_mutex_lock_slow_interruptible ( & bo -> resv -> lock , acquire_ctx ) ; if ( ret ) { ww_acquire_done ( acquire_ctx ) ; return ret ; } } for ( i = 0 ; i < exec -> bo_count ; i ++ ) { if ( i == contended_lock ) continue ; bo = to_v3d_bo ( & exec -> bo [ i ] -> base ) ; ret = ww_mutex_lock_interruptible ( & bo -> resv -> lock , acquire_ctx ) ; if ( ret ) { int j ; for ( j = 0 ; j < i ; j ++ ) { bo = to_v3d_bo ( & exec -> bo [ j ] -> base ) ; ww_mutex_unlock ( & bo -> resv -> lock ) ; } if ( contended_lock != -1 && contended_lock >= i ) { bo = to_v3d_bo ( & exec -> bo [ contended_lock ] -> base ) ; ww_mutex_unlock ( & bo -> resv -> lock ) ; } if ( ret == - EDEADLK ) { contended_lock = i ; goto retry ; } ww_acquire_done ( acquire_ctx ) ; return ret ; } } ww_acquire_done ( acquire_ctx ) ; for ( i = 0 ; i < exec -> bo_count ; i ++ ) { bo = to_v3d_bo ( & exec -> bo [ i ] -> base ) ; ret = reservation_object_reserve_shared ( bo -> resv ) ; if ( ret ) { v3d_unlock_bo_reservations ( dev , exec , acquire_ctx ) ; return ret ; } } return 0 ; }
Takes the reservation lock on all the BOs being referenced, so that
 at queue submit time we can update the reservations.
Takes the reservation lock on all the BOs being referenced so that at queue submit time we can update the reservations .
/* Reserve space for our shared (read-only) fence references,
	 * before we commit the CL to the hardware.
	 */