drm/amdgpu: Add AMDGPU_GPU_PAGES_IN_CPU_PAGE define
Subsystems (2)
PATCH 1/1 drm/amdgpu: Add AMDGPU_GPU_PAGES_IN_CPU_PAGE define
From: Michel Dänzer <[email protected]>
To hopefully make the code dealing with GPU vs CPU pages a little clearer.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4 -4
@@ -234,7 +234,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, } t = offset /AMDGPU_GPU_PAGE_SIZE ; - p = t / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + p = t /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;for (i =0 ; i < pages; i++, p++) {#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS adev->gart.pages[p] =NULL ;
@@ -243,7 +243,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,if (!adev->gart.ptr)continue ; -for (j =0 ; j < (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); j++, t++) { +for (j =0 ; j <AMDGPU_GPU_PAGES_IN_CPU_PAGE ; j++, t++) {amdgpu_gmc_set_pte_pde (adev, adev->gart.ptr, t, page_base, flags); page_base +=AMDGPU_GPU_PAGE_SIZE ;
@@ -282,7 +282,7 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,for (i =0 ; i < pages; i++) { page_base = dma_addr[i]; -for (j =0 ; j < (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); j++, t++) { +for (j =0 ; j <AMDGPU_GPU_PAGES_IN_CPU_PAGE ; j++, t++) {amdgpu_gmc_set_pte_pde (adev, dst, t, page_base, flags); page_base +=AMDGPU_GPU_PAGE_SIZE ; }
@@ -319,7 +319,7 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS t = offset /AMDGPU_GPU_PAGE_SIZE ; - p = t / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + p = t /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;for (i =0 ; i < pages; i++, p++) adev->gart.pages[p] = pagelist ? pagelist[i] :NULL ;#endif
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2 -0
@@ -37,6 +37,8 @@ struct amdgpu_bo;#define AMDGPU_GPU_PAGE_SHIFT 12#define AMDGPU_GPU_PAGE_ALIGN (a) (((a) + AMDGPU_GPU_PAGE_MASK) & ~AMDGPU_GPU_PAGE_MASK) +#define AMDGPU_GPU_PAGES_IN_CPU_PAGE (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE) +struct amdgpu_gart {u64 table_addr;struct amdgpu_bo *robj;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -4
@@ -1571,7 +1571,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,if (nodes) { addr = nodes->start <<PAGE_SHIFT ; max_entries = (nodes->size - pfn) * - (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); +AMDGPU_GPU_PAGES_IN_CPU_PAGE ; }else { addr =0 ; max_entries =S64_MAX ;
@@ -1582,7 +1582,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, max_entries =min (max_entries,16ull *1024ull );for (count =1 ; - count < max_entries / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + count < max_entries /AMDGPU_GPU_PAGES_IN_CPU_PAGE ; ++count) {uint64_t idx = pfn + count;
@@ -1596,7 +1596,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, dma_addr = pages_addr; }else { addr = pages_addr[pfn]; - max_entries = count * (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + max_entries = count *AMDGPU_GPU_PAGES_IN_CPU_PAGE ; } }else if (flags &AMDGPU_PTE_VALID ) {
@@ -1611,7 +1611,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,if (r)return r; - pfn += (last - start +1 ) / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + pfn += (last - start +1 ) /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;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): 20180622165433.4263-1-michel-otUistvHUpPR7s880joybQ@public.gmane.org
Alex Deucher
Reviewed-byQuoted 7 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
To hopefully make the code dealing with GPU vs CPU pages a little clearer.
Suggested-by Christian König <[email protected]>Signed-off-by Michel Dänzer <[email protected]>
Quoted 102 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4
-4@@ -234,7 +234,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, } t = offset /AMDGPU_GPU_PAGE_SIZE ; - p = t / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + p = t /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;for (i =0 ; i < pages; i++, p++) {#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS adev->gart.pages[p] =NULL ;@@ -243,7 +243,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,if (!adev->gart.ptr)continue ; -for (j =0 ; j < (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); j++, t++) { +for (j =0 ; j <AMDGPU_GPU_PAGES_IN_CPU_PAGE ; j++, t++) {amdgpu_gmc_set_pte_pde (adev, adev->gart.ptr, t, page_base, flags); page_base +=AMDGPU_GPU_PAGE_SIZE ;@@ -282,7 +282,7 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,for (i =0 ; i < pages; i++) { page_base = dma_addr[i]; -for (j =0 ; j < (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); j++, t++) { +for (j =0 ; j <AMDGPU_GPU_PAGES_IN_CPU_PAGE ; j++, t++) {amdgpu_gmc_set_pte_pde (adev, dst, t, page_base, flags); page_base +=AMDGPU_GPU_PAGE_SIZE ; }@@ -319,7 +319,7 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS t = offset /AMDGPU_GPU_PAGE_SIZE ; - p = t / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + p = t /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;for (i =0 ; i < pages; i++, p++) adev->gart.pages[p] = pagelist ? pagelist[i] :NULL ;#endif drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2
-0@@ -37,6 +37,8 @@ struct amdgpu_bo;#define AMDGPU_GPU_PAGE_SHIFT 12#define AMDGPU_GPU_PAGE_ALIGN (a) (((a) + AMDGPU_GPU_PAGE_MASK) & ~AMDGPU_GPU_PAGE_MASK) +#define AMDGPU_GPU_PAGES_IN_CPU_PAGE (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE) +struct amdgpu_gart {u64 table_addr;struct amdgpu_bo *robj;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-5@@ -1571,7 +1571,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,if (nodes) { addr = nodes->start <<PAGE_SHIFT ; max_entries = (nodes->size - pfn) * - (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); +AMDGPU_GPU_PAGES_IN_CPU_PAGE ; }else { addr =0 ; max_entries =S64_MAX ;@@ -1582,7 +1582,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, max_entries =min (max_entries,16ull *1024ull );for (count =1 ; - count < max_entries / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + count < max_entries /AMDGPU_GPU_PAGES_IN_CPU_PAGE ; ++count) {uint64_t idx = pfn + count;@@ -1596,7 +1596,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, dma_addr = pages_addr; }else { addr = pages_addr[pfn]; - max_entries = count * (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + max_entries = count *AMDGPU_GPU_PAGES_IN_CPU_PAGE ; } }else if (flags &AMDGPU_PTE_VALID ) {@@ -1611,7 +1611,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,if (r)return r; - pfn += (last - start +1 ) / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + pfn += (last - start +1 ) /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;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
A message that is not in the archive (sent off-list or not yet received): CADnq5_NLmNtSH35TG5i3_WJdLGu_ujbkTW-Z-G5CodCDRZj0Xg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
one question to you:
Did you consider the case that GPU_PAGE_SIZE > CPU_PAGE_SIZE? What happens if the case is ture?
Regards,
David Zhou
Quoted 112 lines · Alex Deucher
Quoted 7 lines · Michel Dänzer
From: Michel Dänzer <[email protected]>
To hopefully make the code dealing with GPU vs CPU pages a little clearer.
Suggested-by Christian König <[email protected]>Signed-off-by Michel Dänzer <[email protected]>Reviewed-by Alex Deucher <[email protected]>Quoted 102 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 8 ++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +4
-4@@ -234,7 +234,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, } t = offset /AMDGPU_GPU_PAGE_SIZE ; - p = t / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + p = t /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;for (i =0 ; i < pages; i++, p++) {#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS adev->gart.pages[p] =NULL ;@@ -243,7 +243,7 @@ int amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset,if (!adev->gart.ptr)continue ; -for (j =0 ; j < (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); j++, t++) { +for (j =0 ; j <AMDGPU_GPU_PAGES_IN_CPU_PAGE ; j++, t++) {amdgpu_gmc_set_pte_pde (adev, adev->gart.ptr, t, page_base, flags); page_base +=AMDGPU_GPU_PAGE_SIZE ;@@ -282,7 +282,7 @@ int amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset,for (i =0 ; i < pages; i++) { page_base = dma_addr[i]; -for (j =0 ; j < (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); j++, t++) { +for (j =0 ; j <AMDGPU_GPU_PAGES_IN_CPU_PAGE ; j++, t++) {amdgpu_gmc_set_pte_pde (adev, dst, t, page_base, flags); page_base +=AMDGPU_GPU_PAGE_SIZE ; }@@ -319,7 +319,7 @@ int amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset,#ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS t = offset /AMDGPU_GPU_PAGE_SIZE ; - p = t / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + p = t /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;for (i =0 ; i < pages; i++, p++) adev->gart.pages[p] = pagelist ? pagelist[i] :NULL ;#endif drivers/gpu/drm/amd/amdgpu/amdgpu_gart.h +2
-0@@ -37,6 +37,8 @@ struct amdgpu_bo;#define AMDGPU_GPU_PAGE_SHIFT 12#define AMDGPU_GPU_PAGE_ALIGN (a) (((a) + AMDGPU_GPU_PAGE_MASK) & ~AMDGPU_GPU_PAGE_MASK) +#define AMDGPU_GPU_PAGES_IN_CPU_PAGE (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE) +struct amdgpu_gart {u64 table_addr;struct amdgpu_bo *robj;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-5@@ -1571,7 +1571,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,if (nodes) { addr = nodes->start <<PAGE_SHIFT ; max_entries = (nodes->size - pfn) * - (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); +AMDGPU_GPU_PAGES_IN_CPU_PAGE ; }else { addr =0 ; max_entries =S64_MAX ;@@ -1582,7 +1582,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, max_entries =min (max_entries,16ull *1024ull );for (count =1 ; - count < max_entries / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + count < max_entries /AMDGPU_GPU_PAGES_IN_CPU_PAGE ; ++count) {uint64_t idx = pfn + count;@@ -1596,7 +1596,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev, dma_addr = pages_addr; }else { addr = pages_addr[pfn]; - max_entries = count * (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + max_entries = count *AMDGPU_GPU_PAGES_IN_CPU_PAGE ; } }else if (flags &AMDGPU_PTE_VALID ) {@@ -1611,7 +1611,7 @@ static int amdgpu_vm_bo_split_mapping(struct amdgpu_device *adev,if (r)return r; - pfn += (last - start +1 ) / (PAGE_SIZE /AMDGPU_GPU_PAGE_SIZE ); + pfn += (last - start +1 ) /AMDGPU_GPU_PAGES_IN_CPU_PAGE ;if (nodes && nodes->size == pfn) { pfn =0 ; ++nodes; --2.17.1
Quoted 8 lines
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
_______________________________________________
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): 9a352ebd-3dea-e8ef-4151-022be90d45c0-5C7GfCeVMHo@public.gmane.org
Quoted 3 lines · On 2018-06-25 03:56 AM, zhoucm1 wrote:
one question to you:
Did you consider the case that
GPU_PAGE_SIZE>CPU_PAGE_SIZE?
That is never the case: AMDGPU_GPU_PAGE_SIZE is always 4096, and PAGE_SIZE is always >= 4096 (an integer multiple of it).
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): b61f92a6-2d90-257d-8aa5-25b88b98459c-otUistvHUpPR7s880joybQ@public.gmane.org
current amdgpu driver indeed always set GPU PAGE SIZE is 4096.
In fact, our gpu supports bigger page size like 64KB, just we don't use it. I remeber previous amdsoc(old android kernel driver) used 64KB.
correct me if I'm wrong.
send from Smartisan Pro
Michel D鋘zer <[email protected]> 于 2018年6月25日 下午5:10写道:
Quoted 3 lines · On 2018-06-25 03:56 AM, zhoucm1 wrote:
one question to you:
Did you consider the case that
GPU_PAGE_SIZE>CPU_PAGE_SIZE?
That is never the case: AMDGPU_GPU_PAGE_SIZE is always 4096, and PAGE_SIZE is always >= 4096 (an integer multiple of it).
--
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): [email protected]
A message that is not in the archive (sent off-list or not yet received): 5b30f068.1c69fb81.45984.62a8SMTPIN_ADDED_BROKEN-ATjtLOhZ0NVl57MIdRCFDg@public.gmane.org
Quoted 5 lines · David(ChunMing)
current amdgpu driver indeed always set GPU PAGE SIZE is 4096. In fact, our gpu supports bigger page size like 64KB, just we don't use it. I remeber previous amdsoc(old android kernel driver) used 64KB.
correct me if I'm wrong.
It's still 4k pages, but you can tweak the fragment size to make a TLB entry cover multiple pages.
Alex
Quoted 14 lines
send from Smartisan Pro
Michel D鋘zer <[email protected]> 于 2018年6月25日 下午5:10写道:
Quoted 3 lines · On 2018-06-25 03:56 AM, zhoucm1 wrote:
one question to you:
Did you consider the case that
GPU_PAGE_SIZE>CPU_PAGE_SIZE?That is never the case:
AMDGPU_GPU_PAGE_SIZEis always 4096, andPAGE_SIZEis always >= 4096 (an integer multiple of it).
Quoted 9 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
_______________________________________________
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): CADnq5_O5kAsZZRdyacuOP7CcN5Ey-Rz+-grW29WOLbR4SL88ng-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Am 25.06.2018 um 16:41 schrieb Alex Deucher:
Quoted 9 lines
Quoted 5 lines · David(ChunMing)
current amdgpu driver indeed always set GPU PAGE SIZE is 4096. In fact, our gpu supports bigger page size like 64KB, just we don't use it. I remeber previous amdsoc(old android kernel driver) used 64KB.
correct me if I'm wrong.
It's still 4k pages, but you can tweak the fragment size to make a TLB entry cover multiple pages.
Yeah, but David is right you can also directly increase the GPU page size. It's just that I'm pretty sure we will never ever support that :)
Anyway original patch is Reviewed-by: Christian König <[email protected]>.
Christian.
Quoted 24 lines
Alex
Quoted 12 lines
send from Smartisan Pro
Michel D鋘zer <[email protected]> 于 2018年6月25日 下午5:10写道:
Quoted 3 lines · On 2018-06-25 03:56 AM, zhoucm1 wrote:
one question to you:
Did you consider the case that
GPU_PAGE_SIZE>CPU_PAGE_SIZE?That is never the case:
AMDGPU_GPU_PAGE_SIZEis always 4096, andPAGE_SIZEis always >= 4096 (an integer multiple of it).Quoted 9 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
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