Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/v3d: Clean up the reservation object setup.

The extra to_v3d_bo() calls came from copying this from the vc4
driver, which stored the cma gem object in the structs.

v2: Fix an unused var warning

Signed-off-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20181108161654.19888-4-eric@anholt.net
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> (v1)

+11 -22
+11 -22
drivers/gpu/drm/v3d/v3d_gem.c
··· 210 210 v3d_attach_object_fences(struct v3d_exec_info *exec) 211 211 { 212 212 struct dma_fence *out_fence = exec->render_done_fence; 213 - struct v3d_bo *bo; 214 213 int i; 215 214 216 215 for (i = 0; i < exec->bo_count; i++) { 217 - bo = to_v3d_bo(&exec->bo[i]->base); 218 - 219 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 ··· 225 228 { 226 229 int i; 227 230 228 - for (i = 0; i < exec->bo_count; i++) { 229 - struct v3d_bo *bo = to_v3d_bo(&exec->bo[i]->base); 230 - 231 - ww_mutex_unlock(&bo->resv->lock); 232 - } 231 + for (i = 0; i < exec->bo_count; i++) 232 + ww_mutex_unlock(&exec->bo[i]->resv->lock); 233 233 234 234 ww_acquire_fini(acquire_ctx); 235 235 } ··· 245 251 { 246 252 int contended_lock = -1; 247 253 int i, ret; 248 - struct v3d_bo *bo; 249 254 250 255 ww_acquire_init(acquire_ctx, &reservation_ww_class); 251 256 252 257 retry: 253 258 if (contended_lock != -1) { 254 - bo = to_v3d_bo(&exec->bo[contended_lock]->base); 259 + struct v3d_bo *bo = exec->bo[contended_lock]; 260 + 255 261 ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, 256 262 acquire_ctx); 257 263 if (ret) { ··· 264 270 if (i == contended_lock) 265 271 continue; 266 272 267 - bo = to_v3d_bo(&exec->bo[i]->base); 268 - 269 - ret = ww_mutex_lock_interruptible(&bo->resv->lock, acquire_ctx); 273 + ret = ww_mutex_lock_interruptible(&exec->bo[i]->resv->lock, 274 + acquire_ctx); 270 275 if (ret) { 271 276 int j; 272 277 273 - for (j = 0; j < i; j++) { 274 - bo = to_v3d_bo(&exec->bo[j]->base); 275 - ww_mutex_unlock(&bo->resv->lock); 276 - } 278 + for (j = 0; j < i; j++) 279 + ww_mutex_unlock(&exec->bo[j]->resv->lock); 277 280 278 281 if (contended_lock != -1 && contended_lock >= i) { 279 - bo = to_v3d_bo(&exec->bo[contended_lock]->base); 282 + struct v3d_bo *bo = exec->bo[contended_lock]; 280 283 281 284 ww_mutex_unlock(&bo->resv->lock); 282 285 } ··· 294 303 * before we commit the CL to the hardware. 295 304 */ 296 305 for (i = 0; i < exec->bo_count; i++) { 297 - bo = to_v3d_bo(&exec->bo[i]->base); 298 - 299 - ret = reservation_object_reserve_shared(bo->resv, 1); 306 + ret = reservation_object_reserve_shared(exec->bo[i]->resv, 1); 300 307 if (ret) { 301 308 v3d_unlock_bo_reservations(dev, exec, acquire_ctx); 302 309 return ret;