Skip to contentSkip to conversation

drm/amdgpu: minor PRT turnoff fix

PATCH In review Christian König 3 participants 7 messages Feb 15, 2017 – Feb 16, 2017 4 messages not in the archive

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

PATCH 1/3 drm/amdgpu: minor PRT turnoff fix

From: Christian König <[email protected]>

When two VMs stop using PRT support at the same time we might not disable it in the right order otherwise.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -7
index bc32239..447cda5 100644
@@ -1200,7 +1200,8 @@ static void amdgpu_vm_prt_cb(struct fence *fence, struct fence_cb *_cb)
 {
 	struct amdgpu_prt_cb *cb = container_of(_cb, struct amdgpu_prt_cb, cb);
 
-	amdgpu_vm_update_prt_state(cb->adev);
+	if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings) == 0)
+		amdgpu_vm_update_prt_state(cb->adev);
 	kfree(cb);
 }
 
@@ -1219,17 +1220,14 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev,
 				   struct amdgpu_bo_va_mapping *mapping,
 				   struct fence *fence)
 {
-	if ((mapping->flags & AMDGPU_PTE_PRT) &&
-	    atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0) {
+	if (mapping->flags & AMDGPU_PTE_PRT) {
 		struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb),
 						   GFP_KERNEL);
 
 		cb->adev = adev;
 		if (!fence || fence_add_callback(fence, &cb->cb,
-						 amdgpu_vm_prt_cb)) {
-			amdgpu_vm_update_prt_state(adev);
-			kfree(cb);
-		}
+						 amdgpu_vm_prt_cb))
+			amdgpu_vm_prt_cb(fence, &cb->cb);
 	}
 	kfree(mapping);
 }
Signature · 6 lines
2.5.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): 1487170641-1927-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

PATCH 2/3 drm/amdgpu: add OOM fallback on PRT teardown

From: Christian König <[email protected]>

Don't assume kmalloc will always succeed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +22 -6
index 447cda5..c11b6b6 100644
@@ -1194,14 +1194,22 @@ static void amdgpu_vm_update_prt_state(struct amdgpu_device *adev)
 }
 
 /**
+ * amdgpu_vm_prt_put - drop a PRT user
+ */
+static void amdgpu_vm_prt_put(struct amdgpu_device *adev)
+{
+	if (atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0)
+		amdgpu_vm_update_prt_state(adev);
+}
+
+/**
  * amdgpu_vm_prt - callback for updating the PRT status
  */
 static void amdgpu_vm_prt_cb(struct fence *fence, struct fence_cb *_cb)
 {
 	struct amdgpu_prt_cb *cb = container_of(_cb, struct amdgpu_prt_cb, cb);
 
-	if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings) == 0)
-		amdgpu_vm_update_prt_state(cb->adev);
+	amdgpu_vm_prt_put(cb->adev);
 	kfree(cb);
 }
 
@@ -1224,10 +1232,18 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev,
 		struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb),
 						   GFP_KERNEL);
 
-		cb->adev = adev;
-		if (!fence || fence_add_callback(fence, &cb->cb,
-						 amdgpu_vm_prt_cb))
-			amdgpu_vm_prt_cb(fence, &cb->cb);
+		if (!cb) {
+			/* Last resort when we are OOM */
+			if (fence)
+				fence_wait(fence, false);
+
+			amdgpu_vm_prt_put(cb->adev);
+		} else {
+			cb->adev = adev;
+			if (!fence || fence_add_callback(fence, &cb->cb,
+							 amdgpu_vm_prt_cb))
+				amdgpu_vm_prt_cb(fence, &cb->cb);
+		}
 	}
 	kfree(mapping);
 }
Signature · 6 lines
2.5.0

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

PATCH 3/3 drm/amdgpu: fix PRT teardown on VM fini v2

In reply to a message not in the archive

From: Christian König <[email protected]>

v2: new approach fixing this by registering a fence callback for
all users of the VM on teardown

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 106 +++++++++++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h |   2 +-
 2 files changed, 82 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +81 -25
index c11b6b6..d3437ad 100644
@@ -1188,22 +1188,31 @@ static void amdgpu_vm_update_prt_state(struct amdgpu_device *adev)
 	bool enable;
 
 	spin_lock_irqsave(&adev->vm_manager.prt_lock, flags);
-	enable = !!atomic_read(&adev->vm_manager.num_prt_mappings);
+	enable = !!atomic_read(&adev->vm_manager.num_prt_users);
 	adev->gart.gart_funcs->set_prt(adev, enable);
 	spin_unlock_irqrestore(&adev->vm_manager.prt_lock, flags);
 }
 
 /**
+ * amdgpu_vm_prt_put - add a PRT user
+ */
+static void amdgpu_vm_prt_get(struct amdgpu_device *adev)
+{
+	if (atomic_inc_return(&adev->vm_manager.num_prt_users) == 1)
+		amdgpu_vm_update_prt_state(adev);
+}
+
+/**
  * amdgpu_vm_prt_put - drop a PRT user
  */
 static void amdgpu_vm_prt_put(struct amdgpu_device *adev)
 {
-	if (atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0)
+	if (atomic_dec_return(&adev->vm_manager.num_prt_users) == 0)
 		amdgpu_vm_update_prt_state(adev);
 }
 
 /**
- * amdgpu_vm_prt - callback for updating the PRT status
+ * amdgpu_vm_prt_cb - callback for updating the PRT status
  */
 static void amdgpu_vm_prt_cb(struct fence *fence, struct fence_cb *_cb)
 {
@@ -1214,6 +1223,29 @@ static void amdgpu_vm_prt_cb(struct fence *fence, struct fence_cb *_cb)
 }
 
 /**
+ * amdgpu_vm_add_prt_cb - add callback for updating the PRT status
+ */
+static void amdgpu_vm_add_prt_cb(struct amdgpu_device *adev,
+				 struct fence *fence)
+{
+	struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb),
+					   GFP_KERNEL);
+
+	if (!cb) {
+		/* Last resort when we are OOM */
+		if (fence)
+			fence_wait(fence, false);
+
+		amdgpu_vm_prt_put(cb->adev);
+	} else {
+		cb->adev = adev;
+		if (!fence || fence_add_callback(fence, &cb->cb,
+						 amdgpu_vm_prt_cb))
+			amdgpu_vm_prt_cb(fence, &cb->cb);
+	}
+}
+
+/**
  * amdgpu_vm_free_mapping - free a mapping
  *
  * @adev: amdgpu_device pointer
@@ -1228,24 +1260,47 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev,
 				   struct amdgpu_bo_va_mapping *mapping,
 				   struct fence *fence)
 {
-	if (mapping->flags & AMDGPU_PTE_PRT) {
-		struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb),
-						   GFP_KERNEL);
+	if (mapping->flags & AMDGPU_PTE_PRT)
+		amdgpu_vm_add_prt_cb(adev, fence);
+	kfree(mapping);
+}
 
-		if (!cb) {
-			/* Last resort when we are OOM */
-			if (fence)
-				fence_wait(fence, false);
+/**
+ * amdgpu_vm_prt_fini - finish all prt mappings
+ *
+ * @adev: amdgpu_device pointer
+ * @vm: requested vm
+ *
+ * Register a cleanup callback to disable PRT support after VM dies.
+ */
+static void amdgpu_vm_prt_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
+{
+	struct reservation_object *resv = vm->page_directory->tbo.resv;
+	struct fence *excl, **shared;
+	unsigned i, shared_count;
+	int r;
 
-			amdgpu_vm_prt_put(cb->adev);
-		} else {
-			cb->adev = adev;
-			if (!fence || fence_add_callback(fence, &cb->cb,
-							 amdgpu_vm_prt_cb))
-				amdgpu_vm_prt_cb(fence, &cb->cb);
-		}
+	r = reservation_object_get_fences_rcu(resv, &excl,
+					      &shared_count, &shared);
+	if (r) {
+		/* Not enough memory to grab the fence list, as last resort
+		 * block for all the fences to complete.
+		 */
+		reservation_object_wait_timeout_rcu(resv, true, false,
+						    MAX_SCHEDULE_TIMEOUT);
+		return;
 	}
-	kfree(mapping);
+
+	/* Add a callback for each fence in the reservation object */
+	amdgpu_vm_prt_get(adev);
+	amdgpu_vm_add_prt_cb(adev, excl);
+
+	for (i = 0; i < shared_count; ++i) {
+		amdgpu_vm_prt_get(adev);
+		amdgpu_vm_add_prt_cb(adev, shared[i]);
+	}
+
+	kfree(shared);
 }
 
 /**
@@ -1395,8 +1450,7 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,
 		if (!adev->gart.gart_funcs->set_prt)
 			return -EINVAL;
 
-		if (atomic_inc_return(&adev->vm_manager.num_prt_mappings) == 1)
-			amdgpu_vm_update_prt_state(adev);
+		amdgpu_vm_prt_get(adev);
 	}
 
 	/* make sure object fit at this offset */
@@ -1699,6 +1753,7 @@ int amdgpu_vm_init(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 {
 	struct amdgpu_bo_va_mapping *mapping, *tmp;
+	bool prt_fini_called = false;
 	int i;
 
 	amd_sched_entity_fini(vm->entity.sched, &vm->entity);
@@ -1712,13 +1767,14 @@ void amdgpu_vm_fini(struct amdgpu_device *adev, struct amdgpu_vm *vm)
 		kfree(mapping);
 	}
 	list_for_each_entry_safe(mapping, tmp, &vm->freed, list) {
-		if (mapping->flags & AMDGPU_PTE_PRT)
-			continue;
+		if (mapping->flags & AMDGPU_PTE_PRT && !prt_fini_called) {
+			amdgpu_vm_prt_fini(adev, vm);
+			prt_fini_called = true;
+		}
 
 		list_del(&mapping->list);
-		kfree(mapping);
+		amdgpu_vm_free_mapping(adev, vm, mapping, NULL);
 	}
-	amdgpu_vm_clear_freed(adev, vm);
 
 	for (i = 0; i < amdgpu_vm_num_pdes(adev); i++) {
 		struct amdgpu_bo *pt = vm->page_tables[i].bo;
@@ -1764,7 +1820,7 @@ void amdgpu_vm_manager_init(struct amdgpu_device *adev)
 	atomic_set(&adev->vm_manager.vm_pte_next_ring, 0);
 	atomic64_set(&adev->vm_manager.client_counter, 0);
 	spin_lock_init(&adev->vm_manager.prt_lock);
-	atomic_set(&adev->vm_manager.num_prt_mappings, 0);
+	atomic_set(&adev->vm_manager.num_prt_users, 0);
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -1
index 51fa12f..7fccd486 100644
@@ -164,7 +164,7 @@ struct amdgpu_vm_manager {
 
 	/* partial resident texture handling */
 	spinlock_t				prt_lock;
-	atomic_t				num_prt_mappings;
+	atomic_t				num_prt_users;
 };
 
 void amdgpu_vm_manager_init(struct amdgpu_device *adev);
Signature · 6 lines
2.5.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw
In reply to a message not in the archive

Nicolai could you give that set a try?

It should fix your problems with PRT tear down on process crash.

Regards,
Christian.

Am 15.02.2017 um 15:57 schrieb Christian König:

Quoted 35 lines

From: Christian König <[email protected]>

When two VMs stop using PRT support at the same time we might not disable it in the right order otherwise.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +3 -3
index bc32239..447cda5 100644
@@ -1200,7 +1200,8 @@ static void amdgpu_vm_prt_cb(struct fence *fence, struct fence_cb *_cb)
  {
  	struct amdgpu_prt_cb *cb = container_of(_cb, struct amdgpu_prt_cb, cb);
 
-	amdgpu_vm_update_prt_state(cb->adev);
+	if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings) == 0)
+		amdgpu_vm_update_prt_state(cb->adev);
  	kfree(cb);
  }
 
@@ -1219,17 +1220,14 @@ static void amdgpu_vm_free_mapping(struct amdgpu_device *adev,
  				   struct amdgpu_bo_va_mapping *mapping,
  				   struct fence *fence)
  {
-	if ((mapping->flags & AMDGPU_PTE_PRT) &&
-	    atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0) {
+	if (mapping->flags & AMDGPU_PTE_PRT) {
  		struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct amdgpu_prt_cb),
  						   GFP_KERNEL);
 
  		cb->adev = adev;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static void amdgpu_vm_free_mapping(struct amdgpu_device *adev, · line 1233

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -4
  		if (!fence || fence_add_callback(fence, &cb->cb,
-						 amdgpu_vm_prt_cb)) {
-			amdgpu_vm_update_prt_state(adev);
-			kfree(cb);
-		}
+						 amdgpu_vm_prt_cb))
+			amdgpu_vm_prt_cb(fence, &cb->cb);
  	}
  	kfree(mapping);
  }

_______________________________________________
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): 79b48c6a-964c-7339-4b5b-1d97401bb107-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#6 lore raw

Hi Christian,

Quoted 3 lines · Christian König

Nicolai could you give that set a try?

It should fix your problems with PRT tear down on process crash.

Yes, it fixes those issues for me, thanks! The first two patches have my R-b, for the third one I don't really understand the bug that it fixes, but I have to leave soon, so...

Thanks
Nicolai

Quoted 49 lines

Regards,
Christian.

Am 15.02.2017 um 15:57 schrieb Christian König:

Quoted 45 lines

From: Christian König <[email protected]>

When two VMs stop using PRT support at the same time we might not disable it in the right order otherwise.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
index bc32239..447cda5 100644
@@ -1200,7 +1200,8 @@ static void amdgpu_vm_prt_cb(struct fence
 *fence, struct fence_cb *_cb)
  {
      struct amdgpu_prt_cb *cb = container_of(_cb, struct
 amdgpu_prt_cb, cb);
  -    amdgpu_vm_update_prt_state(cb->adev);
+    if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings) == 0)
+        amdgpu_vm_update_prt_state(cb->adev);
      kfree(cb);
  }
  @@ -1219,17 +1220,14 @@ static void amdgpu_vm_free_mapping(struct

amdgpu_device *adev,
struct amdgpu_bo_va_mapping *mapping, struct fence *fence)
{

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
-    if ((mapping->flags & AMDGPU_PTE_PRT) &&
-        atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0) {
+    if (mapping->flags & AMDGPU_PTE_PRT) {
          struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct

amdgpu_prt_cb),

                             GFP_KERNEL);
            cb->adev = adev;
          if (!fence || fence_add_callback(fence, &cb->cb,
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -4
-                         amdgpu_vm_prt_cb)) {
-            amdgpu_vm_update_prt_state(adev);
-            kfree(cb);
-        }
+                         amdgpu_vm_prt_cb))
+            amdgpu_vm_prt_cb(fence, &cb->cb);
      }
Quoted 8 lines
Quoted 2 lines
      kfree(mapping);

}

_______________________________________________
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): 1300e2ee-ed90-7920-d135-b75a09347880-5C7GfCeVMHo@public.gmane.org

#8 lore raw

Am 15.02.2017 um 18:28 schrieb Nicolai Hähnle:

Quoted 8 lines

Hi Christian,

Quoted 3 lines · Christian König

Nicolai could you give that set a try?

It should fix your problems with PRT tear down on process crash.

Yes, it fixes those issues for me, thanks! The first two patches have my R-b, for the third one I don't really understand the bug that it fixes, but I have to leave soon, so...

The problem was what to do when we tear down the VM, but still have PRT mappings.

Initially I've just tried to unmap the PRT mappings as if they would have been cleaned up by userspace, but this doesn't work because the PD/PT might be swapped out etc....

Now instead of trying to unmap the PRT mappings I just increase the PRT reference count for each command submission still using the VM.

Can I get an review on those patches?

Thanks,
Christian.

Quoted 63 lines

Thanks
Nicolai

Quoted 58 lines

Regards,
Christian.

Am 15.02.2017 um 15:57 schrieb Christian König:

Quoted 39 lines

From: Christian König <[email protected]>

When two VMs stop using PRT support at the same time we might not disable it in the right order otherwise.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
index bc32239..447cda5 100644
@@ -1200,7 +1200,8 @@ static void amdgpu_vm_prt_cb(struct fence
 *fence, struct fence_cb *_cb)
  {
      struct amdgpu_prt_cb *cb = container_of(_cb, struct
 amdgpu_prt_cb, cb);
  -    amdgpu_vm_update_prt_state(cb->adev);
+    if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings) 
 == 0)
