Skip to contentSkip to conversation

drm/amdgpu: GPU vs CPU page size fixes in amdgpu_vm_bo_split_mapping

PATCH In review Michel Dänzer 3 participants 5 messages Jun 22, 2018 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: GPU vs CPU page size fixes in amdgpu_vm_bo_split_mapping

From: Michel Dänzer <[email protected]>

start / last / max_entries are numbers of GPU pages, pfn / count are numbers of CPU pages. Convert between them accordingly.

Fixes badness on systems with > 4K page size.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106258

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -3
index 7c30451ba897..590db78b8c72 100644
@@ -1577,7 +1577,9 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
 			uint64_t count;
 
 			max_entries = min(max_entries, 16ull * 1024ull);
-			for (count = 1; count < max_entries; ++count) {
+			for (count = 1;
+			     count < max_entries / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
+			     ++count) {
 				uint64_t idx = pfn + count;
 
 				if (pages_addr[idx] !=
@@ -1590,7 +1592,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
 				dma_addr = pages_addr;
 			} else {
 				addr = pages_addr[pfn];
-				max_entries = count;
+				max_entries = count * (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
 			}
 
 		} else if (flags & AMDGPU_PTE_VALID) {
@@ -1605,7 +1607,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
 		if (r)
 			return r;
 
-		pfn += last - start + 1;
+		pfn += (last - start + 1) / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
 		if (nodes && nodes->size == pfn) {
 			pfn = 0;
 			++nodes;
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): 20180622091035.4119-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org

#2 lore raw

Am 22.06.2018 um 11:10 schrieb Michel Dänzer:

Quoted 5 lines

From: Michel Dänzer <[email protected]>

start / last / max_entries are numbers of GPU pages, pfn / count are numbers of CPU pages. Convert between them accordingly.

Quoted 7 lines

Fixes badness on systems with > 4K page size.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106258

Nice work! Just one comment: Can we somewhere add a define for "(PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE)"?

IIRC that term was used in the GART code as well and just adding it somewhere could makes things cleaner if you ask me.

Christian.

Quoted 29 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -2
index 7c30451ba897..590db78b8c72 100644
@@ -1577,7 +1577,9 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
  			uint64_t count;
 
  			max_entries = min(max_entries, 16ull * 1024ull);
-			for (count = 1; count < max_entries; ++count) {
+			for (count = 1;
+			     count < max_entries / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
+			     ++count) {
  				uint64_t idx = pfn + count;
 
  				if (pages_addr[idx] !=
@@ -1590,7 +1592,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
  				dma_addr = pages_addr;
  			} else {
  				addr = pages_addr[pfn];
-				max_entries = count;
+				max_entries = count * (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
  			}
 
  		} else if (flags & AMDGPU_PTE_VALID) {

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, · line 1613

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -1605,7 +1607,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
  		if (r)
  			return r;
 
-		pfn += last - start + 1;
+		pfn += (last - start + 1) / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
  		if (nodes && nodes->size == pfn) {
  			pfn = 0;
  			++nodes;

_______________________________________________
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): a2824504-f765-251c-5adb-dda69ecc9ca7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 8 lines · Christian König

Am 22.06.2018 um 11:10 schrieb Michel Dänzer:

Quoted 7 lines

From: Michel Dänzer <[email protected]>

start / last / max_entries are numbers of GPU pages, pfn / count are numbers of CPU pages. Convert between them accordingly.

Fixes badness on systems with > 4K page size.

Quoted 7 lines
Quoted 5 lines

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106258

Nice work!

Thanks.

Quoted 5 lines

Just one comment: Can we somewhere add a define for "(PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE)"?

IIRC that term was used in the GART code as well and just adding it somewhere could makes things cleaner if you ask me.

Sure, but that can be a follow-up patch, right?

Can I get your R-b for this one?

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
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): a3a30887-bb0e-1d90-69ca-21fac8f35b62-otUistvHUpPR7s880joybQ@public.gmane.org

#6 lore raw

Am 22.06.2018 um 16:12 schrieb Michel Dänzer:

Quoted 18 lines · Christian König
Quoted 6 lines

Am 22.06.2018 um 11:10 schrieb Michel Dänzer:

Quoted 5 lines

From: Michel Dänzer <[email protected]>

start / last / max_entries are numbers of GPU pages, pfn / count are numbers of CPU pages. Convert between them accordingly.

Quoted 8 lines
Quoted 7 lines

Fixes badness on systems with > 4K page size.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106258

Nice work!

Thanks.

Quoted 8 lines
Quoted 5 lines

Just one comment: Can we somewhere add a define for "(PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE)"?

IIRC that term was used in the GART code as well and just adding it somewhere could makes things cleaner if you ask me.

Sure, but that can be a follow-up patch, right?

Can I get your R-b for this one?

Certainly, patch is Reviewed-by: Christian König <[email protected]>.

Thanks,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#7 lore raw
In reply to a message not in the archive
Quoted 5 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

start / last / max_entries are numbers of GPU pages, pfn / count are numbers of CPU pages. Convert between them accordingly.

Quoted 7 lines

Fixes badness on systems with > 4K page size.

Cc: [email protected]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106258

Quoted 40 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -4
index 7c30451ba897..590db78b8c72 100644
@@ -1577,7 +1577,9 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
                        uint64_t count;
 
                        max_entries = min(max_entries, 16ull * 1024ull);
-                       for (count = 1; count < max_entries; ++count) {
+                       for (count = 1;
+                            count < max_entries / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
+                            ++count) {
                                uint64_t idx = pfn + count;
 
                                if (pages_addr[idx] !=
@@ -1590,7 +1592,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
                                dma_addr = pages_addr;
                        } else {
                                addr = pages_addr[pfn];
-                               max_entries = count;
+                               max_entries = count * (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
                        }
 
                } else if (flags & AMDGPU_PTE_VALID) {
@@ -1605,7 +1607,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,
                if (r)
                        return r;
 
-               pfn += last - start + 1;
+               pfn += (last - start + 1) / (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE);
                if (nodes && nodes->size == pfn) {
                        pfn = 0;
                        ++nodes;
--

2.17.1

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