Skip to contentSkip to conversation

drm/amdgpu: correct the wrong cached state for GMC on PICASSO

PATCH In review Evan Quan 4 participants 7 messages Dec 14, 2021

Subsystems (3)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/1 drm/amdgpu: correct the wrong cached state for GMC on PICASSO

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

BUG: https://gitlab.freedesktop.org/drm/amd/-/issues/1828
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
 3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
 		return 0;
 	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
 	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
 	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -4
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,
 	if (amdgpu_sriov_vf(adev))
 		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GMC, true);
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
 }
 
 static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
index 3656a77baea4..9953a77cb987 100644
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void *handle,
 		pp_dpm_powergate_vce(handle, gate);
 		break;
 	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);
 		break;
 	case AMD_IP_BLOCK_TYPE_GFX:
 		ret = pp_dpm_powergate_gfx(handle, gate);
Signature · 1 line
2.29.0
Acked-by on v1 1/1
#1 lore raw

[Public]

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Evan Quan
Sent: Tuesday, December 14, 2021 9:34 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

BUG: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.freedesktop.org%2Fdrm%2Famd%2F-%2Fissues%2F1828&amp;data=04%7C01%7Cguchun.chen%40amd.com%7C42b00d7e1c4e44c0762908d9bea1ef53%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637750424983319967%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&amp;sdata=VgBDAbcKN%2FqUz8iBQby9YP8PsG2y93VlnDVhXVaGNBo%3D&amp;reserved=0
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
 3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
 		return 0;
 	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
 	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
 	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -4
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,
 	if (amdgpu_sriov_vf(adev))
 		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GMC, true);
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
 }
 
 static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev) diff --git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c

index 3656a77baea4..9953a77cb987 100644

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void *handle,
 		pp_dpm_powergate_vce(handle, gate);
 		break;
 	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);
 		break;
 	case AMD_IP_BLOCK_TYPE_GFX:
 		ret = pp_dpm_powergate_gfx(handle, gate);

--
2.29.0

Reviewed-by
#2 lore raw

[Public]

Quoted 30 lines

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, December 13, 2021 21:49
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

[Public]

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Evan Quan
Sent: Tuesday, December 14, 2021 9:34 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

Quoted 10 lines

BUG:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitlab.fr
eedesktop.org%2Fdrm%2Famd%2F- %2Fissues%2F1828&amp;data=04%7C01%7Cguchun.chen%40amd.com%7C42b 00d7e1c4e44c0762908d9bea1ef53%7C3dd8961fe4884e608e11a82d994e183d% 7C0%7C0%7C637750424983319967%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiM C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&a mp;sdata=VgBDAbcKN%2FqUz8iBQby9YP8PsG2y93VlnDVhXVaGNBo%3D&amp;r eserved=0

The syntax here should be BugLink: <url>

Otherwise

Quoted 72 lines
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
 3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
 		return 0;
 	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
 	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
 	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -4
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void
 mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,
 	if (amdgpu_sriov_vf(adev))
 		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev,
 AMD_IP_BLOCK_TYPE_GMC, true);
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
 }

static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev) diff --git
a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 3656a77baea4..9953a77cb987 100644

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void
 *handle,
 		pp_dpm_powergate_vce(handle, gate);
 		break;
 	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);
 		break;
 	case AMD_IP_BLOCK_TYPE_GFX:

ret = pp_dpm_powergate_gfx(handle, gate);
--
2.29.0

author
#3 lore raw

[Public]

Quoted 59 lines

-----Original Message-----
From: Limonciello, Mario <[email protected]>
Sent: Tuesday, December 14, 2021 11:50 AM
To: Chen, Guchun <[email protected]>; Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

[Public]

Quoted 30 lines

-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Monday, December 13, 2021 21:49
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>
Subject: RE: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

[Public]

Regards,
Guchun

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Evan Quan
Sent: Tuesday, December 14, 2021 9:34 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Quan, Evan <[email protected]>; Limonciello, Mario <[email protected]>
Subject: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

Quoted 5 lines

BUG:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgitl
ab.fr
eedesktop.org%2Fdrm%2Famd%2F- %2Fissues%2F1828&amp;data=04%7C01%7Cguchun.chen%40amd.com%7C

42b

Quoted 1 line

00d7e1c4e44c0762908d9bea1ef53%7C3dd8961fe4884e608e11a82d994e183d%

Quoted 1 line

7C0%7C0%7C637750424983319967%7CUnknown%7CTWFpbGZsb3d8eyJWIjoi M

Quoted 1 line

C4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000 &a

Quoted 1 line
Quoted 7 lines

mp;sdata=VgBDAbcKN%2FqUz8iBQby9YP8PsG2y93VlnDVhXVaGNBo%3D&a mp;r

Quoted 2 lines

eserved=0

The syntax here should be BugLink: <url>

[Quan, Evan] Thanks! Will fix that on code submission.

BR
Evan

Quoted 75 lines

Otherwise

Quoted 72 lines
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
 drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
 drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
 3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
 		return 0;
 	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
 	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
 	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -4
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void
 mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,
 	if (amdgpu_sriov_vf(adev))
 		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev,
 AMD_IP_BLOCK_TYPE_GMC, true);
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
 }

static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev) diff
--git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c
index 3656a77baea4..9953a77cb987 100644

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void
 *handle,
 		pp_dpm_powergate_vce(handle, gate);
 		break;
 	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);
 		break;
 	case AMD_IP_BLOCK_TYPE_GFX:

ret = pp_dpm_powergate_gfx(handle, gate);
--
2.29.0

#4 lore raw
In reply to Evan Quan
Quoted 57 lines · Evan Quan

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

BUG: https://gitlab.freedesktop.org/drm/amd/-/issues/1828
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
  drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
  drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
  3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
  		return 0;
  	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
  	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
  	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -4
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,
  	if (amdgpu_sriov_vf(adev))
  		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GMC, true);
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
  }
 
  static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev)
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -0
index 3656a77baea4..9953a77cb987 100644

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_set_powergating_by_smu(void *handle, · line 1175

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void *handle,
  		pp_dpm_powergate_vce(handle, gate);
  		break;
  	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);

This is a generic entry point. Would rather keep PG enable or disable supported in mmhub_v1_0 rather than than here. And this comment also should be in mmhub_v1_0.

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -0
  		break;
  	case AMD_IP_BLOCK_TYPE_GFX:
  		ret = pp_dpm_powergate_gfx(handle, gate);
author
#5 lore raw

[AMD Official Use Only]

Quoted 75 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, December 14, 2021 2:13 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Limonciello, Mario <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c static void

Quoted 40 lines · Evan Quan

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

BUG: https://gitlab.freedesktop.org/drm/amd/-/issues/1828
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
  drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
  drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
  3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
  		return 0;
  	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
  	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
  	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +0 -0
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void

mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c static void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +0 -2
  	if (amdgpu_sriov_vf(adev))
  		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev,

AMD_IP_BLOCK_TYPE_GMC, true);

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_set_powergating_by_smu(void

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -3
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
  }
 
  static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev) diff
--git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c

b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c index 3656a77baea4..9953a77cb987 100644

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -0
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void

*handle,

Quoted 14 lines

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_set_powergating_by_smu(void *handle, · line 1175

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
  		pp_dpm_powergate_vce(handle, gate);
  		break;
  	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);

This is a generic entry point. Would rather keep PG enable or disable supported in mmhub_v1_0 rather than than here. And this comment also should be in mmhub_v1_0.

[Quan, Evan] pp_dpm_powergate_mmhub is not a generic interface. It's customized for PICASSO which accepts no parameter("bool gate") as other interfaces. Thus some comments which explain why the interface is so special are proper I think.

BR
Evan

Quoted 8 lines

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -0
  		break;
  	case AMD_IP_BLOCK_TYPE_GFX:
  		ret = pp_dpm_powergate_gfx(handle, gate);
