drm/radeon: add proper support for RADEON_VM_BLOCK_SIZE v2
authorChristian König <christian.koenig@amd.com>
Sat, 10 May 2014 10:17:56 +0000 (12:17 +0200)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 2 Jun 2014 14:25:03 +0000 (10:25 -0400)
This patch makes it possible to decide how many address
bits are spend on the page directory vs the page tables.

v2: remove unintended change

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/radeon/cikd.h
drivers/gpu/drm/radeon/ni.c
drivers/gpu/drm/radeon/nid.h
drivers/gpu/drm/radeon/radeon_vm.c
drivers/gpu/drm/radeon/si.c
drivers/gpu/drm/radeon/sid.h

index dbb5b2e17c7cdb0ec461f16c83f96421eb8d1051..8d0f1774efbc3f417d45fc2f32a717f0c0548731 100644 (file)
@@ -5378,6 +5378,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev)
               (u32)(rdev->dummy_page.addr >> 12));
        WREG32(VM_CONTEXT1_CNTL2, 4);
        WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(1) |
+                               PAGE_TABLE_BLOCK_SIZE(RADEON_VM_BLOCK_SIZE - 9) |
                                RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT |
                                RANGE_PROTECTION_FAULT_ENABLE_DEFAULT |
                                DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT |
index 213873270d5f6b705974aa57867f0dff47b7901a..0b27ea08c299d2eab3ba5ef7a3f27cc149558a6d 100644 (file)
 #define                READ_PROTECTION_FAULT_ENABLE_DEFAULT            (1 << 16)
 #define                WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT         (1 << 18)
 #define                WRITE_PROTECTION_FAULT_ENABLE_DEFAULT           (1 << 19)
+#define                PAGE_TABLE_BLOCK_SIZE(x)                        (((x) & 0xF) << 24)
 #define VM_CONTEXT1_CNTL                               0x1414
 #define VM_CONTEXT0_CNTL2                              0x1430
 #define VM_CONTEXT1_CNTL2                              0x1434
index 5e8db9bccba15c877a4d39f5a940620492a000da..1d3209ffbbdc354af7666a92fb3faf3b89db6b0c 100644 (file)
@@ -1268,6 +1268,7 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev)
               (u32)(rdev->dummy_page.addr >> 12));
        WREG32(VM_CONTEXT1_CNTL2, 4);
        WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(1) |
+                               PAGE_TABLE_BLOCK_SIZE(RADEON_VM_BLOCK_SIZE - 9) |
                                RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT |
                                RANGE_PROTECTION_FAULT_ENABLE_DEFAULT |
                                DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT |
index d996033c243ee14f4509220a707edf50f9dbe489..2e12e4d69253fde453c3fb648566c0224bfe06bc 100644 (file)
 #define                READ_PROTECTION_FAULT_ENABLE_DEFAULT            (1 << 16)
 #define                WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT         (1 << 18)
 #define                WRITE_PROTECTION_FAULT_ENABLE_DEFAULT           (1 << 19)
+#define                PAGE_TABLE_BLOCK_SIZE(x)                        (((x) & 0xF) << 24)
 #define VM_CONTEXT1_CNTL                               0x1414
 #define VM_CONTEXT0_CNTL2                              0x1430
 #define VM_CONTEXT1_CNTL2                              0x1434
index f8d5b65932e5e5a2d90da84d9c7df66a8e3cdb56..a128a4fd64b371178ecf345e505d7650a87c010c 100644 (file)
@@ -964,6 +964,8 @@ void radeon_vm_bo_invalidate(struct radeon_device *rdev,
  */
 int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
 {
+       const unsigned align = min(RADEON_VM_PTB_ALIGN_SIZE,
+               RADEON_VM_PTE_COUNT * 8);
        unsigned pd_size, pd_entries, pts_size;
        int r;
 
@@ -985,7 +987,7 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm)
                return -ENOMEM;
        }
 
-       r = radeon_bo_create(rdev, pd_size, RADEON_VM_PTB_ALIGN_SIZE, false,
+       r = radeon_bo_create(rdev, pd_size, align, false,
                             RADEON_GEM_DOMAIN_VRAM, NULL,
                             &vm->page_directory);
        if (r)
index 22ecbc07e9a67f2c14f9b283002900fbff257395..9739d71cd0a2ccbe21958cc92157ed42b79bfd9f 100644 (file)
@@ -4095,6 +4095,7 @@ static int si_pcie_gart_enable(struct radeon_device *rdev)
               (u32)(rdev->dummy_page.addr >> 12));
        WREG32(VM_CONTEXT1_CNTL2, 4);
        WREG32(VM_CONTEXT1_CNTL, ENABLE_CONTEXT | PAGE_TABLE_DEPTH(1) |
+                               PAGE_TABLE_BLOCK_SIZE(RADEON_VM_BLOCK_SIZE - 9) |
                                RANGE_PROTECTION_FAULT_ENABLE_INTERRUPT |
                                RANGE_PROTECTION_FAULT_ENABLE_DEFAULT |
                                DUMMY_PAGE_PROTECTION_FAULT_ENABLE_INTERRUPT |
index 683532f849311d1ca19de3daccb168b368d4c0b5..da8f8674a55214a039ab05fa2ca901345beea3b5 100644 (file)
 #define                READ_PROTECTION_FAULT_ENABLE_DEFAULT            (1 << 16)
 #define                WRITE_PROTECTION_FAULT_ENABLE_INTERRUPT         (1 << 18)
 #define                WRITE_PROTECTION_FAULT_ENABLE_DEFAULT           (1 << 19)
+#define                PAGE_TABLE_BLOCK_SIZE(x)                        (((x) & 0xF) << 24)
 #define VM_CONTEXT1_CNTL                               0x1414
 #define VM_CONTEXT0_CNTL2                              0x1430
 #define VM_CONTEXT1_CNTL2                              0x1434