From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Zhu, Rex" Subject: Re: [PATCH v2 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread Date: Mon, 30 Jul 2018 10:25:03 +0000 Message-ID: References: <1532942625-26876-1-git-send-email-Rex.Zhu@amd.com>, <1532942625-26876-2-git-send-email-Rex.Zhu@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1791637033==" Return-path: In-Reply-To: <1532942625-26876-2-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org> Content-Language: en-US List-Id: Discussion list for AMD gfx List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Sender: "amd-gfx" To: "amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org" --===============1791637033== Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CY4PR12MB168727FC303FDB625880C440FB2F0CY4PR12MB1687namp_" --_000_CY4PR12MB168727FC303FDB625880C440FB2F0CY4PR12MB1687namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable One problem, I delay 500ms to enable gfx off feature. Any concern about the delay time? Best Regards Rex ________________________________ From: amd-gfx on behalf of Rex Zhu = Sent: Monday, July 30, 2018 5:23 PM To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: Zhu, Rex Subject: [PATCH v2 2/4] drm/amdgpu: Put enable gfx off feature to a delay t= hread delay to enable gfx off feature to avoid gfx on/off frequently suggested by Alex and Evan. Signed-off-by: Rex Zhu --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 +++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c | 8 ++++++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdg= pu/amdgpu.h index 188bc53..ff16689 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -992,6 +992,8 @@ struct amdgpu_gfx { bool gfx_off_state; /* true: enabled, f= alse: disabled */ struct mutex gfx_off_mutex; uint32_t gfx_off_req_count; /* default 1, e= nable gfx off: dec 1, disable gfx off: add 1 */ + struct delayed_work gfx_off_delay_work; + /* pipe reservation */ struct mutex pipe_reserve_mutex; DECLARE_BITMAP (pipe_reserve_bitmap, AMDGPU_MAX_C= OMPUTE_QUEUES); diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_device.c index 122653f..f6a6fb5 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1925,6 +1925,19 @@ static void amdgpu_device_ip_late_init_func_handler(= struct work_struct *work) DRM_ERROR("ib ring test failed (%d).\n", r); } +static void amdgpu_device_delay_enable_gfx_off(struct work_struct *work) +{ + struct amdgpu_device *adev =3D + container_of(work, struct amdgpu_device, gfx.gfx_off_delay_= work.work); + + mutex_lock(&adev->gfx.gfx_off_mutex); + if (!adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) { + if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_T= YPE_GFX, true)) + adev->gfx.gfx_off_state =3D true; + } + mutex_unlock(&adev->gfx.gfx_off_mutex); +} + /** * amdgpu_device_ip_suspend_phase1 - run suspend for hardware IPs (phase 1= ) * @@ -2394,6 +2407,8 @@ int amdgpu_device_init(struct amdgpu_device *adev, INIT_DELAYED_WORK(&adev->late_init_work, amdgpu_device_ip_late_init_func_handler); + INIT_DELAYED_WORK(&adev->gfx.gfx_off_delay_work, + amdgpu_device_delay_enable_gfx_off); adev->gfx.gfx_off_req_count =3D 1; adev->pm.ac_power =3D power_supply_is_system_supplied() > 0 ? true= : false; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_gfx.c index 1cdb264..11d4d9f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c @@ -26,6 +26,9 @@ #include "amdgpu.h" #include "amdgpu_gfx.h" +/* 0.5 second timeout */ +#define GFX_OFF_DELAY_ENABLE msecs_to_jiffies(500) + /* * GPU scratch registers helpers function. */ @@ -360,6 +363,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, bo= ol enable) if (!adev->powerplay.pp_funcs->set_powergating_by_smu) return; + mutex_lock(&adev->gfx.gfx_off_mutex); if (!enable) @@ -368,11 +372,11 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, = bool enable) adev->gfx.gfx_off_req_count--; if (enable && !adev->gfx.gfx_off_state && !adev->gfx.gfx_off_req_c= ount) { - if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_T= YPE_GFX, true)) - adev->gfx.gfx_off_state =3D true; + schedule_delayed_work(&adev->gfx.gfx_off_delay_work, GFX_OF= F_DELAY_ENABLE); } else if (!enable && adev->gfx.gfx_off_state) { if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_= TYPE_GFX, false)) adev->gfx.gfx_off_state =3D false; } + mutex_unlock(&adev->gfx.gfx_off_mutex); } -- 1.9.1 _______________________________________________ amd-gfx mailing list amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx amd-gfx Info Page - freedesktop.org lists.freedesktop.org Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following f= orm. Use of all freedesktop.org lists is subject to our Code of Conduct. --_000_CY4PR12MB168727FC303FDB625880C440FB2F0CY4PR12MB1687namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

One problem,


I delay 500ms to enable gfx off f= eature.


Any concern about the delay time?=


Best Regards

Rex



From: amd-gfx <amd-gfx-= bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <Rex.Zhu-5C7GfCeVMHo@public.gmane.org&= gt;
Sent: Monday, July 30, 2018 5:23 PM
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: Zhu, Rex
Subject: [PATCH v2 2/4] drm/amdgpu: Put enable gfx off feature to a = delay thread
 
delay to enable gfx off feature to avoid gfx on/of= f frequently
suggested by Alex and Evan.

Signed-off-by: Rex Zhu <Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h     &nbs= p;  |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 15 ++++&= #43;++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    |  8 &= #43;+++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdg= pu/amdgpu.h
index 188bc53..ff16689 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -992,6 +992,8 @@ struct amdgpu_gfx {
         bool   &nbs= p;            &= nbsp;           gfx_off_s= tate; /* true: enabled, false: disabled */
         struct mutex  &n= bsp;            = ;     gfx_off_mutex;
         uint32_t   =             &nb= sp;        gfx_off_req_count; /* default= 1, enable gfx off: dec 1, disable gfx off: add 1 */
+       struct delayed_work  &n= bsp;          gfx_off_delay_wo= rk;
+
         /* pipe reservation */
         struct mutex  &n= bsp;            = ;     pipe_reserve_mutex;
         DECLARE_BITMAP  =             &nb= sp;   (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/a= md/amdgpu/amdgpu_device.c
index 122653f..f6a6fb5 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1925,6 +1925,19 @@ static void amdgpu_device_ip_late_init_func_hand= ler(struct work_struct *work)
            &nb= sp;    DRM_ERROR("ib ring test failed (%d).\n", r)= ;
 }
 
+static void amdgpu_device_delay_enable_gfx_off(struct work_struct *wor= k)
+{
+       struct amdgpu_device *adev =3D +           &nbs= p;   container_of(work, struct amdgpu_device, gfx.gfx_off_delay_w= ork.work);
+
+       mutex_lock(&adev->gfx.gfx_= off_mutex);
+       if (!adev->gfx.gfx_off_state &= amp;& !adev->gfx.gfx_off_req_count) {
+           &nbs= p;   if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TY= PE_GFX, true))
+           &nbs= p;           adev->gfx= .gfx_off_state =3D true;
+       }
+       mutex_unlock(&adev->gfx.gf= x_off_mutex);
+}
+
 /**
  * amdgpu_device_ip_suspend_phase1 - run suspend for hardware IPs (ph= ase 1)
  *
@@ -2394,6 +2407,8 @@ int amdgpu_device_init(struct amdgpu_device *adev= ,
 
         INIT_DELAYED_WORK(&ade= v->late_init_work,
            &nb= sp;            =   amdgpu_device_ip_late_init_func_handler);
+       INIT_DELAYED_WORK(&adev->g= fx.gfx_off_delay_work,
+           &nbs= p;             = amdgpu_device_delay_enable_gfx_off);
 
         adev->gfx.gfx_off_req_c= ount =3D 1;
         adev->pm.ac_power =3D p= ower_supply_is_system_supplied() > 0 ? true : false;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_gfx.c
index 1cdb264..11d4d9f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -26,6 +26,9 @@
 #include "amdgpu.h"
 #include "amdgpu_gfx.h"
 
+/* 0.5 second timeout */
+#define GFX_OFF_DELAY_ENABLE       =   msecs_to_jiffies(500)
+
 /*
  * GPU scratch registers helpers function.
  */
@@ -360,6 +363,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev= , bool enable)
         if (!adev->powerplay.pp= _funcs->set_powergating_by_smu)
            &nb= sp;    return;
 
+
         mutex_lock(&adev->g= fx.gfx_off_mutex);
 
         if (!enable)
@@ -368,11 +372,11 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *ad= ev, bool enable)
            &nb= sp;    adev->gfx.gfx_off_req_count--;
 
         if (enable && !ade= v->gfx.gfx_off_state && !adev->gfx.gfx_off_req_count) {
-            &n= bsp;  if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_G= FX, true))
-            &n= bsp;          adev->gfx.gfx= _off_state =3D true;
+           &nbs= p;   schedule_delayed_work(&adev->gfx.gfx_off_delay_work, = GFX_OFF_DELAY_ENABLE);
         } else if (!enable &&a= mp; adev->gfx.gfx_off_state) {
            &nb= sp;    if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_B= LOCK_TYPE_GFX, false))
            &nb= sp;            adev-= >gfx.gfx_off_state =3D false;
         }
+
         mutex_unlock(&adev->= ;gfx.gfx_off_mutex);
 }
--
1.9.1

_______________________________________________
amd-gfx mailing list
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
https://lists.free= desktop.org/mailman/listinfo/amd-gfx
lists.freedesktop.org
Subscribing to amd-gfx: Subscribe to amd-gfx by filling out the following f= orm. Use of all freedesktop.org lists is subject to our Code of Conduct.

--_000_CY4PR12MB168727FC303FDB625880C440FB2F0CY4PR12MB1687namp_-- --===============1791637033== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KYW1kLWdmeCBt YWlsaW5nIGxpc3QKYW1kLWdmeEBsaXN0cy5mcmVlZGVza3RvcC5vcmcKaHR0cHM6Ly9saXN0cy5m cmVlZGVza3RvcC5vcmcvbWFpbG1hbi9saXN0aW5mby9hbWQtZ2Z4Cg== --===============1791637033==--