drm/amd/powerplay: use work queue to perform throttling logging
Subsystems (2)
PATCH 1/1 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.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 ++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +10 -0
@@ -1053,6 +1053,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;
@@ -1074,6 +1082,7 @@ static int smu_sw_init(void *handle)spin_lock_init (&smu->metrics_lock);spin_lock_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 ;
@@ -1295,6 +1304,7 @@ static int smu_internal_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" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -411,6 +411,8 @@ struct smu_contextbool uploading_custom_pp_table;bool dc_controlled_by_gpio; + +struct work_struct throttling_logging_work; };struct i2c_adapter ;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
@@ -1597,7 +1597,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 ; }
Signature · 6 lines
2.27.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
LGTM
Quoted 65 lines · Evan Quan
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.
Change-Id I454d593e965e54b13fdf04c112abb0a022204278Signed-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 ++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +10
-0@@ -1053,6 +1053,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;@@ -1074,6 +1082,7 @@ static int smu_sw_init(void *handle)spin_lock_init (&smu->metrics_lock);spin_lock_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 ;@@ -1295,6 +1304,7 @@ static int smu_internal_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" );drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2
-0@@ -411,6 +411,8 @@ struct smu_contextbool uploading_custom_pp_table;bool dc_controlled_by_gpio; + +struct work_struct throttling_logging_work; };struct i2c_adapter ;drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0
-0
drivers/gpu/drm/amd/powerplay/smu_v11_0.c static int smu_v11_0_irq_process(struct amdgpu_device *adev, · line 1603
Quoted 8 lines
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1
-1@@ -1597,7 +1597,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 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 7 lines · Evan Quan
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.
Change-Id I454d593e965e54b13fdf04c112abb0a022204278Signed-off-by Evan Quan <[email protected]>
Quoted 70 lines
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 ++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +10
-0@@ -1053,6 +1053,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;@@ -1074,6 +1082,7 @@ static int smu_sw_init(void *handle)spin_lock_init (&smu->metrics_lock);spin_lock_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 ;@@ -1295,6 +1304,7 @@ static int smu_internal_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" );drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2
-0@@ -411,6 +411,8 @@ struct smu_contextbool uploading_custom_pp_table;bool dc_controlled_by_gpio; + +struct work_struct throttling_logging_work; };struct i2c_adapter ;drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1
-2@@ -1597,7 +1597,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 ; } --2.27.0
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