drm/radeon: align VM PTBs (Page Table Blocks) to 32K
authorAlex Deucher <alexander.deucher@amd.com>
Fri, 12 Jul 2013 19:56:02 +0000 (15:56 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 15 Jul 2013 13:37:10 +0000 (09:37 -0400)
Covers requirements of all current asics.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
drivers/gpu/drm/radeon/radeon.h
drivers/gpu/drm/radeon/radeon_gart.c

index 82e8e36064e37377a5abdac00457e58ca085e789..001081757895dd9df9f693ca2f3878409cef45f0 100644 (file)
@@ -784,6 +784,11 @@ struct radeon_mec {
 /* number of entries in page table */
 #define RADEON_VM_PTE_COUNT (1 << RADEON_VM_BLOCK_SIZE)
 
+/* PTBs (Page Table Blocks) need to be aligned to 32K */
+#define RADEON_VM_PTB_ALIGN_SIZE   32768
+#define RADEON_VM_PTB_ALIGN_MASK (RADEON_VM_PTB_ALIGN_SIZE - 1)
+#define RADEON_VM_PTB_ALIGN(a) (((a) + RADEON_VM_PTB_ALIGN_MASK) & ~RADEON_VM_PTB_ALIGN_MASK)
+
 struct radeon_vm {
        struct list_head                list;
        struct list_head                va;
index 5ce190b8bd1f148ff0fb7deac9ba873d1ef2422d..d9d31a3832769d0363b2d0a728f9e3d7a76add98 100644 (file)
@@ -466,8 +466,8 @@ int radeon_vm_manager_init(struct radeon_device *rdev)
                size += rdev->vm_manager.max_pfn * 8;
                size *= 2;
                r = radeon_sa_bo_manager_init(rdev, &rdev->vm_manager.sa_manager,
-                                             RADEON_GPU_PAGE_ALIGN(size),
-                                             RADEON_GPU_PAGE_SIZE,
+                                             RADEON_VM_PTB_ALIGN(size),
+                                             RADEON_VM_PTB_ALIGN_SIZE,
                                              RADEON_GEM_DOMAIN_VRAM);
                if (r) {
                        dev_err(rdev->dev, "failed to allocate vm bo (%dKB)\n",
@@ -621,10 +621,10 @@ int radeon_vm_alloc_pt(struct radeon_device *rdev, struct radeon_vm *vm)
        }
 
 retry:
-       pd_size = RADEON_GPU_PAGE_ALIGN(radeon_vm_directory_size(rdev));
+       pd_size = RADEON_VM_PTB_ALIGN(radeon_vm_directory_size(rdev));
        r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
                             &vm->page_directory, pd_size,
-                            RADEON_GPU_PAGE_SIZE, false);
+                            RADEON_VM_PTB_ALIGN_SIZE, false);
        if (r == -ENOMEM) {
                r = radeon_vm_evict(rdev, vm);
                if (r)
@@ -953,8 +953,8 @@ static int radeon_vm_update_pdes(struct radeon_device *rdev,
 retry:
                r = radeon_sa_bo_new(rdev, &rdev->vm_manager.sa_manager,
                                     &vm->page_tables[pt_idx],
-                                    RADEON_VM_PTE_COUNT * 8,
-                                    RADEON_GPU_PAGE_SIZE, false);
+                                    RADEON_VM_PTB_ALIGN(RADEON_VM_PTE_COUNT * 8),
+                                    RADEON_VM_PTB_ALIGN_SIZE, false);
 
                if (r == -ENOMEM) {
                        r = radeon_vm_evict(rdev, vm);