All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Zhu, Rex" <Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
To: "Quan, Evan" <Evan.Quan-5C7GfCeVMHo@public.gmane.org>,
	"amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org"
	<amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org>
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function
Date: Mon, 30 Jul 2018 03:46:00 +0000	[thread overview]
Message-ID: <CY4PR12MB1687D0B723AB027047CEF32FFB2F0@CY4PR12MB1687.namprd12.prod.outlook.com> (raw)
In-Reply-To: <SN6PR12MB26564CB34A8FD6AFA46AACD4E42F0-kxOKjb6HO/FeL/N0e1LXkAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 7126 bytes --]

>"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.


>"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; amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
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 <rex.zhu-5C7GfCeVMHo@public.gmane.org>
Sent: Sunday, July 29, 2018 7:35:47 PM
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
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.

Signed-off-by: Rex Zhu <Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
---
 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(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index 5b7bb58..318961d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 745f760..b40ce6f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -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);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 239bf2a..68fe9c8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -340,3 +340,55 @@ void amdgpu_gfx_compute_mqd_sw_fini(struct amdgpu_device *adev)
                               &ring->mqd_gpu_addr,
                               &ring->mqd_ptr);
 }
+
+/* amdgpu_gfx_off_ctrl - Handle gfx off feature enable/disable
+ *
+ * @adev: amdgpu_device pointer
+ * @enum amd_ip_block_type gfx ip decide when to set ready for gfx off feature
+ * other clients send disable gfx off feature request
+ * @bool enable
+ *
+ * if gfx ip is ready for power off gfx ip, and no other clients's request for
+ * disable gfx off feature, driver will call smu to enable gfx off immediately.
+ * otherwise, driver will wait until the clients cancel the requests.
+ */
+
+void amdgpu_gfx_off_ctrl(struct amdgpu_device *adev, enum amd_ip_block_type client, bool enable)
+{
+       if (!(adev->powerplay.pp_feature & PP_GFXOFF_MASK))
+               return; /* gfx off feature is not supported or disabled by user via module parameter */
+
+       if (!adev->powerplay.pp_funcs->set_powergating_by_smu)
+               return; /* currently gfx off feature need smu support*/
+
+       mutex_lock(&adev->gfx.gfx_off_ctrl_mutex);
+       if (client == AMD_IP_BLOCK_TYPE_GFX) {
+               adev->gfx.bready_for_off = enable ? true : false; /*true, gfx ip is ready to enable gfx off feature */
+       } else {
+               if (!enable) /* false : reveive one disable gfx off requests from other clients*/
+                       adev->gfx.disable_gfx_off_request++;
+               else if (adev->gfx.disable_gfx_off_request > 0)
+                       adev->gfx.disable_gfx_off_request--;
+       }
+
+/* *
+ * we can enable gfx off feature when meet the following conditions:
+ * 1. gfx off feature is supported by hw
+ * 2. gfx ip is ready to enable gfx off feature
+ * 3. no other clients have requests to disable gfx off
+ * 4. gfx off feature is not enabled
+ * For disable gfx off feature
+ * 1. gfx off feature is supported by hw
+ * 2. receive disable gfx off requests
+ * 3. gfx off feature is enabled
+ */
+       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) {
+               if (!amdgpu_dpm_set_powergating_by_smu(adev, AMD_IP_BLOCK_TYPE_GFX, false))
+                       adev->gfx.bin_off = false;
+       }
+       mutex_unlock(&adev->gfx.gfx_off_ctrl_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<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.




[-- Attachment #1.2: Type: text/html, Size: 23761 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  parent reply	other threads:[~2018-07-30  3:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-29 11:35 [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function Rex Zhu
     [not found] ` <1532864150-32370-1-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org>
2018-07-29 11:35   ` [PATCH 2/4] drm/amdgpu: Put enable gfx off feature to a delay thread Rex Zhu
     [not found]     ` <1532864150-32370-2-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org>
2018-07-30  2:26       ` Quan, Evan
     [not found]         ` <SN6PR12MB2656A6C34BE374E0DF5FD125E42F0-kxOKjb6HO/FeL/N0e1LXkAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-30  3:52           ` Zhu, Rex
     [not found]             ` <CY4PR12MB168726A840EE78ECCA4D9005FB2F0-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-30  4:15               ` Quan, Evan
2018-07-29 11:35   ` [PATCH 3/4] drm/amdgpu: gfx ip ctrl gfx off via amdgpu_gfx_off_ctrl Rex Zhu
     [not found]     ` <1532864150-32370-3-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org>
2018-07-30  2:27       ` Quan, Evan
2018-07-29 11:35   ` [PATCH 4/4] drm/amdgpu: Disable gfx off if VCN is busy Rex Zhu
     [not found]     ` <1532864150-32370-4-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org>
2018-07-30  2:27       ` Quan, Evan
2018-07-30  3:12   ` [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function Quan, Evan
     [not found]     ` <SN6PR12MB26564CB34A8FD6AFA46AACD4E42F0-kxOKjb6HO/FeL/N0e1LXkAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-30  3:46       ` Zhu, Rex [this message]
     [not found]         ` <CY4PR12MB1687D0B723AB027047CEF32FFB2F0-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-30  4:32           ` Quan, Evan
     [not found]             ` <SN6PR12MB26567850D8ABB9D9ED9694D0E42F0-kxOKjb6HO/FeL/N0e1LXkAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2018-07-30  5:39               ` Zhu, Rex

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR12MB1687D0B723AB027047CEF32FFB2F0@CY4PR12MB1687.namprd12.prod.outlook.com \
    --to=rex.zhu-5c7gfcevmho@public.gmane.org \
    --cc=Evan.Quan-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.