Skip to contentSkip to conversation

drm/amdgpu: Move IB pool init and fini.

PATCH Superseded Andrey Grodzovsky 3 participants 4 messages Mar 6, 2019 – Mar 8, 2019 3 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Move IB pool init and fini.

Problem:
Using SDMA for TLB invalidation in certain ASICs exposed a problem of IB pool not being ready while SDMA already up on Init and already shutt down while SDMA still running on Fini. This caused IB allocation failure. Temproary fix was commited into a bringup branch but this is the generic fix.

Fix:
Init IB pool rigth after GMC is ready but before SDMA is ready. Do th opposite for Fini.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +11 -9
index 00def57..c05a551 100644
@@ -1686,6 +1686,13 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 		}
 	}
 
+	r = amdgpu_ib_pool_init(adev);
+	if (r) {
+		dev_err(adev->dev, "IB initialization failed (%d).\n", r);
+		amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
+		goto init_failed;
+	}
+
 	r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/
 	if (r)
 		goto init_failed;
@@ -1888,7 +1895,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if (!adev->ip_blocks[i].status.hw)
 			continue;
-		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
+		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC ||
+		    adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SDMA) {
 			r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
 			/* XXX handle errors */
 			if (r) {
@@ -1900,6 +1908,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 		}
 	}
 
+	amdgpu_ib_pool_fini(adev);
+
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
 		if (!adev->ip_blocks[i].status.hw)
 			continue;
@@ -2651,13 +2661,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	/* Get a log2 for easy divisions. */
 	adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps));
 
-	r = amdgpu_ib_pool_init(adev);
-	if (r) {
-		dev_err(adev->dev, "IB initialization failed (%d).\n", r);
-		amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
-		goto failed;
-	}
-
 	amdgpu_fbdev_init(adev);
 
 	r = amdgpu_pm_sysfs_init(adev);
@@ -2735,7 +2738,6 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
 		else
 			drm_atomic_helper_shutdown(adev->ddev);
 	}
-	amdgpu_ib_pool_fini(adev);
 	amdgpu_fence_driver_fini(adev);
 	amdgpu_pm_sysfs_fini(adev);
 	amdgpu_fbdev_fini(adev);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1551907512-12582-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 06.03.19 um 22:25 schrieb Andrey Grodzovsky:

Quoted 35 lines

Problem:
Using SDMA for TLB invalidation in certain ASICs exposed a problem of IB pool not being ready while SDMA already up on Init and already shutt down while SDMA still running on Fini. This caused IB allocation failure. Temproary fix was commited into a bringup branch but this is the generic fix.

Fix:
Init IB pool rigth after GMC is ready but before SDMA is ready. Do th opposite for Fini.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++---------
  1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -0
index 00def57..c05a551 100644
@@ -1686,6 +1686,13 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
  		}
  	}
 
+	r = amdgpu_ib_pool_init(adev);
+	if (r) {
+		dev_err(adev->dev, "IB initialization failed (%d).\n", r);
+		amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
+		goto init_failed;
+	}
+
  	r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/
  	if (r)
  		goto init_failed;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_fini(struct amdgpu_device *adev) · line 1899

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -1888,7 +1895,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
  	for (i = 0; i < adev->num_ip_blocks; i++) {
  		if (!adev->ip_blocks[i].status.hw)
  			continue;
-		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
+		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC ||
+		    adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SDMA) {

Why is that necessary?

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_fini(struct amdgpu_device *adev) · line 1911

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
  			r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
  			/* XXX handle errors */
  			if (r) {
@@ -1900,6 +1908,8 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
  		}
  	}
 
+	amdgpu_ib_pool_fini(adev);

Thinking more about it this should probably be done right before GMC SW fini.

IIRC we already have an extra case for this somewhere.

Christian.

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -7
+
  	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
  		if (!adev->ip_blocks[i].status.hw)
  			continue;
@@ -2651,13 +2661,6 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  	/* Get a log2 for easy divisions. */
  	adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps));
 
