Blob Blame History Raw
From: Evan Quan <evan.quan@amd.com>
Date: Thu, 28 Dec 2017 14:14:08 +0800
Subject: drm/amd/powerplay: new cgs interface setting dpm thermal range
Git-commit: 1357f0c5ac357f0dfed8f900be7700d4d6bc152a
Patch-mainline: v4.17-rc1
References: FATE#326289 FATE#326079 FATE#326049 FATE#322398 FATE#326166

This will be used by powerplay to update the dpm temp range structure
used to interface with hwmon.

Signed-off-by: Evan Quan <evan.quan@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c  |   13 +++++++++++++
 drivers/gpu/drm/amd/include/cgs_common.h |    7 +++++++
 2 files changed, 20 insertions(+)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c
@@ -1187,6 +1187,18 @@ static int amdgpu_cgs_call_acpi_method(s
 	return amdgpu_cgs_acpi_eval_object(cgs_device, &info);
 }
 
+static int amdgpu_cgs_set_temperature_range(struct cgs_device *cgs_device,
+					int min_temperature,
+					int max_temperature)
+{
+	CGS_FUNC_ADEV;
+
+	adev->pm.dpm.thermal.min_temp = min_temperature;
+	adev->pm.dpm.thermal.max_temp = max_temperature;
+
+	return 0;
+}
+
 static const struct cgs_ops amdgpu_cgs_ops = {
 	.alloc_gpu_mem = amdgpu_cgs_alloc_gpu_mem,
 	.free_gpu_mem = amdgpu_cgs_free_gpu_mem,
@@ -1214,6 +1226,7 @@ static const struct cgs_ops amdgpu_cgs_o
 	.enter_safe_mode = amdgpu_cgs_enter_safe_mode,
 	.lock_grbm_idx = amdgpu_cgs_lock_grbm_idx,
 	.register_pp_handle = amdgpu_cgs_register_pp_handle,
+	.set_temperature_range = amdgpu_cgs_set_temperature_range,
 };
 
 static const struct cgs_os_ops amdgpu_cgs_os_ops = {
--- a/drivers/gpu/drm/amd/include/cgs_common.h
+++ b/drivers/gpu/drm/amd/include/cgs_common.h
@@ -427,6 +427,9 @@ struct amd_pp_init;
 typedef void* (*cgs_register_pp_handle)(struct cgs_device *cgs_device,
 			int (*call_back_func)(struct amd_pp_init *, void **));
 
+typedef int (*cgs_set_temperature_range)(struct cgs_device *cgs_device,
+					int min_temperature,
+					int max_temperature);
 struct cgs_ops {
 	/* memory management calls (similar to KFD interface) */
 	cgs_alloc_gpu_mem_t alloc_gpu_mem;
@@ -464,6 +467,7 @@ struct cgs_ops {
 	cgs_enter_safe_mode enter_safe_mode;
 	cgs_lock_grbm_idx lock_grbm_idx;
 	cgs_register_pp_handle register_pp_handle;
+	cgs_set_temperature_range set_temperature_range;
 };
 
 struct cgs_os_ops; /* To be define in OS-specific CGS header */
@@ -545,4 +549,7 @@ struct cgs_device
 #define cgs_register_pp_handle(cgs_device, call_back_func) \
 		CGS_CALL(register_pp_handle, cgs_device, call_back_func)
 
+#define cgs_set_temperature_range(dev, min_temp, max_temp)	\
+	CGS_CALL(set_temperature_range, dev, min_temp, max_temp)
+
 #endif /* _CGS_COMMON_H */