@@ -1117,8 +1117,8 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
} else {
/* allocate GART space */
- tmp = bo->mem;
- tmp.mm_node = NULL;
+ tmp = bo->mem; /* cache bo->mem */
+ bo->mem.mm_node = NULL;
placement.num_placement = 1;
placement.placement = &placements;
placement.num_busy_placement = 1;
@@ -1128,23 +1128,25 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
placements.flags = (bo->mem.placement & ~TTM_PL_MASK_MEM) |
TTM_PL_FLAG_TT;
- r = ttm_bo_mem_space(bo, &placement, &tmp, &ctx);
- if (unlikely(r))
+ r = ttm_bo_mem_space(bo, &placement, &bo->mem, &ctx);
+ if (unlikely(r)) {
+ bo->mem = tmp;
return r;
+ }
/* compute PTE flags for this buffer object */
- flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &tmp);
+ flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, &bo->mem);
/* Bind pages */
- gtt->offset = (u64)tmp.start << PAGE_SHIFT;
+ gtt->offset = (u64)bo->mem.start << PAGE_SHIFT;
r = amdgpu_ttm_gart_bind(adev, bo, flags);
if (unlikely(r)) {
+ bo->mem = tmp;
ttm_bo_mem_put(bo, &tmp);
return r;
}
- ttm_bo_mem_put(bo, &bo->mem);
- bo->mem = tmp;
+ ttm_bo_mem_put(bo, &tmp);
}
bo->offset = (bo->mem.start << PAGE_SHIFT) +