-	r = amdgpu_ib_pool_init(adev);
-	if (r) {
-		dev_err(adev->dev, "IB initialization failed (%d).\n", r);
-		amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
-		goto failed;
-	}
-
  	amdgpu_fbdev_init(adev);
 
  	r = amdgpu_pm_sysfs_init(adev);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device *adev) · line 2743

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
@@ -2735,7 +2738,6 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
  		else
  			drm_atomic_helper_shutdown(adev->ddev);
  	}
-	amdgpu_ib_pool_fini(adev);
  	amdgpu_fence_driver_fini(adev);
  	amdgpu_pm_sysfs_fini(adev);
  	amdgpu_fbdev_fini(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): 1125fa61-3c2c-4906-954b-ada263f383d1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 42 lines · Christian König

Am 06.03.19 um 22:25 schrieb Andrey Grodzovsky:

Quoted 41 lines

Problem:
Using SDMA for TLB invalidation in certain ASICs exposed a problem of IB pool not being ready while SDMA already up on Init and already shutt down while SDMA still running on Fini. This caused IB allocation failure. Temproary fix was commited into a bringup branch but this is the generic fix.

Fix:
Init IB pool rigth after GMC is ready but before SDMA is ready. Do th opposite for Fini.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++---------

  1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
index 00def57..c05a551 100644
@@ -1686,6 +1686,13 @@ static int amdgpu_device_ip_init(struct 
 amdgpu_device *adev)
           }
       }
   +    r = amdgpu_ib_pool_init(adev);
+    if (r) {
+        dev_err(adev->dev, "IB initialization failed (%d).\n", r);
+        amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
+        goto init_failed;
+    }
+

      r = amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/
      if (r)
          goto init_failed;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1888,7 +1895,8 @@ static int amdgpu_device_ip_fini(struct 
 amdgpu_device *adev)
       for (i = 0; i < adev->num_ip_blocks; i++) {
           if (!adev->ip_blocks[i].status.hw)
               continue;
Quoted 8 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
-        if (adev->ip_blocks[i].version->type == 
 AMD_IP_BLOCK_TYPE_SMC) {
+        if (adev->ip_blocks[i].version->type == 

AMD_IP_BLOCK_TYPE_SMC ||
+            adev->ip_blocks[i].version->type ==
AMD_IP_BLOCK_TYPE_SDMA) {

Why is that necessary?

I assumed SDMA gw fini will call tlb flush but after testing with this removed it didn't so ok.

Quoted 14 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_fini(struct · line 1911

Quoted 10 lines

              r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
              /* XXX handle errors */
              if (r) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1900,6 +1908,8 @@ static int amdgpu_device_ip_fini(struct 
 amdgpu_device *adev)
           }
       }
   +    amdgpu_ib_pool_fini(adev);

Thinking more about it this should probably be done right before GMC SW fini.

Quoted 3 lines

IIRC we already have an extra case for this somewhere.

Christian.

Why do you think that the proper place ? Seemed to work fine where it was.

Anyway, i moved it and resent v2.

Andrey

Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+
       for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
           if (!adev->ip_blocks[i].status.hw)

              continue;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -6
@@ -2651,13 +2661,6 @@ int amdgpu_device_init(struct amdgpu_device 
 *adev,
       /* Get a log2 for easy divisions. */
       adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps));
   -    r = amdgpu_ib_pool_init(adev);
-    if (r) {
-        dev_err(adev->dev, "IB initialization failed (%d).\n", r);
-        amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
-        goto failed;
-    }
-
       amdgpu_fbdev_init(adev);
         r = amdgpu_pm_sysfs_init(adev);
@@ -2735,7 +2738,6 @@ void amdgpu_device_fini(struct amdgpu_device 
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
 *adev)

          else drm_atomic_helper_shutdown(adev->ddev); }
-    amdgpu_ib_pool_fini(adev); amdgpu_fence_driver_fini(adev); amdgpu_pm_sysfs_fini(adev); amdgpu_fbdev_fini(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): 2691287a-1f7e-86c3-c420-8e633c40b837-5C7GfCeVMHo@public.gmane.org

#6 lore raw

Am 07.03.19 um 17:59 schrieb Grodzovsky, Andrey:

Quoted 66 lines · Christian König
Quoted 41 lines

Am 06.03.19 um 22:25 schrieb Andrey Grodzovsky:

Quoted 40 lines

Problem:
Using SDMA for TLB invalidation in certain ASICs exposed a problem of IB pool not being ready while SDMA already up on Init and already shutt down while SDMA still running on Fini. This caused IB allocation failure. Temproary fix was commited into a bringup branch but this is the generic fix.

Fix:
Init IB pool rigth after GMC is ready but before SDMA is ready. Do th opposite for Fini.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 20 +++++++++++---------
   1 file changed, 11 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
index 00def57..c05a551 100644
@@ -1686,6 +1686,13 @@ static int amdgpu_device_ip_init(struct
 amdgpu_device *adev)
           }
       }
   +    r = amdgpu_ib_pool_init(adev);
+    if (r) {
+        dev_err(adev->dev, "IB initialization failed (%d).\n", r);
+        amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
+        goto init_failed;
+    }
+
       r = amdgpu_ucode_create_bo(adev); /* create ucode bo when

sw_init complete*/
      if (r)
          goto init_failed;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1888,7 +1895,8 @@ static int amdgpu_device_ip_fini(struct
 amdgpu_device *adev)
       for (i = 0; i < adev->num_ip_blocks; i++) {
           if (!adev->ip_blocks[i].status.hw)
Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
               continue;
-        if (adev->ip_blocks[i].version->type ==
 AMD_IP_BLOCK_TYPE_SMC) {
+        if (adev->ip_blocks[i].version->type ==

AMD_IP_BLOCK_TYPE_SMC ||
+            adev->ip_blocks[i].version->type ==
AMD_IP_BLOCK_TYPE_SDMA) {

Why is that necessary?

I assumed SDMA gw fini will call tlb flush but after testing with this removed it didn't so ok.

Quoted 12 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_fini(struct · line 1911

Quoted 9 lines

              r = adev->ip_blocks[i].version->funcs->hw_fini((void
*)adev);
              /* XXX handle errors */
              if (r) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1900,6 +1908,8 @@ static int amdgpu_device_ip_fini(struct
 amdgpu_device *adev)
           }
       }
   +    amdgpu_ib_pool_fini(adev);

Thinking more about it this should probably be done right before GMC SW fini.

Quoted 5 lines
Quoted 3 lines

IIRC we already have an extra case for this somewhere.

Christian.

Why do you think that the proper place ? Seemed to work fine where it was.

IIRC we already freed up a couple of other BOs at this place, e.g. the ucode etc..

And you moved the ip_pool_init directly before the ucode allocation, so that seems to be a good choice for freeing it up again.

Christian.

Quoted 24 lines

Anyway, i moved it and resent v2.

Andrey

Quoted 18 lines
Quoted 18 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -6
+
       for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
           if (!adev->ip_blocks[i].status.hw)
               continue;
@@ -2651,13 +2661,6 @@ int amdgpu_device_init(struct amdgpu_device
 *adev,
       /* Get a log2 for easy divisions. */
       adev->mm_stats.log2_max_MBps = ilog2(max(1u, max_MBps));
   -    r = amdgpu_ib_pool_init(adev);
-    if (r) {
-        dev_err(adev->dev, "IB initialization failed (%d).\n", r);
-        amdgpu_vf_error_put(adev, AMDGIM_ERROR_VF_IB_INIT_FAIL, 0, r);
-        goto failed;
-    }
-
       amdgpu_fbdev_init(adev);
         r = amdgpu_pm_sysfs_init(adev);
@@ -2735,7 +2738,6 @@ void amdgpu_device_fini(struct amdgpu_device
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
 *adev)
           else
               drm_atomic_helper_shutdown(adev->ddev);
       }
-    amdgpu_ib_pool_fini(adev);
       amdgpu_fence_driver_fini(adev);
       amdgpu_pm_sysfs_fini(adev);

      amdgpu_fbdev_fini(adev);

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