Skip to contentSkip to conversation

drm/amd/powerplay: initialize rv vq table

PATCH In review Hawking Zhang 2 participants 7 messages May 24, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/6 drm/amd/powerplay: initialize rv vq table

Change-Id I64696e3b5418bcdb24a2c359677506d87769afaf
---
 drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 47 +++++++++++++++++---------
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h      | 18 +++++++++-
 2 files changed, 48 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +31 -16
index 631ef82..26906c3 100644
@@ -45,10 +45,28 @@
 
 static const unsigned long PhwRaven_Magic = (unsigned long) PHM_Cz_Magic;
 
-struct phm_vq_budgeting_record rv_vqtable[] = {
-	/* _TBD
-	 * CUs, SSP low, SSP High, Min Sclk Low, Min Sclk, High, AWD/non-AWD, DCLK, ECLK, Sustainable Sclk, Sustainable CUs */
-	{ 8, 0, 45, 0, 0, VQ_DisplayConfig_NoneAWD, 80000, 120000, 4, 0 },
+struct phm_vq_budgeting_settings RV_VQTable[] =
+{
+	/* CUs, SSP low, SSP High, Display Configuration, AWD/non-AWD,
+	 * Sustainable GFXCLK, Sustainable FCLK, Sustainable CUs,
+         * unused, unused, unused */
+	{ 11, 30, 60, VQ_DisplayConfig_NoneAWD,  80000, 160000, 11, 0, 0, 0 },
+	{ 11, 30, 60, VQ_DisplayConfig_AWD,      80000, 160000, 11, 0, 0, 0 },
+
+	{  8, 30, 60, VQ_DisplayConfig_NoneAWD, 100000, 160000,  8, 0, 0, 0 },
+	{  8, 30, 60, VQ_DisplayConfig_AWD,     100000, 160000,  8, 0, 0, 0 },
+
+	{ 10, 12, 30, VQ_DisplayConfig_NoneAWD,  40000, 120000, 10, 0, 0, 0 },
+	{ 10, 12, 30, VQ_DisplayConfig_AWD,      40000, 120000, 10, 0, 0, 0 },
+
+	{  8, 12, 30, VQ_DisplayConfig_NoneAWD,  45000, 120000,  8, 0, 0, 0 },
+	{  8, 12, 30, VQ_DisplayConfig_AWD,      45000, 120000,  8, 0, 0, 0 },
+
+	{  6, 12, 30, VQ_DisplayConfig_NoneAWD,  45000, 120000,  6, 0, 0, 0 },
+	{  6, 12, 30, VQ_DisplayConfig_AWD,      45000, 120000,  6, 0, 0, 0 },
+
+	{  3, 12, 30, VQ_DisplayConfig_NoneAWD,  45000, 120000,  3, 0, 0, 0 },
+	{  3, 12, 30, VQ_DisplayConfig_AWD,      45000, 120000,  3, 0, 0, 0 },
 };
 
 static struct rv_power_state *cast_rv_ps(struct pp_hw_power_state *hw_ps)
@@ -72,13 +90,13 @@ static int rv_init_vq_budget_table(struct pp_hwmgr *hwmgr)
 {
 	uint32_t table_size, i;
 	struct phm_vq_budgeting_table *ptable;
-	uint32_t num_entries = ARRAY_SIZE(rv_vqtable);
+	uint32_t num_entries = sizeof(RV_VQTable)/sizeof(*RV_VQTable);
 
 	if (hwmgr->dyn_state.vq_budgeting_table != NULL)
 		return 0;
 
 	table_size = sizeof(struct phm_vq_budgeting_table) +
-			sizeof(struct phm_vq_budgeting_record) * (num_entries - 1);
+		sizeof(struct phm_vq_budgeting_record) * (num_entries - 1);
 
 	ptable = kzalloc(table_size, GFP_KERNEL);
 	if (NULL == ptable)
@@ -87,16 +105,13 @@ static int rv_init_vq_budget_table(struct pp_hwmgr *hwmgr)
 	ptable->numEntries = (uint8_t) num_entries;
 
 	for (i = 0; i < ptable->numEntries; i++) {
-		ptable->entries[i].ulCUs = rv_vqtable[i].ulCUs;
-		ptable->entries[i].ulSustainableSOCPowerLimitLow = rv_vqtable[i].ulSustainableSOCPowerLimitLow;
-		ptable->entries[i].ulSustainableSOCPowerLimitHigh = rv_vqtable[i].ulSustainableSOCPowerLimitHigh;
-		ptable->entries[i].ulMinSclkLow = rv_vqtable[i].ulMinSclkLow;
-		ptable->entries[i].ulMinSclkHigh = rv_vqtable[i].ulMinSclkHigh;
-		ptable->entries[i].ucDispConfig = rv_vqtable[i].ucDispConfig;
-		ptable->entries[i].ulDClk = rv_vqtable[i].ulDClk;
-		ptable->entries[i].ulEClk = rv_vqtable[i].ulEClk;
-		ptable->entries[i].ulSustainableSclk = rv_vqtable[i].ulSustainableSclk;
-		ptable->entries[i].ulSustainableCUs = rv_vqtable[i].ulSustainableCUs;
+		ptable->settings[i].ulSetting1 = RV_VQTable[i].ulSetting1;
+		ptable->settings[i].ulSetting2 = RV_VQTable[i].ulSetting2;
+		ptable->settings[i].ulSetting3 = RV_VQTable[i].ulSetting3;
+		ptable->settings[i].ulSetting4 = RV_VQTable[i].ulSetting4;
+		ptable->settings[i].ulSetting5 = RV_VQTable[i].ulSetting5;
+		ptable->settings[i].ulSetting6 = RV_VQTable[i].ulSetting6;
+		ptable->settings[i].ulSetting7 = RV_VQTable[i].ulSetting7;
 	}
 
 	hwmgr->dyn_state.vq_budgeting_table = ptable;
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +17 -1
index 35cb26f..7779600 100644
@@ -519,9 +519,25 @@ struct phm_vq_budgeting_record {
 	uint32_t ulSustainableCUs;
 };
 
+struct phm_vq_budgeting_settings {
+	uint32_t ulSetting1;	/* RV: CUs */
+	uint32_t ulSetting2;	/* RV: SustainableSOCPowerLimitLow in W */
+	uint32_t ulSetting3;	/* RV: SustainableSOCPowerLimitHigh in W */
+	uint8_t ulSetting4;	/* RV: DispConfig */
+	uint32_t ulSetting5;	/* RV: Sustainable GFXCLK in 10KHz */
+	uint32_t ulSetting6;	/* RV: Sustainable FCLK in 10KHz */
+	uint32_t ulSetting7;	/* RV: Sustainable CUs */
+	uint32_t ulSetting8;	/* unused */
+	uint32_t ulSetting9;	/* unused */
+	uint32_t ulSetting10;	/* unused */
+};
+
 struct phm_vq_budgeting_table {
 	uint8_t numEntries;
-	struct phm_vq_budgeting_record entries[1];
+	union {
+		struct phm_vq_budgeting_record   entries[1];
+		struct phm_vq_budgeting_settings settings[1];
+	};
 };
 
 struct phm_clock_and_voltage_limits {
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1495624427-11450-1-git-send-email-Hawking.Zhang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/6 drm/amd/powerplay: using MinFClock/MaxFclock to report Min/Max memory clock limits

Change-Id I713031dced6e1d5a449cb07a53b644d1014c120c
---
 drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +8 -0
index 26906c3..7fa3980 100644
@@ -743,6 +743,7 @@ static int rv_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_p
 	struct rv_hwmgr *data;
 	uint32_t level_index;
 	uint32_t i;
+	uint32_t vol_dep_record_index = 0;
 
 	if (level == NULL || hwmgr == NULL || state == NULL)
 		return -EINVAL;
@@ -762,6 +763,13 @@ static int rv_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_p
 		}
 	}
 
+	if (level_index == 0) {
+		vol_dep_record_index = data->clock_vol_info.vdd_dep_on_fclk->count - 1;
+		level->memory_clock =
+			data->clock_vol_info.vdd_dep_on_fclk->entries[vol_dep_record_index].clk;
+	} else
+		level->memory_clock = data->clock_vol_info.vdd_dep_on_fclk->entries[0].clk;
+
 	level->nonLocalMemoryFreq = 0;
 	level->nonLocalMemoryWidth = 0;
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

PATCH 3/6 drm/amd/powerplay: update magic number for rv hw backend

In reply to a message not in the archive
Change-Id If51c5a5e4c534769b95105a1dd5ed76b4ec4bbf3
---
 drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 2 +-
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h      | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +1 -1
index 7fa3980..8a1f0d9 100644
@@ -43,7 +43,7 @@
 #define SMC_RAM_END                     0x40000
 
 
-static const unsigned long PhwRaven_Magic = (unsigned long) PHM_Cz_Magic;
+static const unsigned long PhwRaven_Magic = (unsigned long) PHM_Rv_Magic;
 
 struct phm_vq_budgeting_settings RV_VQTable[] =
 {
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +2 -1
index 7779600..01755a5 100644
@@ -99,7 +99,8 @@ enum PHM_BackEnd_Magic {
 	PHM_CIslands_Magic    = 0x38AC78B0,
 	PHM_Kv_Magic          = 0xDCBBABC0,
 	PHM_VIslands_Magic    = 0x20130307,
-	PHM_Cz_Magic          = 0x67DCBA25
+	PHM_Cz_Magic          = 0x67DCBA25,
+	PHM_Rv_Magic          = 0x20161121
 };
 
 
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw

PATCH 4/6 drm/amd/powerplay: add get_temperature interface for raven

In reply to a message not in the archive
Change-Id I542b3a5f4e2955dda0b7c9f8c32512b2888ab1c3
---
 drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 27 ++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +25 -2
index 8a1f0d9..01413ca1 100644
@@ -35,6 +35,7 @@
 #include "rv_hwmgr.h"
 #include "power_state.h"
 #include "rv_smumgr.h"
+#include "pp_soc15.h"
 
 #define RAVEN_MAX_DEEPSLEEP_DIVIDER_ID     5
 #define RAVEN_MINIMUM_ENGINE_CLOCK         800   //8Mhz, the low boundary of engine clock allowed on this chip
@@ -42,7 +43,6 @@
 #define RAVEN_DISPCLK_BYPASS_THRESHOLD     10000 //100mhz
 #define SMC_RAM_END                     0x40000
 
-
 static const unsigned long PhwRaven_Magic = (unsigned long) PHM_Rv_Magic;
 
 struct phm_vq_budgeting_settings RV_VQTable[] =
@@ -574,6 +574,7 @@ static int rv_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
 	hwmgr->platform_descriptor.minimumClocksReductionPercentage = 50;
 
 	rv_init_vq_budget_table(hwmgr);
+
 	return result;
 }
 
@@ -959,10 +960,32 @@ static int rv_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_c
 	return -EINVAL;
 }
 
