[PATCH 3/3] drm/amd/powerplay: maximum code sharing on sensor reading

Evan Quan evan.quan at amd.com
Tue Jun 9 10:20:17 UTC 2020


Move the common code to amdgpu_smu.c instead of having one
copy in both smu_v11_0.c and smu_v12_0.c.

Change-Id: Idc59c6f686139d034348a613f1a7b9213198312d
Signed-off-by: Evan Quan <evan.quan at amd.com>
---
 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++++
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c  | 4 ----
 drivers/gpu/drm/amd/powerplay/smu_v12_0.c  | 4 ----
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index c032680c52b0..8415b383e7ae 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -2322,6 +2322,10 @@ int smu_read_sensor(struct smu_context *smu,
 		*(uint32_t *)data = smu->smu_power.power_gate.vcn_gated ? 0 : 1;
 		*size = 4;
 		break;
+	case AMDGPU_PP_SENSOR_MIN_FAN_RPM:
+		*(uint32_t *)data = 0;
+		*size = 4;
+		break;
 	default:
 		if (smu->ppt_funcs->read_sensor)
 			ret = smu->ppt_funcs->read_sensor(smu, sensor, data, size);
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 1a17d853afbd..993976452467 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1193,10 +1193,6 @@ int smu_v11_0_read_sensor(struct smu_context *smu,
 		ret = smu_v11_0_get_gfx_vdd(smu, (uint32_t *)data);
 		*size = 4;
 		break;
-	case AMDGPU_PP_SENSOR_MIN_FAN_RPM:
-		*(uint32_t *)data = 0;
-		*size = 4;
-		break;
 	default:
 		ret = -EOPNOTSUPP;
 		break;
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v12_0.c b/drivers/gpu/drm/amd/powerplay/smu_v12_0.c
index ae1035575808..b03127273d56 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v12_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v12_0.c
@@ -221,10 +221,6 @@ int smu_v12_0_read_sensor(struct smu_context *smu,
 		ret = smu_get_current_clk_freq(smu, SMU_GFXCLK, (uint32_t *)data);
 		*size = 4;
 		break;
-	case AMDGPU_PP_SENSOR_MIN_FAN_RPM:
-		*(uint32_t *)data = 0;
-		*size = 4;
-		break;
 	default:
 		ret = -EOPNOTSUPP;
 		break;
-- 
2.27.0



More information about the amd-gfx mailing list