Skip to content

Commit 6b44b66

Browse files
ChristianKoenigAMDalexdeucher
authored andcommitted
drm/amdgpu: revert "use the new cursor in the VM code"
We are seeing VM page faults with this. Revert the change until the bugs are fixed. This reverts commit 94ae8dc. Signed-off-by: Christian König <[email protected]> Reviewed-by: Guchun Chen <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent c645e4b commit 6b44b66

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
#include "amdgpu_gmc.h"
3838
#include "amdgpu_xgmi.h"
3939
#include "amdgpu_dma_buf.h"
40-
#include "amdgpu_res_cursor.h"
4140

4241
/**
4342
* DOC: GPUVM
@@ -1583,7 +1582,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
15831582
* @last: last mapped entry
15841583
* @flags: flags for the entries
15851584
* @offset: offset into nodes and pages_addr
1586-
* @res: ttm_resource to map
1585+
* @nodes: array of drm_mm_nodes with the MC addresses
15871586
* @pages_addr: DMA addresses to use for mapping
15881587
* @fence: optional resulting fence
15891588
*
@@ -1598,13 +1597,13 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
15981597
bool unlocked, struct dma_resv *resv,
15991598
uint64_t start, uint64_t last,
16001599
uint64_t flags, uint64_t offset,
1601-
struct ttm_resource *res,
1600+
struct drm_mm_node *nodes,
16021601
dma_addr_t *pages_addr,
16031602
struct dma_fence **fence)
16041603
{
16051604
struct amdgpu_vm_update_params params;
1606-
struct amdgpu_res_cursor cursor;
16071605
enum amdgpu_sync_mode sync_mode;
1606+
uint64_t pfn;
16081607
int r;
16091608

16101609
memset(&params, 0, sizeof(params));
@@ -1622,6 +1621,14 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
16221621
else
16231622
sync_mode = AMDGPU_SYNC_EXPLICIT;
16241623

1624+
pfn = offset >> PAGE_SHIFT;
1625+
if (nodes) {
1626+
while (pfn >= nodes->size) {
1627+
pfn -= nodes->size;
1628+
++nodes;
1629+
}
1630+
}
1631+
16251632
amdgpu_vm_eviction_lock(vm);
16261633
if (vm->evicting) {
16271634
r = -EBUSY;
@@ -1640,17 +1647,23 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
16401647
if (r)
16411648
goto error_unlock;
16421649

1643-
amdgpu_res_first(res, offset, (last - start + 1) * AMDGPU_GPU_PAGE_SIZE,
1644-
&cursor);
1645-
while (cursor.remaining) {
1650+
do {
16461651
uint64_t tmp, num_entries, addr;
16471652

1648-
num_entries = cursor.size >> AMDGPU_GPU_PAGE_SHIFT;
1653+
1654+
num_entries = last - start + 1;
1655+
if (nodes) {
1656+
addr = nodes->start << PAGE_SHIFT;
1657+
num_entries = min((nodes->size - pfn) *
1658+
AMDGPU_GPU_PAGES_IN_CPU_PAGE, num_entries);
1659+
} else {
1660+
addr = 0;
1661+
}
1662+
16491663
if (pages_addr) {
16501664
bool contiguous = true;
16511665

16521666
if (num_entries > AMDGPU_GPU_PAGES_IN_CPU_PAGE) {
1653-
uint64_t pfn = cursor.start >> PAGE_SHIFT;
16541667
uint64_t count;
16551668

16561669
contiguous = pages_addr[pfn + 1] ==
@@ -1670,28 +1683,31 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
16701683
}
16711684

16721685
if (!contiguous) {
1673-
addr = cursor.start;
1686+
addr = pfn << PAGE_SHIFT;
16741687
params.pages_addr = pages_addr;
16751688
} else {
1676-
addr = pages_addr[cursor.start >> PAGE_SHIFT];
1689+
addr = pages_addr[pfn];
16771690
params.pages_addr = NULL;
16781691
}
16791692

16801693
} else if (flags & (AMDGPU_PTE_VALID | AMDGPU_PTE_PRT)) {
1681-
addr = bo_adev->vm_manager.vram_base_offset +
1682-
cursor.start;
1683-
} else {
1684-
addr = 0;
1694+
addr += bo_adev->vm_manager.vram_base_offset;
1695+
addr += pfn << PAGE_SHIFT;
16851696
}
16861697

16871698
tmp = start + num_entries;
16881699
r = amdgpu_vm_update_ptes(&params, start, tmp, addr, flags);
16891700
if (r)
16901701
goto error_unlock;
16911702

1692-
amdgpu_res_next(&cursor, num_entries * AMDGPU_GPU_PAGE_SIZE);
1703+
pfn += num_entries / AMDGPU_GPU_PAGES_IN_CPU_PAGE;
1704+
if (nodes && nodes->size == pfn) {
1705+
pfn = 0;
1706+
++nodes;
1707+
}
16931708
start = tmp;
1694-
};
1709+
1710+
} while (unlikely(start != last + 1));
16951711

16961712
r = vm->update_funcs->commit(&params, fence);
16971713

@@ -1720,6 +1736,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
17201736
struct amdgpu_bo_va_mapping *mapping;
17211737
dma_addr_t *pages_addr = NULL;
17221738
struct ttm_resource *mem;
1739+
struct drm_mm_node *nodes;
17231740
struct dma_fence **last_update;
17241741
struct dma_resv *resv;
17251742
uint64_t flags;
@@ -1728,6 +1745,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
17281745

17291746
if (clear || !bo) {
17301747
mem = NULL;
1748+
nodes = NULL;
17311749
resv = vm->root.base.bo->tbo.base.resv;
17321750
} else {
17331751
struct drm_gem_object *obj = &bo->tbo.base;
@@ -1742,6 +1760,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
17421760
bo = gem_to_amdgpu_bo(gobj);
17431761
}
17441762
mem = &bo->tbo.mem;
1763+
nodes = mem->mm_node;
17451764
if (mem->mem_type == TTM_PL_TT)
17461765
pages_addr = bo->tbo.ttm->dma_address;
17471766
}
@@ -1790,7 +1809,7 @@ int amdgpu_vm_bo_update(struct amdgpu_device *adev, struct amdgpu_bo_va *bo_va,
17901809
r = amdgpu_vm_bo_update_mapping(adev, bo_adev, vm, false, false,
17911810
resv, mapping->start,
17921811
mapping->last, update_flags,
1793-
mapping->offset, mem,
1812+
mapping->offset, nodes,
17941813
pages_addr, last_update);
17951814
if (r)
17961815
return r;

0 commit comments

Comments
 (0)