diff options
author | Christian König <christian.koenig@amd.com> | 2017-11-27 08:01:51 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-06 12:48:28 -0500 |
commit | 507831473f126e389039611b309bb5718e38c043 (patch) | |
tree | 436250a93f708a839f83f1100f926a4add2c34e3 | |
parent | 722570435bb066c17ff42bb40fb0bbe581b2eba5 (diff) |
drm/amdgpu: fix VM PD addr shift
The block size only affects the leave nodes, everything else is fixed.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c index 122379dfc7d8..f1e541e9b514 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | |||
@@ -139,6 +139,24 @@ struct amdgpu_prt_cb { | |||
139 | }; | 139 | }; |
140 | 140 | ||
141 | /** | 141 | /** |
142 | * amdgpu_vm_level_shift - return the addr shift for each level | ||
143 | * | ||
144 | * @adev: amdgpu_device pointer | ||
145 | * | ||
146 | * Returns the number of bits the pfn needs to be right shifted for a level. | ||
147 | */ | ||
148 | static unsigned amdgpu_vm_level_shift(struct amdgpu_device *adev, | ||
149 | unsigned level) | ||
150 | { | ||
151 | if (level != adev->vm_manager.num_level) | ||
152 | return 9 * (adev->vm_manager.num_level - level - 1) + | ||
153 | adev->vm_manager.block_size; | ||
154 | else | ||
155 | /* For the page tables on the leaves */ | ||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | /** | ||
142 | * amdgpu_vm_num_entries - return the number of entries in a PD/PT | 160 | * amdgpu_vm_num_entries - return the number of entries in a PD/PT |
143 | * | 161 | * |
144 | * @adev: amdgpu_device pointer | 162 | * @adev: amdgpu_device pointer |
@@ -288,8 +306,7 @@ static int amdgpu_vm_alloc_levels(struct amdgpu_device *adev, | |||
288 | uint64_t saddr, uint64_t eaddr, | 306 | uint64_t saddr, uint64_t eaddr, |
289 | unsigned level) | 307 | unsigned level) |
290 | { | 308 | { |
291 | unsigned shift = (adev->vm_manager.num_level - level) * | 309 | unsigned shift = amdgpu_vm_level_shift(adev, level); |
292 | adev->vm_manager.block_size; | ||
293 | unsigned pt_idx, from, to; | 310 | unsigned pt_idx, from, to; |
294 | int r; | 311 | int r; |
295 | u64 flags; | 312 | u64 flags; |
@@ -1302,18 +1319,19 @@ void amdgpu_vm_get_entry(struct amdgpu_pte_update_params *p, uint64_t addr, | |||
1302 | struct amdgpu_vm_pt **entry, | 1319 | struct amdgpu_vm_pt **entry, |
1303 | struct amdgpu_vm_pt **parent) | 1320 | struct amdgpu_vm_pt **parent) |
1304 | { | 1321 | { |
1305 | unsigned idx, level = p->adev->vm_manager.num_level; | 1322 | unsigned level = 0; |
1306 | 1323 | ||
1307 | *parent = NULL; | 1324 | *parent = NULL; |
1308 | *entry = &p->vm->root; | 1325 | *entry = &p->vm->root; |
1309 | while ((*entry)->entries) { | 1326 | while ((*entry)->entries) { |
1310 | idx = addr >> (p->adev->vm_manager.block_size * level--); | 1327 | unsigned idx = addr >> amdgpu_vm_level_shift(p->adev, level++); |
1328 | |||
1311 | idx %= amdgpu_bo_size((*entry)->base.bo) / 8; | 1329 | idx %= amdgpu_bo_size((*entry)->base.bo) / 8; |
1312 | *parent = *entry; | 1330 | *parent = *entry; |
1313 | *entry = &(*entry)->entries[idx]; | 1331 | *entry = &(*entry)->entries[idx]; |
1314 | } | 1332 | } |
1315 | 1333 | ||
1316 | if (level) | 1334 | if (level != p->adev->vm_manager.num_level) |
1317 | *entry = NULL; | 1335 | *entry = NULL; |
1318 | } | 1336 | } |
1319 | 1337 | ||