drm/amd/amdgpu: cover fragment size between 4 and 9 when not aligned
Subsystems (2)
PATCH 1/1 drm/amd/amdgpu: cover fragment size between 4 and 9 when not aligned
this can get performance improvement for some cases
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 98 +++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 19 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +79 -19
@@ -1375,7 +1375,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, }/* -* amdgpu_vm_frag_ptes - add fragment information to PTEs +* amdgpu_vm_update_ptes_helper - add fragment information to PTEs * * @params: see amdgpu_pte_update_params definition * @vm: requested vm
@@ -1383,11 +1383,12 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,* @end: last PTE to handle * @dst: addr those PTEs should point to * @flags: hw mapping flags +* @fragment: fragment size * Returns 0 for success, -EINVAL for failure. */ -static int amdgpu_vm_frag_ptes (struct amdgpu_pte_update_params *params, -uint64_t start,uint64_t end, -uint64_t dst,uint64_t flags) +static int amdgpu_vm_update_ptes_helper (struct amdgpu_pte_update_params *params, +uint64_t start,uint64_t end,uint64_t dst, +uint64_t flags,int fragment) {int r;
@@ -1409,41 +1410,100 @@ static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,* Userspace can support this by aligning virtual base address and * allocation size to the fragment size. */ -unsigned pages_per_frag = params->adev->vm_manager.fragment_size; -uint64_t frag_flags =AMDGPU_PTE_FRAG (pages_per_frag); -uint64_t frag_align =1 << pages_per_frag; +uint64_t frag_flags, frag_align, frag_start, frag_end; -uint64_t frag_start =ALIGN (start, frag_align); -uint64_t frag_end = end & ~(frag_align -1 ); +if (start > end || fragment <0 ) +return -EINVAL ; -/* system pages are non continuously */ -if (params->src || !(flags &AMDGPU_PTE_VALID ) || - (frag_start >= frag_end)) -return amdgpu_vm_update_ptes (params, start, end, dst, flags); + fragment =min (fragment,max (0 ,fls64 (end - start) -1 )); + frag_flags =AMDGPU_PTE_FRAG (fragment); + frag_align =1 << fragment; + frag_start =ALIGN (start, frag_align); + frag_end = end & ~(frag_align -1 ); + +if (frag_start >= frag_end) { +if (fragment <=4 ) +return amdgpu_vm_update_ptes (params, start, end, + dst, flags); +else +return amdgpu_vm_update_ptes_helper (params, start, + end, dst, flags, fragment -1 ); + } + +if (fragment <=4 ) { +/* handle the 4K area at the beginning */ +if (start != frag_start) { + r =amdgpu_vm_update_ptes (params, start, frag_start, + dst, flags); +if (r) +return r; + dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; + } + +/* handle the area in the middle */ + r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, + flags | frag_flags); +if (r) +return r; + +/* handle the 4K area at the end */ +if (frag_end != end) { + dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; + r =amdgpu_vm_update_ptes (params, frag_end, end, + dst, flags); + } +return r; + } -/* handle the 4K area at the beginning */ +/* handle the area at the beginning not aligned */ if (start != frag_start) { - r =amdgpu_vm_update_ptes (params, start, frag_start, - dst, flags); + r =amdgpu_vm_update_ptes_helper (params, start, frag_start, + dst, flags, fragment -1 );if (r)return r; dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; } -/* handle the area in the middle */ +/* handle the area in the middle aligned*/ r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, flags | frag_flags);if (r)return r; -/* handle the 4K area at the end */ +/* handle the area at the end not aligned */ if (frag_end != end) { dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; - r =amdgpu_vm_update_ptes (params, frag_end, end, dst, flags); + r =amdgpu_vm_update_ptes_helper (params, frag_end, end, + dst, flags, fragment -1 ); }return r; } +/* +* amdgpu_vm_frag_ptes - add fragment information to PTEs +* +* @params: see amdgpu_pte_update_params definition +* @vm: requested vm +* @start: first PTE to handle +* @end: last PTE to handle +* @dst: addr those PTEs should point to +* @flags: hw mapping flags +* Returns 0 for success, -EINVAL for failure. +*/ +static int amdgpu_vm_frag_ptes (struct amdgpu_pte_update_params *params, +uint64_t start,uint64_t end, +uint64_t dst,uint64_t flags) +{ +int fragment = params->adev->vm_manager.fragment_size; +/* system pages are non continuously */ +if (params->src || !(flags &AMDGPU_PTE_VALID )) +return amdgpu_vm_update_ptes (params, start, end, dst, flags); + +/* vram */ +return amdgpu_vm_update_ptes_helper (params, start, end, dst, flags, + fragment); +} +/** * amdgpu_vm_bo_update_mapping - update a mapping in the vm page table *
Signature · 6 lines
2.7.4 _______________________________________________ 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): 1504069279-1060-1-git-send-email-Hongbo.He-5C7GfCeVMHo@public.gmane.org
Hi Roger,
I think when you can select fragment automatically, you shouldn't involve the vm_manager.fragment_size to calculation, then we can use the properest fragment for every segment and get the best performance.
So vm_manager.fragment_size should be always be -1, if it becomes valid fragment value, then we should always use it and disable automatic selection, which should only for validation usage.
Regards,
David Zhou
Quoted 143 lines · Roger He
this can get performance improvement for some cases
Change-Id Ibb58bb3099f7e8c4b5da90da73a03544cdb2bcb7Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 98 +++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +72
-19@@ -1375,7 +1375,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, }/* -* amdgpu_vm_frag_ptes - add fragment information to PTEs +* amdgpu_vm_update_ptes_helper - add fragment information to PTEs * * @params: see amdgpu_pte_update_params definition * @vm: requested vm @@ -1383,11 +1383,12 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,* @end: last PTE to handle * @dst: addr those PTEs should point to * @flags: hw mapping flags +* @fragment: fragment size * Returns 0 for success, -EINVAL for failure. */ -static int amdgpu_vm_frag_ptes (struct amdgpu_pte_update_params *params, -uint64_t start,uint64_t end, -uint64_t dst,uint64_t flags) +static int amdgpu_vm_update_ptes_helper (struct amdgpu_pte_update_params *params, +uint64_t start,uint64_t end,uint64_t dst, +uint64_t flags,int fragment) {int r;@@ -1409,41 +1410,100 @@ static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,* Userspace can support this by aligning virtual base address and * allocation size to the fragment size. */ -unsigned pages_per_frag = params->adev->vm_manager.fragment_size; -uint64_t frag_flags =AMDGPU_PTE_FRAG (pages_per_frag); -uint64_t frag_align =1 << pages_per_frag; +uint64_t frag_flags, frag_align, frag_start, frag_end; -uint64_t frag_start =ALIGN (start, frag_align); -uint64_t frag_end = end & ~(frag_align -1 ); +if (start > end || fragment <0 ) +return -EINVAL ; -/* system pages are non continuously */ -if (params->src || !(flags &AMDGPU_PTE_VALID ) || - (frag_start >= frag_end)) -return amdgpu_vm_update_ptes (params, start, end, dst, flags); + fragment =min (fragment,max (0 ,fls64 (end - start) -1 )); + frag_flags =AMDGPU_PTE_FRAG (fragment); + frag_align =1 << fragment; + frag_start =ALIGN (start, frag_align); + frag_end = end & ~(frag_align -1 ); + +if (frag_start >= frag_end) { +if (fragment <=4 ) +return amdgpu_vm_update_ptes (params, start, end, + dst, flags); +else +return amdgpu_vm_update_ptes_helper (params, start, + end, dst, flags, fragment -1 ); + } + +if (fragment <=4 ) { +/* handle the 4K area at the beginning */ +if (start != frag_start) { + r =amdgpu_vm_update_ptes (params, start, frag_start, + dst, flags); +if (r) +return r; + dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; + } + +/* handle the area in the middle */ + r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, + flags | frag_flags); +if (r) +return r; + +/* handle the 4K area at the end */ +if (frag_end != end) { + dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; + r =amdgpu_vm_update_ptes (params, frag_end, end, + dst, flags); + } +return r; + } -/* handle the 4K area at the beginning */ +/* handle the area at the beginning not aligned */ if (start != frag_start) { - r =amdgpu_vm_update_ptes (params, start, frag_start, - dst, flags); + r =amdgpu_vm_update_ptes_helper (params, start, frag_start, + dst, flags, fragment -1 );if (r)return r; dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; } -/* handle the area in the middle */ +/* handle the area in the middle aligned*/ r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, flags | frag_flags);if (r)return r; -/* handle the 4K area at the end */ +/* handle the area at the end not aligned */ if (frag_end != end) { dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; - r =amdgpu_vm_update_ptes (params, frag_end, end, dst, flags); + r =amdgpu_vm_update_ptes_helper (params, frag_end, end, + dst, flags, fragment -1 ); }return r; } +/* +* amdgpu_vm_frag_ptes - add fragment information to PTEs +* +* @params: see amdgpu_pte_update_params definition +* @vm: requested vm +* @start: first PTE to handle +* @end: last PTE to handle +* @dst: addr those PTEs should point to +* @flags: hw mapping flags +* Returns 0 for success, -EINVAL for failure. +*/ +static int amdgpu_vm_frag_ptes (struct amdgpu_pte_update_params *params, +uint64_t start,uint64_t end, +uint64_t dst,uint64_t flags) +{ +int fragment = params->adev->vm_manager.fragment_size; +/* system pages are non continuously */ +if (params->src || !(flags &AMDGPU_PTE_VALID ))
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params, · line 1509
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7
-0+return amdgpu_vm_update_ptes (params, start, end, dst, flags); + +/* vram */ +return amdgpu_vm_update_ptes_helper (params, start, end, dst, flags, + fragment); +} +/** * amdgpu_vm_bo_update_mapping - update a mapping in the vm page table *
_______________________________________________
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): af3775f8-76a8-60ec-6922-054bdd77e535-5C7GfCeVMHo@public.gmane.org
Hi David & Roger,
Quoted 1 line
I think when you can select fragment automatically, you shouldn't involve the vm_manager.fragment_size to calculation, then we can use the properest fragment for every segment and get the best performance.
No, that won't work. I've already tried this and it decreases performance. The problem is that the L2 on pre Vega10 uses the fragment field to decide in which cache segment to put the PTE.
So we should only cover fragment sizes up to whatever the vm_manager.fragment_size configuration is currently.
Additional to that the patch needs to be simplified, cause another 5 level recursion is not something we want because of the limited kernel stack (only 4K usually).
If you don't mind Roger I'm going to fix this today, already have a good idea how to handle it I think.
Regards,
Christian.
Am 30.08.2017 um 08:15 schrieb zhoucm1:
Quoted 162 lines
Hi Roger,
I think when you can select fragment automatically, you shouldn't involve the vm_manager.fragment_size to calculation, then we can use the properest fragment for every segment and get the best performance.
So vm_manager.fragment_size should be always be -1, if it becomes valid fragment value, then we should always use it and disable automatic selection, which should only for validation usage.
Regards,
David Zhou
Quoted 149 lines · Roger He
this can get performance improvement for some cases
Change-Id Ibb58bb3099f7e8c4b5da90da73a03544cdb2bcb7Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 98 +++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5
-4@@ -1375,7 +1375,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, }/* -* amdgpu_vm_frag_ptes - add fragment information to PTEs +* amdgpu_vm_update_ptes_helper - add fragment information to PTEs * * @params: see amdgpu_pte_update_params definition * @vm: requested vm @@ -1383,11 +1383,12 @@ static int amdgpu_vm_update_ptes(structamdgpu_pte_update_params *params, * @end: last PTE to handle * @dst: addr those PTEs should point to * @flags: hw mapping flags +* @fragment: fragment size * Returns 0 for success, -EINVAL for failure. */ -static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params, - uint64_t start, uint64_t end, - uint64_t dst, uint64_t flags) +static int amdgpu_vm_update_ptes_helper(structamdgpu_pte_update_params *params, +uint64_t start,uint64_t end,uint64_t dst, +uint64_t flags,int fragment){ int r;@@ -1409,41 +1410,100 @@ static int amdgpu_vm_frag_ptes(struct
amdgpu_pte_update_params*params,
* Userspace can support this by aligning virtual base address and
* allocation size to the fragment size.
*/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +60
-10-unsigned pages_per_frag = params->adev->vm_manager.fragment_size; -uint64_t frag_flags =AMDGPU_PTE_FRAG (pages_per_frag); -uint64_t frag_align =1 << pages_per_frag; +uint64_t frag_flags, frag_align, frag_start, frag_end; - uint64_t frag_start = ALIGN(start, frag_align); -uint64_t frag_end = end & ~(frag_align -1 ); +if (start > end || fragment <0 ) +return -EINVAL ; -/* system pages are non continuously */ - if (params->src || !(flags & AMDGPU_PTE_VALID) || - (frag_start >= frag_end)) -return amdgpu_vm_update_ptes (params, start, end, dst, flags); + fragment =min (fragment,max (0 ,fls64 (end - start) -1 )); + frag_flags =AMDGPU_PTE_FRAG (fragment); + frag_align =1 << fragment; + frag_start =ALIGN (start, frag_align); + frag_end = end & ~(frag_align -1 ); + +if (frag_start >= frag_end) { +if (fragment <=4 ) +return amdgpu_vm_update_ptes (params, start, end, + dst, flags); +else +return amdgpu_vm_update_ptes_helper (params, start, + end, dst, flags, fragment -1 ); + } + +if (fragment <=4 ) { +/* handle the 4K area at the beginning */ +if (start != frag_start) { + r =amdgpu_vm_update_ptes (params, start, frag_start, + dst, flags); +if (r) +return r; + dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; + } + +/* handle the area in the middle */ + r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, + flags | frag_flags); +if (r) +return r; + +/* handle the 4K area at the end */ +if (frag_end != end) { + dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; + r =amdgpu_vm_update_ptes (params, frag_end, end, + dst, flags); + } +return r; + } -/* handle the 4K area at the beginning */ +/* handle the area at the beginning not aligned */ if (start != frag_start) { - r =amdgpu_vm_update_ptes (params, start, frag_start, - dst, flags); + r =amdgpu_vm_update_ptes_helper (params, start, frag_start, + dst, flags, fragment -1 );if (r)return r; dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; } -/* handle the area in the middle */ +/* handle the area in the middle aligned*/ r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, flags | frag_flags);if (r)return r; -/* handle the 4K area at the end */ +/* handle the area at the end not aligned */ if (frag_end != end) { dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; - r =amdgpu_vm_update_ptes (params, frag_end, end, dst, flags); + r =amdgpu_vm_update_ptes_helper (params, frag_end, end, + dst, flags, fragment -1 ); }return r; } +/* +* amdgpu_vm_frag_ptes - add fragment information to PTEs +* +* @params: see amdgpu_pte_update_params definition +* @vm: requested vm +* @start: first PTE to handle +* @end: last PTE to handle +* @dst: addr those PTEs should point to +* @flags: hw mapping flags +* Returns 0 for success, -EINVAL for failure. +*/ +static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params*params,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +13
-0+ uint64_t start, uint64_t end, + uint64_t dst, uint64_t flags) +{ + int fragment = params->adev->vm_manager.fragment_size; +/* system pages are non continuously */ +if (params->src || !(flags &AMDGPU_PTE_VALID )) +return amdgpu_vm_update_ptes (params, start, end, dst, flags); + +/* vram */ +return amdgpu_vm_update_ptes_helper (params, start, end, dst, flags, + fragment); +} +
Quoted 8 lines
Quoted 3 lines
/**
*amdgpu_vm_bo_update_mapping- update a mapping in the vm page table *_______________________________________________
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): 3bc6dbb8-e7be-548f-e63f-344f626d0ecb-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Additional to that the patch needs to be simplified, cause another 5 level recursion is not something we want because of the limited kernel stack (only 4K usually). [Roger]:
fragment = min(fragment, max(0, fls64(end - start) - 1))
so the next level fragment which depends on the (end-start), and not always 5 level recursion.
5 level is the worst case I think.
If you don't mind Roger I'm going to fix this today, already have a good idea how to handle it I think. [Roger]: ok, please go ahead.
Thanks
Roger(Hongbo.He)
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Wednesday, August 30, 2017 2:25 PM
To: Zhou, David(ChunMing) <[email protected]>; He, Roger <[email protected]>; [email protected]
Cc: Koenig, Christian <[email protected]>
Subject: Re: [PATCH] drm/amd/amdgpu: cover fragment size between 4 and 9 when not aligned
Hi David & Roger,
Quoted 3 lines
I think when you can select fragment automatically, you shouldn't involve the vm_manager.fragment_size to calculation, then we can use the properest fragment for every segment and get the best performance.
No, that won't work. I've already tried this and it decreases performance. The problem is that the L2 on pre Vega10 uses the fragment field to decide in which cache segment to put the PTE.
So we should only cover fragment sizes up to whatever the vm_manager.fragment_size configuration is currently.
Additional to that the patch needs to be simplified, cause another 5 level recursion is not something we want because of the limited kernel stack (only 4K usually).
If you don't mind Roger I'm going to fix this today, already have a good idea how to handle it I think.
Regards,
Christian.
Am 30.08.2017 um 08:15 schrieb zhoucm1:
Quoted 167 lines
Hi Roger,
I think when you can select fragment automatically, you shouldn't involve the vm_manager.fragment_size to calculation, then we can use the properest fragment for every segment and get the best performance.
So vm_manager.fragment_size should be always be -1, if it becomes valid fragment value, then we should always use it and disable automatic selection, which should only for validation usage.
Regards,
David Zhou
Quoted 150 lines · Roger He
this can get performance improvement for some cases
Change-Id Ibb58bb3099f7e8c4b5da90da73a03544cdb2bcb7Signed-off-by Roger He <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 98 +++++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 19 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5
-4@@ -1375,7 +1375,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params, }/* -* amdgpu_vm_frag_ptes - add fragment information to PTEs +* amdgpu_vm_update_ptes_helper - add fragment information to PTEs * * @params: see amdgpu_pte_update_params definition * @vm: requested vm @@ -1383,11 +1383,12 @@ static int amdgpu_vm_update_ptes(structamdgpu_pte_update_params *params, * @end: last PTE to handle * @dst: addr those PTEs should point to * @flags: hw mapping flags +* @fragment: fragment size * Returns 0 for success, -EINVAL for failure. */ -static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params, - uint64_t start, uint64_t end, - uint64_t dst, uint64_t flags) +static int amdgpu_vm_update_ptes_helper(structamdgpu_pte_update_params *params, +uint64_t start,uint64_t end,uint64_t dst, +uint64_t flags,int fragment){ int r;@@ -1409,41 +1410,100 @@ static int amdgpu_vm_frag_ptes(struct
amdgpu_pte_update_params*params,
* Userspace can support this by aligning virtual base address and
* allocation size to the fragment size.
*/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +60
-10-unsigned pages_per_frag = params->adev->vm_manager.fragment_size; -uint64_t frag_flags =AMDGPU_PTE_FRAG (pages_per_frag); -uint64_t frag_align =1 << pages_per_frag; +uint64_t frag_flags, frag_align, frag_start, frag_end; - uint64_t frag_start = ALIGN(start, frag_align); -uint64_t frag_end = end & ~(frag_align -1 ); +if (start > end || fragment <0 ) +return -EINVAL ; -/* system pages are non continuously */ - if (params->src || !(flags & AMDGPU_PTE_VALID) || - (frag_start >= frag_end)) -return amdgpu_vm_update_ptes (params, start, end, dst, flags); + fragment =min (fragment,max (0 ,fls64 (end - start) -1 )); + frag_flags =AMDGPU_PTE_FRAG (fragment); + frag_align =1 << fragment; + frag_start =ALIGN (start, frag_align); + frag_end = end & ~(frag_align -1 ); + +if (frag_start >= frag_end) { +if (fragment <=4 ) +return amdgpu_vm_update_ptes (params, start, end, + dst, flags); +else +return amdgpu_vm_update_ptes_helper (params, start, + end, dst, flags, fragment -1 ); + } + +if (fragment <=4 ) { +/* handle the 4K area at the beginning */ +if (start != frag_start) { + r =amdgpu_vm_update_ptes (params, start, frag_start, + dst, flags); +if (r) +return r; + dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; + } + +/* handle the area in the middle */ + r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, + flags | frag_flags); +if (r) +return r; + +/* handle the 4K area at the end */ +if (frag_end != end) { + dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; + r =amdgpu_vm_update_ptes (params, frag_end, end, + dst, flags); + } +return r; + } -/* handle the 4K area at the beginning */ +/* handle the area at the beginning not aligned */ if (start != frag_start) { - r =amdgpu_vm_update_ptes (params, start, frag_start, - dst, flags); + r =amdgpu_vm_update_ptes_helper (params, start, frag_start, + dst, flags, fragment -1 );if (r)return r; dst += (frag_start - start) *AMDGPU_GPU_PAGE_SIZE ; } -/* handle the area in the middle */ +/* handle the area in the middle aligned*/ r =amdgpu_vm_update_ptes (params, frag_start, frag_end, dst, flags | frag_flags);if (r)return r; -/* handle the 4K area at the end */ +/* handle the area at the end not aligned */ if (frag_end != end) { dst += (frag_end - frag_start) *AMDGPU_GPU_PAGE_SIZE ; - r =amdgpu_vm_update_ptes (params, frag_end, end, dst, flags); + r =amdgpu_vm_update_ptes_helper (params, frag_end, end, + dst, flags, fragment -1 ); }return r; } +/* +* amdgpu_vm_frag_ptes - add fragment information to PTEs +* +* @params: see amdgpu_pte_update_params definition +* @vm: requested vm +* @start: first PTE to handle +* @end: last PTE to handle +* @dst: addr those PTEs should point to +* @flags: hw mapping flags +* Returns 0 for success, -EINVAL for failure. +*/ +static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params*params,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +13
-0+ uint64_t start, uint64_t end, + uint64_t dst, uint64_t flags) { + int fragment = params->adev->vm_manager.fragment_size; +/* system pages are non continuously */ +if (params->src || !(flags &AMDGPU_PTE_VALID )) +return amdgpu_vm_update_ptes (params, start, end, dst, +flags); + +/* vram */ +return amdgpu_vm_update_ptes_helper (params, start, end, dst, flags, + fragment); +} +
Quoted 8 lines
Quoted 3 lines
/**
*amdgpu_vm_bo_update_mapping- update a mapping in the vm page table *_______________________________________________
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