Commit da11407f authored by Evan Quan's avatar Evan Quan Committed by Alex Deucher

drm/amd/pm: drop unneeded smu->metrics_lock

As all those related APIs are already well protected by
adev->pm.mutex and smu->message_lock.
Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
Reviewed-by: default avatarGuchun Chen <guchun.chen@amd.com>
Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 974d5ef0
......@@ -956,7 +956,6 @@ static int smu_sw_init(void *handle)
bitmap_zero(smu->smu_feature.allowed, SMU_FEATURE_MAX);
mutex_init(&smu->sensor_lock);
mutex_init(&smu->metrics_lock);
mutex_init(&smu->message_lock);
INIT_WORK(&smu->throttling_logging_work, smu_throttling_logging_work_fn);
......
......@@ -487,7 +487,6 @@ struct smu_context
const struct cmn2asic_mapping *pwr_src_map;
const struct cmn2asic_mapping *workload_map;
struct mutex sensor_lock;
struct mutex metrics_lock;
struct mutex message_lock;
uint64_t pool_size;
......
......@@ -602,15 +602,11 @@ static int arcturus_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -693,8 +689,6 @@ static int arcturus_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......
......@@ -150,13 +150,9 @@ cyan_skillfish_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu, NULL, false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu, NULL, false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -200,8 +196,6 @@ cyan_skillfish_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......
......@@ -546,15 +546,11 @@ static int navi10_get_legacy_smu_metrics_data(struct smu_context *smu,
(SmuMetrics_legacy_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -624,8 +620,6 @@ static int navi10_get_legacy_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -638,15 +632,11 @@ static int navi10_get_smu_metrics_data(struct smu_context *smu,
(SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -719,8 +709,6 @@ static int navi10_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -733,15 +721,11 @@ static int navi12_get_legacy_smu_metrics_data(struct smu_context *smu,
(SmuMetrics_NV12_legacy_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -811,8 +795,6 @@ static int navi12_get_legacy_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -825,15 +807,11 @@ static int navi12_get_smu_metrics_data(struct smu_context *smu,
(SmuMetrics_NV12_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -906,8 +884,6 @@ static int navi12_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -2708,20 +2684,14 @@ static ssize_t navi10_get_legacy_gpu_metrics(struct smu_context *smu,
SmuMetrics_legacy_t metrics;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
true);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
true);
if (ret)
return ret;
}
memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_legacy_t));
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
......@@ -2901,20 +2871,14 @@ static ssize_t navi10_get_gpu_metrics(struct smu_context *smu,
SmuMetrics_t metrics;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
true);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
true);
if (ret)
return ret;
}
memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_t));
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
......@@ -2979,20 +2943,14 @@ static ssize_t navi12_get_legacy_gpu_metrics(struct smu_context *smu,
SmuMetrics_NV12_legacy_t metrics;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
true);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
true);
if (ret)
return ret;
}
memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_NV12_legacy_t));
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
......@@ -3060,20 +3018,14 @@ static ssize_t navi12_get_gpu_metrics(struct smu_context *smu,
SmuMetrics_NV12_t metrics;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
true);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
true);
if (ret)
return ret;
}
memcpy(&metrics, smu_table->metrics_table, sizeof(SmuMetrics_NV12_t));
mutex_unlock(&smu->metrics_lock);
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
gpu_metrics->temperature_edge = metrics.TemperatureEdge;
......
......@@ -539,15 +539,11 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,
uint16_t average_gfx_activity;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -647,8 +643,6 @@ static int sienna_cichlid_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -3580,14 +3574,11 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
uint16_t average_gfx_activity;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
&metrics_external,
true);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
&metrics_external,
true);
if (ret)
return ret;
}
smu_cmn_init_soft_gpu_metrics(gpu_metrics, 1, 3);
......@@ -3677,8 +3668,6 @@ static ssize_t sienna_cichlid_get_gpu_metrics(struct smu_context *smu,
smu_v11_0_get_current_pcie_link_speed(smu);
}
mutex_unlock(&smu->metrics_lock);
gpu_metrics->system_clock_counter = ktime_get_boottime_ns();
*table = (void *)gpu_metrics;
......
......@@ -273,15 +273,11 @@ static int vangogh_get_legacy_smu_metrics_data(struct smu_context *smu,
SmuMetrics_legacy_t *metrics = (SmuMetrics_legacy_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -335,8 +331,6 @@ static int vangogh_get_legacy_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -348,15 +342,11 @@ static int vangogh_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -410,8 +400,6 @@ static int vangogh_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......
......@@ -1128,15 +1128,11 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_AVERAGE_GFXCLK:
......@@ -1201,8 +1197,6 @@ static int renoir_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......
......@@ -571,15 +571,11 @@ static int aldebaran_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
NULL,
false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu,
NULL,
false);
if (ret)
return ret;
}
switch (member) {
case METRICS_CURR_GFXCLK:
......@@ -653,8 +649,6 @@ static int aldebaran_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......@@ -1594,17 +1588,14 @@ static void aldebaran_get_unique_id(struct smu_context *smu)
uint32_t upper32 = 0, lower32 = 0;
int ret;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu, NULL, false);
ret = smu_cmn_get_metrics_table(smu, NULL, false);
if (ret)
goto out_unlock;
goto out;
upper32 = metrics->PublicSerialNumUpper32;
lower32 = metrics->PublicSerialNumLower32;
out_unlock:
mutex_unlock(&smu->metrics_lock);
out:
adev->unique_id = ((uint64_t)upper32 << 32) | lower32;
if (adev->serial[0] == '\0')
sprintf(adev->serial, "%016llx", adev->unique_id);
......
......@@ -310,13 +310,9 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,
SmuMetrics_t *metrics = (SmuMetrics_t *)smu_table->metrics_table;
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu, NULL, false);
if (ret) {
mutex_unlock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table(smu, NULL, false);
if (ret)
return ret;
}
switch (member) {
case METRICS_AVERAGE_GFXCLK:
......@@ -387,8 +383,6 @@ static int yellow_carp_get_smu_metrics_data(struct smu_context *smu,
break;
}
mutex_unlock(&smu->metrics_lock);
return ret;
}
......
......@@ -964,9 +964,9 @@ int smu_cmn_write_pptable(struct smu_context *smu)
true);
}
int smu_cmn_get_metrics_table_locked(struct smu_context *smu,
void *metrics_table,
bool bypass_cache)
int smu_cmn_get_metrics_table(struct smu_context *smu,
void *metrics_table,
bool bypass_cache)
{
struct smu_table_context *smu_table= &smu->smu_table;
uint32_t table_size =
......@@ -994,21 +994,6 @@ int smu_cmn_get_metrics_table_locked(struct smu_context *smu,
return 0;
}
int smu_cmn_get_metrics_table(struct smu_context *smu,
void *metrics_table,
bool bypass_cache)
{
int ret = 0;
mutex_lock(&smu->metrics_lock);
ret = smu_cmn_get_metrics_table_locked(smu,
metrics_table,
bypass_cache);
mutex_unlock(&smu->metrics_lock);
return ret;
}
void smu_cmn_init_soft_gpu_metrics(void *table, uint8_t frev, uint8_t crev)
{
struct metrics_table_header *header = (struct metrics_table_header *)table;
......
......@@ -101,10 +101,6 @@ int smu_cmn_write_watermarks_table(struct smu_context *smu);
int smu_cmn_write_pptable(struct smu_context *smu);
int smu_cmn_get_metrics_table_locked(struct smu_context *smu,
void *metrics_table,
bool bypass_cache);
int smu_cmn_get_metrics_table(struct smu_context *smu,
void *metrics_table,
bool bypass_cache);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment