drm/amdgpu: Change some variable names to make code easier understood
Subsystems (2)
PATCH 1/3 drm/amdgpu: Change some variable names to make code easier understood
From: Alex Xie <[email protected]>
Add comment to describe some variables otherwise.
Signed-off-by Alex Xie <[email protected]>
Reviewed-by Christian König <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +16 -16
@@ -748,7 +748,7 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_device *adev,* @vm: requested vm * @start: start of GPU address range * @end: end of GPU address range -* @dst: destination address to map to +* @dst: destination address to map to, the next dst inside the function * @flags: mapping flags * * Update the page tables in the range @start - @end.
@@ -762,43 +762,43 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, {const uint64_t mask =AMDGPU_VM_PTE_COUNT -1 ; -uint64_t last_pe_start = ~0 , last_pe_end = ~0 , last_dst = ~0 ; -uint64_t addr; +uint64_t cur_pe_start = ~0 , cur_pe_end = ~0 , cur_dst = ~0 ; +uint64_t addr;/* next GPU address to be updated */ /* walk over the address space and update the page tables */ for (addr = start; addr < end; ) {uint64_t pt_idx = addr >> amdgpu_vm_block_size;struct amdgpu_bo *pt = vm->page_tables[pt_idx].entry.robj; -unsigned nptes; -uint64_t pe_start; +unsigned nptes;/* next number of ptes to be updated */ +uint64_t next_pe_start;if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;else nptes =AMDGPU_VM_PTE_COUNT - (addr & mask); - pe_start =amdgpu_bo_gpu_offset (pt); - pe_start += (addr & mask) *8 ; + next_pe_start =amdgpu_bo_gpu_offset (pt); + next_pe_start += (addr & mask) *8 ; -if (last_pe_end != pe_start) { +if (cur_pe_end != next_pe_start) {amdgpu_vm_frag_ptes (adev, vm_update_params, - last_pe_start, last_pe_end, - last_dst, flags); + cur_pe_start, cur_pe_end, + cur_dst, flags); - last_pe_start = pe_start; - last_pe_end = pe_start +8 * nptes; - last_dst = dst; + cur_pe_start = next_pe_start; + cur_pe_end = next_pe_start +8 * nptes; + cur_dst = dst; }else { - last_pe_end +=8 * nptes; + cur_pe_end +=8 * nptes; } addr += nptes; dst += nptes *AMDGPU_GPU_PAGE_SIZE ; } -amdgpu_vm_frag_ptes (adev, vm_update_params, last_pe_start, - last_pe_end, last_dst, flags); +amdgpu_vm_frag_ptes (adev, vm_update_params, cur_pe_start, + cur_pe_end, cur_dst, flags); }/**
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/3 drm/amdgpu: Add comment to describe the purpose of one difficult if statement
From: Alex Xie <[email protected]>
Use == instead of != in the if statement to make code easier understood
Signed-off-by Alex Xie <[email protected]>
Reviewed-by Christian König <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -4
@@ -780,8 +780,13 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, next_pe_start =amdgpu_bo_gpu_offset (pt); next_pe_start += (addr & mask) *8 ; -if (cur_pe_end != next_pe_start) { - +if (cur_pe_end == next_pe_start) { +/* The next ptb is consecutive to current ptb. +* Don't call amdgpu_vm_frag_ptes now. +* Will update two ptbs together in future. +*/ + cur_pe_end +=8 * nptes; + }else {amdgpu_vm_frag_ptes (adev, vm_update_params, cur_pe_start, cur_pe_end, cur_dst, flags);
@@ -789,8 +794,6 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, cur_pe_start = next_pe_start; cur_pe_end = next_pe_start +8 * nptes; cur_dst = dst; - }else { - cur_pe_end +=8 * nptes; } addr += nptes;
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/3 drm/amdgpu: Initialize the variables in a straight-forward way
In reply to Alex DeucherFrom: Alex Xie <[email protected]>
Initialize the variable in a straight-forward way instead of hiding the initialization inside the loop. This can also reduce one function call.
Signed-off-by Alex Xie <[email protected]>
Reviewed-by Christian König <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +28 -6
@@ -762,15 +762,36 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, {const uint64_t mask =AMDGPU_VM_PTE_COUNT -1 ; -uint64_t cur_pe_start = ~0 , cur_pe_end = ~0 , cur_dst = ~0 ; +uint64_t cur_pe_start, cur_pe_end, cur_dst;uint64_t addr;/* next GPU address to be updated */ +uint64_t pt_idx; +struct amdgpu_bo *pt; +unsigned nptes;/* next number of ptes to be updated */ +uint64_t next_pe_start; + +/* initialize the variables */ + addr = start; + pt_idx = addr >> amdgpu_vm_block_size; + pt = vm->page_tables[pt_idx].entry.robj; + +if ((addr & ~mask) == (end & ~mask)) + nptes = end - addr; +else + nptes =AMDGPU_VM_PTE_COUNT - (addr & mask); + + cur_pe_start =amdgpu_bo_gpu_offset (pt); + cur_pe_start += (addr & mask) *8 ; + cur_pe_end = cur_pe_start +8 * nptes; + cur_dst = dst; + +/* for next ptb*/ + addr += nptes; + dst += nptes *AMDGPU_GPU_PAGE_SIZE ;/* walk over the address space and update the page tables */ -for (addr = start; addr < end; ) { -uint64_t pt_idx = addr >> amdgpu_vm_block_size; -struct amdgpu_bo *pt = vm->page_tables[pt_idx].entry.robj; -unsigned nptes;/* next number of ptes to be updated */ -uint64_t next_pe_start; +while (addr < end) { + pt_idx = addr >> amdgpu_vm_block_size; + pt = vm->page_tables[pt_idx].entry.robj;if ((addr & ~mask) == (end & ~mask)) nptes = end - addr;
@@ -796,6 +817,7 @@ static void amdgpu_vm_update_ptes(struct amdgpu_device *adev, cur_dst = dst; } +/* for next ptb*/ addr += nptes; dst += nptes *AMDGPU_GPU_PAGE_SIZE ; }
Signature · 6 lines
2.5.5 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel