<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#008000;margin:15pt;" align="Left">
[Public]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Should we set *flags = 0 before we return?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Yu, Lang <Lang.Yu@amd.com><br>
<b>Sent:</b> Wednesday, January 26, 2022 2:53 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Lazar, Lijo <Lijo.Lazar@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Yu, Lang <Lang.Yu@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: add safeguards for accessing mmhub CG registers</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">We observed a gpu hang when querying mmhub CG status(i.e.,<br>
cat amdgpu_pm_info) on cyan skillfish. Acctually, cyan<br>
skillfish doesn't support any CG features.<br>
<br>
Only allow asics which support CG features accessing related<br>
registers. Will add similar safeguards for other IPs in the<br>
furture.<br>
<br>
Signed-off-by: Lang Yu <Lang.Yu@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c | 3 +++<br>
drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c | 3 +++<br>
drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c | 3 +++<br>
drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c | 3 +++<br>
drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c | 3 +++<br>
5 files changed, 15 insertions(+)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c<br>
index 4c9f0c0f3116..1869e2019461 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_0.c<br>
@@ -550,6 +550,9 @@ static void mmhub_v1_0_get_clockgating(struct amdgpu_device *adev, u32 *flags)<br>
{<br>
int data, data1;<br>
<br>
+ if (!(adev->cg_flags & (AMD_CG_SUPPORT_MC_MGCG | AMD_CG_SUPPORT_MC_LS)))<br>
+ return;<br>
+<br>
if (amdgpu_sriov_vf(adev))<br>
*flags = 0;<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c<br>
index 3b901f941627..f7b9843b36e6 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v1_7.c<br>
@@ -546,6 +546,9 @@ static void mmhub_v1_7_get_clockgating(struct amdgpu_device *adev, u32 *flags)<br>
{<br>
int data, data1;<br>
<br>
+ if (!(adev->cg_flags & (AMD_CG_SUPPORT_MC_MGCG | AMD_CG_SUPPORT_MC_LS)))<br>
+ return;<br>
+<br>
if (amdgpu_sriov_vf(adev))<br>
*flags = 0;<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c<br>
index 3718ff610ab2..3f5f326379b7 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_0.c<br>
@@ -686,6 +686,9 @@ static void mmhub_v2_0_get_clockgating(struct amdgpu_device *adev, u32 *flags)<br>
{<br>
int data, data1;<br>
<br>
+ if (!(adev->cg_flags & (AMD_CG_SUPPORT_MC_MGCG | AMD_CG_SUPPORT_MC_LS)))<br>
+ return;<br>
+<br>
if (amdgpu_sriov_vf(adev))<br>
*flags = 0;<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c<br>
index 9e16da28505a..b23dd9ddfb5c 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v2_3.c<br>
@@ -580,6 +580,9 @@ static void mmhub_v2_3_get_clockgating(struct amdgpu_device *adev, u32 *flags)<br>
{<br>
int data, data1, data2, data3;<br>
<br>
+ if (!(adev->cg_flags & (AMD_CG_SUPPORT_MC_MGCG | AMD_CG_SUPPORT_MC_LS)))<br>
+ return;<br>
+<br>
if (amdgpu_sriov_vf(adev))<br>
*flags = 0;<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c b/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c<br>
index 619106f7d23d..a2d5c8424e2b 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/mmhub_v9_4.c<br>
@@ -651,6 +651,9 @@ static void mmhub_v9_4_get_clockgating(struct amdgpu_device *adev, u32 *flags)<br>
{<br>
int data, data1;<br>
<br>
+ if (!(adev->cg_flags & (AMD_CG_SUPPORT_MC_MGCG | AMD_CG_SUPPORT_MC_LS)))<br>
+ return;<br>
+<br>
if (amdgpu_sriov_vf(adev))<br>
*flags = 0;<br>
<br>
-- <br>
2.25.1<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>