Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e2b84e4b authored by Christian König's avatar Christian König Committed by Alex Deucher
Browse files

drm/amdgpu: use more than 64KB fragment size if possible



We align to 64KB, but when userspace aligns even more we can easily use more.

Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 92696dd5
Loading
Loading
Loading
Loading
+8 −4
Original line number Original line Diff line number Diff line
@@ -818,13 +818,13 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,
	 * allocation size to the fragment size.
	 * allocation size to the fragment size.
	 */
	 */


	/* SI and newer are optimized for 64KB */
	const uint64_t frag_align = 1 << AMDGPU_LOG2_PAGES_PER_FRAG;
	uint64_t frag_flags = AMDGPU_PTE_FRAG(AMDGPU_LOG2_PAGES_PER_FRAG);
	uint64_t frag_align = 1 << AMDGPU_LOG2_PAGES_PER_FRAG;


	uint64_t frag_start = ALIGN(start, frag_align);
	uint64_t frag_start = ALIGN(start, frag_align);
	uint64_t frag_end = end & ~(frag_align - 1);
	uint64_t frag_end = end & ~(frag_align - 1);


	uint32_t frag;

	/* system pages are non continuously */
	/* system pages are non continuously */
	if (params->src || params->pages_addr || !(flags & AMDGPU_PTE_VALID) ||
	if (params->src || params->pages_addr || !(flags & AMDGPU_PTE_VALID) ||
	    (frag_start >= frag_end)) {
	    (frag_start >= frag_end)) {
@@ -833,6 +833,10 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,
		return;
		return;
	}
	}


	/* use more than 64KB fragment size if possible */
	frag = lower_32_bits(frag_start | frag_end);
	frag = likely(frag) ? __ffs(frag) : 31;

	/* handle the 4K area at the beginning */
	/* handle the 4K area at the beginning */
	if (start != frag_start) {
	if (start != frag_start) {
		amdgpu_vm_update_ptes(params, vm, start, frag_start,
		amdgpu_vm_update_ptes(params, vm, start, frag_start,
@@ -842,7 +846,7 @@ static void amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params *params,


	/* handle the area in the middle */
	/* handle the area in the middle */
	amdgpu_vm_update_ptes(params, vm, frag_start, frag_end, dst,
	amdgpu_vm_update_ptes(params, vm, frag_start, frag_end, dst,
			      flags | frag_flags);
			      flags | AMDGPU_PTE_FRAG(frag));


	/* handle the 4K area at the end */
	/* handle the 4K area at the end */
	if (frag_end != end) {
	if (frag_end != end) {