drm/radeon: use inline functions to calc sa_bo addr

Instead of hacking the calculation multiple times.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
Christian König 2012-05-09 15:34:49 +02:00 committed by Dave Airlie
parent 8a47cc9ec1
commit dd8bea2111
4 changed files with 17 additions and 12 deletions

View file

@ -404,10 +404,8 @@ int radeon_vm_bind(struct radeon_device *rdev, struct radeon_vm *vm)
radeon_vm_unbind(rdev, vm_evict); radeon_vm_unbind(rdev, vm_evict);
goto retry; goto retry;
} }
vm->pt = rdev->vm_manager.sa_manager.cpu_ptr; vm->pt = radeon_sa_bo_cpu_addr(&vm->sa_bo);
vm->pt += (vm->sa_bo.offset >> 3); vm->pt_gpu_addr = radeon_sa_bo_gpu_addr(&vm->sa_bo);
vm->pt_gpu_addr = rdev->vm_manager.sa_manager.gpu_addr;
vm->pt_gpu_addr += vm->sa_bo.offset;
memset(vm->pt, 0, RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8)); memset(vm->pt, 0, RADEON_GPU_PAGE_ALIGN(vm->last_pfn * 8));
retry_id: retry_id:

View file

@ -146,6 +146,17 @@ extern struct radeon_bo_va *radeon_bo_va(struct radeon_bo *rbo,
/* /*
* sub allocation * sub allocation
*/ */
static inline uint64_t radeon_sa_bo_gpu_addr(struct radeon_sa_bo *sa_bo)
{
return sa_bo->manager->gpu_addr + sa_bo->offset;
}
static inline void * radeon_sa_bo_cpu_addr(struct radeon_sa_bo *sa_bo)
{
return sa_bo->manager->cpu_ptr + sa_bo->offset;
}
extern int radeon_sa_bo_manager_init(struct radeon_device *rdev, extern int radeon_sa_bo_manager_init(struct radeon_device *rdev,
struct radeon_sa_manager *sa_manager, struct radeon_sa_manager *sa_manager,
unsigned size, u32 domain); unsigned size, u32 domain);

View file

@ -127,10 +127,8 @@ int radeon_ib_get(struct radeon_device *rdev, int ring,
size, 256); size, 256);
if (!r) { if (!r) {
*ib = &rdev->ib_pool.ibs[idx]; *ib = &rdev->ib_pool.ibs[idx];
(*ib)->ptr = rdev->ib_pool.sa_manager.cpu_ptr; (*ib)->ptr = radeon_sa_bo_cpu_addr(&(*ib)->sa_bo);
(*ib)->ptr += ((*ib)->sa_bo.offset >> 2); (*ib)->gpu_addr = radeon_sa_bo_gpu_addr(&(*ib)->sa_bo);
(*ib)->gpu_addr = rdev->ib_pool.sa_manager.gpu_addr;
(*ib)->gpu_addr += (*ib)->sa_bo.offset;
(*ib)->fence = fence; (*ib)->fence = fence;
(*ib)->vm_id = 0; (*ib)->vm_id = 0;
(*ib)->is_const_ib = false; (*ib)->is_const_ib = false;

View file

@ -53,10 +53,8 @@ static int radeon_semaphore_add_bo(struct radeon_device *rdev)
kfree(bo); kfree(bo);
return r; return r;
} }
gpu_addr = rdev->ib_pool.sa_manager.gpu_addr; gpu_addr = radeon_sa_bo_gpu_addr(&bo->ib->sa_bo);
gpu_addr += bo->ib->sa_bo.offset; cpu_ptr = radeon_sa_bo_cpu_addr(&bo->ib->sa_bo);
cpu_ptr = rdev->ib_pool.sa_manager.cpu_ptr;
cpu_ptr += (bo->ib->sa_bo.offset >> 2);
for (i = 0; i < (RADEON_SEMAPHORE_BO_SIZE/8); i++) { for (i = 0; i < (RADEON_SEMAPHORE_BO_SIZE/8); i++) {
bo->semaphores[i].gpu_addr = gpu_addr; bo->semaphores[i].gpu_addr = gpu_addr;
bo->semaphores[i].cpu_ptr = cpu_ptr; bo->semaphores[i].cpu_ptr = cpu_ptr;