Skip to contentSkip to conversation

drm/amdgpu: Need to set the baco cap before baco reset

PATCH In review Emily Deng 3 participants 6 messages May 23, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Emily Deng

author
#0 lore raw

PATCH v2 1/1 drm/amdgpu: Need to set the baco cap before baco reset

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 10 +++++++++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h     |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 16 ++++++++++++++++
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22 ++++++++++++++++++++++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -1
index d6286ed..5288763 100644
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	/* check if we need to reset the asic
 	 *  E.g., driver was not cleanly unloaded previously, etc.
 	 */
-	if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+	if (amdgpu_passthrough(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+		if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_asic_baco_cap) {
+			r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+			if (r) {
+				dev_err(adev->dev, "set baco capability failed\n");
+				goto failed;
+			}
+		}
+
 		r = amdgpu_asic_reset(adev);
 		if (r) {
 			dev_err(adev->dev, "asic reset on init failed\n");
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
index 2b579ba..0dcc18d 100644
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
 	int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
 	int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
 	int (*get_asic_baco_capability)(void *handle, bool *cap);
+	int (*set_asic_baco_cap)(void *handle);
 	int (*get_asic_baco_state)(void *handle, int *state);
 	int (*set_asic_baco_state)(void *handle, int state);
 	int (*get_ppfeature_status)(void *handle, char *buf);
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +16 -0
index bea1587..9856760 100644
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void *handle, uint32_t count)
 	return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+	struct pp_hwmgr *hwmgr = handle;
+
+	if (!hwmgr)
+		return -EINVAL;
+
+	if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+		return 0;
+
+	hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+	return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
 	struct pp_hwmgr *hwmgr = handle;
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
 	.set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
 	.set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
 	.get_asic_baco_capability = pp_get_asic_baco_capability,
+	.set_asic_baco_cap = pp_set_asic_baco_cap,
 	.get_asic_baco_state = pp_get_asic_baco_state,
 	.set_asic_baco_state = pp_set_asic_baco_state,
 	.get_ppfeature_status = pp_get_ppfeature_status,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
index ed6c638..8dc23eb 100644
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
 	.odn_edit_dpm_table = vega10_odn_edit_dpm_table,
 	.get_performance_level = vega10_get_performance_level,
 	.get_asic_baco_capability = smu9_baco_get_capability,
+	.set_asic_baco_cap = vega10_baco_set_cap,
 	.get_asic_baco_state = smu9_baco_get_state,
 	.set_asic_baco_state = vega10_baco_set_state,
 	.enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +22 -0
index b6767d7..8fdeb23 100644
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr,
 
 	return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr)
+{
+	int result = 0;
+	const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+	powerplay_table = get_powerplay_table(hwmgr);
+
+	PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+		"Missing PowerPlay Table!", return -1);
+
+	result = check_powerplay_tables(hwmgr, powerplay_table);
+
+	PP_ASSERT_WITH_CODE((result == 0),
+			    "check_powerplay_tables failed", return result);
+
+	set_hw_cap(
+			hwmgr,
+			0 != (le32_to_cpu(powerplay_table->ulPlatformCaps) & ATOM_VEGA10_PP_PLATFORM_CAP_BACO),
+			PHM_PlatformCaps_BACO);
+	return result;
+}
\ No newline at end of file
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +1 -0
index d83ed2a..da5fbec 100644
@@ -59,4 +59,5 @@ extern int vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr);
 extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index,
 		struct pp_power_state *power_state, int (*call_back_func)(struct pp_hwmgr *, void *,
 				struct pp_power_state *, void *, uint32_t));
+extern int vega10_baco_set_cap(struct pp_hwmgr *hwmgr);
 #endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
index bac3d85..14480ae 100644
@@ -339,6 +339,7 @@ struct pp_hwmgr_func {
 	int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
 	int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
 	int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool *cap);
+	int (*set_asic_baco_cap)(struct pp_hwmgr *hwmgr);
 	int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
 	int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE state);
 	int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf);
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1558582017-7545-1-git-send-email-Emily.Deng-5C7GfCeVMHo@public.gmane.org

#2 lore raw

I would actually expect the followings

       if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {         --> no touch for this

+ if (amdgpu_passthrough(adev) && adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_asic_baco_cap) {
+ r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+ if (r) {
+ dev_err(adev->dev, "set baco capability failed\n");
+ goto failed;
+ }
+ }
+

And btw the commit description was lost compared with v1.

Regards,
Evan

Quoted 183 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Emily Deng
Sent: Thursday, May 23, 2019 11:27 AM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Need to set the baco cap before baco reset

[CAUTION: External Email]

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 10 +++++++++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h     |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 16
++++++++++++++++
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22
++++++++++++++++++++++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
index d6286ed..5288763 100644
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device
 *adev,
        /* check if we need to reset the asic
         *  E.g., driver was not cleanly unloaded previously, etc.
         */
-       if (!amdgpu_sriov_vf(adev) &&
 amdgpu_asic_need_reset_on_init(adev)) {
+       if (amdgpu_passthrough(adev) &&
 amdgpu_asic_need_reset_on_init(adev)) {
+               if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs-
Quoted 1 line

set_asic_baco_cap) {

+ r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev-

Quoted 1 line

powerplay.pp_handle);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+                       if (r) {
+                               dev_err(adev->dev, "set baco capability failed\n");
+                               goto failed;
+                       }
+               }
+
                r = amdgpu_asic_reset(adev);
                if (r) {
                        dev_err(adev->dev, "asic reset on init failed\n");
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
index 2b579ba..0dcc18d 100644
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
        int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
        int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
        int (*get_asic_baco_capability)(void *handle, bool *cap);
+       int (*set_asic_baco_cap)(void *handle);
        int (*get_asic_baco_state)(void *handle, int *state);
        int (*set_asic_baco_state)(void *handle, int state);
        int (*get_ppfeature_status)(void *handle, char *buf);
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +15 -0
index bea1587..9856760 100644
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void
 *handle, uint32_t count)
        return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+       struct pp_hwmgr *hwmgr = handle;
+
+       if (!hwmgr)
+               return -EINVAL;
+
+       if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+               return 0;
+
+       hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+       return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
        struct pp_hwmgr *hwmgr = handle;
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +1 -0
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs =
 {
        .set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
        .set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
        .get_asic_baco_capability = pp_get_asic_baco_capability,
+       .set_asic_baco_cap = pp_set_asic_baco_cap,
        .get_asic_baco_state = pp_get_asic_baco_state,
        .set_asic_baco_state = pp_set_asic_baco_state,

.get_ppfeature_status = pp_get_ppfeature_status,

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
index ed6c638..8dc23eb 100644
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func
 vega10_hwmgr_funcs = {
        .odn_edit_dpm_table = vega10_odn_edit_dpm_table,
        .get_performance_level = vega10_get_performance_level,
        .get_asic_baco_capability = smu9_baco_get_capability,
+       .set_asic_baco_cap = vega10_baco_set_cap,
        .get_asic_baco_state = smu9_baco_get_state,
        .set_asic_baco_state = vega10_baco_set_state,

.enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c index b6767d7..8fdeb23 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +19 -0
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct
 pp_hwmgr *hwmgr,
 
        return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr)
+{
+       int result = 0;
+       const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+       powerplay_table = get_powerplay_table(hwmgr);
+
+       PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+               "Missing PowerPlay Table!", return -1);
+
+       result = check_powerplay_tables(hwmgr, powerplay_table);
+
+       PP_ASSERT_WITH_CODE((result == 0),
+                           "check_powerplay_tables failed", return result);
+
+       set_hw_cap(
+                       hwmgr,
+                       0 != (le32_to_cpu(powerplay_table->ulPlatformCaps) &

ATOM_VEGA10_PP_PLATFORM_CAP_BACO),

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +3 -0
+                       PHM_PlatformCaps_BACO);
+       return result;
+}
\ No newline at end of file

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h index d83ed2a..da5fbec 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +0 -0
@@ -59,4 +59,5 @@ extern int

vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr);
extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr,
uint32_t entry_index,
struct pp_power_state *power_state, int (*call_back_func)(struct
pp_hwmgr *, void *,

                                struct pp_power_state *, void *, uint32_t));
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +1 -0
+extern int vega10_baco_set_cap(struct pp_hwmgr *hwmgr);
 #endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
index bac3d85..14480ae 100644
@@ -339,6 +339,7 @@ struct pp_hwmgr_func {
        int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr,
 uint32_t clock);
        int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t
 clock);
        int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool *cap);
+       int (*set_asic_baco_cap)(struct pp_hwmgr *hwmgr);
        int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum

BACO_STATE *state);
int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum

BACO_STATE state);
        int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf);
Quoted 7 lines

--
2.7.4

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): MN2PR12MB33444847ACDEA3838E1B55D1E4010-rweVpJHSKToDMgCC8P//[email protected]

