drm/amdgpu: move VM table mapping into the backend as well
Subsystems (2)
PATCH 1/2 drm/amdgpu: move VM table mapping into the backend as well
Clean that up further and also fix another case where the BO wasn't kmapped for CPU based updates.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 31 ++++----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 11 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 20 +++++++++++++ 4 files changed, 37 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -26
@@ -660,17 +660,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (bo->tbo.type != ttm_bo_type_kernel) {amdgpu_vm_bo_moved (bo_base); }else { -if (vm->use_cpu_for_update) - r =amdgpu_bo_kmap (bo,NULL ); -else - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (r) -break ; -if (bo->shadow) { - r =amdgpu_ttm_alloc_gart (&bo->shadow->tbo); -if (r) -break ; - } + vm->update_funcs->map_table (bo);amdgpu_vm_bo_relocated (bo_base); } }
@@ -752,22 +742,17 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (r) -return r; -if (bo->shadow) { r =ttm_bo_validate (&bo->shadow->tbo, &bo->shadow->placement, &ctx);if (r)return r; - - r =amdgpu_ttm_alloc_gart (&bo->shadow->tbo); -if (r) -return r; - } + r = vm->update_funcs->map_table (bo); +if (r) +return r; +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;
@@ -878,12 +863,6 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,if (r)return r; -if (vm->use_cpu_for_update) { - r =amdgpu_bo_kmap (pt,NULL ); -if (r) - goto error_free_pt; - } -/* Keep a reference to the root directory to avoid * freeing them up in the wrong order. */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -1
@@ -215,7 +215,7 @@ struct amdgpu_vm_update_params { };struct amdgpu_vm_update_funcs { - +int (*map_table)(struct amdgpu_bo *bo);int (*prepare)(struct amdgpu_vm_update_params *p,void * owner,struct dma_fence *exclusive); int (*update)(struct amdgpu_vm_update_params *p,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +11 -0
@@ -24,6 +24,16 @@#include "amdgpu_object.h" #include "amdgpu_trace.h" +/** +* amdgpu_vm_cpu_map_table - make sure new PDs/PTs are kmapped +* +* @table: newly allocated or validated PD/PT +*/ +static int amdgpu_vm_cpu_map_table (struct amdgpu_bo *table) +{ +return amdgpu_bo_kmap (table,NULL ); +} +/** * amdgpu_vm_cpu_prepare - prepare page table update with the CPU *
@@ -110,6 +120,7 @@ static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p, }const struct amdgpu_vm_update_funcs amdgpu_vm_cpu_funcs = { + .map_table = amdgpu_vm_cpu_map_table, .prepare = amdgpu_vm_cpu_prepare, .update = amdgpu_vm_cpu_update, .commit = amdgpu_vm_cpu_commit
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +20 -0
@@ -28,6 +28,25 @@#define AMDGPU_VM_SDMA_MIN_NUM_DW 256u#define AMDGPU_VM_SDMA_MAX_NUM_DW (16u * 1024u) +/** +* amdgpu_vm_sdma_map_table - make sure new PDs/PTs are GTT mapped +* +* @table: newly allocated or validated PD/PT +*/ +static int amdgpu_vm_sdma_map_table (struct amdgpu_bo *table) +{ +int r; + + r =amdgpu_ttm_alloc_gart (&table->tbo); +if (r) +return r; + +if (table->shadow) + r =amdgpu_ttm_alloc_gart (&table->shadow->tbo); + +return r; +} +/** * amdgpu_vm_sdma_prepare - prepare SDMA command submission *
@@ -242,6 +261,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, }const struct amdgpu_vm_update_funcs amdgpu_vm_sdma_funcs = { + .map_table = amdgpu_vm_sdma_map_table, .prepare = amdgpu_vm_sdma_prepare, .update = amdgpu_vm_sdma_update, .commit = amdgpu_vm_sdma_commit
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20190325122246.10105-1-christian.koenig-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: drop the ib from the VM update parameters
It is redundant with the job pointer.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 5 ----- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 24 +++++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -5
@@ -203,11 +203,6 @@ struct amdgpu_vm_update_params {*/ struct amdgpu_job *job; -/** -* @ib: indirect buffer to fill with commands -*/ -struct amdgpu_ib *ib; -/** * @num_dw_left: number of dw left for the IB */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +13 -11
@@ -78,7 +78,6 @@ static int amdgpu_vm_sdma_prepare(struct amdgpu_vm_update_params *p,return r; p->num_dw_left = ndw; - p->ib = &p->job->ibs[0 ];return 0 ; }
@@ -95,15 +94,16 @@ static int amdgpu_vm_sdma_commit(struct amdgpu_vm_update_params *p, struct dma_fence **fence) {struct amdgpu_bo *root = p->vm->root.base.bo; +struct amdgpu_ib *ib = p->job->ibs;struct amdgpu_ring *ring;struct dma_fence *f;int r; ring = container_of(p->vm->entity.rq->sched, struct amdgpu_ring, sched); -WARN_ON (p->ib->length_dw ==0 ); -amdgpu_ring_pad_ib (ring, p->ib); -WARN_ON (p->ib->length_dw > p->num_dw_left); +WARN_ON (ib->length_dw ==0 ); +amdgpu_ring_pad_ib (ring, ib); +WARN_ON (ib->length_dw > p->num_dw_left); r =amdgpu_job_submit (p->job, &p->vm->entity,AMDGPU_FENCE_OWNER_VM , &f);if (r)
@@ -135,14 +135,15 @@ static void amdgpu_vm_sdma_copy_ptes(struct amdgpu_vm_update_params *p, struct amdgpu_bo *bo, uint64_t pe, unsigned count) { - uint64_t src = p->ib->gpu_addr; + struct amdgpu_ib *ib = p->job->ibs; +uint64_t src = ib->gpu_addr; src += p->num_dw_left *4 ; pe +=amdgpu_bo_gpu_offset (bo);trace_amdgpu_vm_copy_ptes (pe, src, count); -amdgpu_vm_copy_pte (p->adev, p->ib, pe, src, count); +amdgpu_vm_copy_pte (p->adev, ib, pe, src, count); }/**
@@ -164,13 +165,15 @@ static void amdgpu_vm_sdma_set_ptes(struct amdgpu_vm_update_params *p, uint64_t addr, unsigned count, uint32_t incr, uint64_t flags) { + struct amdgpu_ib *ib = p->job->ibs; + pe +=amdgpu_bo_gpu_offset (bo);trace_amdgpu_vm_set_ptes (pe, addr, count, incr, flags);if (count <3 ) { -amdgpu_vm_write_pte (p->adev, p->ib, pe, addr | flags, +amdgpu_vm_write_pte (p->adev, ib, pe, addr | flags, count, incr); }else { -amdgpu_vm_set_pte_pde (p->adev, p->ib, pe, addr, +amdgpu_vm_set_pte_pde (p->adev, ib, pe, addr, count, incr, flags); } }
@@ -200,7 +203,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, do { ndw = p->num_dw_left; - ndw -= p->ib->length_dw; + ndw -= p->job->ibs->length_dw; if (ndw < 32) { r = amdgpu_vm_sdma_commit(p, NULL);
@@ -219,7 +222,6 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,return r; p->num_dw_left = ndw; - p->ib = &p->job->ibs[0 ]; }if (!p->pages_addr) {
@@ -243,7 +245,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p,/* Put the PTEs at the end of the IB. */ p->num_dw_left -= nptes *2 ; - pte = (uint64_t *)&(p->ib->ptr[p->num_dw_left]); + pte = (uint64_t *)&(p->job->ibs->ptr[p->num_dw_left]);for (i =0 ; i < nptes; ++i, addr += incr) { pte[i] =amdgpu_vm_map_gart (p->pages_addr, addr); pte[i] |= flags;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
The series is Reviewed-by: Felix Kuehling <[email protected]>
Quoted 147 lines · Christian König
Clean that up further and also fix another case where the BO wasn't kmapped for CPU based updates.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 31 ++++----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 11 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 20 +++++++++++++ 4 files changed, 37 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5
-26@@ -660,17 +660,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (bo->tbo.type != ttm_bo_type_kernel) {amdgpu_vm_bo_moved (bo_base); }else { -if (vm->use_cpu_for_update) - r =amdgpu_bo_kmap (bo,NULL ); -else - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (r) -break ; -if (bo->shadow) { - r =amdgpu_ttm_alloc_gart (&bo->shadow->tbo); -if (r) -break ; - } + vm->update_funcs->map_table (bo);amdgpu_vm_bo_relocated (bo_base); } }@@ -752,22 +742,17 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (r) -return r; -if (bo->shadow) { r =ttm_bo_validate (&bo->shadow->tbo, &bo->shadow->placement, &ctx);if (r)return r; - - r =amdgpu_ttm_alloc_gart (&bo->shadow->tbo); -if (r) -return r; - } + r = vm->update_funcs->map_table (bo); +if (r) +return r; +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;@@ -878,12 +863,6 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,if (r)return r; -if (vm->use_cpu_for_update) { - r =amdgpu_bo_kmap (pt,NULL ); -if (r) - goto error_free_pt; - } -/* Keep a reference to the root directory to avoid * freeing them up in the wrong order. */ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1
-1@@ -215,7 +215,7 @@ struct amdgpu_vm_update_params { };struct amdgpu_vm_update_funcs { - +int (*map_table)(struct amdgpu_bo *bo);int (*prepare)(struct amdgpu_vm_update_params *p,void * owner,struct dma_fence *exclusive); int (*update)(struct amdgpu_vm_update_params *p,drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +11
-0@@ -24,6 +24,16 @@#include "amdgpu_object.h" #include "amdgpu_trace.h" +/** +* amdgpu_vm_cpu_map_table - make sure new PDs/PTs are kmapped +* +* @table: newly allocated or validated PD/PT +*/ +static int amdgpu_vm_cpu_map_table (struct amdgpu_bo *table) +{ +return amdgpu_bo_kmap (table,NULL ); +} +/** * amdgpu_vm_cpu_prepare - prepare page table update with the CPU * @@ -110,6 +120,7 @@ static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p, }const struct amdgpu_vm_update_funcs amdgpu_vm_cpu_funcs = { + .map_table = amdgpu_vm_cpu_map_table, .prepare = amdgpu_vm_cpu_prepare, .update = amdgpu_vm_cpu_update, .commit = amdgpu_vm_cpu_commitdrivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +19
-0@@ -28,6 +28,25 @@#define AMDGPU_VM_SDMA_MIN_NUM_DW 256u#define AMDGPU_VM_SDMA_MAX_NUM_DW (16u * 1024u) +/** +* amdgpu_vm_sdma_map_table - make sure new PDs/PTs are GTT mapped +* +* @table: newly allocated or validated PD/PT +*/ +static int amdgpu_vm_sdma_map_table (struct amdgpu_bo *table) +{ +int r; + + r =amdgpu_ttm_alloc_gart (&table->tbo); +if (r) +return r; + +if (table->shadow) + r =amdgpu_ttm_alloc_gart (&table->shadow->tbo); + +return r; +} +/** * amdgpu_vm_sdma_prepare - prepare SDMA command submission *
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, · line 267
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +1
-0@@ -242,6 +261,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, }const struct amdgpu_vm_update_funcs amdgpu_vm_sdma_funcs = { + .map_table = amdgpu_vm_sdma_map_table, .prepare = amdgpu_vm_sdma_prepare, .update = amdgpu_vm_sdma_update, .commit = amdgpu_vm_sdma_commit
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
I cannot apply your patch ... report error on line 85, what branch are you based on ? I assume it should be amd-staging-drm-next
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Monday, March 25, 2019 8:23 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: [PATCH 1/2] drm/amdgpu: move VM table mapping into the backend as well
Clean that up further and also fix another case where the BO wasn't kmapped for CPU based updates.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 31 ++++----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 11 ++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c | 20 +++++++++++++ 4 files changed, 37 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -26
@@ -660,17 +660,7 @@ int amdgpu_vm_validate_pt_bos(struct amdgpu_device *adev, struct amdgpu_vm *vm,if (bo->tbo.type != ttm_bo_type_kernel) {amdgpu_vm_bo_moved (bo_base); }else { -if (vm->use_cpu_for_update) - r =amdgpu_bo_kmap (bo,NULL ); -else - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (r) -break ; -if (bo->shadow) { - r =amdgpu_ttm_alloc_gart (&bo->shadow->tbo); -if (r) -break ; - } + vm->update_funcs->map_table (bo);amdgpu_vm_bo_relocated (bo_base); } }
@@ -752,22 +742,17 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,if (r)return r; - r =amdgpu_ttm_alloc_gart (&bo->tbo); -if (r) -return r; -if (bo->shadow) { r =ttm_bo_validate (&bo->shadow->tbo, &bo->shadow->placement, &ctx);if (r)return r; - - r =amdgpu_ttm_alloc_gart (&bo->shadow->tbo); -if (r) -return r; - } + r = vm->update_funcs->map_table (bo); +if (r) +return r; +memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.vm = vm;
@@ -878,12 +863,6 @@ static int amdgpu_vm_alloc_pts(struct amdgpu_device *adev,if (r)return r; -if (vm->use_cpu_for_update) { - r =amdgpu_bo_kmap (pt,NULL ); -if (r) - goto error_free_pt; - } -/* Keep a reference to the root directory to avoid * freeing them up in the wrong order. */
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -1
@@ -215,7 +215,7 @@ struct amdgpu_vm_update_params { };struct amdgpu_vm_update_funcs { - +int (*map_table)(struct amdgpu_bo *bo);int (*prepare)(struct amdgpu_vm_update_params *p,void * owner,struct dma_fence *exclusive); int (*update)(struct amdgpu_vm_update_params *p, diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c
index 9d53982021de..5222d165abfc 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +9 -0
@@ -24,6 +24,16 @@#include "amdgpu_object.h" #include "amdgpu_trace.h" +/** +* amdgpu_vm_cpu_map_table - make sure new PDs/PTs are kmapped +* +* @table: newly allocated or validated PD/PT */ static int +amdgpu_vm_cpu_map_table (struct amdgpu_bo *table) { +return amdgpu_bo_kmap (table,NULL ); +} +/** * amdgpu_vm_cpu_prepare - prepare page table update with the CPU *
@@ -110,6 +120,7 @@ static int amdgpu_vm_cpu_commit(struct amdgpu_vm_update_params *p, }const struct amdgpu_vm_update_funcs amdgpu_vm_cpu_funcs = { + .map_table = amdgpu_vm_cpu_map_table, .prepare = amdgpu_vm_cpu_prepare, .update = amdgpu_vm_cpu_update, .commit = amdgpu_vm_cpu_commit
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_sdma.c +18 -1
@@ -28,6 +28,25 @@#define AMDGPU_VM_SDMA_MIN_NUM_DW 256u#define AMDGPU_VM_SDMA_MAX_NUM_DW (16u * 1024u) +/** +* amdgpu_vm_sdma_map_table - make sure new PDs/PTs are GTT mapped +* +* @table: newly allocated or validated PD/PT */ static int +amdgpu_vm_sdma_map_table (struct amdgpu_bo *table) { +int r; + + r =amdgpu_ttm_alloc_gart (&table->tbo); +if (r) +return r; + +if (table->shadow) + r =amdgpu_ttm_alloc_gart (&table->shadow->tbo); + +return r; +} +/** * amdgpu_vm_sdma_prepare - prepare SDMA command submission *
@@ -242,6 +261,7 @@ static int amdgpu_vm_sdma_update(struct amdgpu_vm_update_params *p, }const struct amdgpu_vm_update_funcs amdgpu_vm_sdma_funcs = { + .map_table = amdgpu_vm_sdma_map_table, .prepare = amdgpu_vm_sdma_prepare, .update = amdgpu_vm_sdma_update, .commit = amdgpu_vm_sdma_commit --
2.17.1
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx