RE: [PATCH 3/3] drm/amdgpu: de-initialize software ih ring

2020-12-20 Thread Xu, Feifei
[AMD Official Use Only - Internal Distribution Only]



Series is
Reviewed-by: Feifei Xu 

-Original Message-
From: Zhang, Hawking  
Sent: 2020年12月21日 下午 1:43
To: amd-gfx@lists.freedesktop.org; Xu, Feifei ; Koenig, 
Christian 
Cc: Zhang, Hawking 
Subject: [PATCH 3/3] drm/amdgpu: de-initialize software ih ring

tear down software ih ring and its state.

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c | 1 +  
drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 1 +  
drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
index 04cc41b82661..060357625504 100644
--- a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
@@ -584,6 +584,7 @@ static int navi10_ih_sw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
amdgpu_irq_fini(adev);
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
amdgpu_ih_ring_fini(adev, &adev->irq.ih); diff --git 
a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
index 1581113477cf..88626d83e07b 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
@@ -524,6 +524,7 @@ static int vega10_ih_sw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
amdgpu_irq_fini(adev);
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
amdgpu_ih_ring_fini(adev, &adev->irq.ih); diff --git 
a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c 
b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
index a1d4d67d5ee1..5487262527aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
@@ -571,6 +571,7 @@ static int vega20_ih_sw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
amdgpu_irq_fini(adev);
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
amdgpu_ih_ring_fini(adev, &adev->irq.ih);
--
2.17.1
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 3/3] drm/amdgpu: de-initialize software ih ring

2020-12-20 Thread Hawking Zhang
tear down software ih ring and its state.

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c | 1 +
 drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 1 +
 drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
index 04cc41b82661..060357625504 100644
--- a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
@@ -584,6 +584,7 @@ static int navi10_ih_sw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
amdgpu_irq_fini(adev);
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
amdgpu_ih_ring_fini(adev, &adev->irq.ih);
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
index 1581113477cf..88626d83e07b 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
@@ -524,6 +524,7 @@ static int vega10_ih_sw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
amdgpu_irq_fini(adev);
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
amdgpu_ih_ring_fini(adev, &adev->irq.ih);
diff --git a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c 
b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
index a1d4d67d5ee1..5487262527aa 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
@@ -571,6 +571,7 @@ static int vega20_ih_sw_fini(void *handle)
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
amdgpu_irq_fini(adev);
+   amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
amdgpu_ih_ring_fini(adev, &adev->irq.ih);
-- 
2.17.1

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


[PATCH 1/3] drm/amdgpu: enable software ih ring for vega20 ih block

2020-12-20 Thread Hawking Zhang
software ih ring will be used as a workaround
in case hardware ih ring 1 and ring 2 don't work

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c 
b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
index 4c7bbd0b63c6..a1d4d67d5ee1 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega20_ih.c
@@ -357,6 +357,9 @@ static int vega20_ih_irq_init(struct amdgpu_device *adev)
if (ret)
return ret;
 
+   if (adev->irq.ih_soft.ring_size)
+   adev->irq.ih_soft.enabled = true;
+
return 0;
 }
 
@@ -554,6 +557,10 @@ static int vega20_ih_sw_init(void *handle)
/* initialize ih control registers offset */
vega20_ih_init_register_offset(adev);
 
+   r = amdgpu_ih_ring_init(adev, &adev->irq.ih_soft, PAGE_SIZE, true);
+   if (r)
+   return r;
+
r = amdgpu_irq_init(adev);
 
return r;
-- 
2.17.1

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


[PATCH 2/3] drm/amdgpu: set ih soft ring enabled flag for vega and navi

2020-12-20 Thread Hawking Zhang
software ih ring is enabled in vega10 and navi
ih block by default.

Signed-off-by: Hawking Zhang 
---
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c | 3 +++
 drivers/gpu/drm/amd/amdgpu/vega10_ih.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
index 580a325f08b4..04cc41b82661 100644
--- a/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/navi10_ih.c
@@ -370,6 +370,9 @@ static int navi10_ih_irq_init(struct amdgpu_device *adev)
/* enable wptr force update for self int */
force_update_wptr_for_self_int(adev, 0, 8, true);
 
+   if (adev->irq.ih_soft.ring_size)
+   adev->irq.ih_soft.enabled = true;
+
return 0;
 }
 
diff --git a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c 
b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
index b1d94421c8d1..1581113477cf 100644
--- a/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
+++ b/drivers/gpu/drm/amd/amdgpu/vega10_ih.c
@@ -307,6 +307,9 @@ static int vega10_ih_irq_init(struct amdgpu_device *adev)
if (ret)
return ret;
 
+   if (adev->irq.ih_soft.ring_size)
+   adev->irq.ih_soft.enabled = true;
+
return 0;
 }
 
-- 
2.17.1

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


Re: [PATCH 4/8] amdgpu/pm: Powerplay API for smu , changed 9 pm power functions to use API

2020-12-20 Thread Wang, Kevin(Yang)
[AMD Official Use Only - Internal Distribution Only]




From: amd-gfx  on behalf of Darren 
Powell 
Sent: Saturday, December 19, 2020 8:48 AM
To: amd-gfx@lists.freedesktop.org 
Cc: Powell, Darren 
Subject: [PATCH 4/8] amdgpu/pm: Powerplay API for smu , changed 9 pm power 
functions to use API

Modified Files
  smu_get_power_limit() - modifed arg0 to match Powerplay API 
get_power_limit
  smu_set_power_limit() - modifed arg0 to match Powerplay API 
set_power_limit
  smu_sys_get_pp_table()- modifed signature to match Powerplay API 
get_pp_table
  smu_get_power_num_states()- modifed arg0 to match Powerplay API 
get_pp_num_states
  smu_get_current_power_state() - modifed arg0 to match Powerplay API 
get_current_power_state
  smu_sys_get_pp_feature_mask() - modifed signature to match Powerplay API 
get_ppfeature_status
  smu_sys_set_pp_feature_mask() - modifed arg0 to match Powerplay API 
set_ppfeature_status

Other Changes
  added 7 above smu Powerplay functions to swsmu_dpm_funcs
  removed special smu handling of above functions and called through Powerplay 
API

Signed-off-by: Darren Powell 
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c| 73 ---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   | 16 +++--
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 59 +++---
 3 files changed, 69 insertions(+), 79 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index b345c29147b9..41da5870af58 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -124,6 +124,7 @@ static ssize_t amdgpu_get_power_dpm_state(struct device 
*dev,
 {
 struct drm_device *ddev = dev_get_drvdata(dev);
 struct amdgpu_device *adev = drm_to_adev(ddev);
+   const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 enum amd_pm_state_type pm;
 int ret;

@@ -136,12 +137,7 @@ static ssize_t amdgpu_get_power_dpm_state(struct device 
*dev,
 return ret;
 }

-   if (is_support_sw_smu(adev)) {
-   if (adev->smu.ppt_funcs->get_current_power_state)
-   pm = smu_get_current_power_state(&adev->smu);
-   else
-   pm = adev->pm.dpm.user_state;
-   } else if (adev->powerplay.pp_funcs->get_current_power_state) {
+   if (pp_funcs->get_current_power_state) {
 pm = amdgpu_dpm_get_current_power_state(adev);
 } else {
 pm = adev->pm.dpm.user_state;
@@ -307,6 +303,7 @@ static ssize_t 
amdgpu_set_power_dpm_force_performance_level(struct device *dev,
 {
 struct drm_device *ddev = dev_get_drvdata(dev);
 struct amdgpu_device *adev = drm_to_adev(ddev);
+   const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 enum amd_dpm_forced_level level;
 enum amd_dpm_forced_level current_level = 0xff;
 int ret = 0;
@@ -342,9 +339,7 @@ static ssize_t 
amdgpu_set_power_dpm_force_performance_level(struct device *dev,
 return ret;
 }

-   if (is_support_sw_smu(adev))
-   current_level = smu_get_performance_level(&adev->smu);
-   else if (adev->powerplay.pp_funcs->get_performance_level)
+   if (pp_funcs->get_performance_level)
 current_level = amdgpu_dpm_get_performance_level(adev);

 if (current_level == level) {
@@ -381,7 +376,7 @@ static ssize_t 
amdgpu_set_power_dpm_force_performance_level(struct device *dev,
 pm_runtime_put_autosuspend(ddev->dev);
 return -EINVAL;
 }
-   } else if (adev->powerplay.pp_funcs->force_performance_level) {
+   } else if (pp_funcs->force_performance_level) {
 mutex_lock(&adev->pm.mutex);
 if (adev->pm.dpm.thermal_active) {
 mutex_unlock(&adev->pm.mutex);
@@ -412,6 +407,7 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
 {
 struct drm_device *ddev = dev_get_drvdata(dev);
 struct amdgpu_device *adev = drm_to_adev(ddev);
+   const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
 struct pp_states_info data;
 int i, buf_len, ret;

@@ -424,12 +420,10 @@ static ssize_t amdgpu_get_pp_num_states(struct device 
*dev,
 return ret;
 }

-   if (is_support_sw_smu(adev)) {
-   ret = smu_get_power_num_states(&adev->smu, &data);
-   if (ret)
+   if (pp_funcs->get_pp_num_states) {
+   ret = amdgpu_dpm_get_pp_num_states(adev, &data);
+   if (is_support_sw_smu(adev) && ret)
 return ret;
-   } else if (adev->powerplay.pp_funcs->get_pp_num_states) {
-   amdgpu_dpm_get_pp_num_states(adev, &data);
 } else {
 memset(&data, 0, sizeof(data));
 }
@@ -454,8 +448,8 @@ static ssize_t am

Re: [PATCH 3/8] amdgpu/pm: Powerplay API for smu , changed 6 pm hwmon fan functions to use API

2020-12-20 Thread Wang, Kevin(Yang)
[AMD Official Use Only - Internal Distribution Only]



From: amd-gfx  on behalf of Darren 
Powell 
Sent: Saturday, December 19, 2020 8:48 AM
To: amd-gfx@lists.freedesktop.org 
Cc: Powell, Darren 
Subject: [PATCH 3/8] amdgpu/pm: Powerplay API for smu , changed 6 pm hwmon fan 
functions to use API

Modified Functions
  smu_set_fan_speed_rpm() - modifed arg0 to match Powerplay API 
set_fan_speed_rpm
  smu_get_fan_control_mode()  - modifed signature to match Powerplay API 
get_fan_control_mode
  smu_set_fan_control_mode()  - modifed signature to match Powerplay API 
set_fan_control_mode
  smu_get_fan_speed_percent() - modifed signature to match Powerplay API 
get_fan_speed_percent
  smu_set_fan_speed_percent() - modifed signature to match Powerplay API 
set_fan_speed_percent
  smu_get_fan_speed_rpm() - modifed arg0 to match Powerplay API 
get_fan_speed_rpm

Other Changes
  added 6 above smu fan Powerplay functions to swsmu_dpm_funcs
  removed special smu handling of above functions and called through Powerplay 
API

Signed-off-by: Darren Powell 
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c| 87 +++
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   | 12 ++--
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 33 ++---
 3 files changed, 55 insertions(+), 77 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 0008bbe971d6..b345c29147b9 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -2349,18 +2349,14 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct 
device *dev,
 return ret;
 }

-   if (is_support_sw_smu(adev)) {
-   pwm_mode = smu_get_fan_control_mode(&adev->smu);
-   } else {
-   if (!adev->powerplay.pp_funcs->get_fan_control_mode) {
+   if (!adev->powerplay.pp_funcs->get_fan_control_mode) {
 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
 return -EINVAL;
-   }
-
-   pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
 }

+   pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
+
 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);

@@ -2389,18 +2385,14 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct 
device *dev,
 return ret;
 }

-   if (is_support_sw_smu(adev)) {
-   smu_set_fan_control_mode(&adev->smu, value);
-   } else {
-   if (!adev->powerplay.pp_funcs->set_fan_control_mode) {
-   pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
-   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
-   return -EINVAL;
-   }
-
-   amdgpu_dpm_set_fan_control_mode(adev, value);
+   if (!adev->powerplay.pp_funcs->set_fan_control_mode) {
+   pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
+   pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
+   return -EINVAL;
 }

+   amdgpu_dpm_set_fan_control_mode(adev, value);
+
 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);

@@ -2439,11 +2431,7 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,
 return err;
 }

-   if (is_support_sw_smu(adev))
-   pwm_mode = smu_get_fan_control_mode(&adev->smu);
-   else
-   pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
-
+   pwm_mode = amdgpu_dpm_get_fan_control_mode(adev);
 if (pwm_mode != AMD_FAN_CTRL_MANUAL) {
 pr_info("manual fan speed control should be enabled first\n");
 pm_runtime_mark_last_busy(adev_to_drm(adev)->dev);
@@ -2460,9 +2448,7 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,

 value = (value * 100) / 255;

-   if (is_support_sw_smu(adev))
-   err = smu_set_fan_speed_percent(&adev->smu, value);
-   else if (adev->powerplay.pp_funcs->set_fan_speed_percent)
+   if (adev->powerplay.pp_funcs->set_fan_speed_percent)
 err = amdgpu_dpm_set_fan_speed_percent(adev, value);
 else
 err = -EINVAL;
@@ -2493,9 +2479,7 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,
 return err;
 }

-   if (is_support_sw_smu(adev))
-   err = smu_get_fan_speed_percent(&adev->smu, &speed);
-   else if (adev->powerplay.pp_funcs->get_fan_speed_percent)
+   if (adev->powerplay.pp_funcs->get_fan_speed_percent)
 err = amdgpu_dpm_get_fan_speed_percent(adev, &speed);
 else
 err = -EINVAL;
@@ -2528,9 +2512,7 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device 
*dev,
 

Re: [PATCH 1/8] amdgpu/pm: Powerplay API for smu , added get_performance_level

2020-12-20 Thread Wang, Kevin(Yang)
[AMD Official Use Only - Internal Distribution Only]



From: amd-gfx  on behalf of Darren 
Powell 
Sent: Saturday, December 19, 2020 8:48 AM
To: amd-gfx@lists.freedesktop.org 
Cc: Powell, Darren 
Subject: [PATCH 1/8] amdgpu/pm: Powerplay API for smu , added 
get_performance_level

Modified Functions
  smu_get_performance_level() - modifed arg0 to match Powerplay API 
get_performance_level

Other Changes
  added a new structure swsmu_dpm_funcs to hold smu functions for Powerplay API
  removed special smu handling from amdgpu_get_power_dpm_force_performance_level

Signed-off-by: Darren Powell 
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c|  4 +---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h   |  2 +-
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 12 +++-
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c 
b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 7b6ef05a1d35..0008bbe971d6 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -280,9 +280,7 @@ static ssize_t 
amdgpu_get_power_dpm_force_performance_level(struct device *dev,
 return ret;
 }

-   if (is_support_sw_smu(adev))
-   level = smu_get_performance_level(&adev->smu);
-   else if (adev->powerplay.pp_funcs->get_performance_level)
+   if (adev->powerplay.pp_funcs->get_performance_level)
 level = amdgpu_dpm_get_performance_level(adev);
 else
 level = adev->pm.dpm.forced_level;
diff --git a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h 
b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
index 89be49a43500..10914f3438ac 100644
--- a/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
+++ b/drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h
@@ -743,7 +743,7 @@ int smu_get_dpm_freq_range(struct smu_context *smu, enum 
smu_clk_type clk_type,
uint32_t *min, uint32_t *max);
 int smu_set_soft_freq_range(struct smu_context *smu, enum smu_clk_type 
clk_type,
 uint32_t min, uint32_t max);
-enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu);
+enum amd_dpm_forced_level smu_get_performance_level(void *handle);
 int smu_force_performance_level(struct smu_context *smu, enum 
amd_dpm_forced_level level);
 int smu_set_display_count(struct smu_context *smu, uint32_t count);
 int smu_set_ac_dc(struct smu_context *smu);
diff --git a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c 
b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
index cf999b7a2164..36d18668ec99 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
@@ -46,6 +46,8 @@
 #undef pr_info
 #undef pr_debug

+static const struct amd_pm_funcs swsmu_dpm_funcs;
+
 size_t smu_sys_get_pp_feature_mask(struct smu_context *smu, char *buf)
 {
 size_t size = 0;
@@ -428,6 +430,9 @@ static int smu_early_init(void *handle)
 smu->smu_baco.state = SMU_BACO_STATE_EXIT;
 smu->smu_baco.platform_support = false;

+   adev->powerplay.pp_handle = smu;
+   adev->powerplay.pp_funcs = &swsmu_dpm_funcs;
+
 return smu_set_funcs(adev);
 }

@@ -1569,8 +1574,9 @@ int smu_switch_power_profile(struct smu_context *smu,
 return 0;
 }

-enum amd_dpm_forced_level smu_get_performance_level(struct smu_context *smu)
+enum amd_dpm_forced_level smu_get_performance_level(void *handle)
 {
+   struct smu_context *smu = handle;
 struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm);
 enum amd_dpm_forced_level level;

@@ -2549,3 +2555,7 @@ int smu_gfx_state_change_set(struct smu_context *smu, 
uint32_t state)

 return ret;
 }
+
+static const struct amd_pm_funcs swsmu_dpm_funcs = {
+   .get_performance_level = smu_get_performance_level,
+};

[kevin]:
could you change this name to "smu_pm_funcs" or others,
not of all fields is DPM related functions in data structure of 'amd_pm_funcs'
it will make some confused for developers.

--
2.25.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7CKevin1.Wang%40amd.com%7Ce82fe9048c4d43857c9908d8a3b7e561%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637439357533667974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=vGF8e0xTEWyAqKusXbH23Ez4k5Lzz6RmORQXN6unJz8%3D&reserved=0
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


RE: [PATCH 0/8] amdgpu/pm: Powerplay API for smu

2020-12-20 Thread Quan, Evan
[AMD Official Use Only - Internal Distribution Only]

Thanks for these cleaups. The series is acked-by: Evan Quan 

-Original Message-
From: amd-gfx  On Behalf Of Darren Powell
Sent: Saturday, December 19, 2020 8:48 AM
To: amd-gfx@lists.freedesktop.org
Cc: Powell, Darren 
Subject: [PATCH 0/8] amdgpu/pm: Powerplay API for smu


=== Description ===
Patches to add the Powerplay API to smu and simplify dpm/pm calling code

=== Test System ===
* DESKTOP(AMD FX-8350 + NAVI10(731F/ca), BIOS: F2)  + ISO(Ubuntu 20.04.1 LTS)  
+ Kernel(5.9.0-rc5-custom-pmcallback-00865-gd3b9ec1a13c9)

=== Patch Summary ===
   linux: (git://people.freedesktop.org/~agd5f/linux) 
origin/amd-staging-drm-next @ d3b9ec1a13c9
+ 05e1d87d1cb4 amdgpu/pm: Powerplay API for smu , added 
get_performance_level
+ b9e2be067f01 amdgpu/pm: Powerplay API for smu , changed 6 dpm reset 
functions to use API
+ 9add1d6485a4 amdgpu/pm: Powerplay API for smu , changed 6 pm hwmon fan 
functions to use API
+ c02b35074f14 amdgpu/pm: Powerplay API for smu , changed 9 pm power 
functions to use API
+ 483bd1207f2c amdgpu/pm: Powerplay API for smu , changed 5 dpm powergating 
& sensor functions to use API
+ f91c1665e30e amdgpu/pm: Powerplay API for smu , changes to clock and 
profile mode functions
+ d1400afa4785 amdgpu/pm: Powerplay API for smu , changed 4 dpm functions 
to use API
+ 2f12f7afa690 amdgpu/pm: Powerplay API for smu , updates to some pm 
functions

=== Tests ===
** 0001
 amdgpu_get_power_dpm_force_performance_level()<- 
/sys/class/drm/card0/device/power_dpm_force_performance_level
** 0002
 amdgpu_dpm_set_mp1_state  <- systemctl suspend
 amdgpu_dpm_mode2_reset<- untested: needs Arctic Islands 
Hardware (VEGAx, RAVEN)
 amdgpu_dpm_switch_power_profile   <- untested
 amdgpu_dpm_set_xgmi_pstate<- untested: 
amdgpu_xgmi_set_pstate():411 pstate switching disabled
 amdgpu_dpm_set_df_cstate  <- untested: needs ras enabled hardware
 amdgpu_dpm_enable_mgpu_fan_boost  <- untested: needs multi-gpu hardware
** 0003
 amdgpu_hwmon_get_pwm1_enable<- 
/sys/class/drm/card0/device/hwmon/hwmon?/pwm1_enable
 amdgpu_hwmon_set_pwm1_enable<- 
/sys/class/drm/card0/device/hwmon/hwmon?/pwm1_enable
 amdgpu_hwmon_set_pwm1   <- 
/sys/class/drm/card0/device/hwmon/hwmon?/pwm1
 amdgpu_hwmon_get_pwm1   <- 
/sys/class/drm/card0/device/hwmon/hwmon?/pwm1
 amdgpu_hwmon_get_fan1_input <- 
/sys/class/drm/card0/device/hwmon/hwmon?/fan1_input
 amdgpu_hwmon_get_fan1_target<- 
/sys/class/drm/card0/device/hwmon/hwmon?/fan1_target
 amdgpu_hwmon_set_fan1_target<- 
/sys/class/drm/card0/device/hwmon/hwmon?/fan1_target
 amdgpu_hwmon_get_fan1_enable<- 
/sys/class/drm/card0/device/hwmon/hwmon?/fan1_enable
 amdgpu_hwmon_set_fan1_enable<- 
/sys/class/drm/card0/device/hwmon/hwmon?/fan1_enable
** 0004
 amdgpu_get_power_dpm_state  <- 
/sys/class/drm/card0/device/power_dpm_state
 amdgpu_set_power_dpm_force_performance_level<- 
/sys/class/drm/card0/device/power_dpm_force_performance_level
 amdgpu_get_pp_num_states<- 
/sys/class/drm/card0/device/pp_num_states
 amdgpu_get_pp_cur_state <- 
/sys/class/drm/card0/device/pp_cur_state
 amdgpu_get_pp_table <- 
/sys/class/drm/card0/device/pp_table
 amdgpu_get_pp_features  <- 
/sys/class/drm/card0/device/pp_features
 amdgpu_hwmon_show_power_cap_max <- 
/sys/class/drm/card0/device/hwmon/hwmon?/power1_cap_max
 amdgpu_hwmon_show_power_cap <- 
/sys/class/drm/card0/device/hwmon/hwmon?/power1_cap
 amdgpu_hwmon_set_power_cap  <- 
/sys/class/drm/card0/device/hwmon/hwmon?/power1_cap
** 0005
 amdgpu_dpm_baco_enter  <- untested: called from runtime.pm
 amdgpu_dpm_baco_exit   <- untested: called from runtime.pm
 amdgpu_dpm_is_baco_supported   <- untested: needs other Hardware(cik, 
vi, soc15)
 amdgpu_dpm_baco_reset  <- untested: needs other Hardware(cik, 
vi, soc15)
** 0006
 amdgpu_get_pp_dpm_sclk  <- /sys/class/drm/card0/device/pp_dpm_sclk
 amdgpu_set_pp_dpm_sclk  <- /sys/class/drm/card0/device/pp_dpm_sclk
 amdgpu_get_pp_dpm_mclk  <- /sys/class/drm/card0/device/pp_dpm_mclk
 amdgpu_set_pp_dpm_mclk  <- /sys/class/drm/card0/device/pp_dpm_mclk
 amdgpu_get_pp_dpm_socclk<- 
/sys/class/drm/card0/device/pp_dpm_socclk
 amdgpu_set_pp_dpm_socclk<- 
/sys/class/drm/card0/device/pp_dpm_socclk
 amdgpu_get_pp_dpm_fclk  <- /sys/class/drm/card0/device/pp_dpm_fclk
 amdgpu_set_pp_dpm_fclk  <- /sys/class/drm/card0/device/pp_dpm_fclk
 amdgpu_get_pp_dpm_dcefclk   <- 
/sys/class/drm/c

[PATCH 1/2] drm/amd/display: Return directly after a failed kzalloc() in dc_create()

2020-12-20 Thread Markus Elfring
From: Markus Elfring 
Date: Sat, 19 Dec 2020 18:04:33 +0100

* Return directly after a call of the function “kzalloc” failed
  at the beginning.

* Delete a label which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 7339d9855ec8..e35fbfcb4d0e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -964,8 +964,8 @@ struct dc *dc_create(const struct dc_init_data *init_params)
struct dc *dc = kzalloc(sizeof(*dc), GFP_KERNEL);
unsigned int full_pipe_count;

-   if (NULL == dc)
-   goto alloc_fail;
+   if (!dc)
+   return NULL;

if (init_params->dce_environment == DCE_ENV_VIRTUAL_HW) {
if (false == dc_construct_ctx(dc, init_params)) {
@@ -1009,8 +1009,6 @@ struct dc *dc_create(const struct dc_init_data 
*init_params)

 construct_fail:
kfree(dc);
-
-alloc_fail:
return NULL;
 }

--
2.29.2

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


[PATCH 2/2] drm/amd/display: Use common error handling code in dc_create()

2020-12-20 Thread Markus Elfring
From: Markus Elfring 
Date: Sat, 19 Dec 2020 18:18:59 +0100

Adjust a jump target so that a bit of exception handling can be better
reused at the end of this function.

Signed-off-by: Markus Elfring 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 15 ++-
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index e35fbfcb4d0e..64344c054c93 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -968,15 +968,11 @@ struct dc *dc_create(const struct dc_init_data 
*init_params)
return NULL;

if (init_params->dce_environment == DCE_ENV_VIRTUAL_HW) {
-   if (false == dc_construct_ctx(dc, init_params)) {
-   dc_destruct(dc);
-   goto construct_fail;
-   }
+   if (!dc_construct_ctx(dc, init_params))
+   goto destruct_dc;
} else {
-   if (false == dc_construct(dc, init_params)) {
-   dc_destruct(dc);
-   goto construct_fail;
-   }
+   if (!dc_construct(dc, init_params))
+   goto destruct_dc;

full_pipe_count = dc->res_pool->pipe_count;
if (dc->res_pool->underlay_pipe_index != NO_UNDERLAY_PIPE)
@@ -1007,7 +1003,8 @@ struct dc *dc_create(const struct dc_init_data 
*init_params)

return dc;

-construct_fail:
+destruct_dc:
+   dc_destruct(dc);
kfree(dc);
return NULL;
 }
--
2.29.2

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


[PATCH 0/2] drm/amd/display: Adjustments for dc_create()

2020-12-20 Thread Markus Elfring
From: Markus Elfring 
Date: Sat, 19 Dec 2020 18:30:56 +0100

Two update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
  Return directly after a failed kzalloc()
  Use common error handling code

 drivers/gpu/drm/amd/display/dc/core/dc.c | 21 -
 1 file changed, 8 insertions(+), 13 deletions(-)

--
2.29.2

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