summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/powerplay
diff options
context:
space:
mode:
authorEvan Quan <evan.quan@amd.com>2020-06-03 11:45:49 +0800
committerAlex Deucher <alexander.deucher@amd.com>2020-07-01 01:59:17 -0400
commit6961750f12c8e768c081b5fa8ced8b524d4a659d (patch)
tree795391d2750d3505603a424d458d89bbe09dba4c /drivers/gpu/drm/amd/powerplay
parent9b1a6a581e598c7fdd80efca682fc9a061633dde (diff)
downloadlinux-6961750f12c8e768c081b5fa8ced8b524d4a659d.tar.bz2
drm/amd/powerplay: use work queue to perform throttling logging
As IO operations(access to SMU internals) and possible sleep are involved in throttling logging. Workqueue can handle them well. Otherwise we may hit "scheduling while atomic" error. Signed-off-by: Evan Quan <evan.quan@amd.com> Acked-by: Nirmoy Das <nirmoy.das@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/powerplay')
-rw-r--r--drivers/gpu/drm/amd/powerplay/amdgpu_smu.c11
-rw-r--r--drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h2
-rw-r--r--drivers/gpu/drm/amd/powerplay/smu_v11_0.c2
3 files changed, 14 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 5daa3c855ccc..4fb9aac729a4 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -1034,6 +1034,14 @@ static int smu_smc_table_sw_fini(struct smu_context *smu)
return 0;
}
+static void smu_throttling_logging_work_fn(struct work_struct *work)
+{
+ struct smu_context *smu = container_of(work, struct smu_context,
+ throttling_logging_work);
+
+ smu_log_thermal_throttling(smu);
+}
+
static int smu_sw_init(void *handle)
{
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -1055,6 +1063,7 @@ static int smu_sw_init(void *handle)
mutex_init(&smu->metrics_lock);
mutex_init(&smu->message_lock);
+ INIT_WORK(&smu->throttling_logging_work, smu_throttling_logging_work_fn);
smu->watermarks_bitmap = 0;
smu->power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
smu->default_power_profile_mode = PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT;
@@ -1372,6 +1381,8 @@ static int smu_smc_hw_cleanup(struct smu_context *smu)
smu_i2c_eeprom_fini(smu, &adev->pm.smu_i2c);
+ cancel_work_sync(&smu->throttling_logging_work);
+
ret = smu_disable_thermal_alert(smu);
if (ret) {
pr_warn("Fail to stop thermal control!\n");
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index c7b5b1994129..10234babfbbd 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
@@ -411,6 +411,8 @@ struct smu_context
bool uploading_custom_pp_table;
bool dc_controlled_by_gpio;
+
+ struct work_struct throttling_logging_work;
};
struct i2c_adapter;
diff --git a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
index 480fb74b9121..6940218545a5 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -1605,7 +1605,7 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,
return 0;
if (__ratelimit(&adev->throttling_logging_rs))
- smu_log_thermal_throttling(smu);
+ schedule_work(&smu->throttling_logging_work);
break;
}