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

drm/msm/gpu: simplify tracking in-flight bo's

Since we already track the array of bo's in the submit object, just
unconditionally take and drop ref's per submit (rather than only taking
ref's if bo is not already active). This simplifies later patches.

Signed-off-by: Rob Clark <robdclark@gmail.com>

Rob Clark 7d12a279 340ff410

+22 -29
+22 -29
drivers/gpu/drm/msm/msm_gpu.c
··· 432 432 * Cmdstream submission/retirement: 433 433 */ 434 434 435 + static void retire_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) 436 + { 437 + int i; 438 + 439 + for (i = 0; i < submit->nr_bos; i++) { 440 + struct msm_gem_object *msm_obj = submit->bos[i].obj; 441 + /* move to inactive: */ 442 + msm_gem_move_to_inactive(&msm_obj->base); 443 + msm_gem_put_iova(&msm_obj->base, gpu->id); 444 + drm_gem_object_unreference(&msm_obj->base); 445 + } 446 + 447 + list_del(&submit->node); 448 + kfree(submit); 449 + } 450 + 435 451 static void retire_submits(struct msm_gpu *gpu, uint32_t fence) 436 452 { 437 453 struct drm_device *dev = gpu->dev; ··· 461 445 struct msm_gem_submit, node); 462 446 463 447 if (submit->fence <= fence) { 464 - list_del(&submit->node); 465 - kfree(submit); 448 + retire_submit(gpu, submit); 466 449 } else { 467 450 break; 468 451 } ··· 477 462 msm_update_fence(gpu->dev, fence); 478 463 479 464 mutex_lock(&dev->struct_mutex); 480 - 481 465 retire_submits(gpu, fence); 482 - 483 - while (!list_empty(&gpu->active_list)) { 484 - struct msm_gem_object *obj; 485 - 486 - obj = list_first_entry(&gpu->active_list, 487 - struct msm_gem_object, mm_list); 488 - 489 - if ((obj->read_fence <= fence) && 490 - (obj->write_fence <= fence)) { 491 - /* move to inactive: */ 492 - msm_gem_move_to_inactive(&obj->base); 493 - msm_gem_put_iova(&obj->base, gpu->id); 494 - drm_gem_object_unreference(&obj->base); 495 - } else { 496 - break; 497 - } 498 - } 499 - 500 466 mutex_unlock(&dev->struct_mutex); 501 467 502 468 if (!msm_gpu_active(gpu)) ··· 518 522 519 523 for (i = 0; i < submit->nr_bos; i++) { 520 524 struct msm_gem_object *msm_obj = submit->bos[i].obj; 525 + uint32_t iova; 521 526 522 527 /* can't happen yet.. but when we add 2d support we'll have 523 528 * to deal w/ cross-ring synchronization: 524 529 */ 525 530 WARN_ON(is_active(msm_obj) && (msm_obj->gpu != gpu)); 526 531 527 - if (!is_active(msm_obj)) { 528 - uint32_t iova; 529 - 530 - /* ring takes a reference to the bo and iova: */ 531 - drm_gem_object_reference(&msm_obj->base); 532 - msm_gem_get_iova_locked(&msm_obj->base, 533 - submit->gpu->id, &iova); 534 - } 532 + /* submit takes a reference to the bo and iova until retired: */ 533 + drm_gem_object_reference(&msm_obj->base); 534 + msm_gem_get_iova_locked(&msm_obj->base, 535 + submit->gpu->id, &iova); 535 536 536 537 if (submit->bos[i].flags & MSM_SUBMIT_BO_READ) 537 538 msm_gem_move_to_active(&msm_obj->base, gpu, false, submit->fence);