aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2018-06-21 05:27:46 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-06-22 15:57:17 -0400
commit38e624a18f9a05b8c894409be6b14709a7206c7c (patch)
tree0664fa0973a32fdc4559631eb2b906d5e0e707f9 /drivers/gpu
parentfe2a19652918a5247418aed48a247414a5e45fe2 (diff)
drm/amdgpu: GPU vs CPU page size fixes in amdgpu_vm_bo_split_mapping
start / last / max_entries are numbers of GPU pages, pfn / count are numbers of CPU pages. Convert between them accordingly. Fixes badness on systems with > 4K page size. Cc: stable@vger.kernel.org Bugzilla: https://bugs.freedesktop.org/106258 Reported-by: Matt Corallo <freedesktop@bluematt.me> Tested-by: foxbat@ruin.net Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index b0eb2f537392..edf16b2b957a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -1463,7 +1463,9 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
1463 uint64_t count; 1463 uint64_t count;
1464 1464
1465 max_entries = min(max_entries, 16ull * 1024ull); 1465 max_entries = min(max_entries, 16ull * 1024ull);
1466 for (count = 1; count < max_entries; ++count) { 1466 for (count = 1;
1467 count < max_entries / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
1468 ++count) {
1467 uint64_t idx = pfn + count; 1469 uint64_t idx = pfn + count;
1468 1470
1469 if (pages_addr[idx] != 1471 if (pages_addr[idx] !=
@@ -1476,7 +1478,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
1476 dma_addr = pages_addr; 1478 dma_addr = pages_addr;
1477 } else { 1479 } else {
1478 addr = pages_addr[pfn]; 1480 addr = pages_addr[pfn];
1479 max_entries = count; 1481 max_entries = count * (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
1480 } 1482 }
1481 1483
1482 } else if (flags & AMDGPU_PTE_VALID) { 1484 } else if (flags & AMDGPU_PTE_VALID) {
@@ -1491,7 +1493,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
1491 if (r) 1493 if (r)
1492 return r; 1494 return r;
1493 1495
1494 pfn += last - start + 1; 1496 pfn += (last - start + 1) / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
1495 if (nodes && nodes->size == pfn) { 1497 if (nodes && nodes->size == pfn) {
1496 pfn = 0; 1498 pfn = 0;
1497 ++nodes; 1499 ++nodes;