[PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function
Quan, Evan
Evan.Quan at amd.com
Mon Jul 30 04:32:36 UTC 2018
>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; amd-gfx at lists.freedesktop.org
Subject: Re: [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function
>"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 at lists.freedesktop.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 at lists.freedesktop.org> on behalf of Rex Zhu <rex.zhu at amd.com>
Sent: Sunday, July 29, 2018 7:35:47 PM
To: amd-gfx at lists.freedesktop.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 at amd.com>
---
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 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/687e6c9a/attachment-0001.html>
More information about the amd-gfx
mailing list