Skip to contentSkip to conversation

drm/amdgpu: Add amdgpu_gfx_off_ctrl function

PATCH Superseded Rex Zhu 2 participants 13 messages Jul 29, 2018 – Jul 30, 2018 9 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/4 drm/amdgpu: Add amdgpu_gfx_off_ctrl function

This funciton as the entry of gfx off ctrl feature. we arbitrat gfx off feature enable/disable in this function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  7 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 52 ++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index 5b7bb58..318961d 100644
@@ -988,6 +988,11 @@ struct amdgpu_gfx {
 	/* NGG */
 	struct amdgpu_ngg		ngg;
 
+	/* gfx off */
+	bool                            bready_for_off;
+	bool                            bin_off;
+	struct mutex                    gfx_off_ctrl_mutex;
+	uint32_t                        disable_gfx_off_request;
 	/* pipe reservation */
 	struct mutex			pipe_reserve_mutex;
 	DECLARE_BITMAP			(pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
@@ -1815,6 +1820,8 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,
 					     const u32 array_size);
 
 bool amdgpu_device_is_px(struct drm_device *dev);
+void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev,
+				enum amd_ip_block_type client, bool enable);
 /* atpx handler */
 #if defined(CONFIG_VGA_SWITCHEROO)
 void amdgpu_register_atpx_handler(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index 745f760..b40ce6f 100644
@@ -2367,6 +2367,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	mutex_init(&adev->gfx.gpu_clock_mutex);
 	mutex_init(&adev->srbm_mutex);
 	mutex_init(&adev->gfx.pipe_reserve_mutex);
+	mutex_init(&adev->gfx.gfx_off_ctrl_mutex);
 	mutex_init(&adev->grbm_idx_mutex);
 	mutex_init(&adev->mn_lock);
 	mutex_init(&adev->virt.vf_errors.lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +52 -0

55 lines not on this page · raw message

Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1532864150-32370-1-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 318961d..b59ac02 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16 -0
index b40ce6f..9f8e267 100644
@@ -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;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -2
index 68fe9c8..1ea1e8b 100644
@@ -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;
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1532864150-32370-2-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org

#4 lore raw

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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:48 PM
To: [email protected]
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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 318961d..b59ac02 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16 -0
index b40ce6f..9f8e267 100644
@@ -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;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -2
index 68fe9c8..1ea1e8b 100644
@@ -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 [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): SN6PR12MB2656A6C34BE374E0DF5FD125E42F0-kxOKjb6HO/FeL/[email protected]

author
#6 lore raw

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

Quoted 2 lines

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; [email protected]
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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:48 PM
To: [email protected]
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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 318961d..b59ac02 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16 -0
index b40ce6f..9f8e267 100644
@@ -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;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -2
index 68fe9c8..1ea1e8b 100644
@@ -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
[email protected]
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.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CY4PR12MB168726A840EE78ECCA4D9005FB2F0-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#8 lore raw

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

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; [email protected]
Subject: Re: [PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread

Quoted 1 line

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; [email protected]
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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:48 PM
To: [email protected]
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

---
 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(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index 318961d..b59ac02 100644
@@ -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);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +16 -0
index b40ce6f..9f8e267 100644
@@ -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;
 
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +4 -2
index 68fe9c8..1ea1e8b 100644
@@ -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
[email protected]
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.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#9 lore raw

PATCH 3/4 drm/amdgpu: gfx ip ctrl gfx off via amdgpu_gfx_off_ctrl

In reply to a message not in the archive

use amdgpu_gfx_off_ctrl function so driver can arbitrate whether the gfx ip can be power off or power on.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++----
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -4
index 9f8e267..d861bfc 100644
@@ -1828,8 +1828,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 					  adev->ip_blocks[i].version->funcs->name, r);
 				return r;
 			}
-			if (adev->powerplay.pp_funcs->set_powergating_by_smu)
-				amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false);
+			amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, false);
 			r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
 			/* XXX handle errors */
 			if (r) {
@@ -2013,8 +2012,7 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
 	}
 
 	/* call smu to disable gfx off feature first when suspend */
-	if (adev->powerplay.pp_funcs->set_powergating_by_smu)
-		amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false);
+	amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, false);
 
 	for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
 		if (!adev->ip_blocks[i].status.valid)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -4
index ef00d14..c3d8030 100644
@@ -3783,13 +3783,11 @@ static int gfx_v9_0_set_powergating_state(void *handle,
 		gfx_v9_0_update_gfx_mg_power_gating(adev, enable);
 
 		/* set gfx off through smu */
-		if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu)
-			amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+		amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, true);
 		break;
 	case CHIP_VEGA12:
 		/* set gfx off through smu */
-		if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu)
-			amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+		amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, true);
 		break;
 	default:
 		break;
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1532864150-32370-3-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#11 lore raw

Re: [PATCH 3/4] drm/amdgpu: gfx ip ctrl gfx off via amdgpu_gfx_off_ctrl

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:49 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 3/4] drm/amdgpu: gfx ip ctrl gfx off via amdgpu_gfx_off_ctrl

use amdgpu_gfx_off_ctrl function so driver can arbitrate whether the gfx ip can be power off or power on.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 6 ++----
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c      | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -4
index 9f8e267..d861bfc 100644
@@ -1828,8 +1828,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
                                           adev->ip_blocks[i].version->funcs->name, r);
                                 return r;
                         }
-                       if (adev->powerplay.pp_funcs->set_powergating_by_smu)
-                               amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false);
+                       amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, false);
                         r = adev->ip_blocks[i].version->funcs->hw_fini((void *)adev);
                         /* XXX handle errors */
                         if (r) {
@@ -2013,8 +2012,7 @@ static int amdgpu_device_ip_suspend_phase2(struct amdgpu_device *adev)
         }
 
         /* call smu to disable gfx off feature first when suspend */
-       if (adev->powerplay.pp_funcs->set_powergating_by_smu)
-               amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false);
+       amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, false);
 
         for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
                 if (!adev->ip_blocks[i].status.valid)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +2 -4
index ef00d14..c3d8030 100644
@@ -3783,13 +3783,11 @@ static int gfx_v9_0_set_powergating_state(void *handle,
                 gfx_v9_0_update_gfx_mg_power_gating(adev, enable);
 
                 /* set gfx off through smu */
-               if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu)
-                       amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+               amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, true);
                 break;
         case CHIP_VEGA12:
                 /* set gfx off through smu */
-               if (enable && adev->powerplay.pp_funcs->set_powergating_by_smu)
-                       amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, true);
+               amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_GFX, true);
                 break;
         default:
                 break;

--
1.9.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#12 lore raw

PATCH 4/4 drm/amdgpu: Disable gfx off if VCN is busy

In reply to a message not in the archive

this patch is a workaround for the gpu hang at video end time if play video with gfx off enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +2 -0
index 798648a..d68039f 100644
@@ -214,6 +214,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 	fences += amdgpu_fence_count_emitted(&adev->vcn.ring_jpeg);
 
 	if (fences == 0) {
+		amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_VCN, true);
 		if (adev->pm.dpm_enabled)
 			amdgpu_dpm_enable_uvd(adev, false);
 		else
@@ -230,6 +231,7 @@ void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
 	bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work);
 
 	if (set_clocks) {
+		amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_VCN, false);
 		if (adev->pm.dpm_enabled)
 			amdgpu_dpm_enable_uvd(adev, true);
 		else
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1532864150-32370-4-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#14 lore raw

Re: [PATCH 4/4] drm/amdgpu: Disable gfx off if VCN is busy

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:50 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 4/4] drm/amdgpu: Disable gfx off if VCN is busy

this patch is a workaround for the gpu hang at video end time if play video with gfx off enabled.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c +2 -0
index 798648a..d68039f 100644
@@ -214,6 +214,7 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
         fences += amdgpu_fence_count_emitted(&adev->vcn.ring_jpeg);
 
         if (fences == 0) {
+               amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_VCN, true);
                 if (adev->pm.dpm_enabled)
                         amdgpu_dpm_enable_uvd(adev, false);
                 else
@@ -230,6 +231,7 @@ void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
         bool set_clocks = !cancel_delayed_work_sync(&adev->vcn.idle_work);
 
         if (set_clocks) {
+               amdgpu_gfx_off_ctrl(adev, AMD_IP_BLOCK_TYPE_VCN, false);
                 if (adev->pm.dpm_enabled)
                         amdgpu_dpm_enable_uvd(adev, true);
                 else

--
1.9.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#15 lore raw
In reply to a message not in the archive

+ 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;
+ } else if (!enable && adev->gfx.bin_off) {

What is "adev->gfx.bready_for_off" used for ? Do we need to consider "adev->gfx.bready_for_off == 0" case here?
+ if (!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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:47 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

This funciton as the entry of gfx off ctrl feature. we arbitrat gfx off feature enable/disable in this function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  7 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 52 ++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index 5b7bb58..318961d 100644
@@ -988,6 +988,11 @@ struct amdgpu_gfx {
         /* NGG */
         struct amdgpu_ngg               ngg;
 
+       /* gfx off */
+       bool                            bready_for_off;
+       bool                            bin_off;
+       struct mutex                    gfx_off_ctrl_mutex;
+       uint32_t                        disable_gfx_off_request;
         /* pipe reservation */
         struct mutex                    pipe_reserve_mutex;
         DECLARE_BITMAP                  (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
@@ -1815,6 +1820,8 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,
                                              const u32 array_size);
 
 bool amdgpu_device_is_px(struct drm_device *dev);
+void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev,
+                               enum amd_ip_block_type client, bool enable);
 /* atpx handler */
 #if defined(CONFIG_VGA_SWITCHEROO)
 void amdgpu_register_atpx_handler(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index 745f760..b40ce6f 100644
@@ -2367,6 +2367,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
         mutex_init(&adev->gfx.gpu_clock_mutex);
         mutex_init(&adev->srbm_mutex);
         mutex_init(&adev->gfx.pipe_reserve_mutex);
+       mutex_init(&adev->gfx.gfx_off_ctrl_mutex);
         mutex_init(&adev->grbm_idx_mutex);
         mutex_init(&adev->mn_lock);
         mutex_init(&adev->virt.vf_errors.lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +52 -0

55 lines not on this page · raw message

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
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.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): SN6PR12MB26564CB34A8FD6AFA46AACD4E42F0-kxOKjb6HO/FeL/[email protected]

author
#17 lore raw
Quoted 1 line

"adev->gfx.bready_for_off" used for ?

This flag should only be set by gfx ip after gfx cg/pg feature enabled.

Other clients can't enable gfx off feature before this flag is set.

Quoted 1 line

"adev->gfx.bready_for_off == 0"

For disable gfx off feature, we don't need to care this flag.

Best Regards

Rex

________________________________
From: Quan, Evan
Sent: Monday, July 30, 2018 11:12 AM
To: Zhu, Rex; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

+ 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;
+ } else if (!enable && adev->gfx.bin_off) {

What is "adev->gfx.bready_for_off" used for ? Do we need to consider "adev->gfx.bready_for_off == 0" case here?
+ if (!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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:47 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

This funciton as the entry of gfx off ctrl feature. we arbitrat gfx off feature enable/disable in this function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  7 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 52 ++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index 5b7bb58..318961d 100644
@@ -988,6 +988,11 @@ struct amdgpu_gfx {
         /* NGG */
         struct amdgpu_ngg               ngg;
 
+       /* gfx off */
+       bool                            bready_for_off;
+       bool                            bin_off;
+       struct mutex                    gfx_off_ctrl_mutex;
+       uint32_t                        disable_gfx_off_request;
         /* pipe reservation */
         struct mutex                    pipe_reserve_mutex;
         DECLARE_BITMAP                  (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
@@ -1815,6 +1820,8 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,
                                              const u32 array_size);
 
 bool amdgpu_device_is_px(struct drm_device *dev);
+void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev,
+                               enum amd_ip_block_type client, bool enable);
 /* atpx handler */
 #if defined(CONFIG_VGA_SWITCHEROO)
 void amdgpu_register_atpx_handler(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index 745f760..b40ce6f 100644
@@ -2367,6 +2367,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
         mutex_init(&adev->gfx.gpu_clock_mutex);
         mutex_init(&adev->srbm_mutex);
         mutex_init(&adev->gfx.pipe_reserve_mutex);
+       mutex_init(&adev->gfx.gfx_off_ctrl_mutex);
         mutex_init(&adev->grbm_idx_mutex);
         mutex_init(&adev->mn_lock);
         mutex_init(&adev->virt.vf_errors.lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +52 -0

55 lines not on this page · raw message

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
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.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CY4PR12MB1687D0B723AB027047CEF32FFB2F0-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#19 lore raw
Quoted 2 lines

This flag should only be set by gfx ip after gfx cg/pg feature enabled. Other clients can't enable gfx off feature before this flag is set.

Maybe other clients should also not disable gfx off feature if this flag is not set.

Regards,

Evan

________________________________
From: Zhu, Rex
Sent: Monday, July 30, 2018 11:46:00 AM
To: Quan, Evan; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

Quoted 1 line

"adev->gfx.bready_for_off" used for ?

This flag should only be set by gfx ip after gfx cg/pg feature enabled.

Other clients can't enable gfx off feature before this flag is set.

Quoted 1 line

"adev->gfx.bready_for_off == 0"

For disable gfx off feature, we don't need to care this flag.

Best Regards

Rex

________________________________
From: Quan, Evan
Sent: Monday, July 30, 2018 11:12 AM
To: Zhu, Rex; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

+ 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;
+ } else if (!enable && adev->gfx.bin_off) {

What is "adev->gfx.bready_for_off" used for ? Do we need to consider "adev->gfx.bready_for_off == 0" case here?
+ if (!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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:47 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

This funciton as the entry of gfx off ctrl feature. we arbitrat gfx off feature enable/disable in this function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  7 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 52 ++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index 5b7bb58..318961d 100644
@@ -988,6 +988,11 @@ struct amdgpu_gfx {
         /* NGG */
         struct amdgpu_ngg               ngg;
 
+       /* gfx off */
+       bool                            bready_for_off;
+       bool                            bin_off;
+       struct mutex                    gfx_off_ctrl_mutex;
+       uint32_t                        disable_gfx_off_request;
         /* pipe reservation */
         struct mutex                    pipe_reserve_mutex;
         DECLARE_BITMAP                  (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
@@ -1815,6 +1820,8 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,
                                              const u32 array_size);
 
 bool amdgpu_device_is_px(struct drm_device *dev);
+void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev,
+                               enum amd_ip_block_type client, bool enable);
 /* atpx handler */
 #if defined(CONFIG_VGA_SWITCHEROO)
 void amdgpu_register_atpx_handler(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index 745f760..b40ce6f 100644
@@ -2367,6 +2367,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
         mutex_init(&adev->gfx.gpu_clock_mutex);
         mutex_init(&adev->srbm_mutex);
         mutex_init(&adev->gfx.pipe_reserve_mutex);
+       mutex_init(&adev->gfx.gfx_off_ctrl_mutex);
         mutex_init(&adev->grbm_idx_mutex);
         mutex_init(&adev->mn_lock);
         mutex_init(&adev->virt.vf_errors.lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +52 -0

55 lines not on this page · raw message

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
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.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): SN6PR12MB26567850D8ABB9D9ED9694D0E42F0-kxOKjb6HO/FeL/[email protected]

author
#21 lore raw
Quoted 1 line

Maybe other clients should also not disable gfx off feature if this flag is not set.

For disable gfx off feature, we just need to check adev->gfx.bin_off, it mean

the gfx off feature is enabled.

Best Regards

Rex

________________________________
From: Quan, Evan
Sent: Monday, July 30, 2018 12:32 PM
To: Zhu, Rex; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

Quoted 2 lines

This flag should only be set by gfx ip after gfx cg/pg feature enabled. Other clients can't enable gfx off feature before this flag is set.

Maybe other clients should also not disable gfx off feature if this flag is not set.

Regards,

Evan

________________________________
From: Zhu, Rex
Sent: Monday, July 30, 2018 11:46:00 AM
To: Quan, Evan; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

Quoted 1 line

"adev->gfx.bready_for_off" used for ?

This flag should only be set by gfx ip after gfx cg/pg feature enabled.

Other clients can't enable gfx off feature before this flag is set.

Quoted 1 line

"adev->gfx.bready_for_off == 0"

For disable gfx off feature, we don't need to care this flag.

Best Regards

Rex

________________________________
From: Quan, Evan
Sent: Monday, July 30, 2018 11:12 AM
To: Zhu, Rex; [email protected]
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

+ 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;
+ } else if (!enable && adev->gfx.bin_off) {

What is "adev->gfx.bready_for_off" used for ? Do we need to consider "adev->gfx.bready_for_off == 0" case here?
+ if (!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-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Rex Zhu <[email protected]>
Sent: Sunday, July 29, 2018 7:35:47 PM
To: [email protected]
Cc: Zhu, Rex
Subject: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function

This funciton as the entry of gfx off ctrl feature. we arbitrat gfx off feature enable/disable in this function.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  7 ++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c    | 52 ++++++++++++++++++++++++++++++
 3 files changed, 60 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +7 -0
index 5b7bb58..318961d 100644
@@ -988,6 +988,11 @@ struct amdgpu_gfx {
         /* NGG */
         struct amdgpu_ngg               ngg;
 
+       /* gfx off */
+       bool                            bready_for_off;
+       bool                            bin_off;
+       struct mutex                    gfx_off_ctrl_mutex;
+       uint32_t                        disable_gfx_off_request;
         /* pipe reservation */
         struct mutex                    pipe_reserve_mutex;
         DECLARE_BITMAP                  (pipe_reserve_bitmap, AMDGPU_MAX_COMPUTE_QUEUES);
@@ -1815,6 +1820,8 @@ void amdgpu_device_program_register_sequence(struct amdgpu_device *adev,
                                              const u32 array_size);
 
 bool amdgpu_device_is_px(struct drm_device *dev);
+void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev,
+                               enum amd_ip_block_type client, bool enable);
 /* atpx handler */
 #if defined(CONFIG_VGA_SWITCHEROO)
 void amdgpu_register_atpx_handler(void);
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
index 745f760..b40ce6f 100644
@@ -2367,6 +2367,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
         mutex_init(&adev->gfx.gpu_clock_mutex);
         mutex_init(&adev->srbm_mutex);
         mutex_init(&adev->gfx.pipe_reserve_mutex);
+       mutex_init(&adev->gfx.gfx_off_ctrl_mutex);
         mutex_init(&adev->grbm_idx_mutex);
         mutex_init(&adev->mn_lock);
         mutex_init(&adev->virt.vf_errors.lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c +52 -0

55 lines not on this page · raw message

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
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.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx