All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/powerplay: use work queue to perform throttling logging
@ 2020-06-03  5:03 Evan Quan
  2020-06-03  9:50 ` Nirmoy
  2020-06-03 13:51 ` Alex Deucher
  0 siblings, 2 replies; 3+ messages in thread
From: Evan Quan @ 2020-06-03  5:03 UTC (permalink / raw)
  To: amd-gfx; +Cc: alexander.deucher, 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: I454d593e965e54b13fdf04c112abb0a022204278
Signed-off-by: Evan Quan <evan.quan@amd.com>
---
 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(-)

diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
index 342fd75b0806..e25a3b1ce7ac 100644
--- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
@@ -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");
diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
index 6f44ffb6eb51..b970b4d663b0 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 adde9eb7b283..69b1160d8ba2 100644
--- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
+++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
@@ -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

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd/powerplay: use work queue to perform throttling logging
  2020-06-03  5:03 [PATCH] drm/amd/powerplay: use work queue to perform throttling logging Evan Quan
@ 2020-06-03  9:50 ` Nirmoy
  2020-06-03 13:51 ` Alex Deucher
  1 sibling, 0 replies; 3+ messages in thread
From: Nirmoy @ 2020-06-03  9:50 UTC (permalink / raw)
  To: amd-gfx

LGTM

Acked-by: Nirmoy Das <nirmoy.das@amd.com>

On 6/3/20 7:03 AM, Evan Quan wrote:
> 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: I454d593e965e54b13fdf04c112abb0a022204278
> Signed-off-by: Evan Quan <evan.quan@amd.com>
> ---
>   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(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 342fd75b0806..e25a3b1ce7ac 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -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");
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> index 6f44ffb6eb51..b970b4d663b0 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 adde9eb7b283..69b1160d8ba2 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> @@ -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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/amd/powerplay: use work queue to perform throttling logging
  2020-06-03  5:03 [PATCH] drm/amd/powerplay: use work queue to perform throttling logging Evan Quan
  2020-06-03  9:50 ` Nirmoy
@ 2020-06-03 13:51 ` Alex Deucher
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2020-06-03 13:51 UTC (permalink / raw)
  To: Evan Quan; +Cc: Deucher, Alexander, amd-gfx list

On Wed, Jun 3, 2020 at 1:03 AM Evan Quan <evan.quan@amd.com> wrote:
>
> 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: I454d593e965e54b13fdf04c112abb0a022204278
> Signed-off-by: Evan Quan <evan.quan@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  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(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> index 342fd75b0806..e25a3b1ce7ac 100644
> --- a/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> +++ b/drivers/gpu/drm/amd/powerplay/amdgpu_smu.c
> @@ -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");
> diff --git a/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h b/drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
> index 6f44ffb6eb51..b970b4d663b0 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 adde9eb7b283..69b1160d8ba2 100644
> --- a/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> +++ b/drivers/gpu/drm/amd/powerplay/smu_v11_0.c
> @@ -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
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-06-03 13:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03  5:03 [PATCH] drm/amd/powerplay: use work queue to perform throttling logging Evan Quan
2020-06-03  9:50 ` Nirmoy
2020-06-03 13:51 ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.