[PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread

Quan, Evan Evan.Quan at amd.com
Mon Jul 30 04:15:25 UTC 2018


OK, I see. Then it's better to unlock the gfx_off_ctrl_mutex in amdgpu_gfx_off_ctrl() before calling schedule_delayed_work().


Regards,

Evan

________________________________
From: Zhu, Rex
Sent: Monday, July 30, 2018 11:52:41 AM
To: Quan, Evan; amd-gfx at lists.freedesktop.org
Subject: Re: [PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread



>I think for disable gfxoff case, you need to use cancle_delayed_work_sync((&adev->gfx.delay_gfx_off_enable). E.g.


This makes code a bit complex.

we don't need to cancel the delay work.


In delay work thread, we also need to get the mutex. and check the request count value.

if Other clients have new disable requests before the delay work ran, the count will be added by 1.

so in the delay thread, gfx off will not be enabled.


Best Regards

Rex



________________________________
From: Quan, Evan
Sent: Monday, July 30, 2018 10:26 AM
To: Zhu, Rex; amd-gfx at lists.freedesktop.org
Subject: Re: [PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread


-               if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))
-                       adev->gfx.bin_off = true;
+               schedule_delayed_work(&adev->gfx.delay_gfx_off_enable, GFX_OFF_DELAY_ENABLE);
         } else if (!enable && adev->gfx.bin_off) {
                 if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false))
                         adev->gfx.bin_off = false;


I think for disable gfxoff case, you need to use cancle_delayed_work_sync((&adev->gfx.delay_gfx_off_enable). E.g.


if (!cancle_delayed_work_sync((&adev->gfx.delay_gfx_off_enable) && !amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false))

                         adev->gfx.bin_off = false;


Regards,

Evan

________________________________
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> on behalf of Rex Zhu <rex.zhu at amd.com>
Sent: Sunday, July 29, 2018 7:35:48 PM
To: amd-gfx at lists.freedesktop.org
Cc: Zhu, Rex
Subject: [PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread

delay to enable gfx off feature to avoid gfx on/off frequently

Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 16 ++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    |  6 ++++--
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 318961d..b59ac02 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -993,6 +993,7 @@ struct amdgpu_gfx {
         bool                            bin_off;
         struct mutex                    gfx_off_ctrl_mutex;
         uint32_t                        disable_gfx_off_request;
+       struct delayed_work             delay_gfx_off_enable;
         /* pipe reservation */
         struct mutex                    pipe_reserve_mutex;
         DECLARE_BITMAP                  (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index b40ce6f..9f8e267 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1925,6 +1925,20 @@ 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 =
+               container_of(work, struct amdgpu_device, gfx.delay_gfx_off_enable.work);
+
+       mutex_lock(&adev->gfx.gfx_off_ctrl_mutex);
+       if (adev->gfx.bready_for_off && !adev->gfx.bin_off
+                               && adev->gfx.disable_gfx_off_request) {
+               if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))
+                       adev->gfx.bin_off = true;
+       }
+       mutex_unlock(&adev->gfx.gfx_off_ctrl_mutex);
+}
+
 /**
  * amdgpu_device_ip_suspend_phase1 - run suspend for hardware IPs (phase 1)
  *
@@ -2394,6 +2408,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.delay_gfx_off_enable,
+                         amdgpu_device_delay_enable_gfx_off);

         adev->pm.ac_power = 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 68fe9c8..1ea1e8b 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.
  */
@@ -384,8 +387,7 @@ void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, enum amd_ip_block_type clie
  */
         if (adev->gfx.bready_for_off && !adev->gfx.bin_off
                                 && !adev->gfx.disable_gfx_off_request) {
-               if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true))
-                       adev->gfx.bin_off = true;
+               schedule_delayed_work(&adev->gfx.delay_gfx_off_enable, GFX_OFF_DELAY_ENABLE);
         } else if (!enable && adev->gfx.bin_off) {
                 if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false))
                         adev->gfx.bin_off = false;
--
1.9.1

_______________________________________________
amd-gfx mailing list
amd-gfx at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
amd-gfx Info Page - freedesktop.org<https://lists.freedesktop.org/mailman/listinfo/amd-gfx>
lists.freedesktop.org
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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/amd-gfx/attachments/20180730/d1b82bbf/attachment-0001.html>


More information about the amd-gfx mailing list