<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">
<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">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 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 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="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="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">https://lists.freedesktop.org/mailman/listinfo/amd-gfx</a><br>
</div>
</span></font></div>
</body>
</html>