aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c62
1 files changed, 15 insertions, 47 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index cca8fc931bbb..e873bbb2f0c7 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1488,36 +1488,6 @@ error:
1488} 1488}
1489 1489
1490/** 1490/**
1491 * amdgpu_vm_find_entry - find the entry for an address
1492 *
1493 * @p: see amdgpu_pte_update_params definition
1494 * @addr: virtual address in question
1495 * @entry: resulting entry or NULL
1496 * @parent: parent entry
1497 *
1498 * Find the vm_pt entry and it's parent for the given address.
1499 */
1500void amdgpu_vm_get_entry(struct amdgpu_pte_update_params *p, uint64_t addr,
1501 struct amdgpu_vm_pt **entry,
1502 struct amdgpu_vm_pt **parent)
1503{
1504 unsigned level = p->adev->vm_manager.root_level;
1505
1506 *parent = NULL;
1507 *entry = &p->vm->root;
1508 while ((*entry)->entries) {
1509 unsigned shift = amdgpu_vm_level_shift(p->adev, level++);
1510
1511 *parent = *entry;
1512 *entry = &(*entry)->entries[addr >> shift];
1513 addr &= (1ULL << shift) - 1;
1514 }
1515
1516 if (level != AMDGPU_VM_PTB)
1517 *entry = NULL;
1518}
1519
1520/**
1521 * amdgpu_vm_handle_huge_pages - handle updating the PD with huge pages 1491 * amdgpu_vm_handle_huge_pages - handle updating the PD with huge pages
1522 * 1492 *
1523 * @p: see amdgpu_pte_update_params definition 1493 * @p: see amdgpu_pte_update_params definition
@@ -1580,36 +1550,34 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
1580{ 1550{
1581 struct amdgpu_device *adev = params->adev; 1551 struct amdgpu_device *adev = params->adev;
1582 const uint64_t mask = AMDGPU_VM_PTE_COUNT(adev) - 1; 1552 const uint64_t mask = AMDGPU_VM_PTE_COUNT(adev) - 1;
1583 1553 struct amdgpu_vm_pt_cursor cursor;
1584 uint64_t addr, pe_start;
1585 struct amdgpu_bo *pt;
1586 unsigned nptes;
1587 1554
1588 /* walk over the address space and update the page tables */ 1555 /* walk over the address space and update the page tables */
1589 for (addr = start; addr < end; addr += nptes, 1556 for_each_amdgpu_vm_pt_leaf(adev, params->vm, start, end - 1, cursor) {
1590 dst += nptes * AMDGPU_GPU_PAGE_SIZE) { 1557 struct amdgpu_bo *pt = cursor.entry->base.bo;
1591 struct amdgpu_vm_pt *entry, *parent; 1558 uint64_t pe_start;
1559 unsigned nptes;
1592 1560
1593 amdgpu_vm_get_entry(params, addr, &entry, &parent); 1561 if (!pt || cursor.level != AMDGPU_VM_PTB)
1594 if (!entry)
1595 return -ENOENT; 1562 return -ENOENT;
1596 1563
1597 if ((addr & ~mask) == (end & ~mask)) 1564 if ((cursor.pfn & ~mask) == (end & ~mask))
1598 nptes = end - addr; 1565 nptes = end - cursor.pfn;
1599 else 1566 else
1600 nptes = AMDGPU_VM_PTE_COUNT(adev) - (addr & mask); 1567 nptes = AMDGPU_VM_PTE_COUNT(adev) - (cursor.pfn & mask);
1601 1568
1602 amdgpu_vm_handle_huge_pages(params, entry, parent, 1569 amdgpu_vm_handle_huge_pages(params, cursor.entry, cursor.parent,
1603 nptes, dst, flags); 1570 nptes, dst, flags);
1604 /* We don't need to update PTEs for huge pages */ 1571 /* We don't need to update PTEs for huge pages */
1605 if (entry->huge) 1572 if (cursor.entry->huge) {
1573 dst += nptes * AMDGPU_GPU_PAGE_SIZE;
1606 continue; 1574 continue;
1575 }
1607 1576
1608 pt = entry->base.bo; 1577 pe_start = (cursor.pfn & mask) * 8;
1609 pe_start = (addr & mask) * 8;
1610 amdgpu_vm_update_func(params, pt, pe_start, dst, nptes, 1578 amdgpu_vm_update_func(params, pt, pe_start, dst, nptes,
1611 AMDGPU_GPU_PAGE_SIZE, flags); 1579 AMDGPU_GPU_PAGE_SIZE, flags);
1612 1580 dst += nptes * AMDGPU_GPU_PAGE_SIZE;
1613 } 1581 }
1614 1582
1615 return 0; 1583 return 0;