mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-02-05 13:55:20 +07:00
drm/amd/powerplay: add sensor lock support for smu
when multithreading access sysfs of amdgpu_pm_info at the sametime. the swsmu driver cause smu firmware hang. eg: single thread access: Message A + Param A ==> right Message B + Param B ==> right Message C + Param C ==> right multithreading access: Message A + Param B ==> error Message B + Param A ==> error Message C + Param C ==> right the patch will add sensor lock(mutex) to avoid this error. Signed-off-by: Kevin Wang <kevin1.wang@amd.com> Reviewed-by: Kenneth Feng <kenneth.feng@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
64e51a1b55
commit
95f71bfad2
@ -840,6 +840,8 @@ static int smu_sw_init(void *handle)
|
|||||||
smu->smu_baco.state = SMU_BACO_STATE_EXIT;
|
smu->smu_baco.state = SMU_BACO_STATE_EXIT;
|
||||||
smu->smu_baco.platform_support = false;
|
smu->smu_baco.platform_support = false;
|
||||||
|
|
||||||
|
mutex_init(&smu->sensor_lock);
|
||||||
|
|
||||||
smu->watermarks_bitmap = 0;
|
smu->watermarks_bitmap = 0;
|
||||||
smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
|
smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
|
||||||
smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
|
smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
|
||||||
|
@ -1025,6 +1025,7 @@ static int arcturus_read_sensor(struct smu_context *smu,
|
|||||||
if (!data || !size)
|
if (!data || !size)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&smu->sensor_lock);
|
||||||
switch (sensor) {
|
switch (sensor) {
|
||||||
case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
|
case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
|
||||||
*(uint32_t *)data = pptable->FanMaximumRpm;
|
*(uint32_t *)data = pptable->FanMaximumRpm;
|
||||||
@ -1051,6 +1052,7 @@ static int arcturus_read_sensor(struct smu_context *smu,
|
|||||||
default:
|
default:
|
||||||
ret = smu_smc_read_sensor(smu, sensor, data, size);
|
ret = smu_smc_read_sensor(smu, sensor, data, size);
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&smu->sensor_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -350,6 +350,7 @@ struct smu_context
|
|||||||
const struct smu_funcs *funcs;
|
const struct smu_funcs *funcs;
|
||||||
const struct pptable_funcs *ppt_funcs;
|
const struct pptable_funcs *ppt_funcs;
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
|
struct mutex sensor_lock;
|
||||||
uint64_t pool_size;
|
uint64_t pool_size;
|
||||||
|
|
||||||
struct smu_table_context smu_table;
|
struct smu_table_context smu_table;
|
||||||
|
@ -1387,6 +1387,7 @@ static int navi10_read_sensor(struct smu_context *smu,
|
|||||||
if(!data || !size)
|
if(!data || !size)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&smu->sensor_lock);
|
||||||
switch (sensor) {
|
switch (sensor) {
|
||||||
case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
|
case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
|
||||||
*(uint32_t *)data = pptable->FanMaximumRpm;
|
*(uint32_t *)data = pptable->FanMaximumRpm;
|
||||||
@ -1410,6 +1411,7 @@ static int navi10_read_sensor(struct smu_context *smu,
|
|||||||
default:
|
default:
|
||||||
ret = smu_smc_read_sensor(smu, sensor, data, size);
|
ret = smu_smc_read_sensor(smu, sensor, data, size);
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&smu->sensor_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -3017,6 +3017,7 @@ static int vega20_read_sensor(struct smu_context *smu,
|
|||||||
if(!data || !size)
|
if(!data || !size)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
mutex_lock(&smu->sensor_lock);
|
||||||
switch (sensor) {
|
switch (sensor) {
|
||||||
case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
|
case AMDGPU_PP_SENSOR_MAX_FAN_RPM:
|
||||||
*(uint32_t *)data = pptable->FanMaximumRpm;
|
*(uint32_t *)data = pptable->FanMaximumRpm;
|
||||||
@ -3042,6 +3043,7 @@ static int vega20_read_sensor(struct smu_context *smu,
|
|||||||
default:
|
default:
|
||||||
ret = smu_smc_read_sensor(smu, sensor, data, size);
|
ret = smu_smc_read_sensor(smu, sensor, data, size);
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&smu->sensor_lock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user