<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Hi Alex,</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Is it necessary to export an interface as "is_gfx_on" in powerplay to amdgpu?</p>
<p style="margin-top:0;margin-bottom:0">It can show the current power state of gfx ip.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Best Regards</p>
<p style="margin-top:0;margin-bottom:0">Rex </p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<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> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Zhu, Rex <Rex.Zhu@amd.com><br>
<b>Sent:</b> Monday, July 30, 2018 11:39 AM<br>
<b>To:</b> Quan, Evan; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 3/3] drm/amd/pp: Add gfx power status check support on Rv/Vega12</font>
<div> </div>
</div>
<meta content="text/html; charset=iso-8859-1">
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0"><span>> It means user was told the gfx is on but actually it may switches to gfxoff already.</span></p>
<p style="margin-top:0; margin-bottom:0"><span></span><br>
</p>
<p style="margin-top:0; margin-bottom:0">Correct. <br>
</p>
<p style="margin-top:0; margin-bottom:0">So if the gfx is off, user should disable gfx off feature before they read/write the registers via mmio.</p>
<p style="margin-top:0; margin-bottom:0">if gfx is on, that is not mean the gfx off feature is disabled. it  doesn't mean it is safe to visit the registers through mmio.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Best Regards</p>
<p style="margin-top:0; margin-bottom:0">Rex<br>
</p>
<br>
<div style="color:rgb(0,0,0)">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b> Quan, Evan<br>
<b>Sent:</b> Monday, July 30, 2018 9:31 AM<br>
<b>To:</b> Zhu, Rex; amd-gfx@lists.freedesktop.org<br>
<b>Subject:</b> Re: [PATCH 3/3] drm/amd/pp: Add gfx power status check support on Rv/Vega12</font>
<div> </div>
</div>
<meta content="text/html; charset=us-ascii">
<div dir="ltr">
<div id="x_x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">Since the gfxoff is always in dynamic switch, i do not think the status reported to user is reliable. It means user was told the gfx is on but actually it may switches to gfxoff already.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Regards,</p>
<p style="margin-top:0; margin-bottom:0">Evan</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_x_divRplyFwdMsg" dir="ltr"><font color="#000000" face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Rex Zhu <rex.zhu@amd.com><br>
<b>Sent:</b> Sunday, July 29, 2018 7:42:27 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Zhu, Rex<br>
<b>Subject:</b> [PATCH 3/3] drm/amd/pp: Add gfx power status check support on Rv/Vega12</font>
<div> </div>
</div>
<div class="x_x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_x_PlainText">As gfx off is supported on Rv/Vega12, so this check is<br>
helpful and necessary when visit gfx regesiter via mmio.<br>
<br>
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com><br>
---<br>
 drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c  | 10 +++++++<br>
 drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c | 31 +++++++++++++++++++++-<br>
 2 files changed, 40 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c<br>
index 26d130a..da1be82 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c<br>
@@ -296,6 +296,15 @@ static bool smu10_is_gfx_on(struct pp_hwmgr *hwmgr)<br>
         return false;<br>
 }<br>
 <br>
+static bool smu10_is_hw_ip_on(struct pp_hwmgr *hwmgr,<br>
+                               enum amd_ip_block_type client)<br>
+{<br>
+       if (client == AMD_IP_BLOCK_TYPE_GFX)<br>
+               return smu10_is_gfx_on(hwmgr);<br>
+       else /* for other ip, to do */<br>
+               return true;<br>
+}<br>
+<br>
 static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)<br>
 {<br>
         struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);<br>
@@ -1187,6 +1196,7 @@ static void smu10_powergate_vcn(struct pp_hwmgr *hwmgr, bool bgate)<br>
         .smus_notify_pwe = smu10_smus_notify_pwe,<br>
         .display_clock_voltage_request = smu10_display_clock_voltage_request,<br>
         .powergate_gfx = smu10_gfx_off_control,<br>
+       .is_hw_ip_on = smu10_is_hw_ip_on,<br>
 };<br>
 <br>
 int smu10_init_function_pointers(struct pp_hwmgr *hwmgr)<br>
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c<br>
index 0789d64..ee44300 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega12_hwmgr.c<br>
@@ -45,7 +45,7 @@<br>
 #include "ppinterrupt.h"<br>
 #include "pp_overdriver.h"<br>
 #include "pp_thermal.h"<br>