#4 lore raw

Hi Evan,
If don’t call set_asic_baco_cap, then couldn't enable baco, so need to modify amdgpu_sriov_vf to limit to passthrough. And the comment is in the patch, but don't know why it lost when using " git send-email". And as you gave the reviewed-by, I already pushed the patch to the drm-next.

Best wishes
Emily Deng

Quoted 216 lines

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Thursday, May 23, 2019 11:46 AM
To: Deng, Emily <[email protected]>; [email protected]
Cc: Deng, Emily <[email protected]>
Subject: RE: [PATCH v2] drm/amdgpu: Need to set the baco cap before baco reset

I would actually expect the followings

      if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev))

{ --> no touch for this
+ if (amdgpu_passthrough(adev) && adev->powerplay.pp_funcs &&
adev->powerplay.pp_funcs->set_asic_baco_cap) {
+ r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev-

Quoted 1 line

powerplay.pp_handle);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+                       if (r) {
+                               dev_err(adev->dev, "set baco capability failed\n");
+                               goto failed;
+                       }
+               }
+

And btw the commit description was lost compared with v1.

Regards,
Evan

Quoted 157 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Emily Deng
Sent: Thursday, May 23, 2019 11:27 AM
To: [email protected]
Cc: Deng, Emily <[email protected]>
Subject: [PATCH v2] drm/amdgpu: Need to set the baco cap before baco reset

[CAUTION: External Email]

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 10 +++++++++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h     |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 16
++++++++++++++++
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22
++++++++++++++++++++++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -1
index d6286ed..5288763 100644
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device
 *adev,
        /* check if we need to reset the asic
         *  E.g., driver was not cleanly unloaded previously, etc.
         */
-       if (!amdgpu_sriov_vf(adev) &&
 amdgpu_asic_need_reset_on_init(adev)) {
+       if (amdgpu_passthrough(adev) &&
 amdgpu_asic_need_reset_on_init(adev)) {
+               if (adev->powerplay.pp_funcs &&
+ adev->powerplay.pp_funcs-
Quoted 1 line

set_asic_baco_cap) {

+ r =
+ adev->powerplay.pp_funcs->set_asic_baco_cap(adev-

Quoted 1 line

powerplay.pp_handle);

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+                       if (r) {
+                               dev_err(adev->dev, "set baco capability failed\n");
+                               goto failed;
+                       }
+               }
+
                r = amdgpu_asic_reset(adev);
                if (r) {
                        dev_err(adev->dev, "asic reset on init

failed\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 2b579ba..0dcc18d 100644

drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -1
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
        int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
        int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
        int (*get_asic_baco_capability)(void *handle, bool *cap);
+       int (*set_asic_baco_cap)(void *handle);
        int (*get_asic_baco_state)(void *handle, int *state);
        int (*set_asic_baco_state)(void *handle, int state);
        int (*get_ppfeature_status)(void *handle, char *buf); diff
--git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index bea1587..9856760 100644

drivers/gpu/drm/amd/powerplay/amd_powerplay.c +14 -0
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void
 *handle, uint32_t count)
        return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle) {
+       struct pp_hwmgr *hwmgr = handle;
+
+       if (!hwmgr)
+               return -EINVAL;
+
+       if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+               return 0;
+
+       hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+       return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)  {
        struct pp_hwmgr *hwmgr = handle; @@ -1546,6 +1561,7 @@ static

const struct amd_pm_funcs pp_dpm_funcs = {
.set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq, .set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq, .get_asic_baco_capability = pp_get_asic_baco_capability,
+ .set_asic_baco_cap = pp_set_asic_baco_cap,
.get_asic_baco_state = pp_get_asic_baco_state, .set_asic_baco_state = pp_set_asic_baco_state, .get_ppfeature_status = pp_get_ppfeature_status, diff --git
a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
index ed6c638..8dc23eb 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func
 vega10_hwmgr_funcs = {
        .odn_edit_dpm_table = vega10_odn_edit_dpm_table,
        .get_performance_level = vega10_get_performance_level,
        .get_asic_baco_capability = smu9_baco_get_capability,
+       .set_asic_baco_cap = vega10_baco_set_cap,
        .get_asic_baco_state = smu9_baco_get_state,
        .set_asic_baco_state = vega10_baco_set_state,

.enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost, diff
--git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c index b6767d7..8fdeb23 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +20 -0
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct
 pp_hwmgr *hwmgr,
 
        return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr) {
+       int result = 0;
+       const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+       powerplay_table = get_powerplay_table(hwmgr);
+
+       PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+               "Missing PowerPlay Table!", return -1);
+
+       result = check_powerplay_tables(hwmgr, powerplay_table);
+
+       PP_ASSERT_WITH_CODE((result == 0),
+                           "check_powerplay_tables failed", return
+ result);
+
+       set_hw_cap(
+                       hwmgr,
+                       0 !=
+ (le32_to_cpu(powerplay_table->ulPlatformCaps) &

ATOM_VEGA10_PP_PLATFORM_CAP_BACO),

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +3 -0
+                       PHM_PlatformCaps_BACO);
+       return result;
+}
\ No newline at end of file

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h index d83ed2a..da5fbec 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +0 -0
@@ -59,4 +59,5 @@ extern int
Quoted 1 line

vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr

*hwmgr);

Quoted 30 lines

extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index,
struct pp_power_state *power_state, int
(*call_back_func)(struct pp_hwmgr *, void *,
struct pp_power_state *, void *,
uint32_t));

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +1 -0
+extern int vega10_baco_set_cap(struct pp_hwmgr *hwmgr);
 #endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
index bac3d85..14480ae 100644
@@ -339,6 +339,7 @@ struct pp_hwmgr_func {
        int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr,
 uint32_t clock);
        int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr,
 uint32_t clock);
        int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool
 *cap);
+       int (*set_asic_baco_cap)(struct pp_hwmgr *hwmgr);

int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum
BACO_STATE *state);
int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum
BACO_STATE state);
int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char
*buf);
--
2.7.4

Quoted 4 lines
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

#5 lore raw
In reply to a message not in the archive
Quoted 1 line · Emily Deng

Please include a patch description.

Quoted 16 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 10 +++++++++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h     |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 16 ++++++++++++++++
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22 ++++++++++++++++++++++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index d6286ed..5288763 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 2608

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        /* check if we need to reset the asic
         *  E.g., driver was not cleanly unloaded previously, etc.
         */
-       if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+       if (amdgpu_passthrough(adev) && amdgpu_asic_need_reset_on_init(adev)) {

This will change the current behavior on baremetal.

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 2616

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
+               if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_asic_baco_cap) {
+                       r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+                       if (r) {
+                               dev_err(adev->dev, "set baco capability failed\n");
+                               goto failed;
+                       }
+               }
+

This will also change the current behavior on bare metal.

I think you may want to rework this a bit otherwise this change won't really make any difference due to this patch:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-next&id=60ae2cd5aec94dc6459bdee5c610bb5c76a1d0ae
We need to avoid breaking module reload (modeprobe amdgpu; modprobe -r amdgpu; modeprobe amdgpu).
I think it would be cleaner to call set_asic_baco_cap() in hwmgr_early_init() and then return true in soc15_need_reset_on_init() is it's passthrough mode. then everything should just work as is.

Quoted 54 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                r = amdgpu_asic_reset(adev);
                if (r) {
                        dev_err(adev->dev, "asic reset on init failed\n");
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
index 2b579ba..0dcc18d 100644
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
        int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
        int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
        int (*get_asic_baco_capability)(void *handle, bool *cap);
+       int (*set_asic_baco_cap)(void *handle);
        int (*get_asic_baco_state)(void *handle, int *state);
        int (*set_asic_baco_state)(void *handle, int state);
        int (*get_ppfeature_status)(void *handle, char *buf);
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +16 -0
index bea1587..9856760 100644
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void *handle, uint32_t count)
        return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+       struct pp_hwmgr *hwmgr = handle;
+
+       if (!hwmgr)
+               return -EINVAL;
+
+       if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+               return 0;
+
+       hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+       return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
        struct pp_hwmgr *hwmgr = handle;
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
        .set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
        .set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
        .get_asic_baco_capability = pp_get_asic_baco_capability,
+       .set_asic_baco_cap = pp_set_asic_baco_cap,
        .get_asic_baco_state = pp_get_asic_baco_state,
        .set_asic_baco_state = pp_set_asic_baco_state,
        .get_ppfeature_status = pp_get_ppfeature_status,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -0
index ed6c638..8dc23eb 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c static const struct pp_hwmgr_func vega10_hwmgr_funcs = { · line 5174

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
        .odn_edit_dpm_table = vega10_odn_edit_dpm_table,
        .get_performance_level = vega10_get_performance_level,
        .get_asic_baco_capability = smu9_baco_get_capability,
+       .set_asic_baco_cap = vega10_baco_set_cap,

Any chance you can add callbacks for vega12 and 20 as well?

Quoted 24 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -0
        .get_asic_baco_state = smu9_baco_get_state,
        .set_asic_baco_state = vega10_baco_set_state,
        .enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +13 -0
index b6767d7..8fdeb23 100644
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr,
 
        return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr)
+{
+       int result = 0;
+       const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+       powerplay_table = get_powerplay_table(hwmgr);
+
+       PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+               "Missing PowerPlay Table!", return -1);
+
+       result = check_powerplay_tables(hwmgr, powerplay_table);
+

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, · line 1395

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +9 -0
+       PP_ASSERT_WITH_CODE((result == 0),
+                           "check_powerplay_tables failed", return result);
+
+       set_hw_cap(
+                       hwmgr,
+                       0 != (le32_to_cpu(powerplay_table->ulPlatformCaps) & ATOM_VEGA10_PP_PLATFORM_CAP_BACO),
+                       PHM_PlatformCaps_BACO);
+       return result;
+}
\ No newline at end of file

Missing newline.

Alex

Quoted 25 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +1 -0
index d83ed2a..da5fbec 100644
@@ -59,4 +59,5 @@ extern int vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr);
 extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index,
                struct pp_power_state *power_state, int (*call_back_func)(struct pp_hwmgr *, void *,
                                struct pp_power_state *, void *, uint32_t));
+extern int vega10_baco_set_cap(struct pp_hwmgr *hwmgr);
 #endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -1
index bac3d85..14480ae 100644
@@ -339,6 +339,7 @@ struct pp_hwmgr_func {
        int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
        int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
        int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool *cap);
+       int (*set_asic_baco_cap)(struct pp_hwmgr *hwmgr);
        int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
        int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE state);
        int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf);
--

2.7.4

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

#6 lore raw
Quoted 41 lines · Alex Deucher
Quoted 1 line · Emily Deng

Please include a patch description.

Quoted 16 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 10 +++++++++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h     |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 16 ++++++++++++++++
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22 ++++++++++++++++++++++
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index d6286ed..5288763 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 2608

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -1
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        /* check if we need to reset the asic
         *  E.g., driver was not cleanly unloaded previously, etc.
         */
-       if (!amdgpu_sriov_vf(adev) && amdgpu_asic_need_reset_on_init(adev)) {
+       if (amdgpu_passthrough(adev) && amdgpu_asic_need_reset_on_init(adev)) {

This will change the current behavior on baremetal.

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev, · line 2616

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
+               if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_asic_baco_cap) {
+                       r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev->powerplay.pp_handle);
+                       if (r) {
+                               dev_err(adev->dev, "set baco capability failed\n");
+                               goto failed;
+                       }
+               }
+

This will also change the current behavior on bare metal.

Quoted 8 lines

I think you may want to rework this a bit otherwise this change won't really make any difference due to this patch:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-next&id=60ae2cd5aec94dc6459bdee5c610bb5c76a1d0ae
We need to avoid breaking module reload (modeprobe amdgpu; modprobe -r amdgpu; modeprobe amdgpu).
I think it would be cleaner to call set_asic_baco_cap() in hwmgr_early_init() and then return true in soc15_need_reset_on_init() is it's passthrough mode. then everything should just work as is.

Assuming you set the set_asic_baco_cap callbacks for vega20 and vega12 as well. Otherwise, you'll have to limit it to vega10 which starts to get messy IMHO.

Alex

Quoted 126 lines
Quoted 55 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                r = amdgpu_asic_reset(adev);
                if (r) {
                        dev_err(adev->dev, "asic reset on init failed\n");
drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
index 2b579ba..0dcc18d 100644
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
        int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
        int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
        int (*get_asic_baco_capability)(void *handle, bool *cap);
+       int (*set_asic_baco_cap)(void *handle);
        int (*get_asic_baco_state)(void *handle, int *state);
        int (*set_asic_baco_state)(void *handle, int state);
        int (*get_ppfeature_status)(void *handle, char *buf);
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +16 -0
index bea1587..9856760 100644
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void *handle, uint32_t count)
        return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle)
+{
+       struct pp_hwmgr *hwmgr = handle;
+
+       if (!hwmgr)
+               return -EINVAL;
+
+       if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+               return 0;
+
+       hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+       return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)
 {
        struct pp_hwmgr *hwmgr = handle;
@@ -1546,6 +1561,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = {
        .set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
        .set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
        .get_asic_baco_capability = pp_get_asic_baco_capability,
+       .set_asic_baco_cap = pp_set_asic_baco_cap,
        .get_asic_baco_state = pp_get_asic_baco_state,
        .set_asic_baco_state = pp_set_asic_baco_state,
        .get_ppfeature_status = pp_get_ppfeature_status,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -0
index ed6c638..8dc23eb 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c static const struct pp_hwmgr_func vega10_hwmgr_funcs = { · line 5174

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = {
        .odn_edit_dpm_table = vega10_odn_edit_dpm_table,
        .get_performance_level = vega10_get_performance_level,
        .get_asic_baco_capability = smu9_baco_get_capability,
+       .set_asic_baco_cap = vega10_baco_set_cap,

Any chance you can add callbacks for vega12 and 20 as well?

Quoted 24 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -0
        .get_asic_baco_state = smu9_baco_get_state,
        .set_asic_baco_state = vega10_baco_set_state,
        .enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost,
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +13 -0
index b6767d7..8fdeb23 100644
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr,
 
        return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr)
+{
+       int result = 0;
+       const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+       powerplay_table = get_powerplay_table(hwmgr);
+
+       PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+               "Missing PowerPlay Table!", return -1);
+
+       result = check_powerplay_tables(hwmgr, powerplay_table);
+

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, · line 1395

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +9 -0
+       PP_ASSERT_WITH_CODE((result == 0),
+                           "check_powerplay_tables failed", return result);
+
+       set_hw_cap(
+                       hwmgr,
+                       0 != (le32_to_cpu(powerplay_table->ulPlatformCaps) & ATOM_VEGA10_PP_PLATFORM_CAP_BACO),
+                       PHM_PlatformCaps_BACO);
+       return result;
+}
\ No newline at end of file

Missing newline.

Alex

Quoted 25 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h +1 -0
index d83ed2a..da5fbec 100644
@@ -59,4 +59,5 @@ extern int vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr *hwmgr);
 extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index,
                struct pp_power_state *power_state, int (*call_back_func)(struct pp_hwmgr *, void *,
                                struct pp_power_state *, void *, uint32_t));
+extern int vega10_baco_set_cap(struct pp_hwmgr *hwmgr);
 #endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -1
index bac3d85..14480ae 100644
@@ -339,6 +339,7 @@ struct pp_hwmgr_func {
        int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
        int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr, uint32_t clock);
        int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool *cap);
+       int (*set_asic_baco_cap)(struct pp_hwmgr *hwmgr);
        int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE *state);
        int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum BACO_STATE state);
        int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char *buf);
--

2.7.4

Quoted 4 lines
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

A message that is not in the archive (sent off-list or not yet received): CADnq5_O+F=pSzQmgWuAmretpVuoNo9w1WVq4qWst5BVUq4FnKg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw

Sorry, I have pushed the change as Evan gave the reviewed-by, I will send another patch to reference your review comments, do you think it is Ok?

Quoted 8 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Thursday, May 23, 2019 11:54 AM
To: Deng, Emily <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH v2] drm/amdgpu: Need to set the baco cap before baco reset

Quoted 10 lines

[CAUTION: External Email]

Quoted 2 lines · Alex Deucher

On Wed, May 22, 2019 at 11:27 PM Emily Deng <[email protected]>

Quoted 3 lines · wrote:
Quoted 1 line

Please include a patch description.

The comment is lost when using "git send-email", I will check why.

Quoted 21 lines
Quoted 6 lines
Quoted 6 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 10 +++++++++-
 drivers/gpu/drm/amd/include/kgd_pp_interface.h     |  1 +
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c      | 16

++++++++++++++++

Quoted 2 lines
Quoted 2 lines
 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c |  1 +
 .../amd/powerplay/hwmgr/vega10_processpptables.c   | 22

++++++++++++++++++++++

Quoted 10 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 10 lines
 .../amd/powerplay/hwmgr/vega10_processpptables.h   |  1 +
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 +
 7 files changed, 51 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index d6286ed..5288763 100644
@@ -2605,7 +2605,15 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 9 lines
Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device *adev,

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -1
        /* check if we need to reset the asic
         *  E.g., driver was not cleanly unloaded previously, etc.
         */
-       if (!amdgpu_sriov_vf(adev) &&

amdgpu_asic_need_reset_on_init(adev)) {

Quoted 4 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device · line 2609

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
+       if (amdgpu_passthrough(adev) &&
+ amdgpu_asic_need_reset_on_init(adev)) {

This will change the current behavior on baremetal.

Ok, I will put the passthrough check to "if(adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->set_asic_baco_cap)"

Quoted 12 lines
Quoted 12 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device · line 2610

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+               if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs-

set_asic_baco_cap) {

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device · line 2611

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+                       r = adev->powerplay.pp_funcs->set_asic_baco_cap(adev-

powerplay.pp_handle);

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
+                       if (r) {
+                               dev_err(adev->dev, "set baco capability failed\n");
+                               goto failed;
+                       }
+               }
+
Quoted 12 lines
Quoted 7 lines

This will also change the current behavior on bare metal.

I think you may want to rework this a bit otherwise this change won't really make any difference due to this patch:
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-ne
xt&id=60ae2cd5aec94dc6459bdee5c610bb5c76a1d0ae
We need to avoid breaking module reload (modeprobe amdgpu; modprobe

-r

Quoted 4 lines

amdgpu; modeprobe amdgpu).
I think it would be cleaner to call set_asic_baco_cap() in hwmgr_early_init() and then return true in soc15_need_reset_on_init() is it's passthrough mode. then everything should just work as is.

Ok, will call set_asic_baco_cap in vega10_hwmgr_init

Quoted 3 lines

Assuming you set the set_asic_baco_cap callbacks for vega20 and vega12 as well. Otherwise, you'll have to limit it to vega10 which starts to get messy IMHO.

I don't add the callbacks for vega20 and vega12, as no platform to test these. And if vega20 or vega12 need this, then they could add this and test this. Currently only for vega10.

Quoted 53 lines

Alex

Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                r = amdgpu_asic_reset(adev);
                if (r) {
                        dev_err(adev->dev, "asic reset on init

failed\n"); diff --git
a/drivers/gpu/drm/amd/include/kgd_pp_interface.h
b/drivers/gpu/drm/amd/include/kgd_pp_interface.h
index 2b579ba..0dcc18d 100644

drivers/gpu/drm/amd/include/kgd_pp_interface.h +1 -0
@@ -285,6 +285,7 @@ struct amd_pm_funcs {
        int (*set_hard_min_fclk_by_freq)(void *handle, uint32_t clock);
        int (*set_min_deep_sleep_dcefclk)(void *handle, uint32_t clock);
        int (*get_asic_baco_capability)(void *handle, bool *cap);
+       int (*set_asic_baco_cap)(void *handle);
        int (*get_asic_baco_state)(void *handle, int *state);
Quoted 8 lines

drivers/gpu/drm/amd/powerplay/amd_powerplay.c static int pp_set_active_display_count(void

Quoted 8 lines
drivers/gpu/drm/amd/include/kgd_pp_interface.h +0 -1
        int (*set_asic_baco_state)(void *handle, int state);
        int (*get_ppfeature_status)(void *handle, char *buf); diff
--git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c

b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c
index bea1587..9856760 100644

drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0 -0
@@ -1404,6 +1404,21 @@ static int pp_set_active_display_count(void

*handle, uint32_t count)

Quoted 26 lines
Quoted 26 lines
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +15 -0
        return ret;
 }
 
+static int pp_set_asic_baco_cap(void *handle) {
+       struct pp_hwmgr *hwmgr = handle;
+
+       if (!hwmgr)
+               return -EINVAL;
+
+       if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_cap)
+               return 0;
+
+       hwmgr->hwmgr_func->set_asic_baco_cap(hwmgr);
+
+       return 0;
+}
+
 static int pp_get_asic_baco_capability(void *handle, bool *cap)  {
        struct pp_hwmgr *hwmgr = handle; @@ -1546,6 +1561,7 @@
 static const struct amd_pm_funcs pp_dpm_funcs = {
        .set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq,
        .set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq,
        .get_asic_baco_capability = pp_get_asic_baco_capability,
+       .set_asic_baco_cap = pp_set_asic_baco_cap,
        .get_asic_baco_state = pp_get_asic_baco_state,
        .set_asic_baco_state = pp_set_asic_baco_state,
Quoted 14 lines
Quoted 7 lines

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c static const struct pp_hwmgr_func

Quoted 7 lines
        .get_ppfeature_status = pp_get_ppfeature_status, diff --git

a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c index ed6c638..8dc23eb 100644

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -0
@@ -5171,6 +5171,7 @@ static const struct pp_hwmgr_func

vega10_hwmgr_funcs = {

Quoted 6 lines

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c static const struct pp_hwmgr_func vega10_hwmgr_funcs = { · line 5174

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
        .odn_edit_dpm_table = vega10_odn_edit_dpm_table,
        .get_performance_level = vega10_get_performance_level,
        .get_asic_baco_capability = smu9_baco_get_capability,
+       .set_asic_baco_cap = vega10_baco_set_cap,

Any chance you can add callbacks for vega12 and 20 as well?

Sorry, don't have this.

Quoted 27 lines
Quoted 4 lines

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c static const struct pp_hwmgr_func vega10_hwmgr_funcs = {

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -1
        .get_asic_baco_state = smu9_baco_get_state,
        .set_asic_baco_state = vega10_baco_set_state,
        .enable_mgpu_fan_boost = vega10_enable_mgpu_fan_boost, diff
--git

a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c

Quoted 4 lines
Quoted 4 lines

b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c index b6767d7..8fdeb23 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
+++

b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +12 -0
@@ -1371,3 +1371,25 @@ int vega10_get_powerplay_table_entry(struct
 pp_hwmgr *hwmgr,
 
        return result;
 }
+
+int vega10_baco_set_cap(struct pp_hwmgr *hwmgr) {
+       int result = 0;
+       const ATOM_Vega10_POWERPLAYTABLE *powerplay_table;
+
+       powerplay_table = get_powerplay_table(hwmgr);
+
+       PP_ASSERT_WITH_CODE((powerplay_table != NULL),
+               "Missing PowerPlay Table!", return -1);
+
+       result = check_powerplay_tables(hwmgr, powerplay_table);
+
Quoted 14 lines
Quoted 7 lines

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +7 -0
+       PP_ASSERT_WITH_CODE((result == 0),
+                           "check_powerplay_tables failed", return
+ result);
+
+       set_hw_cap(
+                       hwmgr,
+                       0 != (le32_to_cpu(powerplay_table->ulPlatformCaps) &

ATOM_VEGA10_PP_PLATFORM_CAP_BACO),

Quoted 6 lines

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +3 -0
+                       PHM_PlatformCaps_BACO);
+       return result;
+}
\ No newline at end of file

Missing newline.

Ok, will fix this.

Quoted 29 lines
Quoted 7 lines

Alex

Quoted 5 lines

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h index d83ed2a..da5fbec 100644
---

a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h

Quoted 1 line
Quoted 1 line

+++

b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.h

Quoted 2 lines
Quoted 2 lines
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +0 -0
@@ -59,4 +59,5 @@ extern int

vega10_get_number_of_powerplay_table_entries(struct pp_hwmgr

*hwmgr); extern int vega10_get_powerplay_table_entry(struct pp_hwmgr *hwmgr, uint32_t entry_index,

Quoted 1 line
Quoted 1 line

struct pp_power_state *power_state, int (*call_back_func)(struct

pp_hwmgr *, void *,

Quoted 11 lines

drivers/gpu/drm/amd/powerplay/inc/hwmgr.h struct pp_hwmgr_func { · line 339

Quoted 11 lines

struct pp_power_state *, void *,
uint32_t));

drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +1 -0
+extern int vega10_baco_set_cap(struct pp_hwmgr *hwmgr);
 #endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -0
index bac3d85..14480ae 100644
@@ -339,6 +339,7 @@ struct pp_hwmgr_func {
        int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr,

uint32_t clock);

Quoted 1 line

drivers/gpu/drm/amd/powerplay/inc/hwmgr.h struct pp_hwmgr_func { · line 340

Quoted 1 line
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -0
        int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr,
Quoted 17 lines

uint32_t clock);

Quoted 4 lines

drivers/gpu/drm/amd/powerplay/inc/hwmgr.h struct pp_hwmgr_func { · line 344

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +1 -0
        int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr, bool
 *cap);
+       int (*set_asic_baco_cap)(struct pp_hwmgr *hwmgr);
        int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr, enum

BACO_STATE *state);

Quoted 1 line

drivers/gpu/drm/amd/powerplay/inc/hwmgr.h struct pp_hwmgr_func { · line 345

Quoted 1 line
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -0
        int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr, enum

BACO_STATE state);

Quoted 9 lines
Quoted 9 lines

int (*get_ppfeature_status)(struct pp_hwmgr *hwmgr, char
*buf);
--
2.7.4

_______________________________________________
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