+static int rv_thermal_get_temperature(struct pp_hwmgr *hwmgr)
+{
+	uint32_t reg_offset = soc15_get_register_offset(THM_HWID, 0,
+			mmTHM_TCON_CUR_TMP_BASE_IDX, mmTHM_TCON_CUR_TMP);
+	uint32_t reg_value = cgs_read_register(hwmgr->device, reg_offset);
+	int cur_temp =
+		(reg_value & THM_TCON_CUR_TMP__CUR_TEMP_MASK) >> THM_TCON_CUR_TMP__CUR_TEMP__SHIFT;
+
+	if (cur_temp & THM_TCON_CUR_TMP__CUR_TEMP_RANGE_SEL_MASK)
+		cur_temp = ((cur_temp / 8) - 49) * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+	else
+		cur_temp = (cur_temp / 8) * PP_TEMPERATURE_UNITS_PER_CENTIGRADES;
+
+	return cur_temp;
+}
+
 static int rv_read_sensor(struct pp_hwmgr *hwmgr, int idx,
 			  void *value, int *size)
 {
-	return -EINVAL;
+	switch (idx) {
+	case AMDGPU_PP_SENSOR_GPU_TEMP:
+		*((uint32_t *)value) = rv_thermal_get_temperature(hwmgr);
+		return 0;
+	default:
+		return -EINVAL;
+	}
 }
 
 static const struct pp_hwmgr_func rv_hwmgr_funcs = {
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#5 lore raw

PATCH 5/6 drm/amd/powerplay: bypass pptable process on raven

In reply to a message not in the archive
Change-Id I550c70144213f9a7490be4df04f7efd286c4d05b
---
 drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c +6 -0
index 7138cf9..2716721 100644
@@ -1563,6 +1563,9 @@ static int pp_tables_initialize(struct pp_hwmgr *hwmgr)
 	int result;
 	const ATOM_PPLIB_POWERPLAYTABLE *powerplay_table;
 
+	if (hwmgr->chip_id == CHIP_RAVEN)
+		return 0;
+
 	hwmgr->need_pp_table_upload = true;
 
 	powerplay_table = get_powerplay_table(hwmgr);
@@ -1609,6 +1612,9 @@ static int pp_tables_initialize(struct pp_hwmgr *hwmgr)
 
 static int pp_tables_uninitialize(struct pp_hwmgr *hwmgr)
 {
+	if (hwmgr->chip_id == CHIP_RAVEN)
+		return 0;
+
 	if (NULL != hwmgr->dyn_state.vddc_dependency_on_sclk) {
 		kfree(hwmgr->dyn_state.vddc_dependency_on_sclk);
 		hwmgr->dyn_state.vddc_dependency_on_sclk = NULL;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#6 lore raw

PATCH 6/6 drm/amd/powerplay: set powerplay support cap on raven

In reply to a message not in the archive
Change-Id I9aa5e78c1cf19b9069d37215bfd2517980bdf2a6
---
 drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +3 -0
index 01413ca1..5b130ef 100644
@@ -515,6 +515,9 @@ static int rv_hwmgr_backend_init(struct pp_hwmgr *hwmgr)
 		return result;
 	}
 
+	phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+                PHM_PlatformCaps_PowerPlaySupport);
+
 	rv_populate_clock_table(hwmgr);
 
 	result = rv_get_system_info_data(hwmgr);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1495624427-11450-6-git-send-email-Hawking.Zhang-5C7GfCeVMHo@public.gmane.org

Reviewed-by Alex Deucher
#8 lore raw

RE: [PATCH 6/6] drm/amd/powerplay: set powerplay support cap on raven

Quoted 11 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Hawking Zhang
Sent: Wednesday, May 24, 2017 7:14 AM
To: [email protected]
Cc: Zhang, Hawking
Subject: [PATCH 6/6] drm/amd/powerplay: set powerplay support cap on raven

Change-Id I9aa5e78c1cf19b9069d37215bfd2517980bdf2a6

Series is:

Quoted 23 lines
---
 drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/powerplay/hwmgr/rv_hwmgr.c +3 -0
index 01413ca1..5b130ef 100644
@@ -515,6 +515,9 @@ static int rv_hwmgr_backend_init(struct pp_hwmgr
 *hwmgr)
 		return result;
 	}
 
+	phm_cap_set(hwmgr->platform_descriptor.platformCaps,
+                PHM_PlatformCaps_PowerPlaySupport);
+
 	rv_populate_clock_table(hwmgr);
 

result = rv_get_system_info_data(hwmgr);
--
2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx