* XXX: This is in the VM bind data path, likely should calculate this once and
* store, with a recalculation if the BO is moved.
*/
-static uint64_t vram_region_io_offset(struct xe_bo *bo)
+uint64_t vram_region_io_offset(struct ttm_resource *res)
{
- struct xe_device *xe = xe_bo_device(bo);
- struct xe_gt *gt = mem_type_to_gt(xe, bo->ttm.resource->mem_type);
+ struct xe_device *xe = ttm_to_xe_device(res->bo->bdev);
+ struct xe_gt *gt = mem_type_to_gt(xe, res->mem_type);
- if (bo->ttm.resource->mem_type == XE_PL_STOLEN)
+ if (res->mem_type == XE_PL_STOLEN)
return xe_ttm_stolen_gpu_offset(xe);
return gt->mem.vram.io_start - xe->mem.vram.io_start;
XE_BUG_ON(!(place->flags & TTM_PL_FLAG_CONTIGUOUS));
place->fpfn = (xe_bo_addr(bo, 0, PAGE_SIZE, &vram) -
- vram_region_io_offset(bo)) >> PAGE_SHIFT;
+ vram_region_io_offset(bo->ttm.resource)) >> PAGE_SHIFT;
place->lpfn = place->fpfn + (bo->size >> PAGE_SHIFT);
spin_lock(&xe->pinned.lock);
xe_res_first(bo->ttm.resource, page << PAGE_SHIFT,
page_size, &cur);
- return cur.start + offset + vram_region_io_offset(bo);
+ return cur.start + offset + vram_region_io_offset(bo->ttm.resource);
}
}
static u32 pte_update_size(struct xe_migrate *m,
bool is_vram,
+ struct ttm_resource *res,
struct xe_res_cursor *cur,
u64 *L0, u64 *L0_ofs, u32 *L0_pt,
u32 cmd_size, u32 pt_ofs, u32 avail_pts)
cmds += cmd_size;
} else {
/* Offset into identity map. */
- *L0_ofs = xe_migrate_vram_ofs(cur->start);
+ *L0_ofs = xe_migrate_vram_ofs(cur->start +
+ vram_region_io_offset(res));
cmds += cmd_size;
}
addr |= GEN12_PTE_PS64;
}
+ addr += vram_region_io_offset(bo->ttm.resource);
addr |= GEN12_PPGTT_PTE_LM;
}
addr |= PPAT_CACHED | GEN8_PAGE_PRESENT | GEN8_PAGE_RW;
src_L0 = min(src_L0, dst_L0);
- batch_size += pte_update_size(m, src_is_vram, &src_it, &src_L0,
+ batch_size += pte_update_size(m, src_is_vram, src, &src_it, &src_L0,
&src_L0_ofs, &src_L0_pt, 0, 0,
NUM_PT_PER_BLIT);
- batch_size += pte_update_size(m, dst_is_vram, &dst_it, &src_L0,
+ batch_size += pte_update_size(m, dst_is_vram, dst, &dst_it, &src_L0,
&dst_L0_ofs, &dst_L0_pt, 0,
NUM_PT_PER_BLIT, NUM_PT_PER_BLIT);
if (copy_system_ccs) {
ccs_size = xe_device_ccs_bytes(xe, src_L0);
- batch_size += pte_update_size(m, false, &ccs_it, &ccs_size,
+ batch_size += pte_update_size(m, false, NULL, &ccs_it, &ccs_size,
&ccs_ofs, &ccs_pt, 0,
2 * NUM_PT_PER_BLIT,
NUM_PT_PER_BLIT);
/* Calculate final sizes and batch size.. */
batch_size = 2 +
- pte_update_size(m, clear_vram, &src_it,
+ pte_update_size(m, clear_vram, src, &src_it,
&clear_L0, &clear_L0_ofs, &clear_L0_pt,
emit_clear_cmd_len(xe), 0,
NUM_PT_PER_BLIT);