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

drm/amdgpu: use AMDGPU_GEM_CREATE_VRAM_CLEARED for VM PD/PTs (v2)

Doesn't make much sense to have the same functionality twice.

v2: rebase on dma_fence renaming

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Christian König and committed by
Alex Deucher
617859e0 f45dc74c

+4 -95
+4 -95
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 530 530 } 531 531 532 532 /** 533 - * amdgpu_vm_clear_bo - initially clear the page dir/table 534 - * 535 - * @adev: amdgpu_device pointer 536 - * @bo: bo to clear 537 - * 538 - * need to reserve bo first before calling it. 539 - */ 540 - static int amdgpu_vm_clear_bo(struct amdgpu_device *adev, 541 - struct amdgpu_vm *vm, 542 - struct amdgpu_bo *bo) 543 - { 544 - struct amdgpu_ring *ring; 545 - struct dma_fence *fence = NULL; 546 - struct amdgpu_job *job; 547 - struct amdgpu_pte_update_params params; 548 - unsigned entries; 549 - uint64_t addr; 550 - int r; 551 - 552 - ring = container_of(vm->entity.sched, struct amdgpu_ring, sched); 553 - 554 - r = reservation_object_reserve_shared(bo->tbo.resv); 555 - if (r) 556 - return r; 557 - 558 - r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false); 559 - if (r) 560 - goto error; 561 - 562 - r = amdgpu_ttm_bind(&bo->tbo, &bo->tbo.mem); 563 - if (r) 564 - goto error; 565 - 566 - addr = amdgpu_bo_gpu_offset(bo); 567 - entries = amdgpu_bo_size(bo) / 8; 568 - 569 - r = amdgpu_job_alloc_with_ib(adev, 64, &job); 570 - if (r) 571 - goto error; 572 - 573 - memset(&params, 0, sizeof(params)); 574 - params.adev = adev; 575 - params.ib = &job->ibs[0]; 576 - amdgpu_vm_do_set_ptes(&params, addr, 0, entries, 0, 0); 577 - amdgpu_ring_pad_ib(ring, &job->ibs[0]); 578 - 579 - WARN_ON(job->ibs[0].length_dw > 64); 580 - r = amdgpu_job_submit(job, ring, &vm->entity, 581 - AMDGPU_FENCE_OWNER_VM, &fence); 582 - if (r) 583 - goto error_free; 584 - 585 - amdgpu_bo_fence(bo, fence, true); 586 - dma_fence_put(fence); 587 - return 0; 588 - 589 - error_free: 590 - amdgpu_job_free(job); 591 - 592 - error: 593 - return r; 594 - } 595 - 596 - /** 597 533 * amdgpu_vm_map_gart - Resolve gart mapping of addr 598 534 * 599 535 * @pages_addr: optional DMA address to use for lookup ··· 1371 1435 AMDGPU_GEM_DOMAIN_VRAM, 1372 1436 AMDGPU_GEM_CREATE_NO_CPU_ACCESS | 1373 1437 AMDGPU_GEM_CREATE_SHADOW | 1374 - AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 1438 + AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | 1439 + AMDGPU_GEM_CREATE_VRAM_CLEARED, 1375 1440 NULL, resv, &pt); 1376 1441 if (r) 1377 1442 goto error_free; ··· 1381 1444 * them up in the wrong order. 1382 1445 */ 1383 1446 pt->parent = amdgpu_bo_ref(vm->page_directory); 1384 - 1385 - r = amdgpu_vm_clear_bo(adev, vm, pt); 1386 - if (r) { 1387 - amdgpu_bo_unref(&pt->shadow); 1388 - amdgpu_bo_unref(&pt); 1389 - goto error_free; 1390 - } 1391 - 1392 - if (pt->shadow) { 1393 - r = amdgpu_vm_clear_bo(adev, vm, pt->shadow); 1394 - if (r) { 1395 - amdgpu_bo_unref(&pt->shadow); 1396 - amdgpu_bo_unref(&pt); 1397 - goto error_free; 1398 - } 1399 - } 1400 1447 1401 1448 vm->page_tables[pt_idx].bo = pt; 1402 1449 vm->page_tables[pt_idx].addr = 0; ··· 1563 1642 AMDGPU_GEM_DOMAIN_VRAM, 1564 1643 AMDGPU_GEM_CREATE_NO_CPU_ACCESS | 1565 1644 AMDGPU_GEM_CREATE_SHADOW | 1566 - AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS, 1645 + AMDGPU_GEM_CREATE_VRAM_CONTIGUOUS | 1646 + AMDGPU_GEM_CREATE_VRAM_CLEARED, 1567 1647 NULL, NULL, &vm->page_directory); 1568 1648 if (r) 1569 1649 goto error_free_sched_entity; ··· 1573 1651 if (r) 1574 1652 goto error_free_page_directory; 1575 1653 1576 - r = amdgpu_vm_clear_bo(adev, vm, vm->page_directory); 1577 - if (r) 1578 - goto error_unreserve; 1579 - 1580 - if (vm->page_directory->shadow) { 1581 - r = amdgpu_vm_clear_bo(adev, vm, vm->page_directory->shadow); 1582 - if (r) 1583 - goto error_unreserve; 1584 - } 1585 - 1586 1654 vm->last_eviction_counter = atomic64_read(&adev->num_evictions); 1587 1655 amdgpu_bo_unreserve(vm->page_directory); 1588 1656 1589 1657 return 0; 1590 - 1591 - error_unreserve: 1592 - amdgpu_bo_unreserve(vm->page_directory); 1593 1658 1594 1659 error_free_page_directory: 1595 1660 amdgpu_bo_unref(&vm->page_directory->shadow);