-<br>
+#include "soc15_common.h"<br>
 <br>
 static int vega12_force_clock_level(struct pp_hwmgr *hwmgr,<br>
                 enum pp_clock_type type, uint32_t mask);<br>
@@ -2320,6 +2320,34 @@ static int vega12_get_thermal_temperature_range(struct pp_hwmgr *hwmgr,<br>
         return 0;<br>
 }<br>
 <br>
+/* GFX HW Power Status can be queried from bits [1:0] of MP1_SMN_EXT_SCRATCH0<br>
+ * 2'b00   GFX is OFF<br>
+ * 2'b01   Transitioning out of GFXOFF state<br>
+ * 2'b10   GFX is ON<br>
+ * 2'b11   Transitioning into GFXOFF state<br>
+*/<br>
+<br>
+static bool vega12_is_gfx_on(struct pp_hwmgr *hwmgr)<br>
+{<br>
+       uint32_t tmp;<br>
+       struct amdgpu_device *adev = hwmgr->adev;<br>
+<br>
+       tmp = RREG32_SOC15(MP1, 0, mmMP1_SMN_EXT_SCRATCH0);<br>
+       if (tmp == 1 || tmp == 2)<br>
+               return true;<br>
+       else<br>
+               return false;<br>
+}<br>
+<br>
+static bool vega12_is_hw_ip_on(struct pp_hwmgr *hwmgr,<br>
+                               enum amd_ip_block_type client)<br>
+{<br>
+       if (client == AMD_IP_BLOCK_TYPE_GFX)<br>
+               return vega12_is_gfx_on(hwmgr);<br>
+       else /* for other ip, to do */<br>
+               return true;<br>
+}<br>
+<br>
 static int vega12_enable_gfx_off(struct pp_hwmgr *hwmgr)<br>
 {<br>
         struct vega12_hwmgr *data =<br>
@@ -2402,6 +2430,7 @@ static int vega12_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)<br>
         .register_irq_handlers = smu9_register_irq_handlers,<br>
         .start_thermal_controller = vega12_start_thermal_controller,<br>
         .powergate_gfx = vega12_gfx_off_control,<br>
+       .is_hw_ip_on = vega12_is_hw_ip_on,<br>
 };<br>
 <br>
 int vega12_hwmgr_init(struct pp_hwmgr *hwmgr)<br>
-- <br>
1.9.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" id="LPlnk332384" class="x_OWAAutoLink" previewremoved="true">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a>
<div id="LPBorder_GT_15329216129360.023283015732668888" style="margin-bottom:20px; overflow:auto; width:100%; text-indent:0px">
<table id="LPContainer_15329216129340.4712885778626795" cellspacing="0" style="width:90%; background-color:rgb(255,255,255); overflow:auto; padding-top:20px; padding-bottom:20px; margin-top:20px; border-top:1px dotted rgb(200,200,200); border-bottom:1px dotted rgb(200,200,200)">
<tbody>
<tr valign="top" style="border-spacing:0px">
<td id="x_TextCell_15329216129340.47980485889895885" colspan="2" style="vertical-align: top; padding: 0px; display: table-cell; position: relative;">
<div id="LPRemovePreviewContainer_15329216129340.8736912459594872"></div>
<div id="LPTitle_15329216129340.277757395718243" style="top:0px; color:rgb(0,120,215); font-weight:400; font-size:21px; font-family:"wf_segoe-ui_light","Segoe UI Light","Segoe WP Light","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif; line-height:21px">
<a id="LPUrlAnchor_15329216129340.04206666600487852" href="https://lists.freedesktop.org/mailman/listinfo/amd-gfx" target="_blank" style="text-decoration:none">amd-gfx Info Page - freedesktop.org</a></div>
<div id="LPMetadata_15329216129340.9190483966147242" style="margin:10px 0px 16px; color:rgb(102,102,102); font-weight:400; font-family:"wf_segoe-ui_normal","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif; font-size:14px; line-height:14px">
lists.freedesktop.org</div>
<div id="LPDescription_15329216129340.6657080067609241" style="display:block; color:rgb(102,102,102); font-weight:400; font-family:"wf_segoe-ui_normal","Segoe UI","Segoe WP",Tahoma,Arial,sans-serif; font-size:14px; line-height:20px; max-height:100px; overflow:hidden">
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following form. Use of all freedesktop.org lists is subject to our Code of Conduct.</div>
</td>
</tr>
</tbody>
</table>
</div>
<br>
</div>
</span></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>