#6 lore raw
Quoted 93 lines · Evan

[AMD Official Use Only]

Quoted 75 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, December 14, 2021 2:13 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>; Limonciello, Mario <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: correct the wrong cached state for GMC on PICASSO

drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c static void

Quoted 40 lines · Evan Quan

Pair the operations did in GMC ->hw_init and ->hw_fini. That can help to maintain correct cached state for GMC and avoid unintention gate operation dropping due to wrong cached state.

BUG: https://gitlab.freedesktop.org/drm/amd/-/issues/1828
Change-Id I9976672a64464b86bb45eed0c25c9599d3bb4c06
---
   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c            | 8 ++++++++
   drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c          | 8 ++++----
   drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 7 ++++++-
   3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +8 -0
index db2ec84f7237..c7492db3e189 100644
@@ -1809,6 +1809,14 @@ static int gmc_v9_0_hw_fini(void *handle)
   		return 0;
   	}
 
+	/*
+	 * Pair the operations did in gmc_v9_0_hw_init and thus maintain
+	 * a correct cached state for GMC. Otherwise, the "gate" again
+	 * operation on S3 resuming will fail due to wrong cached state.
+	 */
+	if (adev->mmhub.funcs->update_power_gating)
+		adev->mmhub.funcs->update_power_gating(adev, false);
+
   	amdgpu_irq_put(adev, &adev->gmc.ecc_irq, 0);
   	amdgpu_irq_put(adev, &adev->gmc.vm_fault, 0);
 
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +0 -0
index b3bede1dc41d..1da2ec692057 100644
@@ -301,10 +301,10 @@ static void

mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c static void mmhub_v1_0_update_power_gating(struct amdgpu_device *adev,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +0 -2
   	if (amdgpu_sriov_vf(adev))
   		return;
 
-	if (enable && adev->pg_flags & AMD_PG_SUPPORT_MMHUB) {
-		amdgpu_dpm_set_powergating_by_smu(adev,

AMD_IP_BLOCK_TYPE_GMC, true);

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_set_powergating_by_smu(void

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c +4 -3
-
-	}
+	if (adev->pg_flags & AMD_PG_SUPPORT_MMHUB)
+		amdgpu_dpm_set_powergating_by_smu(adev,
+						  AMD_IP_BLOCK_TYPE_GMC,
+						  enable);
   }
 
   static int mmhub_v1_0_gart_enable(struct amdgpu_device *adev) diff
--git a/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c

b/drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c index 3656a77baea4..9953a77cb987 100644

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -0
@@ -1167,7 +1167,12 @@ static int pp_set_powergating_by_smu(void

*handle,

Quoted 14 lines

drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c static int pp_set_powergating_by_smu(void *handle, · line 1175

Quoted 10 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +6 -1
   		pp_dpm_powergate_vce(handle, gate);
   		break;
   	case AMD_IP_BLOCK_TYPE_GMC:
-		pp_dpm_powergate_mmhub(handle);
+		/*
+		 * For now, this is only used on PICASSO.
+		 * And only "gate" operation is supported.
+		 */
+		if (gate)
+			pp_dpm_powergate_mmhub(handle);

This is a generic entry point. Would rather keep PG enable or disable supported in mmhub_v1_0 rather than than here. And this comment also should be in mmhub_v1_0.

Quoted 3 lines

[Quan, Evan] pp_dpm_powergate_mmhub is not a generic interface. It's customized for PICASSO which accepts no parameter("bool gate") as other interfaces. Thus some comments which explain why the interface is so special are proper I think.

amd_powerplay is the generic entry point and we should avoid ASIC specific things as much as possible. Ideally this should be handled in mmhub v1/smu10 hwmgr and not here.

Thanks,
Lijo

Quoted 10 lines

BR
Evan

Quoted 8 lines

Thanks,
Lijo

Quoted 4 lines
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +0 -0
   		break;
   	case AMD_IP_BLOCK_TYPE_GFX:
   		ret = pp_dpm_powergate_gfx(handle, gate);