Skip to contentSkip to conversation

drm/amdgpu: fix before and after mapping judgement for replace mapping

PATCH In review Junwei Zhang 2 participants 5 messages Mar 16, 2017 4 messages not in the archive

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

PATCH v2 1/1 drm/amdgpu: fix before and after mapping judgement for replace mapping

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -4
index f7c02a9..e95adec 100644
@@ -1748,12 +1748,14 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 	before = kzalloc(sizeof(*before), GFP_KERNEL);
 	if (!before)
 		return -ENOMEM;
+	INIT_LIST_HEAD(&before->list);
 
 	after = kzalloc(sizeof(*after), GFP_KERNEL);
 	if (!after) {
 		kfree(before);
 		return -ENOMEM;
 	}
+	INIT_LIST_HEAD(&after->list);
 
 	/* Now gather all removed mappings */
 	it = interval_tree_iter_first(&vm->va, saddr, eaddr);
@@ -1763,7 +1765,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 
 		/* Remember mapping split at the start */
 		if (tmp->it.start < saddr) {
-			before->it.start = tmp->it.start;;
+			before->it.start = tmp->it.start;
 			before->it.last = saddr - 1;
 			before->offset = tmp->offset;
 			before->flags = tmp->flags;
@@ -1799,8 +1801,8 @@ 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) {
+	/* Insert partial mapping before the range */
+	if (!list_empty(&before->list)) {
 		interval_tree_insert(&before->it, &vm->va);
 		if (before->flags & AMDGPU_PTE_PRT)
 			amdgpu_vm_prt_get(adev);
@@ -1809,7 +1811,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 	}
 
 	/* Insert partial mapping after the range */
-	if (after->it.start != after->it.last) {
+	if (!list_empty(&after->list)) {
 		interval_tree_insert(&after->it, &vm->va);
 		if (after->flags & AMDGPU_PTE_PRT)
 			amdgpu_vm_prt_get(adev);
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): 1489651992-2507-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

Am 16.03.2017 um 09:13 schrieb Junwei Zhang:

Quoted 7 lines

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 44 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -3
index f7c02a9..e95adec 100644
@@ -1748,12 +1748,14 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
  	before = kzalloc(sizeof(*before), GFP_KERNEL);
  	if (!before)
  		return -ENOMEM;
+	INIT_LIST_HEAD(&before->list);
 
  	after = kzalloc(sizeof(*after), GFP_KERNEL);
  	if (!after) {
  		kfree(before);
  		return -ENOMEM;
  	}
+	INIT_LIST_HEAD(&after->list);
 
  	/* Now gather all removed mappings */
  	it = interval_tree_iter_first(&vm->va, saddr, eaddr);
@@ -1763,7 +1765,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 
  		/* Remember mapping split at the start */
  		if (tmp->it.start < saddr) {
-			before->it.start = tmp->it.start;;
+			before->it.start = tmp->it.start;
  			before->it.last = saddr - 1;
  			before->offset = tmp->offset;
  			before->flags = tmp->flags;
@@ -1799,8 +1801,8 @@ 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) {
+	/* Insert partial mapping before the range */
+	if (!list_empty(&before->list)) {
  		interval_tree_insert(&before->it, &vm->va);
  		if (before->flags & AMDGPU_PTE_PRT)
  			amdgpu_vm_prt_get(adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, · line 1817

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
@@ -1809,7 +1811,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
  	}
 
  	/* Insert partial mapping after the range */
-	if (after->it.start != after->it.last) {
+	if (!list_empty(&after->list)) {
  		interval_tree_insert(&after->it, &vm->va);
  		if (after->flags & AMDGPU_PTE_PRT)
  			amdgpu_vm_prt_get(adev);

_______________________________________________
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): 568c0ea6-a1cc-519f-111e-0ced8b7bdc82-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#4 lore raw

Hi Christian,

Thanks for your review.

BTW, Have you pushed the previous patches in all-open branch? I didn't find them. Or any concern?

So we may use these patch on topic branch only for now.

Regards,
Jerry (Junwei Zhang)

Linux Base Graphics
SRDC Software Development
_____________________________________

Quoted 66 lines

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 17:11
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH v2] drm/amdgpu: fix before and after mapping judgement for replace mapping

Am 16.03.2017 um 09:13 schrieb Junwei Zhang:

Quoted 7 lines

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.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct

Quoted 10 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index f7c02a9..e95adec 100644
@@ -1748,12 +1748,14 @@ 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

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -1
  	before = kzalloc(sizeof(*before), GFP_KERNEL);
  	if (!before)
  		return -ENOMEM;
+	INIT_LIST_HEAD(&before->list);
 
  	after = kzalloc(sizeof(*after), GFP_KERNEL);
  	if (!after) {
  		kfree(before);
  		return -ENOMEM;
  	}
+	INIT_LIST_HEAD(&after->list);
 
  	/* Now gather all removed mappings */
  	it = interval_tree_iter_first(&vm->va, saddr, eaddr); @@ -1763,7
+1765,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 
  		/* Remember mapping split at the start */
  		if (tmp->it.start < saddr) {
-			before->it.start = tmp->it.start;;
+			before->it.start = tmp->it.start;
  			before->it.last = saddr - 1;
  			before->offset = tmp->offset;
  			before->flags = tmp->flags;
@@ -1799,8 +1801,8 @@ 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

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
  		trace_amdgpu_vm_bo_unmap(NULL, tmp);
  	}
 
-	/* Insert partial mapping before the range*/
-	if (before->it.start != before->it.last) {
+	/* Insert partial mapping before the range */
+	if (!list_empty(&before->list)) {
  		interval_tree_insert(&before->it, &vm->va);
  		if (before->flags & AMDGPU_PTE_PRT)
  			amdgpu_vm_prt_get(adev);
@@ -1809,7 +1811,7 @@ int amdgpu_vm_bo_clear_mappings(struct

amdgpu_device *adev,

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, · line 1817

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
  	}
 
  	/* Insert partial mapping after the range */
-	if (after->it.start != after->it.last) {
+	if (!list_empty(&after->list)) {
  		interval_tree_insert(&after->it, &vm->va);
  		if (after->flags & AMDGPU_PTE_PRT)
  			amdgpu_vm_prt_get(adev);

_______________________________________________
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): DM5PR12MB1818AC5E1F37475ECE15BD13FF260-2J9CzHegvk+QhrfEZJlvtAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#6 lore raw

Am 16.03.2017 um 10:16 schrieb Zhang, Jerry:

Quoted 6 lines

Hi Christian,

Thanks for your review.

BTW, Have you pushed the previous patches in all-open branch? I didn't find them. Or any concern?

No, unfortunately had a few very busy days this week and didn't found time.

Feel free to push them with your rb.

Christian.

Quoted 76 lines

So we may use these patch on topic branch only for now.

Regards,
Jerry (Junwei Zhang)

Linux Base Graphics
SRDC Software Development
_____________________________________

Quoted 65 lines

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 17:11
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH v2] drm/amdgpu: fix before and after mapping judgement for replace mapping

Am 16.03.2017 um 09:13 schrieb Junwei Zhang:

Quoted 7 lines

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.

     > if (before->it.start != before->it.last) But in this case, we

need the before mapping of 1 page size.
So does after mapping.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct

Quoted 10 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 ++++++----
   1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index f7c02a9..e95adec 100644
@@ -1748,12 +1748,14 @@ 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

Quoted 24 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -1
   	before = kzalloc(sizeof(*before), GFP_KERNEL);
   	if (!before)
   		return -ENOMEM;
+	INIT_LIST_HEAD(&before->list);
 
   	after = kzalloc(sizeof(*after), GFP_KERNEL);
   	if (!after) {
   		kfree(before);
   		return -ENOMEM;
   	}
+	INIT_LIST_HEAD(&after->list);
 
   	/* Now gather all removed mappings */
   	it = interval_tree_iter_first(&vm->va, saddr, eaddr); @@ -1763,7
+1765,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
 
   		/* Remember mapping split at the start */
   		if (tmp->it.start < saddr) {
-			before->it.start = tmp->it.start;;
+			before->it.start = tmp->it.start;
   			before->it.last = saddr - 1;
   			before->offset = tmp->offset;
   			before->flags = tmp->flags;
@@ -1799,8 +1801,8 @@ 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

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
   		trace_amdgpu_vm_bo_unmap(NULL, tmp);
   	}
 
-	/* Insert partial mapping before the range*/
-	if (before->it.start != before->it.last) {
+	/* Insert partial mapping before the range */
+	if (!list_empty(&before->list)) {
   		interval_tree_insert(&before->it, &vm->va);
   		if (before->flags & AMDGPU_PTE_PRT)
   			amdgpu_vm_prt_get(adev);
@@ -1809,7 +1811,7 @@ int amdgpu_vm_bo_clear_mappings(struct

amdgpu_device *adev,

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 1817

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
   	}
 
   	/* Insert partial mapping after the range */
-	if (after->it.start != after->it.last) {
+	if (!list_empty(&after->list)) {
   		interval_tree_insert(&after->it, &vm->va);
   		if (after->flags & AMDGPU_PTE_PRT)
   			amdgpu_vm_prt_get(adev);

_______________________________________________
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): 41e6aea3-17b8-fe3a-e6be-49af4937be7a-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#8 lore raw

Alright.

Regards,
Jerry (Junwei Zhang)

Linux Base Graphics
SRDC Software Development
_____________________________________

Quoted 98 lines

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 17:27
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH v2] drm/amdgpu: fix before and after mapping judgement for replace mapping

Am 16.03.2017 um 10:16 schrieb Zhang, Jerry:

Quoted 6 lines

Hi Christian,

Thanks for your review.

BTW, Have you pushed the previous patches in all-open branch? I didn't find them. Or any concern?

No, unfortunately had a few very busy days this week and didn't found time.

Feel free to push them with your rb.

Christian.

Quoted 77 lines

So we may use these patch on topic branch only for now.

Regards,
Jerry (Junwei Zhang)

Linux Base Graphics
SRDC Software Development
_____________________________________

Quoted 66 lines

-----Original Message-----
From: Christian König [mailto:[email protected]]
Sent: Thursday, March 16, 2017 17:11
To: Zhang, Jerry; [email protected]
Subject: Re: [PATCH v2] drm/amdgpu: fix before and after mapping judgement for replace mapping

Am 16.03.2017 um 09:13 schrieb Junwei Zhang:

Quoted 7 lines

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.

     > if (before->it.start != before->it.last) But in this case, we

need the before mapping of 1 page size.
So does after mapping.

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct

Quoted 10 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 10 ++++++----
   1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
index f7c02a9..e95adec 100644
@@ -1748,12 +1748,14 @@ 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

Quoted 25 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -1
   	before = kzalloc(sizeof(*before), GFP_KERNEL);
   	if (!before)
   		return -ENOMEM;
+	INIT_LIST_HEAD(&before->list);
 
   	after = kzalloc(sizeof(*after), GFP_KERNEL);
   	if (!after) {
   		kfree(before);
   		return -ENOMEM;
   	}
+	INIT_LIST_HEAD(&after->list);
 
   	/* Now gather all removed mappings */
   	it = interval_tree_iter_first(&vm->va, saddr, eaddr); @@ -1763,7
+1765,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device
+*adev,
 
   		/* Remember mapping split at the start */
   		if (tmp->it.start < saddr) {
-			before->it.start = tmp->it.start;;
+			before->it.start = tmp->it.start;
   			before->it.last = saddr - 1;
   			before->offset = tmp->offset;
   			before->flags = tmp->flags;
@@ -1799,8 +1801,8 @@ 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

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
   		trace_amdgpu_vm_bo_unmap(NULL, tmp);
   	}
 
-	/* Insert partial mapping before the range*/
-	if (before->it.start != before->it.last) {
+	/* Insert partial mapping before the range */
+	if (!list_empty(&before->list)) {
   		interval_tree_insert(&before->it, &vm->va);
   		if (before->flags & AMDGPU_PTE_PRT)
   			amdgpu_vm_prt_get(adev);
@@ -1809,7 +1811,7 @@ int amdgpu_vm_bo_clear_mappings(struct

amdgpu_device *adev,

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_clear_mappings(struct · line 1817

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
   	}
 
   	/* Insert partial mapping after the range */
-	if (after->it.start != after->it.last) {
+	if (!list_empty(&after->list)) {
   		interval_tree_insert(&after->it, &vm->va);
   		if (after->flags & AMDGPU_PTE_PRT)
   			amdgpu_vm_prt_get(adev);

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