[PATCH 04/10] drm/amd/pp: Add a work queue for autowattman feature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



driver need to monitor the gfx activity and notify
smu to change the dpm policy

Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c | 17 +++++++++++++++++
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h   |  3 +++
 2 files changed, 20 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index 51c4ecb..cad71ec 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
@@ -252,6 +252,20 @@ int hwmgr_early_init(struct pp_instance *handle)
 	return 0;
 }
 
+static void wattman_sample_handler(struct work_struct *work)
+{
+	struct pp_hwmgr *hwmgr =
+		container_of(work, struct pp_hwmgr, wattman_update_work.work);
+
+	if (hwmgr->autowattman_enabled) {
+		if (hwmgr->hwmgr_func->update_auto_wattman != NULL)
+			hwmgr->hwmgr_func->update_auto_wattman(hwmgr);
+
+		if (hwmgr->hwmgr_func->start_auto_wattman != NULL)
+			hwmgr->hwmgr_func->start_auto_wattman(hwmgr, true);
+	}
+}
+
 int hwmgr_hw_init(struct pp_instance *handle)
 {
 	struct pp_hwmgr *hwmgr;
@@ -262,6 +276,8 @@ int hwmgr_hw_init(struct pp_instance *handle)
 
 	hwmgr = handle->hwmgr;
 
+	INIT_DELAYED_WORK(&hwmgr->wattman_update_work, wattman_sample_handler);
+
 	if (hwmgr->pptable_func == NULL ||
 	    hwmgr->pptable_func->pptable_init == NULL ||
 	    hwmgr->hwmgr_func->backend_init == NULL)
@@ -338,6 +354,7 @@ int hwmgr_hw_suspend(struct pp_instance *handle)
 		return -EINVAL;
 
 	hwmgr = handle->hwmgr;
+
 	phm_disable_smc_firmware_ctf(hwmgr);
 	ret = psm_set_boot_states(hwmgr);
 	if (ret)
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index d9aef88..0fb14a1 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -40,6 +40,7 @@
 struct pp_atomctrl_voltage_table;
 
 #define VOLTAGE_SCALE 4
+#define WATTMAM_SAMPLE_PERIOD msecs_to_jiffies(100)
 
 uint8_t convert_to_vid(uint16_t vddc);
 uint16_t convert_to_vddc(uint8_t vid);
@@ -758,6 +759,8 @@ struct pp_hwmgr {
 	bool od_enabled;
 	uint32_t power_limit;
 	uint32_t default_power_limit;
+	bool autowattman_enabled;
+	struct delayed_work wattman_update_work;
 };
 
 struct cgs_irq_src_funcs {
-- 
1.9.1



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux