All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm/amdgpu: Add amdgpu_gfx_off_ctrl function
@ 2018-07-29 11:35 Rex Zhu
       [not found] ` <1532864150-32370-1-git-send-email-rex.zhu-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Rex Zhu @ 2018-07-29 11:35 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

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@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@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2018-07-30  5:39 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
     [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

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.