drm/amdgpu: insert partial mappings before and after directly
Subsystems (2)
PATCH 1/2 drm/amdgpu: insert partial mappings before and after directly
Currently it may miss one page before or after the target mapping
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -18
@@ -1767,7 +1767,11 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, before->it.last = saddr -1 ; before->offset = tmp->offset; before->flags = tmp->flags; +list_add (&before->list, &tmp->list); +interval_tree_insert (&before->it, &vm->va); +if (before->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }/* Remember mapping split at the end */
@@ -1777,7 +1781,11 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, after->offset = tmp->offset; after->offset += after->it.start - tmp->it.start; after->flags = tmp->flags; +list_add (&after->list, &tmp->list); +interval_tree_insert (&after->it, &vm->va); +if (after->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }list_del (&tmp->list);
@@ -1799,24 +1807,6 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,trace_amdgpu_vm_bo_unmap (NULL , tmp); } -/* Insert partial mapping before the range*/ -if (before->it.start != before->it.last) { -interval_tree_insert (&before->it, &vm->va); -if (before->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (before); - } - -/* Insert partial mapping after the range */ -if (after->it.start != after->it.last) { -interval_tree_insert (&after->it, &vm->va); -if (after->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (after); - } -return 0 ; }
Signature · 6 lines
1.9.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): 1489635888-31293-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org
PATCH 2/2 drm/amdgpu: fix bo_va tracing for bo unmap
--- drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +1 -1
@@ -245,7 +245,7 @@ ), TP_fast_assign( - __entry->bo = bo_va->bo; + __entry->bo = bo_va ? bo_va->bo : NULL; __entry->start = mapping->it.start; __entry->last = mapping->it.last; __entry->offset = mapping->offset;
Signature · 6 lines
1.9.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Am 16.03.2017 um 04:44 schrieb Junwei Zhang:
Quoted 1 line
Currently it may miss one page before or after the target mapping
I don't think that this will work correctly. The interval tree still contains the old mapping at this point and as far as I know inserting overlapping mappings is not allowed here.
But what do you mean with miss one page before or after the target mapping?
Christian.
Quoted 49 lines
Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8
-11@@ -1767,7 +1767,11 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, before->it.last = saddr -1 ; before->offset = tmp->offset; before->flags = tmp->flags; +list_add (&before->list, &tmp->list); +interval_tree_insert (&before->it, &vm->va); +if (before->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }/* Remember mapping split at the end */ @@ -1777,7 +1781,11 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, after->offset = tmp->offset; after->offset += after->it.start - tmp->it.start; after->flags = tmp->flags; +list_add (&after->list, &tmp->list); +interval_tree_insert (&after->it, &vm->va); +if (after->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }list_del (&tmp->list);@@ -1799,24 +1807,6 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,trace_amdgpu_vm_bo_unmap (NULL , tmp); } -/* Insert partial mapping before the range*/ -if (before->it.start != before->it.last) { -interval_tree_insert (&before->it, &vm->va); -if (before->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (before); - } - -/* Insert partial mapping after the range */ -if (after->it.start != after->it.last) {
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, · line 1812
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-7-interval_tree_insert (&after->it, &vm->va); -if (after->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (after); - } -return 0 ; }
_______________________________________________
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): e1b3592f-839e-691d-bc59-af2fb2efe5a8-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 7 lines
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 15:33
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: insert partial mappings before and after directly
Quoted 6 lines
Am 16.03.2017 um 04:44 schrieb Junwei Zhang:
Quoted 1 line
Currently it may miss one page before or after the target mapping
I don't think that this will work correctly. The interval tree still contains the old mapping at this point and as far as I know inserting overlapping mappings is not allowed here.
Ah, I missed that, so this insert op should be after free up. I will revise the patch
Quoted 2 lines
But what do you mean with miss one page before or after the target mapping?
I did a unit test to verify it and found that:
If the before mapping is 1 page size, so its start and last will be same. Thus below condition will become false then to free the before mapping.
Quoted 1 line
if (
before->it.start!=before->it.last)
But in this case, we need the before mapping of 1 page size. So does after mapping.
e.g.
Initialize a mapping: [0, 8] pages size.
A replace mapping: [1, 2] page size.
Before mapping is [0, 1], before.it.start = 0, before.it = 1 - 1 = 0.
Additionally, if we create a bo as 1 page size, the corresponding mapping also has start==last, I think.
Jerry.
Quoted 58 lines
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct
Quoted 12 lines
Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1767,7 +1767,11 @@ int amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0before->it.last = saddr -1 ; before->offset = tmp->offset; before->flags = tmp->flags; +list_add (&before->list, &tmp->list); +interval_tree_insert (&before->it, &vm->va); +if (before->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); } /* Remember mapping split at the end */ @@ -1777,7 +1781,11@@ int
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct
Quoted 13 lines
amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,
after->offset=tmp->offset;after->offset+=after->it.start-tmp->it.start;after->flags=tmp->flags;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0+list_add (&after->list, &tmp->list); +interval_tree_insert (&after->it, &vm->va); +if (after->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }list_del (&tmp->list);@@ -1799,24 +1807,6 @@ int amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-13trace_amdgpu_vm_bo_unmap (NULL , tmp); } -/* Insert partial mapping before the range*/ -if (before->it.start != before->it.last) { -interval_tree_insert (&before->it, &vm->va); -if (before->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (before); - } - -/* Insert partial mapping after the range */ -if (after->it.start != after->it.last) { -interval_tree_insert (&after->it, &vm->va); -if (after->flags &AMDGPU_PTE_PRT )
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, · line 1812
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-5-amdgpu_vm_prt_get (adev); - }else { -kfree (after); - } -return 0 ; }
_______________________________________________
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): DM5PR12MB1818975FC463941DFBB30ACDFF260-2J9CzHegvk+QhrfEZJlvtAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 16.03.2017 um 08:46 schrieb Zhang, Jerry:
Quoted 24 lines
Quoted 7 lines
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 15:33
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: insert partial mappings before and after directlyQuoted 5 lines
Am 16.03.2017 um 04:44 schrieb Junwei Zhang:
Quoted 1 line
Currently it may miss one page before or after the target mapping
I don't think that this will work correctly. The interval tree still contains the old mapping at this point and as far as I know inserting overlapping mappings is not allowed here.
Ah, I missed that, so this insert op should be after free up. I will revise the patch
Quoted 1 line
But what do you mean with miss one page before or after the target mapping?
I did a unit test to verify it and found that:
If the before mapping is 1 page size, so its start and last will be same. Thus below condition will become false then to free the before mapping.
Quoted 1 line
if (
before->it.start!=before->it.last)But in this case, we need the before mapping of 1 page size. So does after mapping.
Quoted 6 lines
e.g.
Initialize a mapping: [0, 8] pages size.
A replace mapping: [1, 2] page size.
Before mapping is [0, 1], before.it.start = 0, before.it = 1 - 1 = 0.Additionally, if we create a bo as 1 page size, the corresponding mapping also has start==last, I think.
Ups, that's indeed not correct.
Yeah we need a better criteria if we should insert the ranges or not.
Christian.
Quoted 59 lines
Jerry.
Quoted 56 lines
Christian.
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct
Quoted 11 lines
Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1767,7 +1767,11 @@ int amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0before->it.last = saddr -1 ; before->offset = tmp->offset; before->flags = tmp->flags; +list_add (&before->list, &tmp->list); +interval_tree_insert (&before->it, &vm->va); +if (before->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); } /* Remember mapping split at the end */ @@ -1777,7 +1781,11@@ int
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct
Quoted 13 lines
amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,after->offset = tmp->offset; after->offset += after->it.start - tmp->it.start; after->flags = tmp->flags;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0+list_add (&after->list, &tmp->list); +interval_tree_insert (&after->it, &vm->va); +if (after->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }list_del (&tmp->list);@@ -1799,24 +1807,6 @@ int amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-13trace_amdgpu_vm_bo_unmap (NULL , tmp); } -/* Insert partial mapping before the range*/ -if (before->it.start != before->it.last) { -interval_tree_insert (&before->it, &vm->va); -if (before->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (before); - } - -/* Insert partial mapping after the range */ -if (after->it.start != after->it.last) { -interval_tree_insert (&after->it, &vm->va); -if (after->flags &AMDGPU_PTE_PRT )
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, · line 1812
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-5-amdgpu_vm_prt_get (adev); - }else { -kfree (after); - } -return 0 ; }
_______________________________________________
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): 3846992f-589e-079c-c8e8-65bbd9a54805-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Quoted 37 lines
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 15:59
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: insert partial mappings before and after directlyAm 16.03.2017 um 08:46 schrieb Zhang, Jerry:
Quoted 29 lines
Quoted 7 lines
-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 15:33
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH 1/2] drm/amdgpu: insert partial mappings before and after directlyQuoted 5 lines
Am 16.03.2017 um 04:44 schrieb Junwei Zhang:
Quoted 1 line
Currently it may miss one page before or after the target mapping
I don't think that this will work correctly. The interval tree still contains the old mapping at this point and as far as I know inserting overlapping mappings is not allowed here.
Ah, I missed that, so this insert op should be after free up. I will revise the patch
Quoted 1 line
But what do you mean with miss one page before or after the target mapping?
I did a unit test to verify it and found that:
If the before mapping is 1 page size, so its start and last will be same. Thus below condition will become false then to free the before mapping.
Quoted 1 line
if (
before->it.start!=before->it.last) But in this case, weneed the before mapping of 1 page size.
So does after mapping.e.g.
Initialize a mapping: [0, 8] pages size.
A replace mapping: [1, 2] page size.
Before mapping is [0, 1], before.it.start = 0, before.it = 1 - 1 = 0.
Quoted 6 lines
Quoted 1 line
Additionally, if we create a bo as 1 page size, the corresponding mapping also
has start==last, I think.
Ups, that's indeed not correct.
Yeah we need a better criteria if we should insert the ranges or not.
How about check the init before->list and after->list, then check if the list is not empty? Otherwise, it may add a bool flag for each of them, I don't like that.
I have sent the patch as v2.
Please check it.
Thanks.
Jerry
Quoted 63 lines
Christian.
Quoted 8 lines
Jerry.
Quoted 5 lines
Christian.
Quoted 3 lines
Signed-off-by Junwei Zhang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 26 ++++++++------------------
Quoted 51 lines
Quoted 51 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct
Quoted 8 lines
1 file changed, 8 insertions(+), 18 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -1767,7 +1767,11 @@ int amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct · line 1777
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0before->it.last = saddr -1 ; before->offset = tmp->offset; before->flags = tmp->flags; +list_add (&before->list, &tmp->list); +interval_tree_insert (&before->it, &vm->va); +if (before->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); } /* Remember mapping split at the end */ @@ -1777,7 +1781,11@@ int
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct
Quoted 13 lines
amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,after->offset = tmp->offset; after->offset += after->it.start - tmp->it.start; after->flags = tmp->flags;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4
-0+list_add (&after->list, &tmp->list); +interval_tree_insert (&after->it, &vm->va); +if (after->flags &AMDGPU_PTE_PRT ) +amdgpu_vm_prt_get (adev); }list_del (&tmp->list);@@ -1799,24 +1807,6 @@ int amdgpu_vm_bo_clear_mappings(struct
amdgpu_device*adev,Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-13trace_amdgpu_vm_bo_unmap (NULL , tmp); } -/* Insert partial mapping before the range*/ -if (before->it.start != before->it.last) { -interval_tree_insert (&before->it, &vm->va); -if (before->flags &AMDGPU_PTE_PRT ) -amdgpu_vm_prt_get (adev); - }else { -kfree (before); - } - -/* Insert partial mapping after the range */ -if (after->it.start != after->it.last) { -interval_tree_insert (&after->it, &vm->va); -if (after->flags &AMDGPU_PTE_PRT )
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct · line 1812
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-5-amdgpu_vm_prt_get (adev); - }else { -kfree (after); - } -return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx