Commit 59276f05 authored by Nirmoy Das's avatar Nirmoy Das Committed by Alex Deucher

drm/amdgpu: switch to amdgpu_bo_vm for vm code

The subclass, amdgpu_bo_vm is intended for PT/PD BOs which are also
shadowed, so switch to amdgpu_bo_vm BO for PT/PD BOs.

v4: update amdgpu_vm_update_funcs to accept amdgpu_bo_vm.
v3: simplify code.
    check also if shadow bo exist instead of checking bo only type.
v2: squash three related patches.
Signed-off-by: default avatarNirmoy Das <nirmoy.das@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1fdc79f6
This diff is collapsed.
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
struct amdgpu_bo_va; struct amdgpu_bo_va;
struct amdgpu_job; struct amdgpu_job;
struct amdgpu_bo_list_entry; struct amdgpu_bo_list_entry;
struct amdgpu_bo_vm;
/* /*
* GPUVM handling * GPUVM handling
...@@ -239,11 +240,11 @@ struct amdgpu_vm_update_params { ...@@ -239,11 +240,11 @@ struct amdgpu_vm_update_params {
}; };
struct amdgpu_vm_update_funcs { struct amdgpu_vm_update_funcs {
int (*map_table)(struct amdgpu_bo *bo); int (*map_table)(struct amdgpu_bo_vm *bo);
int (*prepare)(struct amdgpu_vm_update_params *p, struct dma_resv *resv, int (*prepare)(struct amdgpu_vm_update_params *p, struct dma_resv *resv,
enum amdgpu_sync_mode sync_mode); enum amdgpu_sync_mode sync_mode);
int (*update)(struct amdgpu_vm_update_params *p, int (*update)(struct amdgpu_vm_update_params *p,
struct amdgpu_bo *bo, uint64_t pe, uint64_t addr, struct amdgpu_bo_vm *bo, uint64_t pe, uint64_t addr,
unsigned count, uint32_t incr, uint64_t flags); unsigned count, uint32_t incr, uint64_t flags);
int (*commit)(struct amdgpu_vm_update_params *p, int (*commit)(struct amdgpu_vm_update_params *p,
struct dma_fence **fence); struct dma_fence **fence);
......
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
* *
* @table: newly allocated or validated PD/PT * @table: newly allocated or validated PD/PT
*/ */
static int amdgpu_vm_cpu_map_table(struct amdgpu_bo *table) static int amdgpu_vm_cpu_map_table(struct amdgpu_bo_vm *table)
{ {
return amdgpu_bo_kmap(table, NULL); return amdgpu_bo_kmap(&table->bo, NULL);
} }
/** /**
...@@ -58,7 +58,7 @@ static int amdgpu_vm_cpu_prepare(struct amdgpu_vm_update_params *p, ...@@ -58,7 +58,7 @@ static int amdgpu_vm_cpu_prepare(struct amdgpu_vm_update_params *p,
* amdgpu_vm_cpu_update - helper to update page tables via CPU * amdgpu_vm_cpu_update - helper to update page tables via CPU
* *
* @p: see amdgpu_vm_update_params definition * @p: see amdgpu_vm_update_params definition
* @bo: PD/PT to update * @vmbo: PD/PT to update
* @pe: byte offset of the PDE/PTE, relative to start of PDB/PTB * @pe: byte offset of the PDE/PTE, relative to start of PDB/PTB
* @addr: dst addr to write into pe * @addr: dst addr to write into pe
* @count: number of page entries to update * @count: number of page entries to update
...@@ -68,7 +68,7 @@ static int amdgpu_vm_cpu_prepare(struct amdgpu_vm_update_params *p, ...@@ -68,7 +68,7 @@ static int amdgpu_vm_cpu_prepare(struct amdgpu_vm_update_params *p,
* Write count number of PT/PD entries directly. * Write count number of PT/PD entries directly.
*/ */
static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p, static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
struct amdgpu_bo *bo, uint64_t pe, struct amdgpu_bo_vm *vmbo, uint64_t pe,
uint64_t addr, unsigned count, uint32_t incr, uint64_t addr, unsigned count, uint32_t incr,
uint64_t flags) uint64_t flags)
{ {
...@@ -76,13 +76,13 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p, ...@@ -76,13 +76,13 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
uint64_t value; uint64_t value;
int r; int r;
if (bo->tbo.moving) { if (vmbo->bo.tbo.moving) {
r = dma_fence_wait(bo->tbo.moving, true); r = dma_fence_wait(vmbo->bo.tbo.moving, true);
if (r) if (r)
return r; return r;
} }
pe += (unsigned long)amdgpu_bo_kptr(bo); pe += (unsigned long)amdgpu_bo_kptr(&vmbo->bo);
trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags, p->immediate); trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags, p->immediate);
......
...@@ -33,11 +33,11 @@ ...@@ -33,11 +33,11 @@
* *
* @table: newly allocated or validated PD/PT * @table: newly allocated or validated PD/PT
*/ */
static int amdgpu_vm_sdma_map_table(struct amdgpu_bo *table) static int amdgpu_vm_sdma_map_table(struct amdgpu_bo_vm *table)
{ {
int r; int r;
r = amdgpu_ttm_alloc_gart(&table->tbo); r = amdgpu_ttm_alloc_gart(&table->bo.tbo);
if (r) if (r)
return r; return r;
...@@ -186,7 +186,7 @@ static void amdgpu_vm_sdma_set_ptes(struct amdgpu_vm_update_params *p, ...@@ -186,7 +186,7 @@ static void amdgpu_vm_sdma_set_ptes(struct amdgpu_vm_update_params *p,
* amdgpu_vm_sdma_update - execute VM update * amdgpu_vm_sdma_update - execute VM update
* *
* @p: see amdgpu_vm_update_params definition * @p: see amdgpu_vm_update_params definition
* @bo: PD/PT to update * @vmbo: PD/PT to update
* @pe: byte offset of the PDE/PTE, relative to start of PDB/PTB * @pe: byte offset of the PDE/PTE, relative to start of PDB/PTB
* @addr: dst addr to write into pe * @addr: dst addr to write into pe
* @count: number of page entries to update * @count: number of page entries to update
...@@ -197,10 +197,11 @@ static void amdgpu_vm_sdma_set_ptes(struct amdgpu_vm_update_params *p, ...@@ -197,10 +197,11 @@ static void amdgpu_vm_sdma_set_ptes(struct amdgpu_vm_update_params *p,
* the IB. * the IB.
*/ */
static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
struct amdgpu_bo *bo, uint64_t pe, struct amdgpu_bo_vm *vmbo, uint64_t pe,
uint64_t addr, unsigned count, uint32_t incr, uint64_t addr, unsigned count, uint32_t incr,
uint64_t flags) uint64_t flags)
{ {
struct amdgpu_bo *bo = &vmbo->bo;
enum amdgpu_ib_pool_type pool = p->immediate ? AMDGPU_IB_POOL_IMMEDIATE enum amdgpu_ib_pool_type pool = p->immediate ? AMDGPU_IB_POOL_IMMEDIATE
: AMDGPU_IB_POOL_DELAYED; : AMDGPU_IB_POOL_DELAYED;
unsigned int i, ndw, nptes; unsigned int i, ndw, nptes;
...@@ -238,8 +239,8 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, ...@@ -238,8 +239,8 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
if (!p->pages_addr) { if (!p->pages_addr) {
/* set page commands needed */ /* set page commands needed */
if (bo->shadow) if (vmbo->shadow)
amdgpu_vm_sdma_set_ptes(p, bo->shadow, pe, addr, amdgpu_vm_sdma_set_ptes(p, vmbo->shadow, pe, addr,
count, incr, flags); count, incr, flags);
amdgpu_vm_sdma_set_ptes(p, bo, pe, addr, count, amdgpu_vm_sdma_set_ptes(p, bo, pe, addr, count,
incr, flags); incr, flags);
...@@ -248,7 +249,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, ...@@ -248,7 +249,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
/* copy commands needed */ /* copy commands needed */
ndw -= p->adev->vm_manager.vm_pte_funcs->copy_pte_num_dw * ndw -= p->adev->vm_manager.vm_pte_funcs->copy_pte_num_dw *
(bo->shadow ? 2 : 1); (vmbo->shadow ? 2 : 1);
/* for padding */ /* for padding */
ndw -= 7; ndw -= 7;
...@@ -263,8 +264,8 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, ...@@ -263,8 +264,8 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,
pte[i] |= flags; pte[i] |= flags;
} }
if (bo->shadow) if (vmbo->shadow)
amdgpu_vm_sdma_copy_ptes(p, bo->shadow, pe, nptes); amdgpu_vm_sdma_copy_ptes(p, vmbo->shadow, pe, nptes);
amdgpu_vm_sdma_copy_ptes(p, bo, pe, nptes); amdgpu_vm_sdma_copy_ptes(p, bo, pe, nptes);
pe += nptes * 8; pe += nptes * 8;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment