drm/amdgpu: write PTEs directly into the IB.
Subsystems (2)
PATCH 1/6 drm/amdgpu: write PTEs directly into the IB.
From: Christian König <[email protected]>
Write the PTEs at the end of the IB instead of directly into the SDMA commands. This can save quite some CPU cycles building the entries.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +21 -5
@@ -910,15 +910,15 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,/* padding, etc. */ ndw =64 ; -if (params.src) { +if (src) {/* only copy commands needed */ ndw += ncmds *7 ; - }else if (params.pages_addr) { -/* header for write data commands */ - ndw += ncmds *4 ; + }else if (pages_addr) { +/* copy commands needed */ + ndw += ncmds *7 ; -/* body of write data command */ +/* and also PTEs */ ndw += nptes *2 ; }else {
@@ -935,6 +935,22 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, params.ib = &job->ibs[0 ]; +if (!src && pages_addr) { +uint64_t *pte; +unsigned i; + +/* Put the PTEs at the end of the IB. */ + i = ndw - nptes *2 ; + pte= (uint64_t *)&(job->ibs->ptr[i]); + params.src = job->ibs->gpu_addr + i *4 ; + +for (i =0 ; i < nptes; ++i) { + pte[i] =amdgpu_vm_map_gart (pages_addr, addr + i * +AMDGPU_GPU_PAGE_SIZE ); + pte[i] |= flags; + } + } + r =amdgpu_sync_fence (adev, &job->sync, exclusive);if (r) goto error_free;
Signature · 6 lines
2.5.0 _______________________________________________ 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): 1471009949-2050-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
PATCH 2/6 drm/amdgpu: remove pages_addr handling from the VM code
From: Christian König <[email protected]>
Not needed any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -9
@@ -62,8 +62,6 @@ struct amdgpu_pte_update_params {struct amdgpu_device *adev;/* address where to copy page table entries from */ uint64_t src; -/* DMA addresses to use for mapping */ -dma_addr_t *pages_addr;/* indirect buffer to fill with commands */ struct amdgpu_ib *ib; };
@@ -491,11 +489,6 @@ static void amdgpu_vm_update_pages(struct amdgpu_pte_update_params *params,amdgpu_vm_copy_pte (params->adev, params->ib, pe, (params->src + (addr >>12 ) *8 ), count); - }else if (params->pages_addr) { -amdgpu_vm_write_pte (params->adev, params->ib, - params->pages_addr, - pe, addr, count, incr, flags); - }else if (count <3 ) {amdgpu_vm_write_pte (params->adev, params->ib,NULL , pe, addr, count, incr, flags);
@@ -825,7 +818,7 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,uint32_t frag;/* system pages are non continuously */ -if (params->src || params->pages_addr || !(flags &AMDGPU_PTE_VALID ) || +if (params->src || !(flags &AMDGPU_PTE_VALID ) || (frag_start >= frag_end)) {amdgpu_vm_update_ptes (params, vm, start, end, dst, flags);
@@ -893,7 +886,6 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.src = src; - params.pages_addr = pages_addr;/* sync to everything on unmapping */ if (!(flags &AMDGPU_PTE_VALID ))
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/6 drm/amdgpu: cleanup the write_pte implementations
In reply to a message not in the archiveFrom: Christian König <[email protected]>
We don't need the gart mapping handling here any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 10 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 20 ++++++---------- drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 42 ++++++++++++---------------------- drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 40 ++++++++++++-------------------- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 40 ++++++++++++-------------------- 5 files changed, 54 insertions(+), 98 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -6
@@ -251,10 +251,9 @@ struct amdgpu_vm_pte_funcs { uint64_t pe, uint64_t src, unsigned count);/* write pte one entry at a time with addr mapping */ -void (*write_pte)(struct amdgpu_ib *ib, -const dma_addr_t *pages_addr,uint64_t pe, -uint64_t addr,unsigned count, -uint32_t incr,uint32_t flags); +void (*write_pte)(struct amdgpu_ib *ib,uint64_t pe, +uint64_t value,unsigned count, +uint32_t incr);/* for linear pte/pde updates without addr mapping */ void (*set_pte_pde)(struct amdgpu_ib *ib, uint64_t pe,
@@ -965,7 +964,6 @@ int amdgpu_vm_grab_id(struct amdgpu_vm *vm, struct amdgpu_ring *ring, struct amdgpu_job *job);int amdgpu_vm_flush (struct amdgpu_ring *ring,struct amdgpu_job *job);void amdgpu_vm_reset_id (struct amdgpu_device *adev,unsigned vm_id); -uint64_t amdgpu_vm_map_gart (const dma_addr_t *pages_addr,uint64_t addr);int amdgpu_vm_update_page_directory (struct amdgpu_device *adev,struct amdgpu_vm *vm); int amdgpu_vm_clear_freed(struct amdgpu_device *adev,
@@ -2279,7 +2277,7 @@ amdgpu_get_sdma_instance(struct amdgpu_ring *ring)#define amdgpu_gart_flush_gpu_tlb (adev, vmid) (adev)->gart.gart_funcs->flush_gpu_tlb((adev), (vmid))#define amdgpu_gart_set_pte_pde (adev, pt, idx, addr, flags) (adev)->gart.gart_funcs->set_pte_pde((adev), (pt), (idx), (addr), (flags))#define amdgpu_vm_copy_pte (adev, ib, pe, src, count) ((adev)->vm_manager.vm_pte_funcs->copy_pte((ib), (pe), (src), (count))) -#define amdgpu_vm_write_pte (adev, ib, pa, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pa), (pe), (addr), (count), (incr), (flags))) +#define amdgpu_vm_write_pte (adev, ib, pe, value, count, incr) ((adev)->vm_manager.vm_pte_funcs->write_pte((ib), (pe), (value), (count), (incr)))#define amdgpu_vm_set_pte_pde (adev, ib, pe, addr, count, incr, flags) ((adev)->vm_manager.vm_pte_funcs->set_pte_pde((ib), (pe), (addr), (count), (incr), (flags)))#define amdgpu_ring_parse_cs (r, p, ib) ((r)->funcs->parse_cs((p), (ib)))#define amdgpu_ring_test_ring (r) (r)->funcs->test_ring((r))
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -13
@@ -490,8 +490,8 @@ static void amdgpu_vm_update_pages(struct amdgpu_pte_update_params *params, pe, (params->src + (addr >> 12) * 8), count); }else if (count <3 ) { -amdgpu_vm_write_pte (params->adev, params->ib,NULL , pe, addr, - count, incr, flags); +amdgpu_vm_write_pte (params->adev, params->ib, pe, + addr | flags, count, incr); }else { amdgpu_vm_set_pte_pde(params->adev, params->ib, pe, addr,
@@ -568,21 +568,15 @@ error:* Look up the physical address of the page that the pte resolves * to and return the pointer for the page table entry. */ -uint64_t amdgpu_vm_map_gart (const dma_addr_t *pages_addr,uint64_t addr) +static uint64_t amdgpu_vm_map_gart (const dma_addr_t *pages_addr,uint64_t addr) {uint64_t result; -if (pages_addr) { -/* page table offset */ - result = pages_addr[addr >>PAGE_SHIFT ]; - -/* in case cpu page size != gpu page size*/ - result |= addr & (~PAGE_MASK ); +/* page table offset */ + result = pages_addr[addr >>PAGE_SHIFT ]; - }else { -/* No mapping required */ - result = addr; - } +/* in case cpu page size != gpu page size*/ + result |= addr & (~PAGE_MASK ); result &=0xFFFFFFFFFFFFF000ULL ;
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +15 -27
54 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +14 -26
@@ -774,39 +774,27 @@ static void sdma_v2_4_vm_copy_pte(struct amdgpu_ib *ib,* * @ib: indirect buffer to fill with commands * @pe: addr of the page entry -* @addr: dst addr to write into pe +* @value: dst addr to write into pe * @count: number of page entries to update * @incr: increase next addr by incr bytes -* @flags: access flags * * Update PTEs by writing them manually using sDMA (CIK). */ -static void sdma_v2_4_vm_write_pte (struct amdgpu_ib *ib, -const dma_addr_t *pages_addr,uint64_t pe, -uint64_t addr,unsigned count, -uint32_t incr,uint32_t flags) +static void sdma_v2_4_vm_write_pte (struct amdgpu_ib *ib,uint64_t pe, +uint64_t value,unsigned count, +uint32_t incr) { -uint64_t value; -unsigned ndw; - -while (count) { - ndw = count *2 ; -if (ndw >0xFFFFE ) - ndw =0xFFFFE ; +unsigned ndw = count *2 ; -/* for non-physically contiguous pages (system) */ - ib->ptr[ib->length_dw++] =SDMA_PKT_HEADER_OP (SDMA_OP_WRITE ) | -SDMA_PKT_HEADER_SUB_OP (SDMA_SUBOP_COPY_LINEAR ); - ib->ptr[ib->length_dw++] = pe; - ib->ptr[ib->length_dw++] =upper_32_bits (pe); - ib->ptr[ib->length_dw++] = ndw; -for (; ndw >0 ; ndw -=2 , --count, pe +=8 ) { - value =amdgpu_vm_map_gart (pages_addr, addr); - addr += incr; - value |= flags; - ib->ptr[ib->length_dw++] = value; - ib->ptr[ib->length_dw++] =upper_32_bits (value); - } + ib->ptr[ib->length_dw++] =SDMA_PKT_HEADER_OP (SDMA_OP_WRITE ) | +SDMA_PKT_HEADER_SUB_OP (SDMA_SUBOP_COPY_LINEAR ); + ib->ptr[ib->length_dw++] = pe; + ib->ptr[ib->length_dw++] =upper_32_bits (pe); + ib->ptr[ib->length_dw++] = ndw; +for (; ndw >0 ; ndw -=2 , --count, pe +=8 ) { + ib->ptr[ib->length_dw++] =lower_32_bits (value); + ib->ptr[ib->length_dw++] =upper_32_bits (value); + value += incr; } }
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +14 -26
@@ -1001,39 +1001,27 @@ static void sdma_v3_0_vm_copy_pte(struct amdgpu_ib *ib,* * @ib: indirect buffer to fill with commands * @pe: addr of the page entry -* @addr: dst addr to write into pe +* @value: dst addr to write into pe * @count: number of page entries to update * @incr: increase next addr by incr bytes -* @flags: access flags * * Update PTEs by writing them manually using sDMA (CIK). */ -static void sdma_v3_0_vm_write_pte (struct amdgpu_ib *ib, -const dma_addr_t *pages_addr,uint64_t pe, -uint64_t addr,unsigned count, -uint32_t incr,uint32_t flags) +static void sdma_v3_0_vm_write_pte (struct amdgpu_ib *ib,uint64_t pe, +uint64_t value,unsigned count, +uint32_t incr) { -uint64_t value; -unsigned ndw; - -while (count) { - ndw = count *2 ; -if (ndw >0xFFFFE ) - ndw =0xFFFFE ; +unsigned ndw = count *2 ; -/* for non-physically contiguous pages (system) */ - ib->ptr[ib->length_dw++] =SDMA_PKT_HEADER_OP (SDMA_OP_WRITE ) | -SDMA_PKT_HEADER_SUB_OP (SDMA_SUBOP_COPY_LINEAR ); - ib->ptr[ib->length_dw++] = pe; - ib->ptr[ib->length_dw++] =upper_32_bits (pe); - ib->ptr[ib->length_dw++] = ndw; -for (; ndw >0 ; ndw -=2 , --count, pe +=8 ) { - value =amdgpu_vm_map_gart (pages_addr, addr); - addr += incr; - value |= flags; - ib->ptr[ib->length_dw++] = value; - ib->ptr[ib->length_dw++] =upper_32_bits (value); - } + ib->ptr[ib->length_dw++] =SDMA_PKT_HEADER_OP (SDMA_OP_WRITE ) | +SDMA_PKT_HEADER_SUB_OP (SDMA_SUBOP_COPY_LINEAR ); + ib->ptr[ib->length_dw++] =lower_32_bits (pe); + ib->ptr[ib->length_dw++] =upper_32_bits (pe); + ib->ptr[ib->length_dw++] = ndw; +for (; ndw >0 ; ndw -=2 , --count, pe +=8 ) { + ib->ptr[ib->length_dw++] =lower_32_bits (value); + ib->ptr[ib->length_dw++] =upper_32_bits (value); + value += incr; } }
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/6 drm/amdgpu: remove AMDGPU_VM_NO_FLUSH define
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Not used any more.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 3 --- 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -3
@@ -51,9 +51,6 @@* SI supports 16. */ -/* Special value that no flush is necessary */ -#define AMDGPU_VM_NO_FLUSH (~0ll) -/* Local structure. Encapsulate some VM table update parameters to reduce * the number of function parameters */
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/6 drm/amdgpu: stop splitting PTE commands into smaller ones
In reply to a message not in the archiveFrom: Christian König <[email protected]>
It doesn't make much sense to create bigger commands first which we then need to split into smaller one again. Just make sure the commands we create aren't to big in the first place.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++- drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 71 +++++++++++----------------------- drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 71 +++++++++++----------------------- drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 71 +++++++++++----------------------- 5 files changed, 73 insertions(+), 149 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -833,6 +833,9 @@ struct amdgpu_ring {/* maximum number of VMIDs */ #define AMDGPU_NUM_VM 16 +/* Maximum number of PTEs the hardware can write with one command */ +#define AMDGPU_VM_MAX_UPDATE_SIZE 0x3FFFF +/* number of entries in page table */ #define AMDGPU_VM_PTE_COUNT (1 << amdgpu_vm_block_size)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -2
@@ -638,7 +638,8 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, pde = pd_addr + pt_idx *8 ;if (((last_pde +8 * count) != pde) || - ((last_pt + incr * count) != pt)) { + ((last_pt + incr * count) != pt) || + (count ==AMDGPU_VM_MAX_UPDATE_SIZE )) {if (count) { amdgpu_vm_update_pages(¶ms, last_pde,
@@ -742,7 +743,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, next_pe_start =amdgpu_bo_gpu_offset (pt); next_pe_start += (addr & mask) *8 ; -if ((cur_pe_start +8 * cur_nptes) == next_pe_start) { +if ((cur_pe_start +8 * cur_nptes) == next_pe_start && + ((cur_nptes + nptes) <=AMDGPU_VM_MAX_UPDATE_SIZE )) {/* The next ptb is consecutive to current ptb. * Don't call amdgpu_vm_update_pages now. * Will update two ptbs together in future.
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +22 -49
86 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +22 -49
86 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +22 -49
86 lines not on this page · raw message
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/6 drm/amdgpu: add function pointer to the pte_update_params
In reply to a message not in the archiveFrom: Christian König <[email protected]>
Remember what function to call while planning the commands instead of figuring it our later on.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 76 ++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +54 -22
@@ -61,6 +61,10 @@ struct amdgpu_pte_update_params {uint64_t src;/* indirect buffer to fill with commands */ struct amdgpu_ib *ib; +/* Function which actually does the update */ +void (*func)(struct amdgpu_pte_update_params *params,uint64_t pe, +uint64_t addr,unsigned count,uint32_t incr, +uint32_t flags); };/**
@@ -463,7 +467,7 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm, }/** -* amdgpu_vm_update_pages - helper to call the right asic function +* amdgpu_vm_do_set_ptes - helper to call the right asic function * * @params: see amdgpu_pte_update_params definition * @pe: addr of the page entry
@@ -475,18 +479,14 @@ struct amdgpu_bo_va *amdgpu_vm_bo_find(struct amdgpu_vm *vm,* Traces the parameters and calls the right asic functions * to setup the page table using the DMA. */ -static void amdgpu_vm_update_pages (struct amdgpu_pte_update_params *params, -uint64_t pe,uint64_t addr, -unsigned count,uint32_t incr, -uint32_t flags) +static void amdgpu_vm_do_set_ptes (struct amdgpu_pte_update_params *params, +uint64_t pe,uint64_t addr, +unsigned count,uint32_t incr, +uint32_t flags) {trace_amdgpu_vm_set_page (pe, addr, count, incr, flags); -if (params->src) { -amdgpu_vm_copy_pte (params->adev, params->ib, - pe, (params->src + (addr >>12 ) *8 ), count); - - }else if (count <3 ) { +if (count <3 ) {amdgpu_vm_write_pte (params->adev, params->ib, pe, addr | flags, count, incr);
@@ -497,6 +497,29 @@ static void amdgpu_vm_update_pages(struct amdgpu_pte_update_params *params, }/** +* amdgpu_vm_do_copy_ptes - copy the PTEs from the GART +* +* @params: see amdgpu_pte_update_params definition +* @pe: addr of the page entry +* @addr: dst addr to write into pe +* @count: number of page entries to update +* @incr: increase next addr by incr bytes +* @flags: hw access flags +* +* Traces the parameters and calls the DMA function to copy the PTEs. +*/ +static void amdgpu_vm_do_copy_ptes (struct amdgpu_pte_update_params *params, +uint64_t pe,uint64_t addr, +unsigned count,uint32_t incr, +uint32_t flags) +{ +trace_amdgpu_vm_set_page (pe, addr, count, incr, flags); + +amdgpu_vm_copy_pte (params->adev, params->ib, pe, + (params->src + (addr >>12 ) *8 ), count); +} + +/** * amdgpu_vm_clear_bo - initially clear the page dir/table * * @adev: amdgpu_device pointer
@@ -536,7 +559,7 @@ static int amdgpu_vm_clear_bo(struct amdgpu_device *adev,memset (¶ms,0 ,sizeof (params)); params.adev = adev; params.ib = &job->ibs[0 ]; -amdgpu_vm_update_pages (¶ms, addr,0 , entries,0 ,0 ); +amdgpu_vm_do_set_ptes (¶ms, addr,0 , entries,0 ,0 );amdgpu_ring_pad_ib (ring, &job->ibs[0 ]);WARN_ON (job->ibs[0 ].length_dw >64 );
@@ -642,9 +665,9 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, (count == AMDGPU_VM_MAX_UPDATE_SIZE)) {if (count) { -amdgpu_vm_update_pages (¶ms, last_pde, - last_pt, count, incr, -AMDGPU_PTE_VALID ); +amdgpu_vm_do_set_ptes (¶ms, last_pde, + last_pt, count, incr, +AMDGPU_PTE_VALID ); } count =1 ;
@@ -656,8 +679,8 @@ int amdgpu_vm_update_page_directory(struct amdgpu_device *adev, }if (count) -amdgpu_vm_update_pages (¶ms, last_pde, last_pt, - count, incr,AMDGPU_PTE_VALID ); +amdgpu_vm_do_set_ptes (¶ms, last_pde, last_pt, + count, incr,AMDGPU_PTE_VALID );if (params.ib->length_dw !=0 ) {amdgpu_ring_pad_ib (ring, params.ib);
@@ -746,14 +769,13 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,if ((cur_pe_start +8 * cur_nptes) == next_pe_start && ((cur_nptes + nptes) <=AMDGPU_VM_MAX_UPDATE_SIZE )) {/* The next ptb is consecutive to current ptb. -* Don't call amdgpu_vm_update_pages now. +* Don't call the update function now. * Will update two ptbs together in future. */ cur_nptes += nptes; }else { -amdgpu_vm_update_pages (params, cur_pe_start, cur_dst, - cur_nptes,AMDGPU_GPU_PAGE_SIZE , - flags); + params->func (params, cur_pe_start, cur_dst, cur_nptes, +AMDGPU_GPU_PAGE_SIZE , flags); cur_pe_start = next_pe_start; cur_nptes = nptes;
@@ -765,8 +787,8 @@ static void amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, dst += nptes *AMDGPU_GPU_PAGE_SIZE ; } -amdgpu_vm_update_pages (params, cur_pe_start, cur_dst, cur_nptes, -AMDGPU_GPU_PAGE_SIZE , flags); + params->func (params, cur_pe_start, cur_dst, cur_nptes, +AMDGPU_GPU_PAGE_SIZE , flags); }/*
@@ -874,6 +896,10 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,struct fence *f =NULL ;int r; +memset (¶ms,0 ,sizeof (params)); + params.adev = adev; + params.src = src; + ring = container_of(vm->entity.sched, struct amdgpu_ring, sched);memset (¶ms,0 ,sizeof (params));
@@ -899,6 +925,8 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,/* only copy commands needed */ ndw += ncmds *7 ; + params.func = amdgpu_vm_do_copy_ptes; + }else if (pages_addr) {/* copy commands needed */ ndw += ncmds *7 ;
@@ -906,12 +934,16 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,/* and also PTEs */ ndw += nptes *2 ; + params.func = amdgpu_vm_do_copy_ptes; + }else {/* set page commands needed */ ndw += ncmds *10 ;/* two extra commands for begin/end of fragment */ ndw +=2 *10 ; + + params.func = amdgpu_vm_do_set_ptes; } r =amdgpu_job_alloc_with_ib (adev, ndw *4 , &job);
Signature · 6 lines
2.5.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 37 lines · Christian König
From: Christian König <[email protected]>
Write the PTEs at the end of the IB instead of directly into the SDMA commands. This can save quite some CPU cycles building the entries.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5
-5@@ -910,15 +910,15 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,/* padding, etc. */ ndw =64 ; -if (params.src) { +if (src) {/* only copy commands needed */ ndw += ncmds *7 ; - }else if (params.pages_addr) { -/* header for write data commands */ - ndw += ncmds *4 ; + }else if (pages_addr) { +/* copy commands needed */ + ndw += ncmds *7 ; -/* body of write data command */ +/* and also PTEs */ ndw += nptes *2 ; }else {@@ -935,6 +935,22 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 945
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-0params.ib = &job->ibs[0 ]; +if (!src && pages_addr) { +uint64_t *pte; +unsigned i; + +/* Put the PTEs at the end of the IB. */ + i = ndw - nptes *2 ; + pte= (uint64_t *)&(job->ibs->ptr[i]); + params.src = job->ibs->gpu_addr + i *4 ;
Is the offset correct for all asics? IIRC, ndw was kind of a worst case guess as the packet header sizes vary across families.
Alex
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-1+ +for (i =0 ; i < nptes; ++i) { + pte[i] =amdgpu_vm_map_gart (pages_addr, addr + i * +AMDGPU_GPU_PAGE_SIZE ); + pte[i] |= flags; + } + } + r =amdgpu_sync_fence (adev, &job->sync, exclusive);if (r) goto error_free; --2.5.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): CADnq5_PdK14584qsDB-TqcKR+3FJJKJ1bLOHDV22S9RfAxTw3g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Am 12.08.2016 um 17:46 schrieb Alex Deucher:
Quoted 41 lines
Quoted 39 lines · Christian König
From: Christian König <[email protected]>
Write the PTEs at the end of the IB instead of directly into the SDMA commands. This can save quite some CPU cycles building the entries.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5
-5@@ -910,15 +910,15 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,/* padding, etc. */ ndw =64 ; -if (params.src) { +if (src) {/* only copy commands needed */ ndw += ncmds *7 ; - }else if (params.pages_addr) { -/* header for write data commands */ - ndw += ncmds *4 ; + }else if (pages_addr) { +/* copy commands needed */ + ndw += ncmds *7 ; -/* body of write data command */ +/* and also PTEs */ ndw += nptes *2 ; }else {@@ -935,6 +935,22 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, params.ib = &job->ibs[0 ];
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 945
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-0+if (!src && pages_addr) { +uint64_t *pte; +unsigned i; + +/* Put the PTEs at the end of the IB. */ + i = ndw - nptes *2 ; + pte= (uint64_t *)&(job->ibs->ptr[i]); + params.src = job->ibs->gpu_addr + i *4 ;Is the offset correct for all asics? IIRC, ndw was kind of a worst case guess as the packet header sizes vary across families.
Yeah, that should work, but I can double check once more.
I actually don't change the dw estimation. Just instead of using the inline write command I stitch together the page table entries at the end of dw first and then use the copy command to move them over to the page tables.
That has the clear advantage of being way more cache friendly, because you don't jump around between dithings any more.
Christian.
Quoted 17 lines
Alex
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-1+ +for (i =0 ; i < nptes; ++i) { + pte[i] =amdgpu_vm_map_gart (pages_addr, addr + i * +AMDGPU_GPU_PAGE_SIZE ); + pte[i] |= flags; + } + } + r =amdgpu_sync_fence (adev, &job->sync, exclusive);if (r) goto error_free; --2.5.0
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
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): 10f0107d-5c95-dae9-f9ae-7bca5975edcc-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Deucher, Alexander
Reviewed-by Alex DeucherQuoted 66 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Friday, August 12, 2016 12:56 PM
To: Alex Deucher
Cc: Kasiviswanathan, Harish; amd-gfx list
Subject: Re: [PATCH 1/6] drm/amdgpu: write PTEs directly into the IB.Am 12.08.2016 um 17:46 schrieb Alex Deucher:
Quoted 5 lines
Quoted 3 lines · Christian König
From: Christian König <[email protected]>
Write the PTEs at the end of the IB instead of directly into the SDMA
commands.
Quoted 5 lines
Quoted 5 lines
This can save quite some CPU cycles building the entries.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26+++++++++++++++++++++-----
Quoted 3 lines
Review
Quoted 3 lines
1 file changed, 21 insertions(+), 5 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.cQuoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int
Quoted 4 lines
index 2843132..7efcbe3 100644
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -910,15 +910,15 @@ static intamdgpu_vm_bo_update_mapping(struct
amdgpu_device*adev,Quoted 15 lines
Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-4/* padding, etc. */ ndw =64 ; -if (params.src) { +if (src) {/* only copy commands needed */ ndw += ncmds *7 ; - }else if (params.pages_addr) { -/* header for write data commands */ - ndw += ncmds *4 ; + }else if (pages_addr) { +/* copy commands needed */ + ndw += ncmds *7 ;Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1
-1-/* body of write data command */ +/* and also PTEs */ ndw += nptes *2 ; }else {@@ -935,6 +935,22 @@ static intamdgpu_vm_bo_update_mapping(struct
amdgpu_device*adev,Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 945
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-0params.ib = &job->ibs[0 ]; +if (!src && pages_addr) { +uint64_t *pte; +unsigned i; + +/* Put the PTEs at the end of the IB. */ + i = ndw - nptes *2 ; + pte= (uint64_t *)&(job->ibs->ptr[i]); + params.src = job->ibs->gpu_addr + i *4 ;Quoted 2 lines
Is the offset correct for all asics? IIRC, ndw was kind of a worst case guess as the packet header sizes vary across families.
Quoted 6 lines
Yeah, that should work, but I can double check once more.
I actually don't change the dw estimation. Just instead of using the inline write command I stitch together the page table entries at the end of dw first and then use the copy command to move them over to the page tables.
Ah, I get it now. That's the piece I was missing. Can you add something like that to the commit message? With that, the series is:
Quoted 23 lines
That has the clear advantage of being way more cache friendly, because you don't jump around between dithings any more.
Christian.
Quoted 17 lines
Alex
Quoted 14 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-1+ +for (i =0 ; i < nptes; ++i) { + pte[i] =amdgpu_vm_map_gart (pages_addr, addr + i * +AMDGPU_GPU_PAGE_SIZE ); + pte[i] |= flags; + } + } + r =amdgpu_sync_fence (adev, &job->sync, exclusive);if (r) goto error_free; --2.5.0
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Edward O'Callaghan
Reviewed-byThis series is,
actually quite a nice cleanup!
Quoted 49 lines · Christian König
From: Christian König <[email protected]>
Write the PTEs at the end of the IB instead of directly into the SDMA commands. This can save quite some CPU cycles building the entries.
Signed-off-by Christian König <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +14
-5@@ -910,15 +910,15 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev,/* padding, etc. */ ndw =64 ; -if (params.src) { +if (src) {/* only copy commands needed */ ndw += ncmds *7 ; - }else if (params.pages_addr) { -/* header for write data commands */ - ndw += ncmds *4 ; + }else if (pages_addr) { +/* copy commands needed */ + ndw += ncmds *7 ; -/* body of write data command */ +/* and also PTEs */ ndw += nptes *2 ; }else {@@ -935,6 +935,22 @@ static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, params.ib = &job->ibs[0 ]; +if (!src && pages_addr) { +uint64_t *pte; +unsigned i; + +/* Put the PTEs at the end of the IB. */ + i = ndw - nptes *2 ; + pte= (uint64_t *)&(job->ibs->ptr[i]); + params.src = job->ibs->gpu_addr + i *4 ; +
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_update_mapping(struct amdgpu_device *adev, · line 956
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7
-0+for (i =0 ; i < nptes; ++i) { + pte[i] =amdgpu_vm_map_gart (pages_addr, addr + i * +AMDGPU_GPU_PAGE_SIZE ); + pte[i] |= flags; + } + } + r =amdgpu_sync_fence (adev, &job->sync, exclusive);if (r) goto error_free;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx