[3/3] Revert "drm/amd/amdgpu: switch on/off vcn power profile mode"

Message ID 20230814073438.10682-4-Arvind.Yadav@amd.com
State New
Headers
Series GPU workload hints for better performance |

Commit Message

Arvind Yadav Aug. 14, 2023, 7:34 a.m. UTC
  This reverts commit 5ce71f59bb9bd3d8a09b96afdbc92975cb6dc303.

Reason for revert: New amdgpu_smu* api is added to switch
on/off profile mode. These new api will allow to change the
GPU power profile based on a submitted job.

Cc: Shashank Sharma <shashank.sharma@amd.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Arvind Yadav <Arvind.Yadav@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)
  

Comments

Alex Deucher Aug. 14, 2023, 3:20 p.m. UTC | #1
KFD also changes the profile when queues are active.  Please make sure
that is properly taken into account as well.

Alex

On Mon, Aug 14, 2023 at 3:36 AM Arvind Yadav <Arvind.Yadav@amd.com> wrote:
>
> This reverts commit 5ce71f59bb9bd3d8a09b96afdbc92975cb6dc303.
>
> Reason for revert: New amdgpu_smu* api is added to switch
> on/off profile mode. These new api will allow to change the
> GPU power profile based on a submitted job.
>
> Cc: Shashank Sharma <shashank.sharma@amd.com>
> Cc: Christian Koenig <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Arvind Yadav <Arvind.Yadav@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 14 ++------------
>  1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
> index 2d94f1b63bd6..70777fcfa626 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
> @@ -363,7 +363,6 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
>                 container_of(work, struct amdgpu_device, vcn.idle_work.work);
>         unsigned int fences = 0, fence[AMDGPU_MAX_VCN_INSTANCES] = {0};
>         unsigned int i, j;
> -       int r = 0;
>
>         for (j = 0; j < adev->vcn.num_vcn_inst; ++j) {
>                 if (adev->vcn.harvest_config & (1 << j))
> @@ -392,10 +391,6 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
>         if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
>                 amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
>                        AMD_PG_STATE_GATE);
> -               r = amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_VIDEO,
> -                               false);
> -               if (r)
> -                       dev_warn(adev->dev, "(%d) failed to disable video power profile mode\n", r);
>         } else {
>                 schedule_delayed_work(&adev->vcn.idle_work, VCN_IDLE_TIMEOUT);
>         }
> @@ -404,16 +399,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
>  void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
>  {
>         struct amdgpu_device *adev = ring->adev;
> -       int r = 0;
>
>         atomic_inc(&adev->vcn.total_submission_cnt);
>
> -       if (!cancel_delayed_work_sync(&adev->vcn.idle_work)) {
> -               r = amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_VIDEO,
> -                               true);
> -               if (r)
> -                       dev_warn(adev->dev, "(%d) failed to switch to video power profile mode\n", r);
> -       }
> +       if (!cancel_delayed_work_sync(&adev->vcn.idle_work))
> +               amdgpu_gfx_off_ctrl(adev, false);
>
>         mutex_lock(&adev->vcn.vcn_pg_lock);
>         amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
> --
> 2.34.1
>
  
Shashank Sharma Aug. 14, 2023, 4:05 p.m. UTC | #2
Ah, Thanks for pointing that out Alex.

@Arvind, please refer to the patch 
(https://patchwork.freedesktop.org/patch/504854/?series=109060&rev=4) in 
previous series of SMU workload hints with UAPI (here: 
https://patchwork.freedesktop.org/series/109060/)

Regards

Shashank

On 14/08/2023 17:20, Alex Deucher wrote:
> KFD also changes the profile when queues are active.  Please make sure
> that is properly taken into account as well.
>
> Alex
>
> On Mon, Aug 14, 2023 at 3:36 AM Arvind Yadav <Arvind.Yadav@amd.com> wrote:
>> This reverts commit 5ce71f59bb9bd3d8a09b96afdbc92975cb6dc303.
>>
>> Reason for revert: New amdgpu_smu* api is added to switch
>> on/off profile mode. These new api will allow to change the
>> GPU power profile based on a submitted job.
>>
>> Cc: Shashank Sharma <shashank.sharma@amd.com>
>> Cc: Christian Koenig <christian.koenig@amd.com>
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Signed-off-by: Arvind Yadav <Arvind.Yadav@amd.com>
>> ---
>>   drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 14 ++------------
>>   1 file changed, 2 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>> index 2d94f1b63bd6..70777fcfa626 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
>> @@ -363,7 +363,6 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
>>                  container_of(work, struct amdgpu_device, vcn.idle_work.work);
>>          unsigned int fences = 0, fence[AMDGPU_MAX_VCN_INSTANCES] = {0};
>>          unsigned int i, j;
>> -       int r = 0;
>>
>>          for (j = 0; j < adev->vcn.num_vcn_inst; ++j) {
>>                  if (adev->vcn.harvest_config & (1 << j))
>> @@ -392,10 +391,6 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
>>          if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
>>                  amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
>>                         AMD_PG_STATE_GATE);
>> -               r = amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_VIDEO,
>> -                               false);
>> -               if (r)
>> -                       dev_warn(adev->dev, "(%d) failed to disable video power profile mode\n", r);
>>          } else {
>>                  schedule_delayed_work(&adev->vcn.idle_work, VCN_IDLE_TIMEOUT);
>>          }
>> @@ -404,16 +399,11 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
>>   void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
>>   {
>>          struct amdgpu_device *adev = ring->adev;
>> -       int r = 0;
>>
>>          atomic_inc(&adev->vcn.total_submission_cnt);
>>
>> -       if (!cancel_delayed_work_sync(&adev->vcn.idle_work)) {
>> -               r = amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_VIDEO,
>> -                               true);
>> -               if (r)
>> -                       dev_warn(adev->dev, "(%d) failed to switch to video power profile mode\n", r);
>> -       }
>> +       if (!cancel_delayed_work_sync(&adev->vcn.idle_work))
>> +               amdgpu_gfx_off_ctrl(adev, false);
>>
>>          mutex_lock(&adev->vcn.vcn_pg_lock);
>>          amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
>> --
>> 2.34.1
>>
  

Patch

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
index 2d94f1b63bd6..70777fcfa626 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
@@ -363,7 +363,6 @@  static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 		container_of(work, struct amdgpu_device, vcn.idle_work.work);
 	unsigned int fences = 0, fence[AMDGPU_MAX_VCN_INSTANCES] = {0};
 	unsigned int i, j;
-	int r = 0;
 
 	for (j = 0; j < adev->vcn.num_vcn_inst; ++j) {
 		if (adev->vcn.harvest_config & (1 << j))
@@ -392,10 +391,6 @@  static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 	if (!fences && !atomic_read(&adev->vcn.total_submission_cnt)) {
 		amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,
 		       AMD_PG_STATE_GATE);
-		r = amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_VIDEO,
-				false);
-		if (r)
-			dev_warn(adev->dev, "(%d) failed to disable video power profile mode\n", r);
 	} else {
 		schedule_delayed_work(&adev->vcn.idle_work, VCN_IDLE_TIMEOUT);
 	}
@@ -404,16 +399,11 @@  static void amdgpu_vcn_idle_work_handler(struct work_struct *work)
 void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring)
 {
 	struct amdgpu_device *adev = ring->adev;
-	int r = 0;
 
 	atomic_inc(&adev->vcn.total_submission_cnt);
 
-	if (!cancel_delayed_work_sync(&adev->vcn.idle_work)) {
-		r = amdgpu_dpm_switch_power_profile(adev, PP_SMC_POWER_PROFILE_VIDEO,
-				true);
-		if (r)
-			dev_warn(adev->dev, "(%d) failed to switch to video power profile mode\n", r);
-	}
+	if (!cancel_delayed_work_sync(&adev->vcn.idle_work))
+		amdgpu_gfx_off_ctrl(adev, false);
 
 	mutex_lock(&adev->vcn.vcn_pg_lock);
 	amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_VCN,