+        amdgpu_vm_update_prt_state(cb->adev);
      kfree(cb);
  }
  @@ -1219,17 +1220,14 @@ static void amdgpu_vm_free_mapping(struct

amdgpu_device *adev,
struct amdgpu_bo_va_mapping *mapping, struct fence *fence)
{

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
-    if ((mapping->flags & AMDGPU_PTE_PRT) &&
- atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0) {
+    if (mapping->flags & AMDGPU_PTE_PRT) {
          struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct

amdgpu_prt_cb),

                             GFP_KERNEL);
            cb->adev = adev;
          if (!fence || fence_add_callback(fence, &cb->cb,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static void amdgpu_vm_free_mapping(struct amdgpu_device *adev, · line 1233

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -4
-                         amdgpu_vm_prt_cb)) {
-            amdgpu_vm_update_prt_state(adev);
-            kfree(cb);
-        }
+                         amdgpu_vm_prt_cb))
+            amdgpu_vm_prt_cb(fence, &cb->cb);
      }
      kfree(mapping);
  }

_______________________________________________
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): 7820c81d-28f6-c2a3-2c3b-31be54bfe29e-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

Reviewed-by
#10 lore raw
Quoted 15 lines · Christian König

Am 15.02.2017 um 18:28 schrieb Nicolai Hähnle:

Quoted 10 lines

Hi Christian,

Quoted 3 lines · Christian König

Nicolai could you give that set a try?

It should fix your problems with PRT tear down on process crash.

Yes, it fixes those issues for me, thanks! The first two patches have my R-b, for the third one I don't really understand the bug that it fixes, but I have to leave soon, so...

The problem was what to do when we tear down the VM, but still have PRT mappings.

Quoted 6 lines

Initially I've just tried to unmap the PRT mappings as if they would have been cleaned up by userspace, but this doesn't work because the PD/PT might be swapped out etc....

Now instead of trying to unmap the PRT mappings I just increase the PRT reference count for each command submission still using the VM.

Ah, I see, the update functions assume that the relevant buffers holding the page tables have been validated, but this isn't the case during teardown. Makes sense to me now, thanks!

For the series:

Quoted 69 lines

Can I get an review on those patches?

Thanks,
Christian.

Quoted 63 lines

Thanks
Nicolai

Quoted 58 lines

Regards,
Christian.

Am 15.02.2017 um 15:57 schrieb Christian König:

Quoted 39 lines

From: Christian König <[email protected]>

When two VMs stop using PRT support at the same time we might not disable it in the right order otherwise.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 12 +++++-------
  1 file changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -0
index bc32239..447cda5 100644
@@ -1200,7 +1200,8 @@ static void amdgpu_vm_prt_cb(struct fence
 *fence, struct fence_cb *_cb)
  {
      struct amdgpu_prt_cb *cb = container_of(_cb, struct
 amdgpu_prt_cb, cb);
  -    amdgpu_vm_update_prt_state(cb->adev);
+    if (atomic_dec_return(&cb->adev->vm_manager.num_prt_mappings)
 == 0)
+        amdgpu_vm_update_prt_state(cb->adev);
      kfree(cb);
  }
  @@ -1219,17 +1220,14 @@ static void amdgpu_vm_free_mapping(struct

amdgpu_device *adev,
struct amdgpu_bo_va_mapping *mapping, struct fence *fence)
{

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
-    if ((mapping->flags & AMDGPU_PTE_PRT) &&
- atomic_dec_return(&adev->vm_manager.num_prt_mappings) == 0) {
+    if (mapping->flags & AMDGPU_PTE_PRT) {
          struct amdgpu_prt_cb *cb = kmalloc(sizeof(struct

amdgpu_prt_cb),

                             GFP_KERNEL);
            cb->adev = adev;
          if (!fence || fence_add_callback(fence, &cb->cb,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -4
-                         amdgpu_vm_prt_cb)) {
-            amdgpu_vm_update_prt_state(adev);
-            kfree(cb);
-        }
+                         amdgpu_vm_prt_cb))
+            amdgpu_vm_prt_cb(fence, &cb->cb);
      }
      kfree(mapping);
  }

_______________________________________________
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