drm/amdgpu: use ttm pool first
Subsystems (2)
PATCH 1/1 drm/amdgpu: use ttm pool first
dma path is low than ttm pool.
Question:
But why need two path? What spicific problem can be solved by dma path?
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -4
@@ -996,6 +996,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm,struct amdgpu_device *adev =amdgpu_ttm_adev (ttm->bdev);struct amdgpu_ttm_tt *gtt = (void *)ttm;bool slave = !!(ttm->page_flags &TTM_PAGE_FLAG_SG ); +int r;if (ttm->state != tt_unpopulated)return 0 ;
@@ -1017,13 +1018,14 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm,return 0 ; } + r =ttm_populate_and_map_pages (adev->dev, >t->ttm, ctx); +#ifdef CONFIG_SWIOTLB -if (swiotlb_nr_tbl ()) { -return ttm_dma_populate (>t->ttm, adev->dev, ctx); +if ((r == -EFAULT ) &&swiotlb_nr_tbl ()) { + r =ttm_dma_populate (>t->ttm, adev->dev, ctx); }#endif - -return ttm_populate_and_map_pages (adev->dev, >t->ttm, ctx); +return r; }static void amdgpu_ttm_tt_unpopulate (struct ttm_tt *ttm)
Signature · 6 lines
2.14.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 24.01.2018 um 10:17 schrieb Chunming Zhou:
Quoted 1 line
dma path is low than ttm pool.
That won't work correctly in some cases.
Quoted 2 lines
Question:
But why need two path? What spicific problem can be solved by dma path?
That is mostly for ARM and some (rare) x86 platforms without IOMMU where some memory is above the 40bit limit in the PCIe address space.
Our GPUs can unfortunately only deal with 40bits of address space, so on those systems we need to go the slow path and make sure that we don't try to touch that high memory.
What we could really improve is the detection using swiotlb_nr_tbl(), cause that is actually completely wrong.
Regards,
Christian.
Quoted 28 lines
Change-Id I4a9fc7103658e643f33e267616fc69743b20b09eSigned-off-by Chunming Zhou <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-2@@ -996,6 +996,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm,struct amdgpu_device *adev =amdgpu_ttm_adev (ttm->bdev);struct amdgpu_ttm_tt *gtt = (void *)ttm;bool slave = !!(ttm->page_flags &TTM_PAGE_FLAG_SG ); +int r;if (ttm->state != tt_unpopulated)return 0 ;@@ -1017,13 +1018,14 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm,return 0 ; } + r =ttm_populate_and_map_pages (adev->dev, >t->ttm, ctx); +#ifdef CONFIG_SWIOTLB -if (swiotlb_nr_tbl ()) { -return ttm_dma_populate (>t->ttm, adev->dev, ctx);
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, · line 1031
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-2+if ((r == -EFAULT ) &&swiotlb_nr_tbl ()) { + r =ttm_dma_populate (>t->ttm, adev->dev, ctx); }#endif - -return ttm_populate_and_map_pages (adev->dev, >t->ttm, ctx); +return r; }static void amdgpu_ttm_tt_unpopulate (struct ttm_tt *ttm)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 5 lines · Christian König
Am 24.01.2018 um 10:17 schrieb Chunming Zhou:
Quoted 1 line
dma path is low than ttm pool.
That won't work correctly in some cases.
Quoted 8 lines
Quoted 2 lines
Question:
But why need two path? What spicific problem can be solved by dma path?That is mostly for ARM and some (rare) x86 platforms without IOMMU where some memory is above the 40bit limit in the PCIe address space.
Our GPUs can unfortunately only deal with 40bits of address space, so on those systems we need to go the slow path and make sure that we don't try to touch that high memory.
What we could really improve is the detection using
swiotlb_nr_tbl(), cause that is actually completely wrong.
OK, the patch is trying to use ttm pool first, if dma_map_page fails, then fallback to swtlb path, is that ok?
Regards,
David Zhou
Quoted 38 lines
Regards,
Christian.Quoted 34 lines
Change-Id I4a9fc7103658e643f33e267616fc69743b20b09eSigned-off-by Chunming Zhou <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 10 ++++++----1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4
-4@@ -996,6 +996,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); struct amdgpu_ttm_tt *gtt = (void *)ttm; bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); + int r; if (ttm->state != tt_unpopulated) return 0;@@ -1017,13 +1018,14 @@ static int amdgpu_ttm_tt_populate(structttm_tt *ttm, return 0; } + r = ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); + #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { - return ttm_dma_populate(>t->ttm, adev->dev, ctx); + if ((r == -EFAULT) && swiotlb_nr_tbl()) { + r = ttm_dma_populate(>t->ttm, adev->dev, ctx); } #endif - - return ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx);
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, · line 1031
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1
-0+ return r; } static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)_______________________________________________
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
Quoted 11 lines · Christian König
Am 24.01.2018 um 10:17 schrieb Chunming Zhou:
Quoted 1 line
dma path is low than ttm pool.
That won't work correctly in some cases.
Quoted 2 lines
Question:
But why need two path? What spicific problem can be solved by dma path?That is mostly for ARM and some (rare) x86 platforms without IOMMU where some memory is above the 40bit limit in the PCIe address space.
Quoted 6 lines
Our GPUs can unfortunately only deal with 40bits of address space, so on those systems we need to go the slow path and make sure that we don't try to touch that high memory.
What we could really improve is the detection using
swiotlb_nr_tbl(), cause that is actually completely wrong.
FWIW, there are other cases where SWIOTLB is needed, e.g. Secure Memory
Encryption: https://bugs.freedesktop.org/show_bug.cgi?id=104437
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
Am 24.01.2018 um 10:48 schrieb Chunming Zhou:
Quoted 11 lines · Christian König
Quoted 8 lines
Am 24.01.2018 um 10:17 schrieb Chunming Zhou:
Quoted 1 line
dma path is low than ttm pool.
That won't work correctly in some cases.
Quoted 2 lines
Question:
But why need two path? What spicific problem can be solved by dma path?
Quoted 6 lines
Quoted 5 lines
That is mostly for ARM and some (rare) x86 platforms without IOMMU where some memory is above the 40bit limit in the PCIe address space.
Our GPUs can unfortunately only deal with 40bits of address space, so on those systems we need to go the slow path and make sure that we don't try to touch that high memory.
What we could really improve is the detection using
swiotlb_nr_tbl(), cause that is actually completely wrong.OK, the patch is trying to use ttm pool first, if
dma_map_pagefails, then fallback to swtlb path, is that ok?
Nope, as I wrote that won't work. You must improve the detection if we need coherent or not coherent allocation.
Regards,
Christian.
Quoted 50 lines
Regards,
David ZhouQuoted 46 lines
Regards,
Christian.Quoted 27 lines
Change-Id I4a9fc7103658e643f33e267616fc69743b20b09eSigned-off-by Chunming Zhou <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 10 ++++++----1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-1@@ -996,6 +996,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); struct amdgpu_ttm_tt *gtt = (void *)ttm; bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); + int r; if (ttm->state != tt_unpopulated) return 0;@@ -1017,13 +1018,14 @@ static int amdgpu_ttm_tt_populate(structttm_tt *ttm, return 0; } + r = ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); + #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) {drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_tt_populate(struct · line 1030
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-3- return ttm_dma_populate(>t->ttm, adev->dev, ctx); + if ((r == -EFAULT) && swiotlb_nr_tbl()) { + r = ttm_dma_populate(>t->ttm, adev->dev, ctx); } #endif - - return ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); + return r; } static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)_______________________________________________
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
Am 24.01.2018 um 10:49 schrieb Michel Dänzer:
Quoted 10 lines · Christian König
Quoted 9 lines
Am 24.01.2018 um 10:17 schrieb Chunming Zhou:
Quoted 1 line
dma path is low than ttm pool.
That won't work correctly in some cases.
Quoted 2 lines
Question:
But why need two path? What spicific problem can be solved by dma path?That is mostly for ARM and some (rare) x86 platforms without IOMMU where some memory is above the 40bit limit in the PCIe address space.
Quoted 8 lines
Quoted 6 lines
Our GPUs can unfortunately only deal with 40bits of address space, so on those systems we need to go the slow path and make sure that we don't try to touch that high memory.
What we could really improve is the detection using
swiotlb_nr_tbl(), cause that is actually completely wrong.FWIW, there are other cases where SWIOTLB is needed, e.g. Secure Memory
Encryption: https://bugs.freedesktop.org/show_bug.cgi?id=104437
Oh! Good point, didn't noticed that bug before. But yes the rational makes perfect sense.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 12 lines · Christian König
Am 24.01.2018 um 10:48 schrieb Chunming Zhou:
Quoted 11 lines · Christian König
Quoted 8 lines
Am 24.01.2018 um 10:17 schrieb Chunming Zhou:
Quoted 1 line
dma path is low than ttm pool.
That won't work correctly in some cases.
Quoted 2 lines
Question:
But why need two path? What spicific problem can be solved by dma path?
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
That is mostly for ARM and some (rare) x86 platforms without IOMMU where some memory is above the 40bit limit in the PCIe address space.
Our GPUs can unfortunately only deal with 40bits of address space, so on those systems we need to go the slow path and make sure that we don't try to touch that high memory.
What we could really improve is the detection using
swiotlb_nr_tbl(), cause that is actually completely wrong.OK, the patch is trying to use ttm pool first, if
dma_map_pagefails, then fallback to swtlb path, is that ok?Nope, as I wrote that won't work. You must improve the detection if we need coherent or not coherent allocation.
But how to differentiate coherent or not coherent allocation? check if max io address of system memory under 40bits pcie address space? Do you know how to get the max io address of system memory?
Regards,
David Zhou
Quoted 55 lines
Regards,
Christian.Quoted 50 lines
Regards,
David ZhouQuoted 46 lines
Regards,
Christian.Quoted 27 lines
Change-Id I4a9fc7103658e643f33e267616fc69743b20b09eSigned-off-by Chunming Zhou <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c| 10 ++++++----1 file changed, 6 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2
-1@@ -996,6 +996,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, struct amdgpu_device *adev = amdgpu_ttm_adev(ttm->bdev); struct amdgpu_ttm_tt *gtt = (void *)ttm; bool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG); + int r; if (ttm->state != tt_unpopulated) return 0;@@ -1017,13 +1018,14 @@ static int amdgpu_ttm_tt_populate(structttm_tt *ttm, return 0; } + r = ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); + #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) {drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static int amdgpu_ttm_tt_populate(struct · line 1030
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3
-3- return ttm_dma_populate(>t->ttm, adev->dev, ctx); + if ((r == -EFAULT) && swiotlb_nr_tbl()) { + r = ttm_dma_populate(>t->ttm, adev->dev, ctx); } #endif - - return ttm_populate_and_map_pages(adev->dev, >t->ttm, ctx); + return r; } static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm)_______________________________________________
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
Am 24.01.2018 um 11:32 schrieb Chunming Zhou:
Quoted 4 lines · Christian König
Quoted 2 lines
[SNIP]
Nope, as I wrote that won't work. You must improve the detection if we need coherent or not coherent allocation.But how to differentiate coherent or not coherent allocation? check if max io address of system memory under 40bits pcie address space? Do you know how to get the max io address of system memory?
Well that is a good question, which nobody had an answer for so far (and a couple of people already looked into it).
We could start by checking if max_pfn is <= the 40bits limit or if IOMMU is enabled instead of SWIOTLB.
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 9 lines · Christian König
Am 24.01.2018 um 11:32 schrieb Chunming Zhou:
Quoted 4 lines · Christian König
Quoted 2 lines
[SNIP]
Nope, as I wrote that won't work. You must improve the detection if we need coherent or not coherent allocation.But how to differentiate coherent or not coherent allocation? check if max io address of system memory under 40bits pcie address space? Do you know how to get the max io address of system memory?
Well that is a good question, which nobody had an answer for so far (and a couple of people already looked into it).
We could start by checking if
max_pfnis <= the 40bits limit or if IOMMU is enabled instead of SWIOTLB.
How to get max_pfn?
btw, seems only amdgpu and radeon driver use dma path.
Regards,
David Zhou
Quoted 3 lines
Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx