aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-11-30 07:26:07 -0500
committerAlex Deucher <alexander.deucher@amd.com>2016-02-10 14:17:04 -0500
commitb07c9d2a73f4b956ee141005e7dfbada4e51c52c (patch)
tree862dad43a0ae4ed8a39149430894fdf6eb2071ef /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
parent599f434817c5cdf1af9fd9e7d4bef69bd0c02796 (diff)
drm/amdgpu: move more logic into amdgpu_vm_map_gart v3
No need to duplicate that code over and over again. Also stop using the flags to determine if we need to map the addresses. v2: constify the pages_addr v3: rebased, fix typo in commit message 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>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index dfbcc64ef9fa..ae3b275f2a38 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -299,9 +299,14 @@ static void amdgpu_vm_update_pages(struct amdgpu_device *adev,
299 uint64_t src = adev->gart.table_addr + (addr >> 12) * 8; 299 uint64_t src = adev->gart.table_addr + (addr >> 12) * 8;
300 amdgpu_vm_copy_pte(adev, ib, pe, src, count); 300 amdgpu_vm_copy_pte(adev, ib, pe, src, count);
301 301
302 } else if ((flags & AMDGPU_PTE_SYSTEM) || (count < 3)) { 302 } else if (flags & AMDGPU_PTE_SYSTEM) {
303 amdgpu_vm_write_pte(adev, ib, pe, addr, 303 dma_addr_t *pages_addr = adev->gart.pages_addr;
304 count, incr, flags); 304 amdgpu_vm_write_pte(adev, ib, pages_addr, pe, addr,
305 count, incr, flags);
306
307 } else if (count < 3) {
308 amdgpu_vm_write_pte(adev, ib, NULL, pe, addr,
309 count, incr, flags);
305 310
306 } else { 311 } else {
307 amdgpu_vm_set_pte_pde(adev, ib, pe, addr, 312 amdgpu_vm_set_pte_pde(adev, ib, pe, addr,
@@ -378,24 +383,31 @@ error:
378} 383}
379 384
380/** 385/**
381 * amdgpu_vm_map_gart - get the physical address of a gart page 386 * amdgpu_vm_map_gart - Resolve gart mapping of addr
382 * 387 *
383 * @adev: amdgpu_device pointer 388 * @pages_addr: optional DMA address to use for lookup
384 * @addr: the unmapped addr 389 * @addr: the unmapped addr
385 * 390 *
386 * Look up the physical address of the page that the pte resolves 391 * Look up the physical address of the page that the pte resolves
387 * to (cayman+). 392 * to and return the pointer for the page table entry.
388 * Returns the physical address of the page.
389 */ 393 */
390uint64_t amdgpu_vm_map_gart(struct amdgpu_device *adev, uint64_t addr) 394uint64_t amdgpu_vm_map_gart(const dma_addr_t *pages_addr, uint64_t addr)
391{ 395{
392 uint64_t result; 396 uint64_t result;
393 397
394 /* page table offset */ 398 if (pages_addr) {
395 result = adev->gart.pages_addr[addr >> PAGE_SHIFT]; 399 /* page table offset */
400 result = pages_addr[addr >> PAGE_SHIFT];
401
402 /* in case cpu page size != gpu page size*/
403 result |= addr & (~PAGE_MASK);
404
405 } else {
406 /* No mapping required */
407 result = addr;
408 }
396 409
397 /* in case cpu page size != gpu page size*/ 410 result &= 0xFFFFFFFFFFFFF000ULL;
398 result |= addr & (~PAGE_MASK);
399 411
400 return result; 412 return result;
401} 413}