Skip to contentSkip to conversation

drm/amdgpu: fix CG enabling hang with gfxoff enabled

PATCH In review Huang Rui 3 participants 5 messages Jun 5, 2018 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH v2 1/1 drm/amdgpu: fix CG enabling hang with gfxoff enabled

After defer the execution of clockgating enabling, at that time, gfx already enter into "off" state. Howerver, clockgating enabling will use MMIO to access the gfx registers, then get the gfx hung.

So here we should move the gfx powergating and gfxoff enabling behavior at the end of initialization behind clockgating.

Cc Hawking Zhang <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Christian König <[email protected]>

---

Changes from V1 -> V2:
- Update real root cause of gfx hung with gfxoff enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             |  5 -----
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  2 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  4 ++--
 4 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index f509d32..72b95f7 100644
@@ -1723,6 +1723,18 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
 			}
 		}
 	}
+
+	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) {
+		/* enable gfx powergating */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_GFX,
+						       AMD_CG_STATE_GATE);
+		/* enable gfxoff */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_SMC,
+						       AMD_CG_STATE_GATE);
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
index 2c5e2a4..31ecc86 100644
@@ -3358,11 +3358,6 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1 -1
index b493369..d0e6e2d 100644
@@ -245,7 +245,7 @@ static int pp_set_powergating_state(void *handle,
 	}
 
 	if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
-		pr_info("%s was not implemented.\n", __func__);
+		pr_debug("%s was not implemented.\n", __func__);
 		return 0;
 	}
 
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +2 -2
index 7712eb6..b72d089 100644
@@ -284,7 +284,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
 {
-	return smu10_disable_gfx_off(hwmgr);
+	return 0;
 }
 
 static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
@@ -299,7 +299,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
 {
-	return smu10_enable_gfx_off(hwmgr);
+	return 0;
 }
 
 static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
Signature · 1 line
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): 1528167702-28398-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 05.06.2018 um 05:01 schrieb Huang Rui:

Quoted 11 lines

After defer the execution of clockgating enabling, at that time, gfx already enter into "off" state. Howerver, clockgating enabling will use MMIO to access the gfx registers, then get the gfx hung.

So here we should move the gfx powergating and gfxoff enabling behavior at the end of initialization behind clockgating.

Cc Hawking Zhang <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Christian König <[email protected]>

Thanks for the patience figuring out the real root cause, Christian.

Quoted 78 lines

---

Changes from V1 -> V2:
- Update real root cause of gfx hung with gfxoff enabled.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        | 12 ++++++++++++
  drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             |  5 -----
  drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  2 +-
  drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  4 ++--
  4 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index f509d32..72b95f7 100644
@@ -1723,6 +1723,18 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
  			}
  		}
  	}
+
+	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) {
+		/* enable gfx powergating */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_GFX,
+						       AMD_CG_STATE_GATE);
+		/* enable gfxoff */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_SMC,
+						       AMD_CG_STATE_GATE);
+	}
+
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
index 2c5e2a4..31ecc86 100644
@@ -3358,11 +3358,6 @@ static int gfx_v9_0_late_init(void *handle)
  	if (r)
  		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
  	return 0;
  }
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1 -1
index b493369..d0e6e2d 100644
@@ -245,7 +245,7 @@ static int pp_set_powergating_state(void *handle,
  	}
 
  	if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
-		pr_info("%s was not implemented.\n", __func__);
+		pr_debug("%s was not implemented.\n", __func__);
  		return 0;
  	}
 
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +1 -1
index 7712eb6..b72d089 100644
@@ -284,7 +284,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 
  static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
  {
-	return smu10_disable_gfx_off(hwmgr);
+	return 0;
  }
 
  static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)

drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr) · line 305

Quoted 8 lines
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +1 -1
@@ -299,7 +299,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
 
  static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
  {
-	return smu10_enable_gfx_off(hwmgr);
+	return 0;
  }
 
  static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)

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

Reviewed-by Hawking Zhang
#3 lore raw
In reply to a message not in the archive

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Huang Rui
Sent: 2018年6月5日 11:02
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH v2] drm/amdgpu: fix CG enabling hang with gfxoff enabled

After defer the execution of clockgating enabling, at that time, gfx already enter into "off" state. Howerver, clockgating enabling will use MMIO to access the gfx registers, then get the gfx hung.

So here we should move the gfx powergating and gfxoff enabling behavior at the end of initialization behind clockgating.

Cc Hawking Zhang <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Christian König <[email protected]>

---

Changes from V1 -> V2:
- Update real root cause of gfx hung with gfxoff enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             |  5 -----
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  2 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  4 ++--
 4 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index f509d32..72b95f7 100644
@@ -1723,6 +1723,18 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
 			}
 		}
 	}
+
+	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) {
+		/* enable gfx powergating */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_GFX,
+						       AMD_CG_STATE_GATE);
+		/* enable gfxoff */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_SMC,
+						       AMD_CG_STATE_GATE);
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
index 2c5e2a4..31ecc86 100644
@@ -3358,11 +3358,6 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1 -1
index b493369..d0e6e2d 100644
@@ -245,7 +245,7 @@ static int pp_set_powergating_state(void *handle,
 	}
 
 	if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
-		pr_info("%s was not implemented.\n", __func__);
+		pr_debug("%s was not implemented.\n", __func__);
 		return 0;
 	}
 
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +1 -1
index 7712eb6..b72d089 100644
@@ -284,7 +284,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)  {
-	return smu10_disable_gfx_off(hwmgr);
+	return 0;
 }
 
 static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr) @@ -299,7 +299,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
 

static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) {
- return smu10_enable_gfx_off(hwmgr);
+ return 0;
}

static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
--
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): DM5PR1201MB24757EB590F13D0C1BA25885FC660-grEf7a3NxMAyj5E7E3lLiWrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

Reviewed-by Hawking Zhang
#5 lore raw

+ amdgpu_device_ip_set_powergating_state(adev,
+ AMD_IP_BLOCK_TYPE_GFX,
+ AMD_CG_STATE_GATE);

There is typo that AMD_CG_STATE_GATE should be AMD_PG_STATE_GATE. Please correct that before push the patch.

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhang, Hawking
Sent: 2018年6月5日 14:42
To: Huang, Ray <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH v2] drm/amdgpu: fix CG enabling hang with gfxoff enabled

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Huang Rui
Sent: 2018年6月5日 11:02
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH v2] drm/amdgpu: fix CG enabling hang with gfxoff enabled

After defer the execution of clockgating enabling, at that time, gfx already enter into "off" state. Howerver, clockgating enabling will use MMIO to access the gfx registers, then get the gfx hung.

So here we should move the gfx powergating and gfxoff enabling behavior at the end of initialization behind clockgating.

Cc Hawking Zhang <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Christian König <[email protected]>

---

Changes from V1 -> V2:
- Update real root cause of gfx hung with gfxoff enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             |  5 -----
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  2 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  4 ++--
 4 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index f509d32..72b95f7 100644
@@ -1723,6 +1723,18 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
 			}
 		}
 	}
+
+	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) {
+		/* enable gfx powergating */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_GFX,
+						       AMD_CG_STATE_GATE);
+		/* enable gfxoff */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_SMC,
+						       AMD_CG_STATE_GATE);
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
index 2c5e2a4..31ecc86 100644
@@ -3358,11 +3358,6 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1 -1
index b493369..d0e6e2d 100644
@@ -245,7 +245,7 @@ static int pp_set_powergating_state(void *handle,
 	}
 
 	if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
-		pr_info("%s was not implemented.\n", __func__);
+		pr_debug("%s was not implemented.\n", __func__);
 		return 0;
 	}
 
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +1 -1
index 7712eb6..b72d089 100644
@@ -284,7 +284,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)  {
-	return smu10_disable_gfx_off(hwmgr);
+	return 0;
 }
 
 static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr) @@ -299,7 +299,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
 

static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) {
- return smu10_enable_gfx_off(hwmgr);
+ return 0;
}

static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
--
2.7.4

_______________________________________________
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): DM5PR1201MB24757856D579A6D3100F8EA2FC660-grEf7a3NxMAyj5E7E3lLiWrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

author Reviewed-by Hawking Zhang
#7 lore raw

Updated.

Thanks,
Ray

-----Original Message-----
From: Zhang, Hawking
Sent: Tuesday, June 05, 2018 3:28 PM
To: Zhang, Hawking <[email protected]>; Huang, Ray <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH v2] drm/amdgpu: fix CG enabling hang with gfxoff enabled

+ amdgpu_device_ip_set_powergating_state(adev,
+ AMD_IP_BLOCK_TYPE_GFX,
+ AMD_CG_STATE_GATE);

There is typo that AMD_CG_STATE_GATE should be AMD_PG_STATE_GATE. Please correct that before push the patch.

Regards,
Hawking

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Zhang, Hawking
Sent: 2018年6月5日 14:42
To: Huang, Ray <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>
Subject: RE: [PATCH v2] drm/amdgpu: fix CG enabling hang with gfxoff enabled

Regards,
Hawking
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Huang Rui
Sent: 2018年6月5日 11:02
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Huang, Ray <[email protected]>; Koenig, Christian <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH v2] drm/amdgpu: fix CG enabling hang with gfxoff enabled

After defer the execution of clockgating enabling, at that time, gfx already enter into "off" state. Howerver, clockgating enabling will use MMIO to access the gfx registers, then get the gfx hung.

So here we should move the gfx powergating and gfxoff enabling behavior at the end of initialization behind clockgating.

Cc Hawking Zhang <[email protected]>
Cc Felix Kuehling <[email protected]>
Cc Christian König <[email protected]>

---

Changes from V1 -> V2:
- Update real root cause of gfx hung with gfxoff enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c        | 12 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c             |  5 -----
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c     |  2 +-
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c |  4 ++--
 4 files changed, 15 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +12 -0
index f509d32..72b95f7 100644
@@ -1723,6 +1723,18 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
 			}
 		}
 	}
+
+	if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) {
+		/* enable gfx powergating */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_GFX,
+						       AMD_CG_STATE_GATE);
+		/* enable gfxoff */
+		amdgpu_device_ip_set_powergating_state(adev,
+						       AMD_IP_BLOCK_TYPE_SMC,
+						       AMD_CG_STATE_GATE);
+	}
+
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0 -5
index 2c5e2a4..31ecc86 100644
@@ -3358,11 +3358,6 @@ static int gfx_v9_0_late_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-						   AMD_PG_STATE_GATE);
-	if (r)
-		return r;
-
 	return 0;
 }
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1 -1
index b493369..d0e6e2d 100644
@@ -245,7 +245,7 @@ static int pp_set_powergating_state(void *handle,
 	}
 
 	if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
-		pr_info("%s was not implemented.\n", __func__);
+		pr_debug("%s was not implemented.\n", __func__);
 		return 0;
 	}
 
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c +1 -1
index 7712eb6..b72d089 100644
@@ -284,7 +284,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)  {
-	return smu10_disable_gfx_off(hwmgr);
+	return 0;
 }
 
 static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr) @@ -299,7 +299,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
 

static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr) {
- return smu10_enable_gfx_off(hwmgr);
+ return 0;
}

static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
--
2.7.4

_______________________________________________
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